Skip to content

Commit 9fd352a

Browse files
authored
Merge branch 'master' into co_broadcast-derived-type
2 parents 2ed2e9a + d13375d commit 9fd352a

File tree

8 files changed

+394
-102
lines changed

8 files changed

+394
-102
lines changed

CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ string(REGEX REPLACE "-rc[0-9]+$"
9595
project(opencoarrays VERSION "${OPENCOARRAYS_CMAKE_PROJECT_VERSION}" LANGUAGES C Fortran)
9696

9797
if(DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" MATCHES "[Rr][Ee][Ll]")
98-
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-working-directory")
99-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-working-directory")
98+
if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
99+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-working-directory")
100+
endif()
101+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.")
102+
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
103+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-working-directory")
104+
endif()
105+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.")
100106
endif()
101107

102108
message( STATUS "Building OpenCoarrays version: ${full_git_describe}" )
@@ -718,8 +724,6 @@ if(opencoarrays_aware_compiler)
718724
add_caf_test(allocate_as_barrier_proc 8 allocate_as_barrier_proc)
719725
endif()
720726
if (gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0) OR (CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER}))
721-
message( STATUS "Allocatable components of coarray derived types only supported in GFortran >= 7 with OpenCoarrays > 1.8.4" )
722-
message( STATUS "(but full support not anticipated until OpenCoarrays 2.0 release)" )
723727
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0)
724728
message( AUTHOR_WARNING "Allocatable components of coarray derived type developer tests enabled, despite lack of support in GFortran < 7\n These tests should fail." )
725729
endif()
@@ -735,6 +739,11 @@ if(opencoarrays_aware_compiler)
735739
add_caf_test(team_number 8 team_number)
736740
add_caf_test(teams_subset 3 teams_subset)
737741
add_caf_test(get_communicator 3 get_communicator)
742+
add_caf_test(teams_coarray_get 5 teams_coarray_get)
743+
add_caf_test(teams_coarray_get_by_ref 5 teams_coarray_get_by_ref)
744+
add_caf_test(teams_coarray_send 5 teams_coarray_send)
745+
add_caf_test(teams_coarray_send_by_ref 5 teams_coarray_send_by_ref)
746+
add_caf_test(teams_coarray_sendget 5 teams_coarray_sendget)
738747
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
739748
endif()
740749
endif()

src/mpi/mpi_caf.c

Lines changed: 224 additions & 98 deletions
Large diffs are not rendered by default.

src/tests/unit/teams/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
caf_compile_executable(team_number team-number.f90)
22
caf_compile_executable(teams_subset teams_subset.f90)
33
caf_compile_executable(get_communicator get-communicator.F90)
4+
caf_compile_executable(teams_coarray_get teams_coarray_get.f90)
5+
caf_compile_executable(teams_coarray_get_by_ref teams_coarray_get.f90)
6+
caf_compile_executable(teams_coarray_send teams_coarray_send.f90)
7+
caf_compile_executable(teams_coarray_send_by_ref teams_coarray_send.f90)
8+
caf_compile_executable(teams_coarray_sendget teams_coarray_sendget.f90)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
program teams_coarray_get
2+
use, intrinsic :: iso_fortran_env, only: team_type
3+
implicit none
4+
type(team_type) :: team
5+
integer, allocatable :: L(:)
6+
integer :: i, my_team, R[*]
7+
8+
! handle odd or even number of images
9+
allocate(L(num_images()/2+mod(num_images(),2)*mod(this_image(),2)))
10+
11+
R = this_image()
12+
my_team = mod(this_image()-1,2)+1
13+
14+
form team (my_team, team)
15+
16+
change team (team)
17+
do i = 1, num_images()
18+
L(i) = R[i]
19+
end do
20+
end team
21+
22+
if (any(L /= [(i, i=my_team, num_images(), 2)])) error stop 'Test failed.'
23+
24+
sync all
25+
26+
if (this_image() == 1) write(*,*) 'Test passed.'
27+
end program teams_coarray_get
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
program teams_coarray_get_by_ref
2+
use, intrinsic :: iso_fortran_env, only: team_type
3+
implicit none
4+
type(team_type) :: team
5+
type :: allocatable_array_t
6+
integer, allocatable :: A(:)
7+
end type
8+
type(allocatable_array_t) :: R[*]
9+
integer, allocatable :: L(:)
10+
integer :: i, my_team
11+
12+
! handle odd or even number of images
13+
allocate(L(num_images()/2+mod(num_images(),2)*mod(this_image(),2)))
14+
15+
my_team = mod(this_image()-1,2)+1
16+
17+
form team (my_team, team)
18+
19+
! size(R%A) == this_image(team)
20+
allocate(R%A((this_image()+1)/2), source=0)
21+
22+
R%A(ubound(R%A,1)) = this_image()
23+
24+
change team (team)
25+
do i = 1, num_images()
26+
L(i) = R[i]%A(i)
27+
end do
28+
end team
29+
30+
if (any(L /= [(i, i=my_team, num_images(), 2)])) error stop 'Test failed.'
31+
32+
sync all
33+
34+
if (this_image() == 1) write(*,*) 'Test passed.'
35+
end program teams_coarray_get_by_ref
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
program teams_coarray_send
2+
use, intrinsic :: iso_fortran_env, only: team_type
3+
implicit none
4+
type(team_type) :: team
5+
integer, allocatable :: R(:)[:]
6+
integer :: extent, i, my_team, initial_team_this_image, odd
7+
8+
! if odd number of images, even images have R(extent) == 0
9+
extent = num_images()/2+mod(num_images(),2)
10+
allocate(R(extent)[*], source=0)
11+
12+
initial_team_this_image = this_image()
13+
my_team = mod(this_image()-1,2)+1
14+
15+
form team (my_team, team)
16+
17+
change team (team)
18+
do i = 1, num_images()
19+
R(this_image())[i] = initial_team_this_image
20+
end do
21+
end team
22+
23+
if (any(R /= [(mod(i, num_images()+1), i=my_team, 2*extent, 2)])) error stop 'Test failed.'
24+
25+
sync all
26+
27+
if (this_image() == 1) write(*,*) 'Test passed.'
28+
end program teams_coarray_send
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
program teams_coarray_get_by_ref
2+
use, intrinsic :: iso_fortran_env, only: team_type
3+
implicit none
4+
type(team_type) :: team
5+
type :: allocatable_array_t
6+
integer, allocatable :: A(:)
7+
end type
8+
type(allocatable_array_t) :: R[*]
9+
integer :: i, my_team, initial_team_this_image
10+
11+
! handle odd or even number of images
12+
allocate(R%A(num_images()/2+mod(num_images(),2)*mod(this_image(),2)), source=0)
13+
14+
initial_team_this_image = this_image()
15+
my_team = mod(this_image()-1,2)+1
16+
17+
form team (my_team, team)
18+
19+
change team (team)
20+
do i = 1, num_images()
21+
R[i]%A(this_image()) = initial_team_this_image
22+
end do
23+
end team
24+
25+
if (any(R%A /= [(i, i=my_team, num_images(), 2)])) error stop 'Test failed.'
26+
27+
sync all
28+
29+
if (this_image() == 1) write(*,*) 'Test passed.'
30+
end program teams_coarray_get_by_ref
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
program teams_coarray_sendget
2+
use, intrinsic :: iso_fortran_env, only: team_type
3+
implicit none
4+
type(team_type) :: team
5+
integer, allocatable :: R_send(:,:)[:]
6+
integer :: extent, i, j, my_team, team_num_images, R_get[*]
7+
8+
! if there are an odd number of images, then even images have R(:,extent) == 0
9+
extent = num_images()/2+mod(num_images(),2)
10+
allocate(R_send(extent, extent)[*], source=0)
11+
12+
my_team = mod(this_image()-1,2)+1
13+
14+
form team (my_team, team)
15+
16+
R_get = this_image()
17+
18+
change team (team)
19+
team_num_images = num_images()
20+
do concurrent (i = 1:num_images(), j = 1:num_images())
21+
R_send(this_image(),j)[i] = R_get[j]
22+
end do
23+
end team
24+
25+
if (any(R_send /= reshape([((merge(i,0,i<=num_images() .and. j <= team_num_images), &
26+
i=my_team,2*extent,2),j=1,extent)], &
27+
shape=[extent,extent], order=[2,1]))) error stop 'Test failed.'
28+
29+
sync all
30+
31+
if (this_image() == 1) write(*,*) 'Test passed.'
32+
end program teams_coarray_sendget

0 commit comments

Comments
 (0)