-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyMPI.h
35 lines (31 loc) · 899 Bytes
/
MyMPI.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
typedef struct {
MPI_Comm row_com;
MPI_Comm col_com;
MPI_Comm com;
int rank;
int row_rank;
int col_rank;
int p;
int q;
int coords[2];
int dim;
int sub_rows;
int sub_cols;
} GRID;
#define BLOCK_LOW(rank,p,n) (rank * n / p)
#define BLOCK_HIGH(rank,p,n) (BLOCK_LOW((rank + 1),p,n) - 1)
#define BLOCK_SIZE(rank,p,n) (BLOCK_HIGH(rank,p,n) - BLOCK_LOW(rank,p,n) + 1)
#define BLOCK_OWNER(idx, p, n) ( (p * (idx + 1)-1) / n)
#define MIN(a,b) ( (a < b) ? a : b )
#define INF INT_MAX/2
#define INPUT_ERROR -1
#define PROC_ERROR -2
#define OPEN_ERROR -3
#define FILE_ERROR -4
#define CALLOC_ERROR -5
void initial_setup(GRID* grid);
int **manage_matrix(GRID *grid, char *filename);
int **alloc_matrix(long rows, long cols);
void print_buffer(long size, int *buffer);
void print_matrix(GRID *grid, int ***matrix);
void floyd(GRID* grid, int ***submatrix);