Skip to content

Improve teams implementation #794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ endif()
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0.0 ) )
add_definitions(-DGCC_GE_8) # Tell library to build against GFortran 8.x bindings w/ descriptor change
endif()
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 14.0.0 ) )
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS_EQUAL 15.0.0 ) )
add_definitions(-DGCC_GE_15) # Tell library to build against GFortran 15.x bindings
endif()
if ( gfortran_compiler AND ( CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0.0 ) )
add_definitions(-DGCC_GE_16) # Tell library to build against GFortran 16.x bindings
endif()

if(gfortran_compiler)
set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
Expand Down Expand Up @@ -815,6 +818,12 @@ if(opencoarrays_aware_compiler)
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
set_tests_properties(alloc_comp_multidim_shape PROPERTIES TIMEOUT 300)
endif()
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 16)
add_caf_test(teams_this_image 8 teams_this_image)
add_caf_test(teams_num_images 8 teams_num_images)
add_caf_test(test_teams_1 9 test_teams_1)
add_caf_test(teams_coindexed 2 teams_coindexed)
endif()
endif()

if (gfortran_compiler)
Expand Down
48 changes: 33 additions & 15 deletions src/application-binary-interface/libcaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
#define STAT_STOPPED_IMAGE 6000
#define STAT_FAILED_IMAGE 6001

#ifdef GCC_GE_16
/* Definitions of the Fortran 2018 standard; need to kept in sync with
ISO_FORTRAN_ENV, cf. gcc/fortran/libgfortran.h. */
typedef enum
{
CAF_INITIAL_TEAM = 0,
CAF_PARENT_TEAM,
CAF_CURRENT_TEAM
} caf_team_level_t;
#endif

/* Describes what type of array we are registerring. Keep in sync with
gcc/fortran/trans.h. */
typedef enum caf_register_t
Expand All @@ -77,7 +88,10 @@ typedef enum caf_register_t
CAF_REGTYPE_EVENT_STATIC,
CAF_REGTYPE_EVENT_ALLOC,
CAF_REGTYPE_COARRAY_ALLOC_REGISTER_ONLY,
CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY
CAF_REGTYPE_COARRAY_ALLOC_ALLOCATE_ONLY,
#ifdef GCC_GE_16
CAF_REGTYPE_COARRAY_MAP_EXISTING,
#endif
} caf_register_t;

/* Describes the action to take on _caf_deregister. Keep in sync with
Expand All @@ -88,24 +102,12 @@ typedef enum caf_deregister_t
CAF_DEREGTYPE_COARRAY_DEALLOCATE_ONLY
} caf_deregister_t;

/** The opaque type to represent a coarray token. */
typedef void *caf_token_t;
/** Add a dummy type representing teams in coarrays. */

/** The opaque type for teams. */
typedef void *caf_team_t;

typedef struct caf_teams_list
{
caf_team_t team;
int team_id;
struct caf_teams_list *prev;
} caf_teams_list;

typedef struct caf_used_teams_list
{
struct caf_teams_list *team_list_elem;
struct caf_used_teams_list *prev;
} caf_used_teams_list;

/* When there is a vector subscript in this dimension, nvec == 0, otherwise,
lower_bound, upper_bound, stride contains the bounds relative to the declared
bounds; kind denotes the integer kind of the elements of vector[]. */
Expand Down Expand Up @@ -238,8 +240,15 @@ bool PREFIX(is_contiguous)(gfc_descriptor_t *);
void PREFIX(init)(int *, char ***);
void PREFIX(finalize)(void);

#ifdef GCC_GE_16
int PREFIX(this_image)(caf_team_t);

int PREFIX(num_images)(caf_team_t, int32_t *);
#else
int PREFIX(this_image)(int);

int PREFIX(num_images)(int, int);
#endif

#ifdef GCC_GE_7
void PREFIX(register)(size_t, caf_register_t, caf_token_t *, gfc_descriptor_t *,
Expand Down Expand Up @@ -359,11 +368,20 @@ void PREFIX(error_stop)(int QUIETARG) __attribute__((noreturn));

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

#ifdef GCC_GE_16
void PREFIX(form_team)(int, caf_team_t *, int *, int *, char *, charlen_t);
void PREFIX(change_team)(caf_team_t, int *, char *, charlen_t);
void PREFIX(end_team)(int *, char *, charlen_t);
void PREFIX(sync_team)(caf_team_t, int *, char *, charlen_t);
int PREFIX(team_number)(caf_team_t);
caf_team_t PREFIX(get_team)(int32_t *);
#else
void PREFIX(form_team)(int, caf_team_t *, int);
void PREFIX(change_team)(caf_team_t *, int);
void PREFIX(end_team)(caf_team_t *);
void PREFIX(sync_team)(caf_team_t *, int);
int PREFIX(team_number)(caf_team_t *);
#endif

int PREFIX(image_status)(int);
void PREFIX(failed_images)(gfc_descriptor_t *, int, int *);
Expand Down
Loading