Skip to content

Commit

Permalink
Deploy ASSERT_MULTI_IMAGE feature macro
Browse files Browse the repository at this point in the history
Use it to disable multi-image execution by default on Intel,
which in turn removes the dependence on Intel MPI

Adjust test code accordingly
  • Loading branch information
bonachea committed Nov 12, 2024
1 parent 1c60620 commit 8afd114
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
14 changes: 14 additions & 0 deletions include/assert_features.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef _ASSERT_FEATURES_H
#define _ASSERT_FEATURES_H

! Whether or not the assert library may use multi-image features
! Default is compiler-dependent
#ifndef ASSERT_MULTI_IMAGE
# if defined(__flang__) || defined(__INTEL_COMPILER)
# define ASSERT_MULTI_IMAGE 0
# else
# define ASSERT_MULTI_IMAGE 1
# endif
#endif

#endif
5 changes: 4 additions & 1 deletion src/assert/assert_subroutine_s.F90
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
! "Multi-Dimensional Physics Implementation into Fuel Analysis under Steady-state and Transients (FAST)",
! contract # NRC-HQ-60-17-C-0007
!

#include "assert_features.h"

submodule(assert_subroutine_m) assert_subroutine_s
implicit none

Expand All @@ -26,7 +29,7 @@
check_assertion: &
if (.not. assertion) then

#ifndef __flang__
#if ASSERT_MULTI_IMAGE
associate(me=>this_image()) ! work around gfortran bug
header = 'Assertion "' // description // '" failed on image ' // string(me)
end associate
Expand Down
3 changes: 3 additions & 0 deletions test/run-false-assertion-intel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
output=$(fpm run --example false-assertion --compiler ifx --flag '-O3 -DASSERTIONS' > /dev/null 2>&1)
echo $?
8 changes: 5 additions & 3 deletions test/test-assert-subroutine-error-termination.F90
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "assert_features.h"

program test_assert_subroutine_error_termination
!! Test "assert" subroutine calls that are intended to error terminate
use assert_m, only : assert
Expand All @@ -21,7 +23,7 @@ program test_assert_subroutine_error_termination
#elif __flang__
command = "./test/run-false-assertion.sh | fpm run --example check-exit-status", &
#elif __INTEL_COMPILER
command = "fpm run --example false-assertion --compiler ifx --flag '-DASSERTIONS -O3' > /dev/null 2>&1", &
command = "./test/run-false-assertion-intel.sh | fpm run --example check-exit-status", &
#elif _CRAYFTN
command = "fpm run --example false-assertion --profile release --compiler crayftn.sh --flag '-DASSERTIONS' > /dev/null 2>&1", &
#else
Expand All @@ -31,7 +33,7 @@ program test_assert_subroutine_error_termination
exitstat = exit_status &
)

#ifndef __flang__
#if ASSERT_MULTI_IMAGE
block
logical error_termination

Expand Down Expand Up @@ -63,7 +65,7 @@ pure function and_operation(lhs,rhs) result(lhs_and_rhs)
lhs_and_rhs = lhs .and. rhs
end function

#ifndef __flang__
#if ASSERT_MULTI_IMAGE
subroutine co_all(boolean)
logical, intent(inout) :: boolean
call co_reduce(boolean, and_operation)
Expand Down
6 changes: 4 additions & 2 deletions test/test-assert-subroutine-normal-termination.F90
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "assert_features.h"

program test_assert_subroutine_normal_termination
!! Test direct calls to the "assert" subroutine that don't error-terminate
use assert_m, only : assert
Expand All @@ -12,7 +14,7 @@ program test_assert_subroutine_normal_termination
call assert( .true., "1 keyword argument ", diagnostic_data=0)
call assert( .true., "0 keyword arguments ", 0)
call assert( .true., "no optional argument" )
#ifndef __flang__
#if ASSERT_MULTI_IMAGE
sync all
if (this_image()==1) &
#endif
Expand All @@ -30,7 +32,7 @@ program test_assert_subroutine_normal_termination
call assert(all(integer_1D < 3 ), "all(int_array < 3 )", intrinsic_array_t(integer_1D))
call assert(all(logical_1D ), "all(logical_array )", intrinsic_array_t(logical_1D))
call assert(all(real_1D < 3.), "all(real_array < 3.)", intrinsic_array_t( real_1D))
#ifndef __flang__
#if ASSERT_MULTI_IMAGE
sync all
if (this_image()==1) &
#endif
Expand Down

0 comments on commit 8afd114

Please sign in to comment.