-
Notifications
You must be signed in to change notification settings - Fork 0
/
testwin.c
89 lines (76 loc) · 2.08 KB
/
testwin.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
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
// 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;
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_Win a, as, c, cd;
void *ba, *bas;
char bc[1024], b[1024];
rc = MPI_Win_allocate(1024,1,MPI_INFO_NULL,MPI_COMM_WORLD,&ba,&a);
if (rc) {
printf("rc = %d line = %d\n", rc, __LINE__);
MPI_Abort(MPI_COMM_WORLD,rc);
}
MPI_Win_fence(0,a);
MPI_Win_free(&a);
if (a != MPI_WIN_NULL) {
printf("win null? %d\n",a==MPI_WIN_NULL);
MPI_Abort(MPI_COMM_WORLD,1);
}
rc = MPI_Win_allocate_shared(1024,1,MPI_INFO_NULL,MPI_COMM_WORLD,&bas,&as);
if (rc) {
printf("rc = %d line = %d\n", rc, __LINE__);
MPI_Abort(MPI_COMM_WORLD,rc);
}
MPI_Win_fence(0,as);
MPI_Win_free(&as);
if (as != MPI_WIN_NULL) {
printf("win null? %d\n",as==MPI_WIN_NULL);
MPI_Abort(MPI_COMM_WORLD,2);
}
// this is broken with OMPI and np=1
rc = MPI_Win_create(&bc,1024,1,MPI_INFO_NULL,MPI_COMM_WORLD,&c);
if (rc) {
printf("rc = %d line = %d\n", rc, __LINE__);
MPI_Abort(MPI_COMM_WORLD,rc);
}
MPI_Win_fence(0,c);
MPI_Win_free(&c);
if (c != MPI_WIN_NULL) {
printf("win null? %d\n",c==MPI_WIN_NULL);
MPI_Abort(MPI_COMM_WORLD,3);
}
rc = MPI_Win_create_dynamic(MPI_INFO_NULL,MPI_COMM_WORLD,&cd);
if (rc) {
printf("rc = %d line = %d\n", rc, __LINE__);
MPI_Abort(MPI_COMM_WORLD,rc);
}
MPI_Win_attach(cd,&b,1024);
MPI_Win_fence(0,cd);
MPI_Win_detach(cd,&b);
MPI_Win_free(&cd);
if (cd != MPI_WIN_NULL) {
printf("win null? %d\n",cd==MPI_WIN_NULL);
MPI_Abort(MPI_COMM_WORLD,4);
}
fflush(0);
usleep(1);
MPI_Barrier(MPI_COMM_WORLD);
if (me==0) printf("all done\n");
MPI_Finalize();
return 0;
}