Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EdgeHostDecls.h
Go to the documentation of this file.
1 /*
2  * This file belongs to the Galois project, a C++ library for exploiting
3  * parallelism. The code is being released under the terms of the 3-Clause BSD
4  * License (a copy is located in LICENSE.txt at the top-level directory).
5  *
6  * Copyright (C) 2018, The University of Texas at Austin. All rights reserved.
7  * UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING THIS
8  * SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY,
9  * FITNESS FOR ANY PARTICULAR PURPOSE, NON-INFRINGEMENT AND WARRANTIES OF
10  * PERFORMANCE, AND ANY WARRANTY THAT MIGHT OTHERWISE ARISE FROM COURSE OF
11  * DEALING OR USAGE OF TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH
12  * RESPECT TO THE USE OF THE SOFTWARE OR DOCUMENTATION. Under no circumstances
13  * shall University be liable for incidental, special, indirect, direct or
14  * consequential damages or loss of profits, interruption of business, or
15  * related expenses which may arise from use of Software or Documentation,
16  * including but not limited to those resulting from defects in Software and/or
17  * Documentation, or loss or inaccuracy of data of any kind.
18  */
19 
29 #pragma once
30 #include <string>
31 
32 #ifndef LSG_CSR_GRAPH
33 typedef unsigned int index_type; // GPU kernels choke on size_t
34 typedef unsigned int node_data_type;
35 typedef unsigned edge_data_type;
36 #endif
37 
39  size_t nnodes;
40  size_t nedges;
41  unsigned int numOwned; // Number of nodes owned (masters) by this host
42  unsigned int beginMaster; // local id of the beginning of master nodes
43  unsigned int numNodesWithEdges; // Number of nodes (masters + mirrors) that
44  // have outgoing edges
45  int id;
46  unsigned numHosts;
51  unsigned int* num_master_edges;
52  unsigned int** master_edges;
53  unsigned int* num_mirror_edges;
54  unsigned int** mirror_edges;
55 
57  : nnodes(0), nedges(0), numOwned(0), beginMaster(0), numNodesWithEdges(0),
58  id(-1), numHosts(0), row_start(NULL), edge_dst(NULL), node_data(NULL),
59  edge_data(NULL), num_master_edges(NULL), master_edges(NULL),
60  num_mirror_edges(NULL), mirror_edges(NULL) {}
61 
63  if (!row_start)
64  free(row_start);
65  if (!edge_dst)
66  free(edge_dst);
67  if (!node_data)
68  free(node_data);
69  if (!edge_data)
70  free(edge_data);
71  if (!num_master_edges)
72  free(num_master_edges);
73  if (master_edges != NULL) {
74  for (unsigned i = 0; i < numHosts; ++i) {
75  free(master_edges[i]);
76  }
77  free(master_edges);
78  }
79  if (!num_mirror_edges)
80  free(num_mirror_edges);
81  if (mirror_edges != NULL) {
82  for (unsigned i = 0; i < numHosts; ++i) {
83  free(mirror_edges[i]);
84  }
85  free(mirror_edges);
86  }
87  }
88 };
89 
90 // to determine the GPU device id
91 int get_gpu_device_id(std::string personality_set,
92  int num_nodes); // defined on the host
93 
94 struct CUDA_Context; // forward declaration only because rest is dependent on
95  // the dist_app
96 
97 // defined on the device
98 struct CUDA_Context* get_CUDA_context(int id);
99 bool init_CUDA_context(struct CUDA_Context* ctx, int device);
100 void load_graph_CUDA(struct CUDA_Context* ctx, EdgeMarshalGraph& g,
101  unsigned num_hosts);
102 void reset_CUDA_context(struct CUDA_Context* ctx);
unsigned int * num_master_edges
Definition: EdgeHostDecls.h:51
size_t nedges
Definition: EdgeHostDecls.h:40
unsigned int numOwned
Definition: EdgeHostDecls.h:41
unsigned int ** mirror_edges
Definition: EdgeHostDecls.h:54
unsigned int ** master_edges
Definition: EdgeHostDecls.h:52
index_type * row_start
Definition: EdgeHostDecls.h:47
unsigned int index_type
Definition: EdgeHostDecls.h:33
bool init_CUDA_context(struct CUDA_Context *ctx, int device)
int get_gpu_device_id(std::string personality_set, int num_nodes)
Definition: cuda_device.cpp:33
unsigned int numNodesWithEdges
Definition: EdgeHostDecls.h:43
int id
Definition: EdgeHostDecls.h:45
~EdgeMarshalGraph()
Definition: EdgeHostDecls.h:62
struct CUDA_Context * get_CUDA_context(int id)
unsigned int * num_mirror_edges
Definition: EdgeHostDecls.h:53
void reset_CUDA_context(struct CUDA_Context *ctx)
node_data_type * node_data
Definition: EdgeHostDecls.h:49
void load_graph_CUDA(struct CUDA_Context *ctx, EdgeMarshalGraph &g, unsigned num_hosts)
unsigned int beginMaster
Definition: EdgeHostDecls.h:42
index_type * edge_dst
Definition: EdgeHostDecls.h:48
unsigned int node_data_type
Definition: EdgeHostDecls.h:34
size_t nnodes
Definition: EdgeHostDecls.h:39
unsigned numHosts
Definition: EdgeHostDecls.h:46
EdgeMarshalGraph()
Definition: EdgeHostDecls.h:56
edge_data_type * edge_data
Definition: EdgeHostDecls.h:50
unsigned edge_data_type
Definition: EdgeHostDecls.h:35
Definition: EdgeHostDecls.h:38