PandA-2024.02
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 
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 }
struct Node nodes[7]
#define N_NODES
Definition: bfs.h:18
uint64_t node_index_t
Definition: bfs.h:26
int8_t level_t
Definition: bfs.h:40
unsigned edges[4545]
Definition: graph.h:25
#define N_LEVELS
Definition: bfs.h:22
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
#define MAX_LEVEL
Definition: bfs.h:41
uint64_t edge_index_t
Definition: bfs.h:25
int level
Definition: main.c:98
#define N_EDGES
Definition: bfs.h:19

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13