-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMultiNodeMatrix3d.h
108 lines (77 loc) · 1.73 KB
/
MultiNodeMatrix3d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef MULTINODEMATRIX3D_H
#define MULTINODEMATRIX3D_H
#include "cuda_utils.h"
#include "Matrix3d.h"
template <typename T>
class node_t {
public:
int node;
int x0, x1;
int y0, y1;
int z0, z1;
int xsize;
int ysize;
int len;
T *h_data;
T *d_data;
node_t() {
len = 0;
h_data = NULL;
d_data = NULL;
}
~node_t() {
if (h_data != NULL) deallocate_host<T>(&h_data); //delete [] h_data;
if (d_data != NULL) deallocate<T>(&d_data);
}
};
template <typename T>
class MultiNodeMatrix3d : public Matrix3d<T> {
private:
// Number of nodes
int nnode;
// Number of nodes in each coordinate direction
// NOTE: nnode = nnodex * nnodey * nnodez
int nnodex;
int nnodey;
int nnodez;
// Node (MPI) ID list
int *nodeID;
// My node index
int mynode;
// Coordinate limits for each node
int *x0, *x1;
int *y0, *y1;
int *z0, *z1;
int nxtot;
int nytot;
int nztot;
int xsizetot;
int ysizetot;
int zsizetot;
// Stuff for matrix transpose
MultiNodeMatrix3d<T>* mat_yzx;
int nsend;
node_t<T> *send;
int nrecv;
node_t<T> *recv;
bool loc_transpose;
int loc_x0, loc_x1;
int loc_y0, loc_y1;
int loc_z0, loc_z1;
void *recv_req;
void *send_req;
void *recv_stat;
void *send_stat;
public:
MultiNodeMatrix3d(const int nxtot, const int nytot, const int nztot,
const int nnodex, const int nnodey, const int nnodez,
const int mynode,
const char *filename = NULL);
~MultiNodeMatrix3d();
bool compare(Matrix3d<T>* mat, const double tol, double& max_diff);
void print_info();
void setup_transpose_xyz_yzx(MultiNodeMatrix3d<T>* mat);
void transpose_xyz_yzx();
void transpose_xyz_yzx(MultiNodeMatrix3d<T>* mat);
};
#endif // MULTINODEMATRIX3D_H