Skip to content

Commit a409f4f

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

File tree

8 files changed

+679
-111
lines changed

8 files changed

+679
-111
lines changed

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,10 @@ if(opencoarrays_aware_compiler)
815815
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
816816
set_tests_properties(alloc_comp_multidim_shape PROPERTIES TIMEOUT 300)
817817
endif()
818+
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15)
819+
add_caf_test(teams_this_image 8 teams_this_image)
820+
add_caf_test(teams_num_images 8 teams_num_images)
821+
endif()
818822
endif()
819823

820824
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)