Skip to content
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

Fix #632 coarray image-selector image index values for teams #633

Merged
Merged
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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ if(opencoarrays_aware_compiler)
add_caf_test(team_number 8 team_number)
add_caf_test(teams_subset 3 teams_subset)
add_caf_test(get_communicator 3 get_communicator)
add_caf_test(teams_coarray_get 5 teams_coarray_get)
add_caf_test(teams_coarray_get_by_ref 5 teams_coarray_get_by_ref)
add_caf_test(teams_coarray_send 5 teams_coarray_send)
add_caf_test(teams_coarray_send_by_ref 5 teams_coarray_send_by_ref)
add_caf_test(teams_coarray_sendget 5 teams_coarray_sendget)
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
endif()
endif()
Expand Down
308 changes: 216 additions & 92 deletions src/mpi/mpi_caf.c

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/tests/unit/teams/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
caf_compile_executable(team_number team-number.f90)
caf_compile_executable(teams_subset teams_subset.f90)
caf_compile_executable(get_communicator get-communicator.F90)
caf_compile_executable(teams_coarray_get teams_coarray_get.f90)
caf_compile_executable(teams_coarray_get_by_ref teams_coarray_get.f90)
caf_compile_executable(teams_coarray_send teams_coarray_send.f90)
caf_compile_executable(teams_coarray_send_by_ref teams_coarray_send.f90)
caf_compile_executable(teams_coarray_sendget teams_coarray_sendget.f90)
27 changes: 27 additions & 0 deletions src/tests/unit/teams/teams_coarray_get.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
program teams_coarray_get
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
integer, allocatable :: L(:)
integer :: i, my_team, R[*]

! handle odd or even number of images
allocate(L(num_images()/2+mod(num_images(),2)*mod(this_image(),2)))

R = this_image()
my_team = mod(this_image()-1,2)+1

form team (my_team, team)

change team (team)
do i = 1, num_images()
L(i) = R[i]
end do
end team

if (any(L /= [(i, i=my_team, num_images(), 2)])) error stop 'Test failed.'

sync all

if (this_image() == 1) write(*,*) 'Test passed.'
end program teams_coarray_get
35 changes: 35 additions & 0 deletions src/tests/unit/teams/teams_coarray_get_by_ref.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
program teams_coarray_get_by_ref
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
type :: allocatable_array_t
integer, allocatable :: A(:)
end type
type(allocatable_array_t) :: R[*]
integer, allocatable :: L(:)
integer :: i, my_team

! handle odd or even number of images
allocate(L(num_images()/2+mod(num_images(),2)*mod(this_image(),2)))

my_team = mod(this_image()-1,2)+1

form team (my_team, team)

! size(R%A) == this_image(team)
allocate(R%A((this_image()+1)/2), source=0)

R%A(ubound(R%A,1)) = this_image()

change team (team)
do i = 1, num_images()
L(i) = R[i]%A(i)
end do
end team

if (any(L /= [(i, i=my_team, num_images(), 2)])) error stop 'Test failed.'

sync all

if (this_image() == 1) write(*,*) 'Test passed.'
end program teams_coarray_get_by_ref
28 changes: 28 additions & 0 deletions src/tests/unit/teams/teams_coarray_send.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
program teams_coarray_send
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
integer, allocatable :: R(:)[:]
integer :: extent, i, my_team, initial_team_this_image, odd

! if odd number of images, even images have R(extent) == 0
extent = num_images()/2+mod(num_images(),2)
allocate(R(extent)[*], source=0)

initial_team_this_image = this_image()
my_team = mod(this_image()-1,2)+1

form team (my_team, team)

change team (team)
do i = 1, num_images()
R(this_image())[i] = initial_team_this_image
end do
end team

if (any(R /= [(mod(i, num_images()+1), i=my_team, 2*extent, 2)])) error stop 'Test failed.'

sync all

if (this_image() == 1) write(*,*) 'Test passed.'
end program teams_coarray_send
30 changes: 30 additions & 0 deletions src/tests/unit/teams/teams_coarray_send_by_ref.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
program teams_coarray_get_by_ref
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
type :: allocatable_array_t
integer, allocatable :: A(:)
end type
type(allocatable_array_t) :: R[*]
integer :: i, my_team, initial_team_this_image

! handle odd or even number of images
allocate(R%A(num_images()/2+mod(num_images(),2)*mod(this_image(),2)), source=0)

initial_team_this_image = this_image()
my_team = mod(this_image()-1,2)+1

form team (my_team, team)

change team (team)
do i = 1, num_images()
R[i]%A(this_image()) = initial_team_this_image
end do
end team

if (any(R%A /= [(i, i=my_team, num_images(), 2)])) error stop 'Test failed.'

sync all

if (this_image() == 1) write(*,*) 'Test passed.'
end program teams_coarray_get_by_ref
32 changes: 32 additions & 0 deletions src/tests/unit/teams/teams_coarray_sendget.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
program teams_coarray_sendget
use, intrinsic :: iso_fortran_env, only: team_type
implicit none
type(team_type) :: team
integer, allocatable :: R_send(:,:)[:]
integer :: extent, i, j, my_team, team_num_images, R_get[*]

! if there are an odd number of images, then even images have R(:,extent) == 0
extent = num_images()/2+mod(num_images(),2)
allocate(R_send(extent, extent)[*], source=0)

my_team = mod(this_image()-1,2)+1

form team (my_team, team)

R_get = this_image()

change team (team)
team_num_images = num_images()
do concurrent (i = 1:num_images(), j = 1:num_images())
R_send(this_image(),j)[i] = R_get[j]
end do
end team

if (any(R_send /= reshape([((merge(i,0,i<=num_images() .and. j <= team_num_images), &
i=my_team,2*extent,2),j=1,extent)], &
shape=[extent,extent], order=[2,1]))) error stop 'Test failed.'

sync all

if (this_image() == 1) write(*,*) 'Test passed.'
end program teams_coarray_sendget