Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GPU Accelerated Tree Search Chapel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UltraBO
GPU Accelerated Tree Search Chapel
Commits
10afb02a
Commit
10afb02a
authored
3 months ago
by
Guillaume-Helbecque
Browse files
Options
Downloads
Patches
Plain Diff
allocate arrays outside while loop
parent
bd8d24eb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
nqueens_gpu_chpl.chpl
+9
-7
9 additions, 7 deletions
nqueens_gpu_chpl.chpl
nqueens_multigpu_chpl.chpl
+10
-7
10 additions, 7 deletions
nqueens_multigpu_chpl.chpl
with
19 additions
and
14 deletions
nqueens_gpu_chpl.chpl
+
9
−
7
View file @
10afb02a
...
...
@@ -83,10 +83,9 @@ proc decompose(const parent: Node, ref tree_loc: uint, ref num_sol: uint, ref po
for j in depth..(N-1) {
if isSafe(parent.board, depth, parent.board[j]) {
var child = new Node();
child.depth =
parent.
depth;
child.depth = depth
+ 1
;
child.board = parent.board;
child.board[depth] <=> child.board[j];
child.depth += 1;
pool.pushBack(child);
tree_loc += 1;
}
...
...
@@ -159,6 +158,12 @@ proc nqueens_search(ref exploredTree: uint, ref exploredSol: uint, ref elapsedTi
var timer: stopwatch;
timer.start();
var parents: [0..#M] Node = noinit;
var labels: [0..#(M*N)] uint(8) = noinit;
on device var parents_d: [0..#M] Node;
on device var labels_d: [0..#(M*N)] uint(8);
while true {
var hasWork = 0;
var parent = pool.popBack(hasWork);
...
...
@@ -171,7 +176,6 @@ proc nqueens_search(ref exploredTree: uint, ref exploredSol: uint, ref elapsedTi
// If 'poolSize' is sufficiently large, we offload the pool on GPU.
if (poolSize >= m) {
var parents: [0..#poolSize] Node = noinit;
for i in 0..#poolSize {
var hasWork = 0;
parents[i] = pool.popBack(hasWork);
...
...
@@ -179,14 +183,12 @@ proc nqueens_search(ref exploredTree: uint, ref exploredSol: uint, ref elapsedTi
}
const numLabels = N * poolSize;
var labels: [0..#numLabels] uint(8) = noinit;
parents_d = parents; // host-to-device
on device {
const parents_d = parents; // host-to-device
var labels_d: [0..#numLabels] uint(8) = noinit;
evaluate_gpu(parents_d, numLabels, labels_d);
labels = labels_d; // device-to-host
}
labels = labels_d; // device-to-host
/*
Each task generates and inserts its children nodes to the pool.
...
...
This diff is collapsed.
Click to expand it.
nqueens_multigpu_chpl.chpl
+
10
−
7
View file @
10afb02a
...
...
@@ -84,10 +84,9 @@ proc decompose(const parent: Node, ref tree_loc: uint, ref num_sol: uint, ref po
for j in depth..(N-1) {
if isSafe(parent.board, depth, parent.board[j]) {
var child = new Node();
child.depth =
parent.
depth;
child.depth = depth
+ 1
;
child.board = parent.board;
child.board[depth] <=> child.board[j];
child.depth += 1;
pool.pushBack(child);
tree_loc += 1;
}
...
...
@@ -208,6 +207,12 @@ proc nqueens_search(ref exploredTree: uint, ref exploredSol: uint, ref elapsedTi
pool_loc.size += l-c;
}
var parents: [0..#M] Node = noinit;
var labels: [0..#(M*N)] uint(8) = noinit;
on device var parents_d: [0..#M] Node;
on device var labels_d: [0..#(M*N)] uint(8);
while true {
/*
Each task gets its parents nodes from the pool.
...
...
@@ -215,7 +220,7 @@ proc nqueens_search(ref exploredTree: uint, ref exploredSol: uint, ref elapsedTi
var poolSize = pool_loc.size;
if (poolSize >= m) {
poolSize = min(poolSize, M);
var parents: [0..#poolSize] Node = noinit;
for i in 0..#poolSize {
var hasWork = 0;
parents[i] = pool_loc.popBack(hasWork);
...
...
@@ -223,14 +228,12 @@ proc nqueens_search(ref exploredTree: uint, ref exploredSol: uint, ref elapsedTi
}
const numLabels = N * poolSize;
var labels: [0..#numLabels] uint(8) = noinit;
parents_d = parents; // host-to-device
on device {
const parents_d = parents; // host-to-device
var labels_d: [0..#numLabels] uint(8) = noinit;
evaluate_gpu(parents_d, numLabels, labels_d);
labels = labels_d; // device-to-host
}
labels = labels_d; // device-to-host
/*
Each task generates and inserts its children nodes to the pool.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment