PandA-2024.02
examples
MachSuite
MachSuite
bfs
bulk
bfs.c
Go to the documentation of this file.
1
/*
2
Implementations based on:
3
Harish and Narayanan. "Accelerating large graph algorithms on the GPU using CUDA." HiPC, 2007.
4
Hong, Oguntebi, Olukotun. "Efficient Parallel Graph Exploration on Multi-Core CPU and GPU." PACT, 2011.
5
*/
6
7
#include "
bfs.h
"
8
9
void
bfs
(
node_t
nodes
[
N_NODES
],
edge_t
edges
[
N_EDGES
],
10
node_index_t
starting_node,
level_t
level
[N_NODES],
11
edge_index_t
level_counts[
N_LEVELS
])
12
{
13
node_index_t
n;
14
edge_index_t
e;
15
level_t
horizon;
16
edge_index_t
cnt;
17
18
level
[starting_node] = 0;
19
level_counts[0] = 1;
20
21
loop_horizons:
for
( horizon=0; horizon<
N_LEVELS
; horizon++ ) {
22
cnt = 0;
23
// Add unmarked neighbors of the current horizon to the next horizon
24
loop_nodes:
for
( n=0; n<
N_NODES
; n++ ) {
25
if
(
level
[n]==horizon ) {
26
edge_index_t
tmp_begin =
nodes
[n].edge_begin;
27
edge_index_t
tmp_end =
nodes
[n].edge_end;
28
loop_neighbors:
for
( e=tmp_begin; e<tmp_end; e++ ) {
29
node_index_t
tmp_dst =
edges
[e].dst;
30
level_t
tmp_level =
level
[tmp_dst];
31
32
if
( tmp_level ==
MAX_LEVEL
) {
// Unmarked
33
level
[tmp_dst] = horizon+1;
34
++cnt;
35
}
36
}
37
}
38
}
39
if
( (level_counts[horizon+1]=cnt)==0 )
40
break
;
41
}
42
}
nodes
struct Node nodes[7]
Definition:
simple_raytrace.c:62
N_NODES
#define N_NODES
Definition:
bfs.h:18
node_index_t
uint64_t node_index_t
Definition:
bfs.h:26
level_t
int8_t level_t
Definition:
bfs.h:40
edges
unsigned edges[4545]
Definition:
graph.h:25
N_LEVELS
#define N_LEVELS
Definition:
bfs.h:22
bfs
void bfs(node_t nodes[N_NODES], edge_t edges[N_EDGES], node_index_t starting_node, level_t level[N_NODES], edge_index_t level_counts[N_LEVELS])
Definition:
bfs.c:9
MAX_LEVEL
#define MAX_LEVEL
Definition:
bfs.h:41
edge_index_t
uint64_t edge_index_t
Definition:
bfs.h:25
node_t_struct
Definition:
bfs.h:35
level
int level
Definition:
main.c:98
bfs.h
edge_t_struct
Definition:
bfs.h:28
N_EDGES
#define N_EDGES
Definition:
bfs.h:19
Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by
1.8.13