-
Notifications
You must be signed in to change notification settings - Fork 10
/
group.c
271 lines (181 loc) · 4.8 KB
/
group.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#include "mpiP.h"
/*********/
int FC_FUNC( mpi_group_incl, MPI_GROUP_INCL )
(int *group, int *n, int *ranks, int *newgroup, int *ierror)
{
*ierror= MPI_Group_incl(*group, *n, ranks, newgroup);
return MPI_SUCCESS;
}
int MPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group *newgroup)
{
if (group==MPI_GROUP_NULL)
{
fprintf(stderr,"MPI_Group_incl: null group passed in\n");
abort();
}
if (group==MPI_GROUP_EMPTY || n==0)
*newgroup=MPI_GROUP_EMPTY;
else
if (n==1 && ranks[0]==0)
*newgroup=MPI_GROUP_ONE;
else
{
fprintf(stderr,"MPI_Group_incl: more than 1 proc in group\n");
abort();
}
return(MPI_SUCCESS);
}
/*********/
/* MPI_Group_range_incl
* Include a strided range of ranks in a group. For one processor, if
* "0" is included in any of these ranges, it can only be the first rank.
* Thus, if rank 0 is specified, include it, otherwise use GROUP_NULL
*/
int FC_FUNC( mpi_group_range_incl, MPI_GROUP_RANGE_INCL )
(int *group, int *n, int ranges[][3], int *newgroup, int *ierror)
{
*ierror= MPI_Group_range_incl(*group, *n, ranges, newgroup);
return MPI_SUCCESS;
}
int MPI_Group_range_incl(MPI_Group group, int n, int ranges[][3],
MPI_Group *newgroup)
{
if (group==MPI_GROUP_NULL)
{
fprintf(stderr,"MPI_Group_range_incl: null group passed in\n");
abort();
}
if (group==MPI_GROUP_EMPTY || n==0)
*newgroup=MPI_GROUP_EMPTY;
else
if (n==1 && ranges[0][0]==0 && ranges[0][1]==0)
*newgroup=MPI_GROUP_ONE;
else
{
fprintf(stderr,"MPI_Group_range_incl: more than 1 proc in group\n");
abort();
}
return(MPI_SUCCESS);
}
/*********/
int FC_FUNC( mpi_group_union, MPI_GROUP_UNION )
(int *group1, int *group2, int *newgroup, int *ierror)
{
*ierror= MPI_Group_union(*group1,*group2,newgroup);
return MPI_SUCCESS;
}
int MPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group *newgroup)
{
if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
{
fprintf(stderr,"MPI_Group_union: null group passed in\n");
abort();
}
if (group1==MPI_GROUP_ONE || group2==MPI_GROUP_ONE)
*newgroup=MPI_GROUP_ONE;
else
*newgroup=MPI_GROUP_EMPTY;
return(MPI_SUCCESS);
}
/*********/
int FC_FUNC( mpi_group_intersection, MPI_GROUP_INTERSECTION )
(int *group1, int *group2, int *newgroup, int *ierror)
{
*ierror= MPI_Group_intersection(*group1,*group2,newgroup);
return MPI_SUCCESS;
}
int MPI_Group_intersection(MPI_Group group1, MPI_Group group2,
MPI_Group *newgroup)
{
if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
{
fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
abort();
}
if (group1==MPI_GROUP_ONE && group2==MPI_GROUP_ONE)
*newgroup=MPI_GROUP_ONE;
else
*newgroup=MPI_GROUP_EMPTY;
return(MPI_SUCCESS);
}
/*********/
int FC_FUNC( mpi_group_difference, MPI_GROUP_DIFFERENCE )
(int *group1, int *group2, int *newgroup, int *ierror)
{
*ierror= MPI_Group_difference(*group1,*group2,newgroup);
return MPI_SUCCESS;
}
int MPI_Group_difference(MPI_Group group1, MPI_Group group2,
MPI_Group *newgroup)
{
if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
{
fprintf(stderr,"MPI_Group_intersection: null group passed in\n");
abort();
}
if (group1==MPI_GROUP_EMPTY || group2==MPI_GROUP_ONE)
*newgroup=MPI_GROUP_EMPTY;
else
*newgroup=MPI_GROUP_ONE;
return(MPI_SUCCESS);
}
/*********/
int FC_FUNC( mpi_group_free, MPI_GROUP_FREE )(int *group, int *ierror)
{
*ierror= MPI_Group_free(group);
return MPI_SUCCESS;
}
int MPI_Group_free(MPI_Group *group)
{
*group= MPI_GROUP_NULL;
return(MPI_SUCCESS);
}
/*********/
int FC_FUNC( mpi_group_translate_ranks, MPI_GROUP_TRANSLATE_RANKS )
( int *group1, int *n, int *ranks1,
int *group2, int *ranks2, int *ierror)
{
*ierror= MPI_Group_translate_ranks(*group1,*n,ranks1,*group2,ranks2);
return MPI_SUCCESS;
}
int MPI_Group_translate_ranks(MPI_Group group1, int n, int *ranks1,
MPI_Group group2, int *ranks2)
{
int i;
if (group1==MPI_GROUP_NULL || group2==MPI_GROUP_NULL)
{
fprintf(stderr,"MPI_Group_translate_ranks: null group passed in\n");
abort();
}
if (n==0)
return(MPI_SUCCESS);
if (group1==MPI_GROUP_EMPTY)
{
fprintf(stderr,"MPI_Group_translate_ranks: empty input group\n");
abort();
}
for (i=0; i<n; i++)
{
if (ranks1[i]!=0)
{
fprintf(stderr,"MPI_Group_translate_ranks: bad input rank: %d\n",
ranks1[i]);
abort();
}
if (group2!=MPI_GROUP_EMPTY)
ranks2[i]=ranks1[i];
else
ranks2[i]=MPI_UNDEFINED;
}
return(MPI_SUCCESS);
}
/*********/
MPI_Group MPI_Group_f2c(MPI_Fint group)
{
return(group);
}
/*********/
MPI_Fint MPI_Group_c2f(MPI_Group group)
{
return(group);
}