Skip to content

Commit 3282568

Browse files
authored
Merge pull request #423 from sourceryinstitute/issue-422-better-error-message
Fixes #422: better error message & more unit tests
2 parents 55e36d7 + fce3456 commit 3282568

File tree

7 files changed

+227
-16
lines changed

7 files changed

+227
-16
lines changed

CMakeLists.txt

+25-7
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ endif()
151151
set(opencoarrays_aware_compiler false)
152152
add_definitions(-DPREFIX_NAME=_caf_extensions_)
153153
endif()
154-
if(gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.4))
154+
if(gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.4.0))
155155
# GCC patch to fix issue accepted for 5.4 release
156156
# See https://github.com/sourceryinstitute/opencoarrays/issues/28 and
157157
# https://groups.google.com/forum/#!msg/opencoarrays/RZOwwYTqG80/46S9eL696dgJ
@@ -537,7 +537,12 @@ if(opencoarrays_aware_compiler)
537537
add_mpi_test(register_alloc_vector 2 ${tests_root}/unit/init_register/register_alloc_vector)
538538
add_mpi_test(allocate_as_barrier 2 ${tests_root}/unit/init_register/allocate_as_barrier)
539539
add_mpi_test(allocate_as_barrier_proc 8 ${tests_root}/unit/init_register/allocate_as_barrier_proc)
540-
if (gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7))
540+
if (gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0) OR (CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER}))
541+
message( STATUS "Allocatable components of coarray derived types only supported in GFortran >= 7 with OpenCoarrays > 1.8.4" )
542+
message( STATUS "(but full support not anticipated until OpenCoarrays 2.0 release)" )
543+
if (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0)
544+
message( WARNING "Allocatable components of coarray derived type developer tests enabled, despite lack of support in GFortran < 7\n These tests should fail." )
545+
endif()
541546
add_mpi_test(register_alloc_comp_1 2 ${tests_root}/unit/init_register/register_alloc_comp_1)
542547
add_mpi_test(register_alloc_comp_2 2 ${tests_root}/unit/init_register/register_alloc_comp_2)
543548
add_mpi_test(register_alloc_comp_3 2 ${tests_root}/unit/init_register/register_alloc_comp_3)
@@ -560,6 +565,7 @@ if(opencoarrays_aware_compiler)
560565
add_mpi_test(duplicate_syncimages 8 ${tests_root}/unit/sync/duplicate_syncimages)
561566
add_mpi_test(co_reduce 4 ${tests_root}/unit/collectives/co_reduce_test)
562567
add_mpi_test(co_reduce_res_im 4 ${tests_root}/unit/collectives/co_reduce_res_im)
568+
add_mpi_test(co_reduce_string 4 ${tests_root}/unit/collectives/co_reduce_string)
563569
add_mpi_test(syncimages_status 8 ${tests_root}/unit/sync/syncimages_status)
564570
add_mpi_test(sync_ring_abort_np3 3 ${tests_root}/unit/sync/sync_image_ring_abort_on_stopped_image)
565571
add_mpi_test(sync_ring_abort_np7 7 ${tests_root}/unit/sync/sync_image_ring_abort_on_stopped_image)
@@ -574,21 +580,33 @@ if(opencoarrays_aware_compiler)
574580
add_mpi_test(asynchronous_hello_world 3 ${tests_root}/integration/events/asynchronous_hello_world)
575581

576582
# Regression tests based on reported issues
577-
if(gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0))
578-
# GFortran PR 78505 only fixed on trunk/gcc 7
583+
if((gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0)) OR (CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER}))
584+
if( CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0 )
585+
message( WARNING "Developer tests requested and GFortran < 7: test source-alloc-no-sync may fail" )
586+
endif()
587+
# GFortran PR 78505 only fixed on trunk/gcc 7, issue #243
579588
add_mpi_test(source-alloc-no-sync 8 ${tests_root}/regression/reported/source-alloc-sync)
580589
endif()
581-
if (CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER})
590+
591+
# Open GCC 7 regressions
592+
if ((CAF_RUN_DEVELOPER_TESTS OR $ENV{OPENCOARRAYS_DEVELOPER}) OR (gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0)))
582593
add_mpi_test(convert-before-put 3 ${tests_root}/regression/reported/convert-before-put)
594+
add_mpi_test(put-alloc-comp 2 ${tests_root}/regression/reported/issue-422-send)
595+
add_mpi_test(get-put-alloc-comp 3 ${tests_root}/regression/reported/issue-422-send-get)
583596
endif()
597+
598+
# Fixed GCC 7 regressions, should run on GCC 6 and 7
584599
add_mpi_test(event-post 3 ${tests_root}/regression/reported/event-post)
600+
601+
# These co_reduce (#172, fixed by PR #332, addl discussion in PR
602+
# #331) tests are for bugs not regressions. Should be fixed in all
603+
# version of GCC, I beleive
585604
add_mpi_test(co_reduce-factorial 4 ${tests_root}/regression/reported/co_reduce-factorial)
586605
add_mpi_test(co_reduce-factorial-int8 4 ${tests_root}/regression/reported/co_reduce-factorial-int8)
587606
add_mpi_test(co_reduce-factorial-int64 4 ${tests_root}/regression/reported/co_reduce-factorial-int64)
588-
add_mpi_test(co_reduce_string 4 ${tests_root}/unit/collectives/co_reduce_string)
589607

590608
# IMAGE FAIL tests
591-
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7)
609+
if(NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0)
592610
add_mpi_test(image_status_test_1 4 ${tests_root}/unit/fail_images/image_status_test_1)
593611
if(CAF_ENABLE_FAILED_IMAGES)
594612
# No other way to check that image_fail_test_1 passes.

src/mpi/mpi_caf.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
595595
#endif
596596

597597
locking_atomic_op(win, &value, newval, compare, image_index, index);
598-
#ifdef WITH_FAILED_IMAGES
598+
#ifdef WITH_FAILED_IMAGES
599599
if (image_stati[value] == STAT_FAILED_IMAGE)
600600
{
601601
CAF_Win_lock (MPI_LOCK_EXCLUSIVE, image_index - 1, win);
@@ -613,7 +613,7 @@ void mutex_lock(MPI_Win win, int image_index, int index, int *stat,
613613
*stat = ierr;
614614
else if (ierr == STAT_FAILED_IMAGE)
615615
terminate_internal (ierr, 0);
616-
616+
617617
return;
618618

619619
stat_error:
@@ -659,7 +659,7 @@ void mutex_unlock(MPI_Win win, int image_index, int index, int *stat,
659659
*stat = ierr;
660660
else if(ierr == STAT_FAILED_IMAGE)
661661
terminate_internal (ierr, 0);
662-
662+
663663
return;
664664

665665
stat_error:
@@ -4436,7 +4436,7 @@ PREFIX (event_post) (caf_token_t token, size_t index,
44364436

44374437
if(!stat && ierr == STAT_FAILED_IMAGE)
44384438
terminate_internal (ierr, 0);
4439-
4439+
44404440
if(ierr != MPI_SUCCESS)
44414441
{
44424442
if(stat != NULL)
@@ -4498,7 +4498,7 @@ PREFIX (event_wait) (caf_token_t token, size_t index,
44984498

44994499
if(!stat && ierr == STAT_FAILED_IMAGE)
45004500
terminate_internal (ierr, 0);
4501-
4501+
45024502
if(ierr != MPI_SUCCESS)
45034503
{
45044504
if(stat != NULL)
@@ -4796,10 +4796,11 @@ unsupported_fail_images_message (const char * functionname)
47964796
void
47974797
unimplemented_alloc_comps_message (const char * functionname)
47984798
{
4799-
fprintf (stderr, "*** caf_mpi-lib runtime message on image %d:\n"
4800-
"*** The allocatable components feature '%s' of Fortran 2008 standard\n"
4801-
"*** is not yet supported by OpenCoarrays.\n",
4802-
caf_this_image, functionname);
4799+
fprintf (stderr,
4800+
"*** Message from libcaf_mpi runtime function '%s' on image %d:\n"
4801+
"*** Assigning to an allocatable coarray component of a derived type is not yet supported with GCC 7.\n"
4802+
"*** Either revert to GCC 6 or convert all puts (type(foo)::x; x%%y[recipient] = z) to gets (z = x%%y[provider]).\n",
4803+
functionname, caf_this_image );
48034804
#ifdef STOP_ON_UNSUPPORTED
48044805
exit (EXIT_FAILURE);
48054806
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../reported/issue-422-send.f90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../reported/issue-422-sendget.f90

src/tests/regression/reported/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ target_link_libraries(convert-before-put OpenCoarrays)
1616
add_executable(event-post issue-293-silent-event-failure.F90)
1717
target_link_libraries(event-post OpenCoarrays)
1818

19+
add_executable(issue-422-send issue-422-send.F90)
20+
target_link_libraries(issue-422-send OpenCoarrays)
21+
22+
add_executable(issue-422-send-get issue-422-send-get.F90)
23+
target_link_libraries(issue-422-send-get OpenCoarrays)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
! BSD 3-Clause License
2+
!
3+
! Copyright (c) 2016, Sourcery Institute
4+
! All rights reserved.
5+
!
6+
! Redistribution and use in source and binary forms, with or without
7+
! modification, are permitted provided that the following conditions are met:
8+
!
9+
! * Redistributions of source code must retain the above copyright notice, this
10+
! list of conditions and the following disclaimer.
11+
!
12+
! * Redistributions in binary form must reproduce the above copyright notice,
13+
! this list of conditions and the following disclaimer in the documentation
14+
! and/or other materials provided with the distribution.
15+
!
16+
! * Neither the name of the copyright holder nor the names of its
17+
! contributors may be used to endorse or promote products derived from
18+
! this software without specific prior written permission.
19+
!
20+
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
program main
32+
!! author: Damian Rouson
33+
!! date: 2017-08-01
34+
!! category: regression
35+
!! Test whether assigning an allocatable coarray component to an allocatable
36+
!! coarray component works.
37+
!! OpenCoarrays issue #422
38+
use iso_fortran_env, only : error_unit
39+
implicit none
40+
41+
type foo
42+
!! A derived type is required to demonstrate issue #422
43+
integer, allocatable :: bar(:)[:]
44+
end type
45+
type(foo) :: foobar
46+
47+
enum, bind(C)
48+
enumerator :: recipient=1, provider, getter_putter
49+
!! provider=2, getter_putter=3
50+
end enum
51+
52+
integer, parameter :: bar_size=2, required_images=3
53+
54+
associate( me=>this_image(), N_images=>num_images() )
55+
56+
verify_num_images: if (N_images<required_images) then
57+
write(error_unit,*) "issue-422-send-get.f90 requires at least ",required_images," images"
58+
error stop
59+
end if verify_num_images
60+
61+
allocate(foobar%bar(bar_size)[*],source=me)
62+
!! Assign each image's identifier to each element of foobar%bar
63+
#ifndef GCC_GE_7
64+
sync all
65+
!! Issue #243 not backported to GCC < 7: implicit sync happens
66+
!! after allocataion but before assignment
67+
#endif
68+
69+
get_put_component: if (me==getter_putter) then
70+
foobar%bar(:)[recipient] = foobar%bar(:)[provider]
71+
!! Get bar from provider image and put bar on recipient image
72+
sync images(recipient)
73+
!! Signal recipient that get and put have completed
74+
end if get_put_component
75+
76+
wait_and_verify: if (me==recipient) then
77+
sync images(getter_putter)
78+
!! Wait for signal from getter-putter
79+
80+
verify_result: if (any(foobar%bar/=provider)) then
81+
write(error_unit,*) "Recipient image ",recipient," received ",foobar%bar," but expected ",provider
82+
error stop
83+
end if verify_result
84+
85+
print *,"Test passed."
86+
!! Report success
87+
88+
end if wait_and_verify
89+
90+
end associate
91+
92+
end program
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
! BSD 3-Clause License
2+
!
3+
! Copyright (c) 2016, Sourcery Institute
4+
! All rights reserved.
5+
!
6+
! Redistribution and use in source and binary forms, with or without
7+
! modification, are permitted provided that the following conditions are met:
8+
!
9+
! * Redistributions of source code must retain the above copyright notice, this
10+
! list of conditions and the following disclaimer.
11+
!
12+
! * Redistributions in binary form must reproduce the above copyright notice,
13+
! this list of conditions and the following disclaimer in the documentation
14+
! and/or other materials provided with the distribution.
15+
!
16+
! * Neither the name of the copyright holder nor the names of its
17+
! contributors may be used to endorse or promote products derived from
18+
! this software without specific prior written permission.
19+
!
20+
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
! DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
! FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
! OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
program main
32+
!! author: Damian Rouson
33+
!! date: 2017-08-01
34+
!! category: regression
35+
!! Test whether assigning an allocatable coarray component to an allocatable
36+
!! coarray component works.
37+
!! OpenCoarrays issue #422
38+
use iso_fortran_env, only : error_unit
39+
implicit none
40+
41+
type foo
42+
!! A derived type is required to demonstrate issue #422
43+
integer, allocatable :: bar(:)[:]
44+
end type
45+
type(foo) :: foobar
46+
47+
enum, bind(C)
48+
enumerator :: recipient=1, provider
49+
!! provider=2
50+
end enum
51+
52+
integer, parameter :: message(*)=[3,4], required_images=2
53+
!! Data for provider image to put on recipient image
54+
55+
associate( me=>this_image(), N_images=>num_images() )
56+
57+
verify_num_images: if (N_images<required_images) then
58+
write(error_unit,*) "issue-422-send.f90 requires at least ",required_images," images"
59+
error stop
60+
end if verify_num_images
61+
62+
allocate(foobar%bar(size(message))[*],source=me)
63+
!! Assign each image's identifier to each element of foobar%bar
64+
#ifndef GCC_GE_7
65+
sync all
66+
!! Fix to #243 has not been backported to GCC < 7. Implicit sync
67+
!! happens after allocation but before sourced assignment
68+
#endif
69+
70+
get_put_component: if (me==provider) then
71+
foobar%bar(:)[recipient] = message
72+
!! Get bar from provider image and put bar on recipient image
73+
sync images(recipient)
74+
!! Signal recipient that get and put have completed
75+
end if get_put_component
76+
77+
wait_and_verify: if (me==recipient) then
78+
sync images(provider)
79+
!! Wait for signal from provider image
80+
81+
verify_result: if (any(foobar%bar/=message)) then
82+
write(error_unit,*) "Recipient image ",recipient," received ",foobar%bar," but expected ",provider
83+
error stop
84+
end if verify_result
85+
86+
print *,"Test passed."
87+
!! Report success
88+
89+
end if wait_and_verify
90+
91+
end associate
92+
93+
end program

0 commit comments

Comments
 (0)