Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hpvm-release
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
hpvm-release
Commits
b2d72aa0
Commit
b2d72aa0
authored
9 years ago
by
Prakalp Srivastava
Browse files
Options
Downloads
Patches
Plain Diff
Added a working visc_base version of bfs
parent
13e445d6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
llvm/test/VISC/parboil/benchmarks/bfs/src/visc_base/main.cpp
+21
-27
21 additions, 27 deletions
llvm/test/VISC/parboil/benchmarks/bfs/src/visc_base/main.cpp
with
21 additions
and
27 deletions
llvm/test/VISC/parboil/benchmarks/bfs/src/visc_base/main.cpp
+
21
−
27
View file @
b2d72aa0
...
...
@@ -27,7 +27,6 @@
#include
<stdio.h>
#include
<string.h>
#include
<math.h>
//#include <stdatomic.h>
#include
"parboil.h"
#include
"config.h"
#include
<visc.h>
...
...
@@ -177,25 +176,16 @@ BFSLeaf(int *q1, size_t bytesq1,
int
cost
=
cur_edge
.
y
;
cost
+=
cur_cost
;
// TODO: What to do with atomics
// Following is an atomic statement replaced for now to amove forward. Has
// to be dealt with.
//int orig_cost = atom_min(&g_cost[id],cost);
int
orig_cost
;
if
(
g_cost
[
id
]
>
cost
)
{
orig_cost
=
g_cost
[
id
];
g_cost
[
id
]
=
cost
;
}
// Remove till here
int
orig_cost
=
__visc__atomic_min
(
&
g_cost
[
id
],
cost
);
if
(
orig_cost
>
cost
){
//the node should be visited
if
(
g_color
[
id
]
>
UP_LIMIT
){
int
old_color
=
__
sync_swap
(
&
g_color
[
id
],
gray_shade
);
int
old_color
=
__
visc__atomic_xchg
(
&
g_color
[
id
],
gray_shade
);
//this guarantees that only one thread will push this node
//into a queue
if
(
old_color
!=
gray_shade
)
{
//atomic operation guarantees the correctness
//even if multiple warps are executing simultaneously
int
index
=
__
sync_fetch_and
_add
(
local_q_tail
,
1
);
int
index
=
__
visc__atomic
_add
(
local_q_tail
,
1
);
local_q
[
index
]
=
id
;
}
}
...
...
@@ -209,7 +199,7 @@ BFSLeaf(int *q1, size_t bytesq1,
int
tot_sum
=
*
local_q_tail
;
//the offset or "shift" of the block-level queue within the grid-level queue
//is determined by atomic operation
*
shift
=
__
sync_fetch_and
_add
(
tail
,
tot_sum
);
*
shift
=
__
visc__atomic
_add
(
tail
,
tot_sum
);
}
__visc__barrier
();
...
...
@@ -377,7 +367,6 @@ int main( int argc, char** argv)
exit
(
-
1
);
}
pb_SwitchToTimer
(
&
timers
,
pb_TimerID_IO
);
//Read in Graph from a file
fp
=
fopen
(
params
->
inpFiles
[
0
],
"r"
);
if
(
!
fp
)
...
...
@@ -428,9 +417,8 @@ int main( int argc, char** argv)
cost
[
source
]
=
0
;
pb_SwitchToTimer
(
&
timers
,
pb_TimerID_COMPUTE
);
size_t
bytes_graph_nodes
,
bytes_graph_edges
;
bytes_graph_nodes
=
num_of_nodes
*
sizeof
(
struct
Node
);
bytes_graph_nodes
=
num_of_edges
*
sizeof
(
struct
Edge
);
size_t
bytes_graph_nodes
=
num_of_nodes
*
sizeof
(
struct
Node
);
size_t
bytes_graph_edges
=
num_of_edges
*
sizeof
(
struct
Edge
);
llvm_visc_track_mem
(
graph_nodes
,
bytes_graph_nodes
);
llvm_visc_track_mem
(
graph_edges
,
bytes_graph_edges
);
...
...
@@ -446,8 +434,8 @@ int main( int argc, char** argv)
llvm_visc_track_mem
(
q2
,
bytes_cost
);
// Scalar variable read/written by both graph and host.
int
tail
;
llvm_visc_track_mem
(
&
tail
,
sizeof
(
int
));
int
*
tail
;
llvm_visc_track_mem
(
tail
,
sizeof
(
int
));
pb_SwitchToTimer
(
&
timers
,
pb_TimerID_KERNEL
);
int
num_of_blocks
;
...
...
@@ -455,8 +443,10 @@ int main( int argc, char** argv)
// Initializations. Can some of these be done in the graph. That way we can
// move these arrays completely in the graph
tail
=
h_top
;
cost
[
0
]
=
0
;
*
tail
=
h_top
;
// Potential source of inefficiency.
//Entire array would be copied intially
cost
[
0
]
=
zero
;
q1
[
0
]
=
source
;
int
num_t
;
//number of threads
...
...
@@ -474,7 +464,7 @@ int main( int argc, char** argv)
graph_edges
,
bytes_graph_edges
,
color
,
bytes_cost
,
cost
,
bytes_cost
,
&
tail
,
sizeof
(
int
),
tail
,
sizeof
(
int
),
num_of_nodes
,
gray
,
k
,
...
...
@@ -484,9 +474,11 @@ int main( int argc, char** argv)
do
{
llvm_visc_request_mem
(
&
tail
,
sizeof
(
int
));
num_t
=
tail
;
tail
=
0
;
llvm_visc_request_mem
(
tail
,
sizeof
(
int
));
num_t
=
*
tail
;
//printf("tail for iteration %d = %d\n",k, num_t);
*
tail
=
0
;
//tail = 0;
if
(
num_t
==
0
){
//frontier is empty
break
;
...
...
@@ -498,6 +490,8 @@ int main( int argc, char** argv)
args
->
grid
=
num_of_blocks
;
args
->
block
=
num_of_threads_per_block
;
args
->
no_of_nodes
=
num_t
;
args
->
k
=
k
;
if
(
k
%
2
==
0
){
args
->
gray_shade
=
GRAY0
;
...
...
@@ -519,7 +513,7 @@ int main( int argc, char** argv)
//0);
void
*
bfsDFG
=
__visc__launch
(
0
,
BFS_Root
,
(
void
*
)
args
);
__visc__wait
(
bfsDFG
);
k
++
;
// Swap q1 and q2
// Swap q1 and q2
int
*
temp
=
args
->
q1
;
args
->
q1
=
args
->
q2
;
...
...
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