@@ -292,10 +292,7 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
292
292
locking_atomic_op (win , & value , newval , compare , image_index , index );
293
293
294
294
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 ;
299
296
300
297
if (acquired_lock != NULL )
301
298
{
@@ -320,6 +317,7 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
320
317
{
321
318
communicator_shrink (& CAF_COMM_WORLD );
322
319
error_called = 0 ;
320
+ ierr = STAT_FAILED_IMAGE ;
323
321
}
324
322
325
323
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,
342
340
}
343
341
}
344
342
343
+ if (stat )
344
+ * stat = ierr ;
345
+ else if (ierr == STAT_FAILED_IMAGE )
346
+ error_stop (ierr );
347
+
345
348
return ;
346
349
347
350
stat_error :
@@ -369,7 +372,14 @@ void mutex_unlock(MPI_Win win, int image_index, int index, int *stat,
369
372
#if MPI_VERSION >= 3
370
373
int value = 1 , compare = 1 , newval = 0 ;
371
374
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
+ }
373
383
374
384
# ifdef CAF_MPI_LOCK_UNLOCK
375
385
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,
383
393
384
394
if (value == 0 )
385
395
goto stat_error ;
396
+
397
+ if (stat )
398
+ * stat = ierr ;
399
+ else if (ierr == STAT_FAILED_IMAGE )
400
+ error_stop (ierr );
386
401
387
402
return ;
388
403
@@ -1852,12 +1867,21 @@ PREFIX (sync_images) (int count, int images[], int *stat, char *errmsg,
1852
1867
for (i = 0 ; i < count ; i ++ )
1853
1868
ierr = MPI_Wait (& handlers [images [i ]- 1 ], & s );
1854
1869
1870
+ if (error_called == 1 )
1871
+ {
1872
+ communicator_shrink (& CAF_COMM_WORLD );
1873
+ error_called = 0 ;
1874
+ ierr = STAT_FAILED_IMAGE ;
1875
+ }
1876
+
1855
1877
memset (arrived , 0 , sizeof (int )* caf_num_images );
1856
1878
1857
1879
}
1858
1880
1859
1881
if (stat )
1860
1882
* stat = ierr ;
1883
+ else if (ierr == STAT_FAILED_IMAGE )
1884
+ error_stop (ierr );
1861
1885
1862
1886
sync_images_err_chk :
1863
1887
0 commit comments