-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed commits from Brad @ 171bf08 rebased onto main
test(collectives): outline simpler test suite chore: remove old collective implementations chore: update interfaces of collectives feat(co_broadcast): use wrapper to make contiguous feat: re-implement co_sum feat: create implementation of co_reduce feat: create co_min implementation feat: create implementation for co_max
- Loading branch information
1 parent
98baa51
commit 6d6ac10
Showing
13 changed files
with
607 additions
and
948 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,60 @@ | ||
! Copyright (c), The Regents of the University of California | ||
! Terms of use are as specified in LICENSE.txt | ||
|
||
#include "assert_macros.h" | ||
|
||
submodule(prif:prif_private_s) co_max_s | ||
use iso_c_binding, only : c_funloc | ||
|
||
use iso_c_binding, only: c_loc, c_f_pointer | ||
implicit none | ||
|
||
contains | ||
|
||
module procedure prif_co_max | ||
if (present(stat)) stat=0 | ||
|
||
if (caf_numeric_type(a)) then | ||
call caf_co_max( & | ||
a, optional_value(result_image), int(product(shape(a)), c_size_t), current_team%info%gex_team) | ||
else if (caf_is_f_string(a)) then | ||
call prif_co_reduce(a, c_funloc(reverse_alphabetize), optional_value(result_image), stat, errmsg, errmsg_alloc) | ||
else | ||
call prif_error_stop(.false._c_bool, stop_code_char="caf_co_max: unsupported type") | ||
end if | ||
call contiguous_co_max(a, result_image, stat, errmsg, errmsg_alloc) | ||
end procedure | ||
|
||
contains | ||
subroutine contiguous_co_max(a, result_image, stat, errmsg, errmsg_alloc) | ||
implicit none | ||
type(*), intent(inout), target, contiguous :: a(..) | ||
integer(c_int), intent(in), optional :: result_image | ||
integer(c_int), intent(out), optional :: stat | ||
character(len=*), intent(inout), optional :: errmsg | ||
character(len=:), intent(inout), allocatable, optional :: errmsg_alloc | ||
|
||
function reverse_alphabetize(lhs, rhs) result(last_alphabetically) | ||
character(len=*), intent(in) :: lhs, rhs | ||
character(len=len(lhs)) :: last_alphabetically | ||
call_assert_diagnose(len(lhs)==len(rhs), "caf_co_max: LHS/RHS length match", lhs//" , "//rhs) | ||
last_alphabetically = max(lhs,rhs) | ||
end function | ||
if (present(stat)) stat=0 | ||
|
||
call caf_co_max( & | ||
a, & | ||
optional_value(result_image), & | ||
int(product(shape(a)), c_size_t), & | ||
current_team%info%gex_team) | ||
end subroutine | ||
|
||
module procedure prif_co_max_character | ||
call unimplemented("prif_co_max_character") | ||
! integer(c_size_t), target :: char_len | ||
! procedure(prif_operation_wrapper_interface), pointer :: op | ||
|
||
! char_len = len(a) | ||
! op => char_max_wrapper | ||
! call prif_co_reduce(a, op, c_loc(char_len), result_image, stat, errmsg, errmsg_alloc) | ||
end procedure | ||
|
||
! subroutine char_max_wrapper(arg1, arg2_and_out, count, cdata) bind(C) | ||
! type(c_ptr), intent(in), value :: arg1, arg2_and_out | ||
! integer(c_size_t), intent(in), value :: count | ||
! type(c_ptr), intent(in), value :: cdata | ||
|
||
! integer(c_size_t), pointer :: char_len | ||
! integer(c_size_t) :: i | ||
|
||
! if (count == 0) return | ||
! call c_f_pointer(cdata, char_len) | ||
! block | ||
! character(len=char_len,kind=c_char), pointer :: lhs(:), rhs_and_result(:) | ||
! call c_f_pointer(arg1, lhs, [count]) | ||
! call c_f_pointer(arg2_and_out, rhs_and_result, [count]) | ||
! do i = 1, count | ||
! if (lhs(i) <= rhs_and_result(i)) rhs_and_result(i) = lhs(i) | ||
! end do | ||
! end block | ||
! end subroutine | ||
|
||
end submodule co_max_s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,60 @@ | ||
! Copyright (c), The Regents of the University of California | ||
! Terms of use are as specified in LICENSE.txt | ||
|
||
#include "assert_macros.h" | ||
|
||
submodule(prif:prif_private_s) co_min_s | ||
use iso_c_binding, only : c_funloc | ||
|
||
use iso_c_binding, only: c_loc, c_f_pointer | ||
implicit none | ||
|
||
contains | ||
|
||
module procedure prif_co_min | ||
if (present(stat)) stat=0 | ||
|
||
if (caf_numeric_type(a)) then | ||
call caf_co_min( & | ||
a, optional_value(result_image), int(product(shape(a)), c_size_t), current_team%info%gex_team) | ||
else if (caf_is_f_string(a)) then | ||
call prif_co_reduce(a, c_funloc(alphabetize), optional_value(result_image), stat, errmsg, errmsg_alloc) | ||
else | ||
call prif_error_stop(.false._c_bool, stop_code_char="prif_co_min: unsupported type") | ||
end if | ||
call contiguous_co_min(a, result_image, stat, errmsg, errmsg_alloc) | ||
end procedure | ||
|
||
contains | ||
subroutine contiguous_co_min(a, result_image, stat, errmsg, errmsg_alloc) | ||
implicit none | ||
type(*), intent(inout), target, contiguous :: a(..) | ||
integer(c_int), intent(in), optional :: result_image | ||
integer(c_int), intent(out), optional :: stat | ||
character(len=*), intent(inout), optional :: errmsg | ||
character(len=:), intent(inout), allocatable, optional :: errmsg_alloc | ||
|
||
function alphabetize(lhs, rhs) result(first_alphabetically) | ||
character(len=*), intent(in) :: lhs, rhs | ||
character(len=len(lhs)) :: first_alphabetically | ||
call_assert_diagnose(len(lhs)==len(rhs), "prif_co_min: LHS/RHS length match", lhs//" , "//rhs) | ||
first_alphabetically = min(lhs,rhs) | ||
end function | ||
if (present(stat)) stat=0 | ||
|
||
call caf_co_min( & | ||
a, & | ||
optional_value(result_image), & | ||
int(product(shape(a)), c_size_t), & | ||
current_team%info%gex_team) | ||
end subroutine | ||
|
||
module procedure prif_co_min_character | ||
call unimplemented("prif_co_min_character") | ||
! integer(c_size_t), target :: char_len | ||
! procedure(prif_operation_wrapper_interface), pointer :: op | ||
|
||
! char_len = len(a) | ||
! op => char_min_wrapper | ||
! call prif_co_reduce(a, op, c_loc(char_len), result_image, stat, errmsg, errmsg_alloc) | ||
end procedure | ||
|
||
! subroutine char_min_wrapper(arg1, arg2_and_out, count, cdata) bind(C) | ||
! type(c_ptr), intent(in), value :: arg1, arg2_and_out | ||
! integer(c_size_t), intent(in), value :: count | ||
! type(c_ptr), intent(in), value :: cdata | ||
|
||
! integer(c_size_t), pointer :: char_len | ||
! integer(c_size_t) :: i | ||
|
||
! if (count == 0) return | ||
! call c_f_pointer(cdata, char_len) | ||
! block | ||
! character(len=char_len,kind=c_char), pointer :: lhs(:), rhs_and_result(:) | ||
! call c_f_pointer(arg1, lhs, [count]) | ||
! call c_f_pointer(arg2_and_out, rhs_and_result, [count]) | ||
! do i = 1, count | ||
! if (lhs(i) <= rhs_and_result(i)) rhs_and_result(i) = lhs(i) | ||
! end do | ||
! end block | ||
! end subroutine | ||
|
||
end submodule co_min_s |
Oops, something went wrong.