Skip to content

Commit 8ceb2ce

Browse files
author
Damian Rouson
committed
mv get_team->get_communicator; build if have MPI
1 parent ccf0fe5 commit 8ceb2ce

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ if (NOT MPIEXEC)
229229
report this bug to the OpenCoarrays developers at
230230
https://github.com/sourceryinstitute/opencoarrays/issues, otherwise use point CMake
231231
to the desired MPI runtime.")
232+
else()
233+
add_definitions(-DHAVE_MPI)
232234
endif()
233235

234236
get_filename_component(MPIEXEC_RELATIVE_LOC "${MPIEXEC}"
@@ -545,7 +547,7 @@ if(opencoarrays_aware_compiler)
545547
add_mpi_test(async_comp_alloc 6 ${tests_root}/unit/init_register/async_comp_alloc)
546548
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8)
547549
add_mpi_test(team_number 2 ${tests_root}/unit/teams/team_number)
548-
add_mpi_test(get_team 3 ${tests_root}/unit/teams/get_team)
550+
add_mpi_test(get_communicator 3 ${tests_root}/unit/teams/get_communicator)
549551
endif()
550552
endif()
551553
endif()

src/extensions/opencoarrays.F90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ module opencoarrays
4747
public :: error_stop
4848
public :: sync_all
4949
public :: team_number
50-
public :: get_team
50+
#ifdef HAVE_MPI
51+
public :: get_communicator
52+
#endif
5153
#ifdef COMPILER_SUPPORTS_ATOMICS
5254
public :: event_type
5355
public :: event_post
@@ -117,9 +119,9 @@ function team_number(team_type_ptr) result(my_team_number) bind(C,name="_gfortra
117119
end function
118120

119121
#ifdef COMPILER_SUPPORTS_CAF_INTRINSICS
120-
function get_team(team_type_ptr) result(my_team) bind(C,name="_caf_extensions_get_team")
122+
function get_communicator(team_type_ptr) result(my_team) bind(C,name="_caf_extensions_get_communicator")
121123
#else
122-
function get_team(team_type_ptr) result(my_team) bind(C,name="_gfortran_caf_get_team")
124+
function get_communicator(team_type_ptr) result(my_team) bind(C,name="_gfortran_caf_get_communicator")
123125
#endif
124126
use iso_c_binding, only : c_int,c_ptr
125127
implicit none

src/libcaf.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ void PREFIX (change_team) (caf_team_t *, int);
299299
void PREFIX (end_team) (caf_team_t *);
300300
void PREFIX (sync_team) (caf_team_t *, int);
301301
int PREFIX (team_number) (caf_team_t *);
302-
MPI_Fint PREFIX (get_team) (caf_team_t *);
303302

304303
int PREFIX (image_status) (int);
305304
void PREFIX (failed_images) (gfc_descriptor_t *, int, int *);
@@ -317,4 +316,10 @@ void PREFIX (unlock) (caf_token_t, size_t, int, int *, char *, int);
317316
void PREFIX (event_post) (caf_token_t, size_t, int, int *, char *, int);
318317
void PREFIX (event_wait) (caf_token_t, size_t, int, int *, char *, int);
319318
void PREFIX (event_query) (caf_token_t, size_t, int, int *, int *);
319+
320+
/* Language extension */
321+
#ifdef HAVE_MPI
322+
MPI_Fint PREFIX (get_communicator) (caf_team_t *);
323+
#endif
324+
320325
#endif /* LIBCAF_H */

src/mpi/mpi_caf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4877,9 +4877,9 @@ void PREFIX (change_team) (caf_team_t *team, int coselector __attribute__ ((unus
48774877
}
48784878

48794879
MPI_Fint
4880-
PREFIX (get_team) (caf_team_t *team)
4880+
PREFIX (get_communicator) (caf_team_t *team)
48814881
{
4882-
if(team != NULL) caf_runtime_error("get_team does not yet support the optional team argument");
4882+
if(team != NULL) caf_runtime_error("get_communicator does not yet support the optional team argument");
48834883

48844884
MPI_Comm* comm_ptr = teams_list->team;
48854885

src/tests/unit/teams/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ add_executable(team_number team-number.f90)
22
target_link_libraries(team_number OpenCoarrays)
33
target_include_directories(team_number PRIVATE ${CMAKE_BINARY_DIR}/mod)
44

5-
add_executable(get_team get-team.f90)
6-
target_link_libraries(get_team OpenCoarrays)
7-
target_include_directories(get_team PRIVATE ${CMAKE_BINARY_DIR}/mod)
5+
add_executable(get_communicator get-communicator.f90)
6+
target_link_libraries(get_communicator OpenCoarrays)
7+
target_include_directories(get_communicator PRIVATE ${CMAKE_BINARY_DIR}/mod)

src/tests/unit/teams/get-team.f90 renamed to src/tests/unit/teams/get-communicator.f90

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2929
! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
program main
31-
!! summary: Test get_team function, an OpenCoarrays-specific language extension
32-
use opencoarrays, only : get_team
31+
!! summary: Test get_commiunicator function, an OpenCoarrays-specific language extension
32+
use opencoarrays, only : get_communicator
3333

3434
implicit none
3535

36-
call mpi_matches_caf(get_team())
36+
call mpi_matches_caf(get_communicator())
3737
!! verify # ranks = # images and image number = rank + 1
3838

3939
block
4040
use iso_fortran_env, only : team_type
41-
use opencoarrays, only : get_team, team_number !! TODO: remove team_number once gfortran supports it
41+
use opencoarrays, only : get_communicator, team_number !! TODO: remove team_number once gfortran supports it
4242

4343
type(team_type) :: league
4444
integer, parameter :: num_teams=2
@@ -52,7 +52,7 @@ program main
5252
change team(league)
5353
!! join my destination team
5454

55-
call mpi_matches_caf(get_team())
55+
call mpi_matches_caf(get_communicator())
5656
!! verify new # ranks = new # images and new image number = new rank + 1
5757

5858
associate(my_team=>team_number())

0 commit comments

Comments
 (0)