-
Notifications
You must be signed in to change notification settings - Fork 1
/
block_grid.h
executable file
·72 lines (50 loc) · 1.79 KB
/
block_grid.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
#ifndef _BLOCK_GRID_H_
#define _BLOCK_GRID_H_
#include<iostream>
#include<cstring>
#include<list>
#include<map>
#include "mpi.h"
#include "helper.h"
namespace RRR{
using namespace std;
class Block_Grid
{
private:
// Multidimensional size of the actual block grid
int* actual_grid;
// Actual coordinates of this block in the allocated grid
int* actual_addr;
// Maps each dimension of the allocated block grid to one of the
// dimensions of the exposed block grid
int *gdmap;
// Inverse grid dimension map
list<int>* igdmap;
public:
// Number of dimensions in the exposed block grid
int grid_dims;
// Dimension sizes of the exposed block grid
int* bgrid;
// Rank of this block
int rank;
// Virtual address/coordinates of this block in the exposed proc grid
int* block_addr;
// Total size of the block grid
int nblocks;
// Constructor
Block_Grid(int num_dims, int* block_grid);
// Returns rank of a block given its multi-dimensional address
int get_block_rank(int* &address);
// Finds out ranks of n blocks given their multi-dimensional addresses
void get_block_ranks(int n, int** &addresses, int* &ranks);
// Computes a block's multi-dimensional address given its rank
void get_block_addr(int rank, int* &address);
// Computes n blocks' multi-dimensional addresses given their ranks
void get_block_addrs(int n, int** &addresses, int* &ranks);
// prints address of a block given its rank
void print_block_addr(int r);
// Returns the string of the block's multi-dimensional address, given its rank
string get_block_addr_str(int r);
};
}
#endif