Skip to content

Commit 168615a

Browse files
committed
Improve teams implementation
Improve the implementation of team's functions to adhere to the Fortran 2018 standard and gfortran from 16 on.
1 parent 3d0fa68 commit 168615a

File tree

8 files changed

+759
-101
lines changed

8 files changed

+759
-101
lines changed

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,12 @@ 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()
239+
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 16.0.0 ) )
240+
add_definitions(-DGCC_GE_16) # Tell library to build against GFortran 16.x bindings
241+
endif()
239242

240243
if(gfortran_compiler)
241244
set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
@@ -803,7 +806,6 @@ if(opencoarrays_aware_compiler)
803806
add_caf_test(comp_allocated_2 2 comp_allocated_2)
804807
add_caf_test(alloc_comp_get_convert_nums 2 alloc_comp_get_convert_nums)
805808
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8)
806-
add_caf_test(team_number 8 team_number)
807809
add_caf_test(teams_subset 3 teams_subset)
808810
add_caf_test(get_communicator 3 get_communicator)
809811
add_caf_test(teams_coarray_get 5 teams_coarray_get)
@@ -815,6 +817,13 @@ if(opencoarrays_aware_compiler)
815817
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
816818
set_tests_properties(alloc_comp_multidim_shape PROPERTIES TIMEOUT 300)
817819
endif()
820+
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15)
821+
add_caf_test(team_number 8 team_number)
822+
add_caf_test(teams_this_image 8 teams_this_image)
823+
add_caf_test(teams_num_images 8 teams_num_images)
824+
else()
825+
add_caf_test(team_number_pre15 8 team_number_pre15)
826+
endif()
818827
endif()
819828

820829
if (gfortran_compiler)

src/application-binary-interface/libcaf.h

Lines changed: 29 additions & 14 deletions
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_16
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_16
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_16
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)