Skip to content

Commit 0252461

Browse files
committed
oshmem: add some useless but inoffensive communications and see how oshmem+ucx handles that
Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent 13bbc39 commit 0252461

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

oshmem/runtime/oshmem_shmem_init.c

+68
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,74 @@ int oshmem_shmem_init(int argc, char **argv, int requested, int *provided)
152152
return ret;
153153
}
154154

155+
{
156+
int world_rank, world_size;
157+
int *prank, *ranks;
158+
ompi_request_t **reqs, *req;
159+
ompi_status_public_t status, *statuses;
160+
MPI_Status status;
161+
PMPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
162+
PMPI_Comm_size(MPI_COMM_WORLD, &world_size);
163+
prank = (int *)malloc(sizeof(int));
164+
*prank = world_rank;
165+
if (0 == world_rank) {
166+
ranks = (int *)calloc(world_size-1, sizeof(int));
167+
reqs = (ompi_request_t *)malloc(world_size-1, sizeof(ompi_request_t *));
168+
statuses = (ompi_status_public_t *)malloc(world_size-1, sizeof(ompi_status_public_t)));
169+
u
170+
fprintf (stderr, "oshmem_shmem_init: isend/irecv\n");
171+
for (int i=0; i<world_size-1; i++)
172+
MCA_PML_CALL(irecv(ranks+i, 1, MPI_INT, i, -6667, MPI_COMM_WORLD, reqs+i)
173+
ompi_request_wait_all(world_size-1, reqs, statuses);
174+
for (int i=0; i<world_size-1; i++) {
175+
if (MPI_SUCCESS != statuses[i].MPI_ERROR)
176+
fprintf(stderr, "rank %d: irecv failed with status error %d\n", i+1, statuses[i].MPI_ERROR);
177+
if (MPI_SUCCESS != reqs[i]->req_status.MPI_ERROR)
178+
fprintf(stderr, "rank %d: irecv failed with request error %d\n", i+1, reqs[i]->req_status..MPI_ERROR);
179+
if (i+1 != ranks[i]) fprintf(stderr, "irecv(): expected %d got %d\n", i+1, ranks[i]);
180+
}
181+
} else {
182+
MCA_PML_CALL(isend(prank, 1, MPI_INT, 0, -6667, MCA_PML_BASE_SEND_STANDARD, MPI_COMM_WORLD, &req));
183+
ompi_request_wait(&req, &status);
184+
if (MPI_SUCCESS != status.MPI_ERROR)
185+
fprintf(stderr, "rank %d: isend failed with status error %d\n", world_rank, status.MPI_ERROR);
186+
if (MPI_SUCCESS != req->req_status.MPI_ERROR)
187+
fprintf(stderr, "rank %d: isend failed with request error %d\n", world_rank, status.MPI_ERROR);
188+
}
189+
}
190+
191+
{
192+
int world_rank, world_size;
193+
int *prank, *ranks;
194+
MPI_Request req;
195+
MPI_Status status;
196+
PMPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
197+
PMPI_Comm_size(MPI_COMM_WORLD, &world_size);
198+
prank = (int *)malloc(sizeof(int));
199+
*prank = world_rank + 1;
200+
if (0 == world_rank) ranks = (int *)calloc(world_size, sizeof(int));
201+
if (0 == world_rank) reqs = (MPI_Request *)malloc(world_size, sizeof(MPI_Request));
202+
if (0 == world_rank) fprintf (stderr, "oshmem_shmem_init: PMPI_Gather\n");
203+
if (0 == world_rank) fprintf (stderr, "oshmem_shmem_init: PMPI_Gather\n");
204+
PMPI_Gather(prank, 1, MPI_INT, ranks, 1, MPI_INT, 0, MPI_COMM_WORLD);
205+
if (0 == world_rank)
206+
for (int i=0; i<world_size; i++)
207+
if (i+1 != ranks[i]) fprintf(stderr, "PMPI_Gather: at %d expected %d got %d\n", i, i+1, ranks[i]);
208+
if (0 == world_rank) fprintf (stderr, "oshmem_shmem_init: PMPI_Igather\n");
209+
*prank = world_rank + 2;
210+
if (0 == world_rank) memset(ranks, 0, world_size*sizeof(int));
211+
PMPI_Igather(prank, 1, MPI_INT, ranks, 1, MPI_INT, 0, MPI_COMM_WORLD, &req);
212+
PMPI_Wait(&req, &status);
213+
if (MPI_SUCCESS != status.MPI_ERROR)
214+
fprintf(stderr, "PMPI_Igather failed with error %d on rank %d\n", status.MPI_ERROR, world_rank);
215+
if (0 == world_rank)
216+
for (int i=0; i<world_size; i++)
217+
if (i+2 != ranks[i]) fprintf(stderr, "PMPI_Igather: at %d expected %d got %d\n", i, i+2, ranks[i]);
218+
free(prank);
219+
if (0 == world_rank) free(ranks);
220+
}
221+
222+
155223
PMPI_Comm_dup(MPI_COMM_WORLD, &oshmem_comm_world);
156224
ret = _shmem_init(argc, argv, requested, provided);
157225

0 commit comments

Comments
 (0)