Skip to content

Commit

Permalink
fix: collective tests
Browse files Browse the repository at this point in the history
  • Loading branch information
everythingfunctional committed Dec 17, 2024
1 parent bf7999f commit 89d2bab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
7 changes: 3 additions & 4 deletions test/caf_co_max_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ function max_elements_in_2D_string_arrays() result(result_)
function reverse_alphabetize_default_character_scalars() result(result_)
type(result_t) result_
integer, parameter :: length = len("loddy")
character(len=length), parameter :: words(*) = [character(len=length):: "loddy","doddy","we","like","to","party"]
character(len=:), allocatable :: my_word, expected_word
character(len=*), parameter :: words(*) = [character(len=length):: "loddy","doddy","we","like","to","party"]
character(len=len(words)) :: my_word, expected_word
integer :: me, num_imgs

call prif_this_image_no_coarray(this_image=me)
Expand All @@ -135,8 +135,7 @@ function reverse_alphabetize_default_character_scalars() result(result_)
end associate

call prif_num_images(num_imgs)
!expected_word = maxval(words(1:min(num_imgs, size(words)))) ! this line crashes flang
expected_word = "we"
expected_word = maxval(words(1:min(num_imgs, size(words))), dim=1)
result_ = assert_equals(expected_word, my_word)
end function

Expand Down
5 changes: 2 additions & 3 deletions test/caf_co_min_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function alphabetically_1st_scalar_string() result(result_)
type(result_t) result_
integer, parameter :: length = len("to party!")
character(len=length), parameter :: words(*) = [character(len=length):: "Loddy","doddy","we","like","to party!"]
character(len=:), allocatable :: my_word, expected_word
character(len=length) :: my_word, expected_word
integer :: me, num_imgs

call prif_this_image_no_coarray(this_image=me)
Expand All @@ -137,8 +137,7 @@ function alphabetically_1st_scalar_string() result(result_)
end associate

call prif_num_images(num_images=num_imgs)
! expected_word = minval(words(1:min(num_imgs, size(words)))) ! this line exposes a flang bug
expected_word = "Loddy"
expected_word = minval(words(1:min(num_imgs, size(words))), dim=1)
result_ = assert_equals(expected_word, my_word)
end function

Expand Down
17 changes: 6 additions & 11 deletions test/caf_co_reduce_test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,26 @@ function test_prif_co_reduce() result(tests)
function alphabetically_1st_size1_string_array() result(result_)
type(result_t) result_
character(len=*, kind=c_char), parameter :: names(*) = ["larry","harry","carey","betty","tommy","billy"]
character(len=:, kind=c_char), allocatable :: my_name(:)
character(len=:), allocatable :: expected_name
character(len=len(names), kind=c_char) :: my_name(1)
character(len=len(names)) :: expected_name
integer :: me, num_imgs

call prif_this_image_no_coarray(this_image=me)
associate(periodic_index => 1 + mod(me-1,size(names)))
my_name = [names(periodic_index)]
my_name(1) = names(periodic_index)
call prif_co_reduce(my_name, c_funloc(alphabetize))
end associate

call prif_num_images(num_images=num_imgs)
!expected_name = minval(names(1:min(num_imgs, size(names)))) ! this exposes a flang bug
expected_name = "betty"
expected_name = minval(names(1:min(num_imgs, size(names))), dim=1)
result_ = assert_that(all(expected_name == my_name))

contains

function alphabetize(lhs, rhs) result(first_alphabetically)
character(len=*), intent(in) :: lhs, rhs
character(len=:), allocatable :: first_alphabetically
character(len=len(names)), intent(in) :: lhs, rhs
character(len=len(names)) :: first_alphabetically

if (len(lhs).ne.len(rhs)) then
call prif_error_stop(quiet=.false._c_bool, &
stop_code_char="co_reduce_s alphabetize: LHS(" // lhs // ")/RHS(" // rhs // ") length don't match")
end if
first_alphabetically = min(lhs,rhs)
end function

Expand Down

0 comments on commit 89d2bab

Please sign in to comment.