@@ -439,6 +439,7 @@ _gfortran_caf_init (int *argc, char ***argv)
439
439
PREFIX (init ) (int * argc , char * * * argv )
440
440
#endif
441
441
{
442
+ int rc ,flag ;
442
443
if (caf_num_images == 0 )
443
444
{
444
445
int ierr = 0 , i = 0 , j = 0 ;
@@ -475,7 +476,12 @@ PREFIX (init) (int *argc, char ***argv)
475
476
476
477
/* Duplicate MPI_COMM_WORLD so that no CAF internal functions
477
478
use it - this is critical for MPI-interoperability. */
478
- MPI_Comm_dup (MPI_COMM_WORLD , & CAF_COMM_WORLD );
479
+ rc = MPI_Comm_dup (MPI_COMM_WORLD , & CAF_COMM_WORLD );
480
+ flag = (MPI_SUCCESS == rc );
481
+ flag = MPIX_Comm_agree (MPI_COMM_WORLD ,& flag );
482
+ if (flag != MPI_SUCCESS )
483
+ MPI_Abort (MPI_COMM_WORLD ,10000 );
484
+ MPI_Barrier (MPI_COMM_WORLD );
479
485
480
486
MPI_Comm_size (CAF_COMM_WORLD , & caf_num_images );
481
487
MPI_Comm_rank (CAF_COMM_WORLD , & caf_this_image );
@@ -562,7 +568,7 @@ PREFIX (finalize) (void)
562
568
failed = 1 ;
563
569
break ;
564
570
}
565
- if (!failed )
571
+ if (!failed && i != caf_this_image - 1 )
566
572
{
567
573
MPI_Accumulate (& one , 1 , MPI_INT , i , (caf_this_image - 1 )* sizeof (int ), 1 , MPI_INT , MPI_REPLACE , * stat_tok );
568
574
}
@@ -676,28 +682,31 @@ void *
676
682
{
677
683
/* int ierr; */
678
684
void * mem ;
685
+ MPI_Win * p ;
679
686
size_t actual_size ;
680
687
int l_var = 0 , * init_array = NULL ,ierr = 0 ,flag = 0 ;
681
688
MPI_Win * stopped_win ;
682
-
689
+
683
690
if (unlikely (caf_is_finalized ))
684
691
goto error ;
685
-
692
+
686
693
/* Start GASNET if not already started. */
687
694
if (caf_num_images == 0 )
688
695
#ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
689
696
_gfortran_caf_init (NULL , NULL );
690
697
#else
691
- PREFIX (init ) (NULL , NULL );
698
+ PREFIX (init ) (NULL , NULL );
692
699
#endif
693
-
700
+
694
701
/* Token contains only a list of pointers. */
695
-
696
- * token = malloc (sizeof (MPI_Win ));
702
+
703
+ /* *token = malloc (sizeof(MPI_Win)); */
704
+ p = malloc (sizeof (MPI_Win ));
705
+ * token = p ;
697
706
stopped_win = (MPI_Win * )malloc (sizeof (MPI_Win ));
698
-
699
- MPI_Win * p = * token ;
700
-
707
+
708
+ /* MPI_Win *p = *token; */
709
+
701
710
if (type == CAF_REGTYPE_LOCK_STATIC || type == CAF_REGTYPE_LOCK_ALLOC ||
702
711
type == CAF_REGTYPE_CRITICAL || type == CAF_REGTYPE_EVENT_STATIC ||
703
712
type == CAF_REGTYPE_EVENT_ALLOC )
@@ -717,9 +726,9 @@ void *
717
726
}
718
727
719
728
#if MPI_VERSION >= 3
720
- MPI_Win_allocate (actual_size , 1 , mpi_info_same_size , CAF_COMM_WORLD , & mem , * token );
729
+ MPI_Win_allocate (actual_size , 1 , MPI_INFO_NULL , CAF_COMM_WORLD , & mem , p );
721
730
# ifndef CAF_MPI_LOCK_UNLOCK
722
- MPI_Win_lock_all (MPI_MODE_NOCHECK , * p );
731
+ MPI_Win_lock_all (0 , * p );
723
732
# endif // CAF_MPI_LOCK_UNLOCK
724
733
#else // MPI_VERSION
725
734
MPI_Alloc_mem (actual_size , MPI_INFO_NULL , & mem );
@@ -728,7 +737,7 @@ void *
728
737
729
738
p = * token ;
730
739
731
- MPI_Win_set_errhandler (* p ,errh_w );
740
+ /* MPI_Win_set_errhandler(*p,errh_w); */
732
741
733
742
if (error_called == 1 )
734
743
{
@@ -897,13 +906,13 @@ PREFIX (sync_all) (int *stat, char *errmsg, int errmsg_len)
897
906
{
898
907
int ierr = 0 ,flag = 0 ;
899
908
900
- if (error_called == 1 )
901
- {
902
- communicator_shrink (& CAF_COMM_WORLD );
903
- error_called = 0 ;
904
- ierr = STAT_FAILED_IMAGE ;
905
- / * MPI_Barrier(CAF_COMM_WORLD); */
906
- }
909
+ /* if(error_called == 1) */
910
+ /* { */
911
+ /* communicator_shrink(&CAF_COMM_WORLD); */
912
+ /* error_called = 0; */
913
+ /* ierr = STAT_FAILED_IMAGE; */
914
+ /* /\ * MPI_Barrier(CAF_COMM_WORLD); *\/ */
915
+ /* } */
907
916
908
917
if (unlikely (caf_is_finalized ))
909
918
ierr = STAT_STOPPED_IMAGE ;
@@ -1196,6 +1205,20 @@ PREFIX (send) (caf_token_t token, size_t offset, int image_index,
1196
1205
if (size == 0 )
1197
1206
return ;
1198
1207
1208
+ for (j = 0 ;j < n_failed_imgs ;j ++ )
1209
+ {
1210
+ if (image_index == failed_images_array [j ])
1211
+ {
1212
+ if (!stat )
1213
+ error_stop (STAT_FAILED_IMAGE );
1214
+
1215
+ if (stat )
1216
+ * stat = STAT_FAILED_IMAGE ;
1217
+
1218
+ return ;
1219
+ }
1220
+ }
1221
+
1199
1222
if (GFC_DESCRIPTOR_TYPE (dest ) == BT_CHARACTER && dst_size > src_size )
1200
1223
{
1201
1224
pad_str = alloca (dst_size - src_size );
@@ -1571,6 +1594,20 @@ PREFIX (get) (caf_token_t token, size_t offset,
1571
1594
if (size == 0 )
1572
1595
return ;
1573
1596
1597
+ for (j = 0 ;j < n_failed_imgs ;j ++ )
1598
+ {
1599
+ if (image_index == failed_images_array [j ])
1600
+ {
1601
+ if (!stat )
1602
+ error_stop (STAT_FAILED_IMAGE );
1603
+
1604
+ if (stat )
1605
+ * stat = STAT_FAILED_IMAGE ;
1606
+
1607
+ return ;
1608
+ }
1609
+ }
1610
+
1574
1611
if (GFC_DESCRIPTOR_TYPE (dest ) == BT_CHARACTER && dst_size > src_size )
1575
1612
{
1576
1613
pad_str = alloca (dst_size - src_size );
0 commit comments