Skip to content

Commit ae7d58c

Browse files
committed
Improve teams implementation
Improve the implementation of team's functions to adhere to the Fortran 2018 standard and gfortran from 15 on.
1 parent 5166003 commit ae7d58c

File tree

9 files changed

+760
-103
lines changed

9 files changed

+760
-103
lines changed

CMakeLists.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ endif()
233233
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0.0 ) )
234234
add_definitions(-DGCC_GE_8) # Tell library to build against GFortran 8.x bindings w/ descriptor change
235235
endif()
236-
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 14.0.0 ) )
236+
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15.0.0 ) )
237237
add_definitions(-DGCC_GE_15) # Tell library to build against GFortran 15.x bindings
238238
endif()
239239

@@ -803,7 +803,6 @@ if(opencoarrays_aware_compiler)
803803
add_caf_test(comp_allocated_2 2 comp_allocated_2)
804804
add_caf_test(alloc_comp_get_convert_nums 2 alloc_comp_get_convert_nums)
805805
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8)
806-
add_caf_test(team_number 8 team_number)
807806
add_caf_test(teams_subset 3 teams_subset)
808807
add_caf_test(get_communicator 3 get_communicator)
809808
add_caf_test(teams_coarray_get 5 teams_coarray_get)
@@ -815,6 +814,13 @@ if(opencoarrays_aware_compiler)
815814
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
816815
set_tests_properties(alloc_comp_multidim_shape PROPERTIES TIMEOUT 300)
817816
endif()
817+
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15)
818+
add_caf_test(team_number 8 team_number)
819+
add_caf_test(teams_this_image 8 teams_this_image)
820+
add_caf_test(teams_num_images 8 teams_num_images)
821+
else()
822+
add_caf_test(team_number_pre15 8 team_number_pre15)
823+
endif()
818824
endif()
819825

820826
if (gfortran_compiler)

src/application-binary-interface/libcaf.h

+29-14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
6565
#define STAT_STOPPED_IMAGE 6000
6666
#define STAT_FAILED_IMAGE 6001
6767

68+
#ifdef GCC_GE_15
69+
/* Definitions of the Fortran 2018 standard; need to kept in sync with
70+
ISO_FORTRAN_ENV, cf. gcc/fortran/libgfortran.h. */
71+
typedef enum
72+
{
73+
CAF_INITIAL_TEAM = 0,
74+
CAF_PARENT_TEAM,
75+
CAF_CURRENT_TEAM
76+
} caf_team_level_t;
77+
#endif
78+
6879
/* Describes what type of array we are registerring. Keep in sync with
6980
gcc/fortran/trans.h. */
7081
typedef enum caf_register_t
@@ -88,24 +99,12 @@ typedef enum caf_deregister_t
8899
CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY
89100
} caf_deregister_t;
90101

102+
/** The opaque type to represent a coarray token. */
91103
typedef void *caf_token_t;
92-
/** Add a dummy type representing teams in coarrays. */
93104

105+
/** The opaque type for teams. */
94106
typedef void *caf_team_t;
95107

96-
typedef struct caf_teams_list
97-
{
98-
caf_team_t team;
99-
int team_id;
100-
struct caf_teams_list *prev;
101-
} caf_teams_list;
102-
103-
typedef struct caf_used_teams_list
104-
{
105-
struct caf_teams_list *team_list_elem;
106-
struct caf_used_teams_list *prev;
107-
} caf_used_teams_list;
108-
109108
/* When there is a vector subscript in this dimension, nvec == 0, otherwise,
110109
lower_bound, upper_bound, stride contains the bounds relative to the declared
111110
bounds; kind denotes the integer kind of the elements of vector[]. */
@@ -238,8 +237,15 @@ bool PREFIX(is_contiguous)(gfc_descriptor_t *);
238237
void PREFIX(init)(int *, char ***);
239238
void PREFIX(finalize)(void);
240239

240+
#ifdef GCC_GE_15
241+
int PREFIX(this_image)(caf_team_t);
242+
243+
int PREFIX(num_images)(caf_team_t, int32_t *);
244+
#else
241245
int PREFIX(this_image)(int);
246+
242247
int PREFIX(num_images)(int, int);
248+
#endif
243249

244250
#ifdef GCC_GE_7
245251
void PREFIX(register)(size_t, caf_register_t, caf_token_t *, gfc_descriptor_t *,
@@ -359,11 +365,20 @@ void PREFIX(error_stop)(int QUIETARG) __attribute__((noreturn));
359365

360366
void PREFIX(fail_image)(void) __attribute__((noreturn));
361367

368+
#ifdef GCC_GE_15
369+
void PREFIX(form_team)(int, caf_team_t *, int *, int *, char *, charlen_t);
370+
void PREFIX(change_team)(caf_team_t, int *, char *, charlen_t);
371+
void PREFIX(end_team)(int *, char *, charlen_t);
372+
void PREFIX(sync_team)(caf_team_t, int *, char *, charlen_t);
373+
int PREFIX(team_number)(caf_team_t);
374+
caf_team_t PREFIX(get_team)(int32_t *);
375+
#else
362376
void PREFIX(form_team)(int, caf_team_t *, int);
363377
void PREFIX(change_team)(caf_team_t *, int);
364378
void PREFIX(end_team)(caf_team_t *);
365379
void PREFIX(sync_team)(caf_team_t *, int);
366380
int PREFIX(team_number)(caf_team_t *);
381+
#endif
367382

368383
int PREFIX(image_status)(int);
369384
void PREFIX(failed_images)(gfc_descriptor_t *, int, int *);

0 commit comments

Comments
 (0)