COMBINATORIAL_BLAS  1.6
common.h
Go to the documentation of this file.
1 /* Copyright (C) 2010 The Trustees of Indiana University. */
2 /* */
3 /* Use, modification and distribution is subject to the Boost Software */
4 /* License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at */
5 /* http://www.boost.org/LICENSE_1_0.txt) */
6 /* */
7 /* Authors: Jeremiah Willcock */
8 /* Andrew Lumsdaine */
9 
10 #ifndef COMMON_H
11 #define COMMON_H
12 
13 #include <stdint.h>
14 #include <stddef.h>
15 
16 #define INT64_T_MPI_TYPE MPI_LONG_LONG
17 
18 #define SIZE_MUST_BE_A_POWER_OF_TWO
19 
20 extern int rank, size;
21 #ifdef SIZE_MUST_BE_A_POWER_OF_TWO
22 extern int lgsize, size_minus_one;
23 #endif
24 
25 /* Distribute edges by their endpoints (make two directed copies of each input
26  * undirected edge); distribution is 1-d and cyclic. */
27 #ifdef SIZE_MUST_BE_A_POWER_OF_TWO
28 #define MOD_SIZE(v) ((v) & size_minus_one)
29 #define DIV_SIZE(v) ((v) >> lgsize)
30 #else
31 #define MOD_SIZE(v) ((v) % size)
32 #define DIV_SIZE(v) ((v) / size)
33 #endif
34 #define VERTEX_OWNER(v) ((int)(MOD_SIZE(v)))
35 #define VERTEX_LOCAL(v) ((size_t)(DIV_SIZE(v)))
36 #define VERTEX_TO_GLOBAL(i) ((int64_t)((i) * size + rank))
37 
38 typedef struct csr_graph {
39  size_t nlocalverts;
40  size_t nlocaledges;
42  size_t *rowstarts;
44 } csr_graph;
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 void setup_globals(void); /* In utils.c */
51 void free_csr_graph(csr_graph* const g); /* In utils.c */
52 void* xMPI_Alloc_mem(size_t nbytes); /* In utils.c */
53 void* xmalloc(size_t nbytes); /* In utils.c */
54 void* xcalloc(size_t n, size_t unit); /* In utils.c */
55 void* xrealloc(void* p, size_t nbytes); /* In utils.c */
56 
57 void convert_graph_to_csr(const int64_t nedges, const int64_t* const edges, csr_graph* const g); /* In convert_to_csr.c */
58 void find_bfs_roots(int *num_bfs_roots, const csr_graph* const g, const uint64_t seed1, const uint64_t seed2, int64_t* const bfs_roots); /* In find_roots.c */
59 int validate_bfs_result(const csr_graph* const g, const int64_t root, const int64_t* const pred, const int64_t nvisited); /* In validate.c */
60 
61 void run_mpi_bfs(const csr_graph* const g, int64_t root, int64_t* pred, int64_t* nvisited); /* Provided by user */
62 
63 #ifdef __cplusplus
64 }
65 #endif
66 
67 #endif /* COMMON_H */
void convert_graph_to_csr(const int64_t nedges, const int64_t *const edges, csr_graph *const g)
void * xrealloc(void *p, size_t nbytes)
void run_mpi_bfs(const csr_graph *const g, int64_t root, int64_t *pred, int64_t *nvisited)
int size
size_t nlocalverts
Definition: common.h:39
void * xmalloc(size_t nbytes)
void setup_globals(void)
size_t nlocaledges
Definition: common.h:40
void free_csr_graph(csr_graph *const g)
int size_minus_one
void * xcalloc(size_t n, size_t unit)
int64_t nglobalverts
Definition: common.h:41
int validate_bfs_result(const csr_graph *const g, const int64_t root, const int64_t *const pred, const int64_t nvisited)
void find_bfs_roots(int *num_bfs_roots, const csr_graph *const g, const uint64_t seed1, const uint64_t seed2, int64_t *const bfs_roots)
struct csr_graph csr_graph
long int64_t
Definition: compat.h:21
int64_t * column
Definition: common.h:43
int lgsize
size_t * rowstarts
Definition: common.h:42
int rank
void * xMPI_Alloc_mem(size_t nbytes)