Skip to content

Commit 58d18b5

Browse files
committed
refac(data_partition_test): enable selective tests
1 parent 981b190 commit 58d18b5

File tree

1 file changed

+56
-25
lines changed

1 file changed

+56
-25
lines changed

test/data_partition_test.F90

Lines changed: 56 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module data_partition_test_m
2-
!! verify data partitioning across images and data gathering
3-
use sourcery_m, only : data_partition_t, test_t, test_result_t
2+
!! check data partitioning across images and data gathering
3+
use sourcery_m, only : &
4+
data_partition_t, test_t, test_result_t, test_description_substring, test_description_t, test_function_i, string_t
45
use iso_fortran_env, only : real64
56
implicit none
67

@@ -25,23 +26,53 @@ pure function subject() result(specimen)
2526

2627
function results() result(test_results)
2728
type(test_result_t), allocatable :: test_results(:)
28-
29-
test_results = [ &
30-
test_result_t("partitioning data in nearly even blocks", verify_block_partitioning()), &
31-
test_result_t("default image_number is this_image()", verify_default_image_number()), &
32-
test_result_t("partitioning all data across all images without data loss", verify_all_particles_partitioned()), &
33-
test_result_t("gathering a 1D real array onto all images", verify_all_gather_1D_real_array()), &
34-
test_result_t("gathering dimension 1 of 2D real array onto all images witout dim argument", &
35-
verify_all_gather_2D_real_array()), &
36-
test_result_t("gathering dimension 1 of 2D real array onton all images with dim argument", &
37-
verify_all_gather_2D_real_array_dim1()), &
38-
test_result_t("gathering dimension 1 of 2D real array onto result_image with dim argument", &
39-
verify_gather_2D_real_array_dim1()) &
40-
]
29+
type(test_description_t), allocatable :: test_descriptions(:)
30+
#ifndef __GFORTRAN__
31+
test_descriptions = [ &
32+
test_description_t(string_t("partitioning data in nearly even blocks"), check_block_partitioning), &
33+
test_description_t(string_t("default image_number is this_image()"), check_default_image_number), &
34+
test_description_t(string_t("partitioning all data across all images without data loss"), check_all_particles_partitioned), &
35+
test_description_t(string_t("gathering a 1D real array onto all images"), check_all_gather_1D_real_array), &
36+
test_description_t(string_t("gathering dimension 1 of 2D real array onto all images witout dim argument"), &
37+
check_all_gather_2D_real_array), &
38+
test_description_t(string_t("gathering dimension 1 of 2D real array onton all images with dim argument"), &
39+
check_all_gather_2D_real_array_dim1), &
40+
test_description_t(strint_t("gathering dimension 1 of 2D real array onto result_image with dim argument"), &
41+
check_gather_2D_real_array_dim1) &
42+
]
43+
#else
44+
! Work around missing Fortran 2008 feature: associating a procedure actual argument with a procedure pointer dummy argument:
45+
procedure(test_function_i), pointer :: &
46+
check_block_ptr, check_default_ptr, check_all_particles_ptr, check_all_gather_ptr, check_all_gather_2D_ptr, &
47+
check_all_gather_2D_real_ptr, check_gather_2D_real_array_ptr
48+
49+
check_block_ptr => check_block_partitioning
50+
check_default_ptr => check_default_image_number
51+
check_all_particles_ptr => check_all_particles_partitioned
52+
check_all_gather_ptr => check_all_gather_1D_real_array
53+
check_all_gather_2D_ptr => check_all_gather_2D_real_array
54+
check_all_gather_2D_real_ptr => check_all_gather_2D_real_array_dim1
55+
check_gather_2D_real_array_ptr => check_gather_2D_real_array_dim1
56+
57+
test_descriptions = [ &
58+
test_description_t(string_t("partitioning data in nearly even blocks"), check_block_ptr), &
59+
test_description_t(string_t("default image_number is this_image()"), check_default_ptr), &
60+
test_description_t(string_t("partitioning all data across all images without data loss"), check_all_particles_ptr), &
61+
test_description_t(string_t("gathering a 1D real array onto all images"), check_all_gather_ptr), &
62+
test_description_t( &
63+
string_t("gathering dimension 1 of 2D real array onto all images witout dim argument"), check_all_gather_ptr), &
64+
test_description_t( &
65+
string_t("gathering dimension 1 of 2D real array onton all images with dim argument"), check_all_gather_2D_ptr), &
66+
test_description_t( &
67+
string_t("gathering dimension 1 of 2D real array onto result_image with dim argument"), check_gather_2D_real_array_ptr) &
68+
]
69+
#endif
70+
test_descriptions = pack(test_descriptions, test_descriptions%contains_text(string_t(test_description_substring)))
71+
test_results = test_descriptions%run()
4172
end function
4273

43-
function verify_block_partitioning() result(test_passes)
44-
!! Verify that the data is partitioned across images evenly to
74+
function check_block_partitioning() result(test_passes)
75+
!! check that the data is partitioned across images evenly to
4576
!! within a difference of one datum between any two images.
4677
logical test_passes
4778

@@ -72,8 +103,8 @@ function verify_block_partitioning() result(test_passes)
72103

73104
end function
74105

75-
function verify_default_image_number() result(test_passes)
76-
!! Verify that the first and last functions assume image_number == this_image() if image_number is not present
106+
function check_default_image_number() result(test_passes)
107+
!! check that the first and last functions assume image_number == this_image() if image_number is not present
77108
logical test_passes
78109

79110
#ifndef _CRAYFTN
@@ -90,8 +121,8 @@ function verify_default_image_number() result(test_passes)
90121
#endif
91122
end function
92123

93-
function verify_all_particles_partitioned() result(test_passes)
94-
!! Verify that the number of particles on each image sums to the
124+
function check_all_particles_partitioned() result(test_passes)
125+
!! check that the number of particles on each image sums to the
95126
!! total number of particles distributed.
96127
logical test_passes
97128
integer particles
@@ -118,7 +149,7 @@ function verify_all_particles_partitioned() result(test_passes)
118149
#endif
119150
end function
120151

121-
function verify_all_gather_1D_real_array() result(test_passes)
152+
function check_all_gather_1D_real_array() result(test_passes)
122153
logical test_passes
123154
real(real64) :: particle_scalar(num_particles)
124155
real(real64), parameter :: junk=-12345._real64, expected=1._real64
@@ -149,7 +180,7 @@ function verify_all_gather_1D_real_array() result(test_passes)
149180
#endif
150181
end function
151182

152-
function verify_all_gather_2D_real_array() result(test_passes)
183+
function check_all_gather_2D_real_array() result(test_passes)
153184
logical test_passes
154185
integer, parameter :: vec_space_dim=3
155186
real(real64) particle_vector(vec_space_dim, num_particles)
@@ -181,7 +212,7 @@ function verify_all_gather_2D_real_array() result(test_passes)
181212
#endif
182213
end function
183214

184-
function verify_all_gather_2D_real_array_dim1() result(test_passes)
215+
function check_all_gather_2D_real_array_dim1() result(test_passes)
185216
logical test_passes
186217
integer, parameter :: vec_space_dim=3
187218
real(real64) :: vector_transpose(num_particles, vec_space_dim)
@@ -213,7 +244,7 @@ function verify_all_gather_2D_real_array_dim1() result(test_passes)
213244
#endif
214245
end function
215246

216-
function verify_gather_2D_real_array_dim1() result(test_passes)
247+
function check_gather_2D_real_array_dim1() result(test_passes)
217248
logical test_passes
218249
integer, parameter :: vec_space_dim=3
219250
real(real64) :: vector_transpose(num_particles, vec_space_dim)

0 commit comments

Comments
 (0)