-
Notifications
You must be signed in to change notification settings - Fork 0
/
testcart.c
57 lines (44 loc) · 1.18 KB
/
testcart.c
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
// SPDX-License-Identifier: MIT
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef NOWRAP
#include <mpi.h>
#else
#include "mpi.h"
#endif
int main(int argc, char* argv[])
{
int rc;
rc = MPI_Init(&argc,&argv);
int me, np;
MPI_Comm_rank(MPI_COMM_WORLD,&me);
MPI_Comm_size(MPI_COMM_WORLD,&np);
printf("I am %d of %d\n", me, np);
{
MPI_Comm cart_world;
int dims[1] = { np };
int periodic[1] = { 0 };
int reorder = 0;
MPI_Cart_create(MPI_COMM_WORLD, 1, dims, periodic, reorder, &cart_world);
int result;
MPI_Comm_compare(MPI_COMM_WORLD,cart_world,&result);
if (result != MPI_CONGRUENT) {
printf("cartesian world is not congruent: %d\n", result);
MPI_Abort(MPI_COMM_WORLD,result);
}
MPI_Comm_free(&cart_world);
if (cart_world != MPI_COMM_NULL) {
printf("freed window is not null\n");
MPI_Abort(MPI_COMM_WORLD,1);
}
}
fflush(0);
usleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if (me==0) printf("all done\n");
rc = MPI_Finalize();
return rc;
}