Skip to content

Commit 7f3df6f

Browse files
bonachearouson
authored andcommitted
Deploy ASSERT_MULTI_IMAGE feature macro
Use it to disable multi-image execution by default on Intel, which in turn removes the dependence on Intel MPI Adjust test code accordingly
1 parent bc7d40c commit 7f3df6f

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

include/assert_features.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef _ASSERT_FEATURES_H
2+
#define _ASSERT_FEATURES_H
3+
4+
! Whether or not the assert library may use multi-image features
5+
! Default is compiler-dependent
6+
#ifndef ASSERT_MULTI_IMAGE
7+
# if defined(__flang__) || defined(__INTEL_COMPILER)
8+
# define ASSERT_MULTI_IMAGE 0
9+
# else
10+
# define ASSERT_MULTI_IMAGE 1
11+
# endif
12+
#endif
13+
14+
#endif

src/assert/assert_subroutine_s.F90

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
! "Multi-Dimensional Physics Implementation into Fuel Analysis under Steady-state and Transients (FAST)",
55
! contract # NRC-HQ-60-17-C-0007
66
!
7+
8+
#include "assert_features.h"
9+
710
submodule(assert_subroutine_m) assert_subroutine_s
811
implicit none
912

@@ -26,7 +29,7 @@
2629
check_assertion: &
2730
if (.not. assertion) then
2831

29-
#ifndef __flang__
32+
#if ASSERT_MULTI_IMAGE
3033
associate(me=>this_image()) ! work around gfortran bug
3134
header = 'Assertion "' // description // '" failed on image ' // string(me)
3235
end associate

test/run-false-assertion-intel.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
output=$(fpm run --example false-assertion --compiler ifx --flag '-O3 -DASSERTIONS' > /dev/null 2>&1)
3+
echo $?

test/test-assert-subroutine-error-termination.F90

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "assert_features.h"
2+
13
program test_assert_subroutine_error_termination
24
!! Test "assert" subroutine calls that are intended to error terminate
35
use assert_m, only : assert
@@ -21,7 +23,7 @@ program test_assert_subroutine_error_termination
2123
#elif __flang__
2224
command = "./test/run-false-assertion.sh | fpm run --example check-exit-status", &
2325
#elif __INTEL_COMPILER
24-
command = "fpm run --example false-assertion --compiler ifx --flag '-DASSERTIONS -O3' > /dev/null 2>&1", &
26+
command = "./test/run-false-assertion-intel.sh | fpm run --example check-exit-status", &
2527
#elif _CRAYFTN
2628
command = "fpm run --example false-assertion --profile release --compiler crayftn.sh --flag '-DASSERTIONS' > /dev/null 2>&1", &
2729
#else
@@ -31,7 +33,7 @@ program test_assert_subroutine_error_termination
3133
exitstat = exit_status &
3234
)
3335

34-
#ifndef __flang__
36+
#if ASSERT_MULTI_IMAGE
3537
block
3638
logical error_termination
3739

@@ -63,7 +65,7 @@ pure function and_operation(lhs,rhs) result(lhs_and_rhs)
6365
lhs_and_rhs = lhs .and. rhs
6466
end function
6567

66-
#ifndef __flang__
68+
#if ASSERT_MULTI_IMAGE
6769
subroutine co_all(boolean)
6870
logical, intent(inout) :: boolean
6971
call co_reduce(boolean, and_operation)

test/test-assert-subroutine-normal-termination.F90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "assert_features.h"
2+
13
program test_assert_subroutine_normal_termination
24
!! Test direct calls to the "assert" subroutine that don't error-terminate
35
use assert_m, only : assert
@@ -12,7 +14,7 @@ program test_assert_subroutine_normal_termination
1214
call assert( .true., "1 keyword argument ", diagnostic_data=0)
1315
call assert( .true., "0 keyword arguments ", 0)
1416
call assert( .true., "no optional argument" )
15-
#ifndef __flang__
17+
#if ASSERT_MULTI_IMAGE
1618
sync all
1719
if (this_image()==1) &
1820
#endif
@@ -30,7 +32,7 @@ program test_assert_subroutine_normal_termination
3032
call assert(all(integer_1D < 3 ), "all(int_array < 3 )", intrinsic_array_t(integer_1D))
3133
call assert(all(logical_1D ), "all(logical_array )", intrinsic_array_t(logical_1D))
3234
call assert(all(real_1D < 3.), "all(real_array < 3.)", intrinsic_array_t( real_1D))
33-
#ifndef __flang__
35+
#if ASSERT_MULTI_IMAGE
3436
sync all
3537
if (this_image()==1) &
3638
#endif

0 commit comments

Comments
 (0)