diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4cf475266..db782ba79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,7 @@ defaults: jobs: build: - name: ${{ matrix.compiler }}-${{ matrix.version }} ${{ matrix.network }} (${{ matrix.os }}) + name: ${{ matrix.compiler }}-${{ matrix.version }} ${{ matrix.network }} (${{ matrix.os }}) ${{ matrix.label }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -61,11 +61,21 @@ jobs: FFLAGS: -mmlir -allow-assumed-rank # https://hub.docker.com/r/phhargrove/llvm-flang/tags container: phhargrove/llvm-flang:19.1.1-latest -# - os: ubuntu-24.04 -# compiler: flang -# version: new -# network: smp -# container: gmao/llvm-flang:latest + # --- PRIF-old coverage --- + - os: ubuntu-24.04 + compiler: flang + version: 21 + network: smp + label: PRIF-0.5 + FFLAGS: -DFORCE_PRIF_0_5 + container: phhargrove/llvm-flang:21.1.0-latest + - os: ubuntu-24.04 + compiler: flang + version: 21 + network: smp + label: PRIF-0.6 + FFLAGS: -DFORCE_PRIF_0_6 + container: phhargrove/llvm-flang:21.1.0-latest # --- udp coverage for selected configs --- - os: macos-15 compiler: gfortran diff --git a/docs/implementation-status.md b/docs/implementation-status.md index 034f9c4a3..37b646d72 100644 --- a/docs/implementation-status.md +++ b/docs/implementation-status.md @@ -70,6 +70,7 @@ are accepted, but in some cases, the associated runtime behavior is not fully im | `prif_allocate_coarray` | **YES** | | | `prif_allocate` | **YES** | | | `prif_deallocate_coarray` | *partial* | no `final_func` arg support | +| `prif_deallocate_coarrays` | *partial* | no `final_func` arg support | | `prif_deallocate` | **YES** | | | `prif_alias_create` | **YES** | includes `data_pointer_offset` argument added in PRIF 0.6 | | `prif_alias_destroy` | **YES** | | diff --git a/src/caffeine/allocation_s.F90 b/src/caffeine/allocation_s.F90 index 92a188330..6b4458e1f 100644 --- a/src/caffeine/allocation_s.F90 +++ b/src/caffeine/allocation_s.F90 @@ -72,7 +72,14 @@ allocated_memory = caf_allocate(non_symmetric_heap_mspace, size_in_bytes) end procedure +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 module procedure prif_deallocate_coarray +#else + module procedure prif_deallocate_coarray + call prif_deallocate_coarrays([coarray_handle], stat, errmsg, errmsg_alloc) + end procedure + module procedure prif_deallocate_coarrays +#endif ! gfortran is yelling that this isn't valid for bind(C) ! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113338 ! abstract interface diff --git a/src/caffeine/prif_private_s.F90 b/src/caffeine/prif_private_s.F90 index d59727ea4..62c352238 100644 --- a/src/caffeine/prif_private_s.F90 +++ b/src/caffeine/prif_private_s.F90 @@ -23,7 +23,7 @@ implicit none - type(team_data), target :: initial_team + type(prif_team_descriptor), target :: initial_team type(prif_team_type) :: current_team type(c_ptr) :: non_symmetric_heap_mspace diff --git a/src/caffeine/teams_s.F90 b/src/caffeine/teams_s.F90 index 47d59a814..bb938198e 100644 --- a/src/caffeine/teams_s.F90 +++ b/src/caffeine/teams_s.F90 @@ -43,7 +43,12 @@ teams_coarrays(i)%info => tmp_data call c_f_pointer(tmp_data%next_handle, tmp_data) end do - call prif_deallocate_coarray(teams_coarrays, stat, errmsg, errmsg_alloc) +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + call prif_deallocate_coarray & +#else + call prif_deallocate_coarrays & +#endif + (teams_coarrays, stat, errmsg, errmsg_alloc) nullify(current_team%info%coarrays) else ! child team sync required by F23 11.1.5.2, diff --git a/src/prif.F90 b/src/prif.F90 index 69b4f9abd..85d1a9999 100644 --- a/src/prif.F90 +++ b/src/prif.F90 @@ -28,7 +28,12 @@ module prif public :: prif_init public :: prif_register_stop_callback, prif_stop_callback_interface public :: prif_stop, prif_error_stop, prif_fail_image - public :: prif_allocate_coarray, prif_allocate, prif_deallocate_coarray, prif_deallocate + public :: prif_allocate_coarray, prif_allocate, prif_deallocate +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + public :: prif_deallocate_coarray +#else + public :: prif_deallocate_coarray, prif_deallocate_coarrays +#endif public :: prif_put, prif_put_indirect, prif_get, prif_get_indirect, prif_put_with_notify, prif_put_with_notify_indirect public :: prif_put_indirect_with_notify, prif_put_indirect_with_notify_indirect public :: prif_get_strided, prif_get_strided_indirect, prif_put_strided, prif_put_strided_indirect @@ -139,7 +144,7 @@ module prif type, public :: prif_team_type private - type(team_data), pointer :: info => null() + type(prif_team_descriptor), pointer :: info => null() end type abstract interface @@ -214,6 +219,7 @@ module subroutine prif_allocate(size_in_bytes, allocated_memory, stat, errmsg, e character(len=:), intent(inout), allocatable, optional :: errmsg_alloc end subroutine +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 module subroutine prif_deallocate_coarray(coarray_handles, stat, errmsg, errmsg_alloc) implicit none type(prif_coarray_handle), intent(in) :: coarray_handles(:) @@ -221,6 +227,22 @@ module subroutine prif_deallocate_coarray(coarray_handles, stat, errmsg, errmsg_ character(len=*), intent(inout), optional :: errmsg character(len=:), intent(inout), allocatable, optional :: errmsg_alloc end subroutine +#else + module subroutine prif_deallocate_coarray(coarray_handle, stat, errmsg, errmsg_alloc) + implicit none + type(prif_coarray_handle), intent(in) :: coarray_handle + integer(c_int), intent(out), optional :: stat + character(len=*), intent(inout), optional :: errmsg + character(len=:), intent(inout), allocatable, optional :: errmsg_alloc + end subroutine + module subroutine prif_deallocate_coarrays(coarray_handles, stat, errmsg, errmsg_alloc) + implicit none + type(prif_coarray_handle), intent(in) :: coarray_handles(:) + integer(c_int), intent(out), optional :: stat + character(len=*), intent(inout), optional :: errmsg + character(len=:), intent(inout), allocatable, optional :: errmsg_alloc + end subroutine +#endif module subroutine prif_deallocate(mem, stat, errmsg, errmsg_alloc) implicit none @@ -1155,14 +1177,14 @@ module subroutine prif_atomic_ref_logical_indirect(image_num, atom_remote_ptr, v type(c_ptr) :: reserved end type - type, private :: team_data + type, private :: prif_team_descriptor type(c_ptr) :: gex_team type(c_ptr) :: heap_mspace integer(c_intptr_t) :: heap_start integer(c_size_t) :: heap_size integer(c_int64_t) :: team_number integer(c_int) :: this_image, num_images - type(team_data), pointer :: parent_team => null() + type(prif_team_descriptor), pointer :: parent_team => null() type(prif_coarray_descriptor), pointer :: coarrays => null() type(child_team_info), pointer :: child_heap_info => null() end type diff --git a/test/main.F90 b/test/main.F90 index 425fb2ea6..0581dbce1 100644 --- a/test/main.F90 +++ b/test/main.F90 @@ -26,6 +26,7 @@ function run() result(passed) use caf_image_index_test, only: & caf_image_index_prif_image_index => & test_prif_image_index + use prif_types_test, only: test_prif_types use caf_rma_test, only: & caf_rma_prif_rma => & test_prif_rma @@ -73,6 +74,7 @@ function run() result(passed) end block #endif individual_tests = [a00_caffeinate_caffeinate()] + individual_tests = [individual_tests, test_prif_types()] individual_tests = [individual_tests, caf_allocate_prif_allocate()] individual_tests = [individual_tests, caf_image_index_prif_image_index()] individual_tests = [individual_tests, caf_rma_prif_rma()] diff --git a/test/prif_allocate_test.F90 b/test/prif_allocate_test.F90 index af57f01a1..e93093140 100644 --- a/test/prif_allocate_test.F90 +++ b/test/prif_allocate_test.F90 @@ -1,10 +1,17 @@ module caf_allocate_test use prif, only : & - prif_allocate_coarray, prif_deallocate_coarray, & + prif_allocate_coarray, & prif_allocate, prif_deallocate, & prif_coarray_handle, prif_num_images, prif_size_bytes, & prif_set_context_data, prif_get_context_data, prif_local_data_pointer, & prif_alias_create, prif_alias_destroy +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#else + use prif, only : prif_deallocate_coarray, prif_deallocate_coarrays +#endif use veggies, only: result_t, test_item_t, assert_that, assert_equals, describe, it, succeed use iso_c_binding, only: & c_ptr, c_int, c_int64_t, c_size_t, c_funptr, c_null_funptr, & @@ -78,7 +85,7 @@ function check_allocate_integer_scalar_coarray_with_corank1() result(result_) end do end block - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function @@ -258,7 +265,7 @@ function check_allocate_integer_array_coarray_with_corank2() result(result_) end do end block - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function end module caf_allocate_test diff --git a/test/prif_atomic_test.F90 b/test/prif_atomic_test.F90 index ea005ac48..14a2b4dee 100644 --- a/test/prif_atomic_test.F90 +++ b/test/prif_atomic_test.F90 @@ -6,6 +6,11 @@ module caf_atomic_test c_ptr, c_int64_t, c_intptr_t, c_size_t, c_null_funptr, c_f_pointer, c_loc, c_sizeof use veggies, only: result_t, test_item_t, assert_equals, assert_that, describe, it, succeed use prif +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#endif implicit none private @@ -325,8 +330,7 @@ function check_atomic_uncontended() result(result_) end block - call prif_deallocate_coarray([coarray_handle_int]) - call prif_deallocate_coarray([coarray_handle_logical]) + call prif_deallocate_coarrays(([coarray_handle_int,coarray_handle_logical])) end function function check_atomic_contended() result(result_) diff --git a/test/prif_coarray_inquiry_test.F90 b/test/prif_coarray_inquiry_test.F90 index 46496e46c..7d3ddcdb8 100644 --- a/test/prif_coarray_inquiry_test.F90 +++ b/test/prif_coarray_inquiry_test.F90 @@ -6,6 +6,13 @@ module prif_coarray_inquiry_test_m prif_lcobound_no_dim, prif_lcobound_with_dim, & prif_ucobound_no_dim, prif_ucobound_with_dim, & prif_coshape +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#else + use prif, only : prif_deallocate_coarray, prif_deallocate_coarrays +#endif use julienne_m, only: & operator(//) & ,operator(.all.) & @@ -68,7 +75,7 @@ function check_prif_local_data_pointer() result(diag) allocation_ptr) call prif_local_data_pointer(coarray_handle, local_ptr) diag = .expect. c_associated(local_ptr, allocation_ptr) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function impure elemental function check_cobound(corank) result(diag) @@ -132,7 +139,7 @@ impure elemental function check_cobound(corank) result(diag) diag = diag .also. & (.all. ((ucobounds - lcobounds + 1) .equalsExpected. sizes)) // "prif_coshape is valid" - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_cobounds() result(diag) diff --git a/test/prif_event_test.F90 b/test/prif_event_test.F90 index d977f4d82..0db533f88 100644 --- a/test/prif_event_test.F90 +++ b/test/prif_event_test.F90 @@ -17,11 +17,17 @@ module caf_event_test prif_notify_type, prif_notify_wait, prif_put_with_notify, prif_put_strided_with_notify, & prif_coarray_handle, & prif_allocate_coarray, & - prif_deallocate_coarray, & prif_num_images, & prif_put, & prif_sync_all, & prif_this_image_no_coarray +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#else + use prif, only : prif_deallocate_coarray, prif_deallocate_coarrays +#endif use veggies, only: result_t, test_item_t, assert_equals, describe, it, succeed implicit none @@ -133,7 +139,7 @@ function check_event_serial() result(result_) end do end block - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function @@ -233,8 +239,7 @@ function check_event_parallel() result(result_) end do end block - call prif_deallocate_coarray([coarray_handle_ctr]) - call prif_deallocate_coarray([coarray_handle_evt]) + call prif_deallocate_coarrays(([coarray_handle_ctr, coarray_handle_evt])) end function function check_notify() result(result_) @@ -334,8 +339,7 @@ function check_notify() result(result_) end do end block - call prif_deallocate_coarray([coarray_handle_ctr]) - call prif_deallocate_coarray([coarray_handle_evt]) + call prif_deallocate_coarrays(([coarray_handle_ctr, coarray_handle_evt])) end function end module diff --git a/test/prif_image_index_test.F90 b/test/prif_image_index_test.F90 index 7bf505dc1..aa8abe468 100644 --- a/test/prif_image_index_test.F90 +++ b/test/prif_image_index_test.F90 @@ -1,6 +1,6 @@ module caf_image_index_test use iso_c_binding, only: c_int, c_ptr, c_size_t, c_null_funptr, c_int64_t - use prif, only: prif_coarray_handle, prif_allocate_coarray, prif_deallocate_coarray, & + use prif, only: prif_coarray_handle, prif_allocate_coarray, & prif_image_index, prif_num_images, & prif_team_type, prif_get_team, & prif_this_image_no_coarray, & @@ -10,6 +10,13 @@ module caf_image_index_test prif_this_image_with_coarray, prif_this_image_with_dim, & prif_lcobound_no_dim, prif_ucobound_no_dim, & prif_num_images_with_team, PRIF_INITIAL_TEAM +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#else + use prif, only : prif_deallocate_coarray, prif_deallocate_coarrays +#endif use veggies, only: result_t, test_item_t, assert_equals, assert_that, describe, it, succeed implicit none @@ -100,7 +107,7 @@ function check_simple_case() result(result_) result_ = result_ .and. & check_this_image_coarray(coarray_handle, 1) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_lower_bounds() result(result_) @@ -127,7 +134,7 @@ function check_lower_bounds() result(result_) result_ = result_ .and. & check_this_image_coarray(coarray_handle, 2) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_invalid_subscripts() result(result_) @@ -151,7 +158,7 @@ function check_invalid_subscripts() result(result_) result_ = result_ .and. & check_this_image_coarray(coarray_handle, 2) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_complicated_2d() result(result_) @@ -181,7 +188,7 @@ function check_complicated_2d() result(result_) result_ = result_ .and. & check_this_image_coarray(coarray_handle, 2) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_complicated_3d() result(result_) @@ -217,7 +224,7 @@ function check_complicated_3d() result(result_) result_ = result_ .and. & check_this_image_coarray(coarray_handle, 3) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_complicated_2d_team() result(result_) @@ -385,7 +392,7 @@ function check_complicated_2d_team() result(result_) check_this_image_coarray(coarray_handle, 2, child_team) call prif_end_team() - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function diff --git a/test/prif_rma_test.F90 b/test/prif_rma_test.F90 index 3e4e1f4c7..ff13b8bbb 100644 --- a/test/prif_rma_test.F90 +++ b/test/prif_rma_test.F90 @@ -4,7 +4,6 @@ module caf_rma_test use prif, only: & prif_coarray_handle, & prif_allocate_coarray, & - prif_deallocate_coarray, & prif_allocate, & prif_deallocate, & prif_num_images, & @@ -15,6 +14,13 @@ module caf_rma_test prif_sync_all, & prif_sync_memory, & prif_this_image_no_coarray +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#else + use prif, only : prif_deallocate_coarray, prif_deallocate_coarrays +#endif use veggies, only: result_t, test_item_t, assert_equals, describe, it implicit none @@ -72,7 +78,7 @@ function check_put() result(result_) result_ = assert_equals(expected, local_slice) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_put_indirect() result(result_) @@ -130,7 +136,7 @@ function check_put_indirect() result(result_) result_ = assert_equals(expected, component_access) call prif_deallocate(local_slice%my_component) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_get() result(result_) @@ -170,7 +176,7 @@ function check_get() result(result_) result_ = assert_equals(expected, retrieved) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_get_indirect() result(result_) @@ -228,6 +234,6 @@ function check_get_indirect() result(result_) result_ = assert_equals(expected, retrieved) call prif_deallocate(local_slice%my_component) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function end module diff --git a/test/prif_strided_test.F90 b/test/prif_strided_test.F90 index 72a07b7d1..a86d6e7cb 100644 --- a/test/prif_strided_test.F90 +++ b/test/prif_strided_test.F90 @@ -4,7 +4,6 @@ module caf_strided_test use prif, only: & prif_coarray_handle, & prif_allocate_coarray, & - prif_deallocate_coarray, & prif_allocate, & prif_deallocate, & prif_num_images, & @@ -15,6 +14,13 @@ module caf_strided_test prif_get_strided_indirect, & prif_sync_all, & prif_this_image_no_coarray +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#else + use prif, only : prif_deallocate_coarray, prif_deallocate_coarrays +#endif use veggies, only: result_t, test_item_t, assert_equals, describe, it, succeed, fail implicit none @@ -112,7 +118,7 @@ function check_put() result(result_) result_ = assert_equals_array2d(expected, local_slice) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_put_indirect() result(result_) @@ -187,7 +193,7 @@ function check_put_indirect() result(result_) result_ = assert_equals_array2d(expected, component_access) call prif_deallocate(local_slice%my_component) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_get() result(result_) @@ -241,7 +247,7 @@ function check_get() result(result_) result_ = assert_equals_array2d(expected, mydata) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function function check_get_indirect() result(result_) @@ -314,7 +320,7 @@ function check_get_indirect() result(result_) result_ = assert_equals_array2d(expected, mydata) call prif_deallocate(local_slice%my_component) - call prif_deallocate_coarray([coarray_handle]) + call prif_deallocate_coarray(coarray_handle) end function end module diff --git a/test/prif_teams_test.F90 b/test/prif_teams_test.F90 index 3a5df0772..d8feb0f78 100644 --- a/test/prif_teams_test.F90 +++ b/test/prif_teams_test.F90 @@ -1,6 +1,11 @@ module caf_teams_test use iso_c_binding, only: c_size_t, c_ptr, c_null_funptr, c_int64_t, c_int use prif +#if FORCE_PRIF_0_5 || FORCE_PRIF_0_6 + use prif, only : prif_deallocate_coarray_ => prif_deallocate_coarray +# define prif_deallocate_coarray(h) prif_deallocate_coarray_([h]) +# define prif_deallocate_coarrays(arr) prif_deallocate_coarray_(arr) +#endif use veggies, only: result_t, test_item_t, assert_equals, assert_that, describe, it, succeed, fail implicit none @@ -179,8 +184,8 @@ function check_teams() result(result_) coarray_handle = coarrays(i), & allocated_memory = allocated_memory) end do - call prif_deallocate_coarray(coarrays(4:4)) - call prif_deallocate_coarray(coarrays(2:2)) + call prif_deallocate_coarrays(coarrays(4:4)) + call prif_deallocate_coarrays(coarrays(2:2)) call prif_end_team() diff --git a/test/prif_types_test.F90 b/test/prif_types_test.F90 new file mode 100644 index 000000000..7e2722da5 --- /dev/null +++ b/test/prif_types_test.F90 @@ -0,0 +1,138 @@ +module prif_types_test + use iso_fortran_env, only: int8 + use prif + use veggies, only: result_t, test_item_t, assert_that, assert_not, assert_equals, describe, it, succeed + + implicit none + private + public :: test_prif_types + + type, private :: dummy_t + private + integer foo + type(dummy_t), pointer :: p + end type + + type :: pointer_wrapper_t + private + type(dummy_t), pointer :: info => null() + end type + +contains + function test_prif_types() result(tests) + type(test_item_t) :: tests + + tests = describe( & + "PRIF types", & + [ it("prif_team_type has a compliant representation", check_team_type) & + , it("prif_event_type has a compliant representation", check_event_type) & + , it("prif_lock_type has a compliant representation", check_lock_type) & + , it("prif_notify_type has a compliant representation", check_notify_type) & + , it("prif_critical_type has a compliant representation", check_critical_type) & + ]) + end function + + function check_team_type() result(diag) + type(result_t) :: diag + type(prif_team_type) :: team + type(pointer_wrapper_t) :: pointer_wrap + type(dummy_t), target :: tgt + + diag = succeed("") + + ! size check + diag = diag .and. & + assert_equals(storage_size(team), storage_size(pointer_wrap)) + + ! default initialization check + pointer_wrap%info => tgt + pointer_wrap = transfer(team, pointer_wrap) + diag = diag .and. & + assert_that(.not. associated(pointer_wrap%info)) + end function + + function check_event_type() result(diag) + type(result_t) :: diag + type(prif_event_type) :: event + integer :: ssz + integer(int8), allocatable :: bytes(:) + + diag = succeed("") + + ! size check + ssz = storage_size(event) + diag = diag .and. & + assert_that(ssz > 0) .and. & + assert_that(ssz <= 64*8) + + ! default initialization check + allocate(bytes(64)) + bytes = transfer(event, bytes) + diag = diag .and. & + assert_that( all(bytes == 0) ) + end function + + function check_lock_type() result(diag) + type(result_t) :: diag + type(prif_lock_type) :: lock + integer :: ssz + integer(int8), allocatable :: bytes(:) + + diag = succeed("") + + ! size check + ssz = storage_size(lock) + diag = diag .and. & + assert_that(ssz > 0) .and. & + assert_that(ssz <= 64*8) + + ! default initialization check + allocate(bytes(64)) + bytes = transfer(lock, bytes) + diag = diag .and. & + assert_that( all(bytes == 0) ) + end function + + function check_notify_type() result(diag) + type(result_t) :: diag + type(prif_notify_type) :: notify + integer :: ssz + integer(int8), allocatable :: bytes(:) + + diag = succeed("") + + ! size check + ssz = storage_size(notify) + diag = diag .and. & + assert_that(ssz > 0) .and. & + assert_that(ssz <= 64*8) + + ! default initialization check + allocate(bytes(64)) + bytes = transfer(notify, bytes) + diag = diag .and. & + assert_that( all(bytes == 0) ) + end function + + function check_critical_type() result(diag) + type(result_t) :: diag + type(prif_critical_type) :: critical + integer :: ssz + integer(int8), allocatable :: bytes(:) + + diag = succeed("") + + ! size check + ssz = storage_size(critical) + diag = diag .and. & + assert_that(ssz > 0) .and. & + assert_that(ssz <= 64*8) + + ! default initialization check + allocate(bytes(64)) + bytes = transfer(critical, bytes) + diag = diag .and. & + assert_that( all(bytes == 0) ) + end function + +end module prif_types_test