Skip to content

Migrate to gfortran-15 ABI for accessing data in non-coarray aware codes. #792

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

Merged
merged 14 commits into from
Apr 10, 2025
Merged
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ 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 ) )
add_definitions(-DGCC_GE_15) # Tell library to build against GFortran 15.x bindings
endif()

if(gfortran_compiler)
set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
Expand Down Expand Up @@ -661,7 +664,10 @@ define_property(TARGET
# Add global openmpi property, because using a variable an setting in parent scope did
# not work as expected, i.e., not at all, on Linux Fedora 39.
#-------------------------------------------------------------------------------------
define_property(GLOBAL PROPERTY openmpi BRIEF_DOCS "True when mpi is openMPI.")
define_property(GLOBAL
PROPERTY openmpi
BRIEF_DOCS "True when mpi is openMPI."
FULL_DOCS "Set internally when the mpi library to use is openmpi.")

#-------------------------------
# Recurse into the src directory
Expand Down Expand Up @@ -807,6 +813,7 @@ if(opencoarrays_aware_compiler)
add_caf_test(teams_coarray_sendget 5 teams_coarray_sendget)
add_caf_test(sync_team 8 sync_team)
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
set_tests_properties(alloc_comp_multidim_shape PROPERTIES TIMEOUT 300)
endif()
endif()

Expand Down Expand Up @@ -858,6 +865,7 @@ if(opencoarrays_aware_compiler)

# Pure sendget tests
add_caf_test(strided_sendget 3 strided_sendget)
add_caf_test(get_with_1d_vector_index 3 get_with_1d_vector_index)
add_caf_test(get_with_vector_index 4 get_with_vector_index)

# Collective subroutine tests
Expand Down
44 changes: 44 additions & 0 deletions src/application-binary-interface/libcaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

#include <stdbool.h>
#include <stddef.h> /* For size_t. */
#include <stdint.h>

#include "libcaf-gfortran-descriptor.h"
#include "libcaf-version-def.h"
Expand Down Expand Up @@ -261,6 +262,49 @@ void PREFIX(caf_sendget)(caf_token_t, size_t, int, gfc_descriptor_t *,
gfc_descriptor_t *, caf_vector_t *, int, int, bool,
int *);

#ifdef GCC_GE_15
void PREFIX(register_accessor)(const int hash,
void (*accessor)(void *, const int *, void **,
int32_t *, void *, caf_token_t,
const size_t, size_t *,
const size_t *));

void PREFIX(register_accessors_finish)();

int PREFIX(get_remote_function_index)(const int hash);

void PREFIX(get_from_remote)(
caf_token_t token, const gfc_descriptor_t *opt_src_desc,
const size_t *opt_src_charlen, const int image_index, const size_t dst_size,
void **dst_data, size_t *opt_dst_charlen, gfc_descriptor_t *opt_dst_desc,
const bool may_realloc_dst, const int getter_index, void *get_data,
const size_t get_data_size, int *stat, caf_team_t *team, int *team_number);

int32_t PREFIX(is_present_on_remote)(caf_token_t token, const int image_index,
const int is_present_index, void *add_data,
const size_t add_data_size);

void PREFIX(send_to_remote)(caf_token_t token, gfc_descriptor_t *opt_dst_desc,
const size_t *opt_dst_charlen,
const int image_index, const size_t src_size,
const void *src_data, size_t *opt_src_charlen,
const gfc_descriptor_t *opt_src_desc,
const int setter_index, void *add_data,
const size_t add_data_size, int *stat,
caf_team_t *team, int *team_number);

void PREFIX(transfer_between_remotes)(
caf_token_t dst_token, gfc_descriptor_t *opt_dst_desc,
size_t *opt_dst_charlen, const int dst_image_index,
const int dst_access_index, void *dst_add_data,
const size_t dst_add_data_size, caf_token_t src_token,
const gfc_descriptor_t *opt_src_desc, const size_t *opt_src_charlen,
const int src_image_index, const int src_access_index, void *src_add_data,
const size_t src_add_data_size, const size_t src_size,
const bool scalar_transfer, int *dst_stat, int *src_stat,
caf_team_t *dst_team, int *dst_team_number, caf_team_t *src_team,
int *src_team_number);
#endif
#ifdef GCC_GE_8
void PREFIX(get_by_ref)(caf_token_t, int, gfc_descriptor_t *dst,
caf_reference_t *refs, int dst_kind, int src_kind,
Expand Down
5 changes: 5 additions & 0 deletions src/runtime-libraries/mpi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ set(HOST_NAME ${HOST_NAME} PARENT_SCOPE)
execute_process(COMMAND ${MPIEXEC_EXECUTABLE} --version
OUTPUT_VARIABLE mpi_version_out)
if (mpi_version_out MATCHES "[Oo]pen[ -][Mm][Pp][Ii]")
if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 14.0.0 ) )
# OpenMPI uses addresses for windows instead of identical ids on all images for the same token.
# Therefore we can't use it (yet; and probably never).
message( FATAL_ERROR "OpenMPI is incompatible with gfortran's coarray implementation from gfortran version 15 on. Please use a different MPI implementation!")
endif ()
message( STATUS "OpenMPI detected")
set_property(GLOBAL PROPERTY openmpi true)
# Write out a host file because OMPI's mpiexec is dumb
Expand Down
Loading