Skip to content

Commit 282aaaf

Browse files
author
Alessandro Fanfarillo
committed
Form team
1 parent c64cc1e commit 282aaaf

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/libcaf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ typedef void* caf_token_t;
9292
#ifdef GCC_GE_7
9393
/** Add a dummy type representing teams in coarrays. */
9494
typedef void * caf_team_t;
95+
typedef struct caf_teams_list {
96+
caf_team_t team;
97+
int team_id;
98+
struct caf_teams_list *prev;
99+
}
100+
caf_teams_list;
95101
#endif
96102

97103
/* Linked list of static coarrays registered. */
@@ -277,6 +283,8 @@ void PREFIX (error_stop_str) (const char *, int32_t)
277283
void PREFIX (error_stop) (int32_t) __attribute__ ((noreturn));
278284
void PREFIX (fail_image) (void) __attribute__ ((noreturn));
279285

286+
void PREFIX (form_team) (int, caf_team_t *, int);
287+
280288
int PREFIX (image_status) (int);
281289
void PREFIX (failed_images) (gfc_descriptor_t *, int, int *);
282290
void PREFIX (stopped_images) (gfc_descriptor_t *, int, int *);

src/mpi/mpi_caf.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ char err_buffer[MPI_MAX_ERROR_STRING];
173173
MPI_COMM_WORLD for interoperability purposes. */
174174
MPI_Comm CAF_COMM_WORLD;
175175

176+
static caf_teams_list *teams_list = NULL;
177+
static MPI_Comm current_team;
178+
176179
#ifdef WITH_FAILED_IMAGES
177180
/* The stati of the other images. image_stati is an array of size
178181
* caf_num_images at the beginning the status of each image is noted here
@@ -754,6 +757,8 @@ PREFIX (init) (int *argc, char ***argv)
754757

755758
stat_tok = malloc (sizeof (MPI_Win));
756759

760+
current_team = CAF_COMM_WORLD;
761+
757762
#ifdef WITH_FAILED_IMAGES
758763
MPI_Comm_dup (MPI_COMM_WORLD, &alive_comm);
759764
/* Handling of failed/stopped images is done by setting an error handler
@@ -4310,7 +4315,6 @@ PREFIX(atomic_ref) (caf_token_t token, size_t offset,
43104315
return;
43114316
}
43124317

4313-
43144318
void
43154319
PREFIX(atomic_cas) (caf_token_t token, size_t offset,
43164320
int image_index, void *old, void *compare,
@@ -4802,3 +4806,20 @@ unimplemented_alloc_comps_message (const char * functionname)
48024806
exit (EXIT_FAILURE);
48034807
#endif
48044808
}
4809+
4810+
void PREFIX (form_team) (int team_id, caf_team_t *team, int index __attribute__ ((unused)))
4811+
{
4812+
struct caf_teams_list *tmp;
4813+
void * tmp_team;
4814+
MPI_Comm newcomm;
4815+
MPI_Comm *current_comm = &current_team;
4816+
4817+
MPI_Comm_split(*current_comm, team_id, caf_this_image, &newcomm);
4818+
4819+
tmp = calloc(1,sizeof(struct caf_teams_list));
4820+
tmp->prev = teams_list;
4821+
teams_list = tmp;
4822+
teams_list->team_id = team_id;
4823+
teams_list->team = &newcomm;
4824+
*team = &newcomm;
4825+
}

0 commit comments

Comments
 (0)