Skip to content

Commit f7de5fd

Browse files
author
Alessandro Fanfarillo
committed
Adding stat constraint to sync images, lock, unlock
1 parent c12de97 commit f7de5fd

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

src/mpi/mpi_caf.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,7 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
292292
locking_atomic_op(win, &value, newval, compare, image_index, index);
293293

294294
if(value == caf_this_image && image_index == caf_this_image)
295-
{
296-
printf("Lock already taken %d\n",caf_this_image);
297-
goto stat_error;
298-
}
295+
goto stat_error;
299296

300297
if(acquired_lock != NULL)
301298
{
@@ -320,6 +317,7 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
320317
{
321318
communicator_shrink(&CAF_COMM_WORLD);
322319
error_called = 0;
320+
ierr = STAT_FAILED_IMAGE;
323321
}
324322

325323
locking_atomic_op(win, &value, newval, compare, image_index, index);
@@ -342,6 +340,11 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
342340
}
343341
}
344342

343+
if(stat)
344+
*stat = ierr;
345+
else if(ierr == STAT_FAILED_IMAGE)
346+
error_stop (ierr);
347+
345348
return;
346349

347350
stat_error:
@@ -369,7 +372,14 @@ void mutex_unlock(MPI_Win win, int image_index, int index, int *stat,
369372
#if MPI_VERSION >= 3
370373
int value=1, compare = 1, newval = 0;
371374

372-
/* locking_atomic_op(win, &value, newval, compare, image_index, index); */
375+
MPI_Test(&lock_req,&flag,MPI_STATUS_IGNORE);
376+
377+
if(error_called == 1)
378+
{
379+
communicator_shrink(&CAF_COMM_WORLD);
380+
error_called = 0;
381+
ierr = STAT_FAILED_IMAGE;
382+
}
373383

374384
# ifdef CAF_MPI_LOCK_UNLOCK
375385
MPI_Win_lock (MPI_LOCK_EXCLUSIVE, image_index-1, 0, win);
@@ -383,6 +393,11 @@ void mutex_unlock(MPI_Win win, int image_index, int index, int *stat,
383393

384394
if(value == 0)
385395
goto stat_error;
396+
397+
if(stat)
398+
*stat = ierr;
399+
else if(ierr == STAT_FAILED_IMAGE)
400+
error_stop (ierr);
386401

387402
return;
388403

@@ -1852,12 +1867,21 @@ PREFIX (sync_images) (int count, int images[], int *stat, char *errmsg,
18521867
for(i=0; i < count; i++)
18531868
ierr = MPI_Wait(&handlers[images[i]-1], &s);
18541869

1870+
if(error_called == 1)
1871+
{
1872+
communicator_shrink(&CAF_COMM_WORLD);
1873+
error_called = 0;
1874+
ierr = STAT_FAILED_IMAGE;
1875+
}
1876+
18551877
memset(arrived, 0, sizeof(int)*caf_num_images);
18561878

18571879
}
18581880

18591881
if (stat)
18601882
*stat = ierr;
1883+
else if(ierr == STAT_FAILED_IMAGE)
1884+
error_stop (ierr);
18611885

18621886
sync_images_err_chk:
18631887

0 commit comments

Comments
 (0)