Skip to content

Commit c2373cf

Browse files
author
Alessandro Fanfarillo
committed
Partial version for stopped images
1 parent d66b185 commit c2373cf

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

src/libcaf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef void* caf_token_t;
8080
/* Linked list of static coarrays registered. */
8181
typedef struct caf_static_t {
8282
caf_token_t token;
83+
caf_token_t stopped_token;
8384
struct caf_static_t *prev;
8485
}
8586
caf_static_t;

src/mpi/mpi_caf.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ static void verbose_comm_errhandler(MPI_Comm* pcomm, int* err, ...){
132132
MPI_Group group_c, group_f;
133133
comm = *pcomm;
134134

135-
memset(ranks_gf,0,sizeof(int)*caf_num_images);
136-
memset(ranks_gc,0,sizeof(int)*caf_num_images);
135+
/* memset(ranks_gf,0,sizeof(int)*caf_num_images); */
136+
/* memset(ranks_gc,0,sizeof(int)*caf_num_images); */
137137

138138
MPIX_Comm_failure_ack(comm);
139139
MPIX_Comm_failure_get_acked(comm, &group_f);
@@ -144,15 +144,10 @@ static void verbose_comm_errhandler(MPI_Comm* pcomm, int* err, ...){
144144
MPI_Group_translate_ranks(group_f, nf, ranks_gf,
145145
group_c, ranks_gc);
146146
for(i = 0; i < nf; i++)
147-
{
148-
ranks_gc[i]++;
149-
/* printf("me: %d - ranks failed %d\n",caf_this_image,ranks_gc[i]); */
150-
}
147+
ranks_gc[i]++;
151148

152-
n_failed_imgs = nf;
149+
n_failed_imgs += nf;
153150
error_called = 1;
154-
/* used_comm++; */
155-
/* CAF_COMM_WORLD = communicators[used_comm]; */
156151
}
157152

158153
/* For MPI interoperability, allow external initialization
@@ -500,21 +495,21 @@ PREFIX (init) (int *argc, char ***argv)
500495

501496
MPI_Win_create_errhandler(verbose_win_errhandler, &errh_w);
502497

503-
ranks_gf = (int*)malloc(caf_num_images * sizeof(int));
504-
ranks_gc = (int*)malloc(caf_num_images * sizeof(int));
498+
ranks_gf = (int*)calloc(caf_num_images,sizeof(int));
499+
ranks_gc = (int*)calloc(caf_num_images,sizeof(int));
505500
stopped_images = (int*)calloc(caf_num_images, sizeof(int));
506501

507502
#if MPI_VERSION >= 3
508503
MPI_Info_create (&mpi_info_same_size);
509504
MPI_Info_set (mpi_info_same_size, "same_size", "true");
510505
/* Setting img_status */
511-
MPI_Win_allocate(sizeof(int), 1, mpi_info_same_size, CAF_COMM_WORLD, &img_status, stat_tok);
506+
MPI_Win_allocate(sizeof(int), 1, mpi_info_same_size, stopped_comm, &img_status, stat_tok);
512507
# ifndef CAF_MPI_LOCK_UNLOCK
513508
MPI_Win_lock_all(MPI_MODE_NOCHECK, *stat_tok);
514509
# endif // CAF_MPI_LOCK_UNLOCK
515510
#else
516511
MPI_Alloc_mem(sizeof(int), MPI_INFO_NULL, &img_status, stat_tok);
517-
MPI_Win_create(img_status, sizeof(int), 1, MPI_INFO_NULL, CAF_COMM_WORLD, stat_tok);
512+
MPI_Win_create(img_status, sizeof(int), 1, MPI_INFO_NULL, stopped_comm, stat_tok);
518513
#endif // MPI_VERSION
519514
*img_status = 0;
520515
MPI_Win_set_errhandler(*stat_tok,errh_w);
@@ -539,7 +534,7 @@ PREFIX (finalize) (void)
539534
communicator_shrink(&CAF_COMM_WORLD);
540535

541536
MPI_Barrier(stopped_comm);
542-
537+
543538
while (caf_static_list != NULL)
544539
{
545540
caf_static_t *tmp = caf_static_list->prev;
@@ -643,6 +638,7 @@ void *
643638
void *mem;
644639
size_t actual_size;
645640
int l_var=0, *init_array=NULL,ierr=0,flag=0;
641+
MPI_Win *stopped_win;
646642

647643
if (unlikely (caf_is_finalized))
648644
goto error;
@@ -658,6 +654,7 @@ void *
658654
/* Token contains only a list of pointers. */
659655

660656
*token = malloc (sizeof(MPI_Win));
657+
stopped_win = (MPI_Win *)malloc(sizeof(MPI_Win));
661658

662659
MPI_Win *p = *token;
663660

@@ -671,7 +668,7 @@ void *
671668
else
672669
actual_size = size;
673670

674-
MPI_Test(&lock_req,&flag,MPI_STATUS_IGNORE);
671+
MPI_Barrier(CAF_COMM_WORLD);
675672

676673
if(error_called == 1)
677674
{
@@ -710,18 +707,21 @@ void *
710707
/* PREFIX(sync_all) (NULL,NULL,0); */
711708
}
712709

713-
MPI_Barrier(CAF_COMM_WORLD);
710+
/* MPI_Barrier(CAF_COMM_WORLD); */
714711

715-
if(error_called == 1)
716-
{
717-
communicator_shrink(&CAF_COMM_WORLD);
718-
error_called = 0;
719-
ierr = STAT_FAILED_IMAGE;
720-
}
712+
/* if(error_called == 1) */
713+
/* { */
714+
/* communicator_shrink(&CAF_COMM_WORLD); */
715+
/* error_called = 0; */
716+
/* ierr = STAT_FAILED_IMAGE; */
717+
/* } */
721718

719+
/* MPI_Win_create_dynamic(MPI_INFO_NULL, stopped_comm, stopped_win); */
720+
722721
caf_static_t *tmp = malloc (sizeof (caf_static_t));
723722
tmp->prev = caf_tot;
724723
tmp->token = *token;
724+
tmp->stopped_token = stopped_win;
725725
caf_tot = tmp;
726726

727727
if (type == CAF_REGTYPE_COARRAY_STATIC)

0 commit comments

Comments
 (0)