Galois
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HostDecls.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 int edge_data_type;
36 #endif
37 
38 struct MarshalGraph {
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_nodes;
52  unsigned int** master_nodes;
53  unsigned int* num_mirror_nodes;
54  unsigned int** mirror_nodes;
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_nodes(NULL), master_nodes(NULL),
60  num_mirror_nodes(NULL), mirror_nodes(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_nodes)
72  free(num_master_nodes);
73  if (!master_nodes) {
74  for (unsigned i = 0; i < numHosts; ++i) {
75  free(master_nodes[i]);
76  }
77  free(master_nodes);
78  }
79  if (!num_mirror_nodes)
80  free(num_mirror_nodes);
81  if (!mirror_nodes) {
82  for (unsigned i = 0; i < numHosts; ++i) {
83  free(mirror_nodes[i]);
84  }
85  free(mirror_nodes);
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, MarshalGraph& g,
101  unsigned num_hosts);
102 void reset_CUDA_context(struct CUDA_Context* ctx);
unsigned int index_type
Definition: EdgeHostDecls.h:33
unsigned int * num_mirror_nodes
Definition: HostDecls.h:53
unsigned int numNodesWithEdges
Definition: HostDecls.h:43
MarshalGraph()
Definition: HostDecls.h:56
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 numOwned
Definition: HostDecls.h:41
edge_data_type * edge_data
Definition: HostDecls.h:50
struct CUDA_Context * get_CUDA_context(int id)
unsigned numHosts
Definition: HostDecls.h:46
void reset_CUDA_context(struct CUDA_Context *ctx)
size_t nnodes
Definition: HostDecls.h:39
unsigned int * num_master_nodes
Definition: HostDecls.h:51
int id
Definition: HostDecls.h:45
index_type * edge_dst
Definition: HostDecls.h:48
unsigned int ** master_nodes
Definition: HostDecls.h:52
void load_graph_CUDA(struct CUDA_Context *ctx, EdgeMarshalGraph &g, unsigned num_hosts)
unsigned int node_data_type
Definition: EdgeHostDecls.h:34
index_type * row_start
Definition: HostDecls.h:47
~MarshalGraph()
Definition: HostDecls.h:62
Definition: HostDecls.h:38
unsigned edge_data_type
Definition: EdgeHostDecls.h:35
size_t nedges
Definition: HostDecls.h:40
unsigned int beginMaster
Definition: HostDecls.h:42
unsigned int ** mirror_nodes
Definition: HostDecls.h:54
node_data_type * node_data
Definition: HostDecls.h:49