Skip to content

Commit c144397

Browse files
authored
Merge pull request #97 from bonachea/parallel-callbacks
Adjust configuration knobs
2 parents 1f8b06b + 1fe7514 commit c144397

5 files changed

Lines changed: 141 additions & 149 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ jobs:
7878
container: snowstep/llvm:jammy
7979

8080
# https://hub.docker.com/r/phhargrove/llvm-flang/tags
81+
- os: ubuntu-24.04-arm
82+
compiler: flang
83+
version: 23
84+
container: phhargrove/llvm-flang:23.1.0-latest-arm64
85+
8186
- os: ubuntu-24.04
8287
compiler: flang
8388
version: 23
@@ -143,13 +148,8 @@ jobs:
143148
# https://hub.docker.com/r/phhargrove/lfortran/tags
144149
- os: ubuntu-24.04
145150
compiler: lfortran
146-
version: 0.54.0
147-
container: phhargrove/lfortran:0.54.0-1
148-
149-
# - os: ubuntu-24.04
150-
# compiler: lfortran
151-
# version: 0.55.0
152-
# container: phhargrove/lfortran:0.55.0-1
151+
version: 0.55.0
152+
container: phhargrove/lfortran:0.55.0-1
153153
#
154154
# - os: ubuntu-24.04
155155
# compiler: lfortran
@@ -186,11 +186,6 @@ jobs:
186186
version: 0.62.0
187187
container: phhargrove/lfortran:0.62.0-1
188188

189-
- os: ubuntu-24.04
190-
compiler: lfortran
191-
version: 0.63.0
192-
container: phhargrove/lfortran:0.63.0-1
193-
194189
# https://github.com/lfortran/lfortran/pkgs/container/lfortran
195190
- os: ubuntu-22.04
196191
compiler: lfortran
@@ -207,6 +202,11 @@ jobs:
207202
version: 0.65.0
208203
container: ghcr.io/lfortran/lfortran:v0.65.0
209204

205+
- os: ubuntu-22.04
206+
compiler: lfortran
207+
version: 0.66.0
208+
container: ghcr.io/lfortran/lfortran:v0.66.0
209+
210210
- os: ubuntu-22.04
211211
compiler: lfortran
212212
version: latest
@@ -328,10 +328,11 @@ jobs:
328328
if: ${{ runner.os == 'Linux' && runner.arch == 'ARM64' }}
329329
run: |
330330
export FPM_VERSION=0.13.0
331+
mkdir -p fpm-temp/bin
332+
cd fpm-temp
331333
curl --retry 5 -LOsS https://github.com/fortran-lang/fpm/releases/download/v$FPM_VERSION/fpm-$FPM_VERSION.F90
332-
mkdir fpm-temp
333-
gfortran-14 -o fpm-temp/fpm fpm-$FPM_VERSION.F90
334-
echo "PATH=${PWD}/fpm-temp:${PATH}" >> "$GITHUB_ENV"
334+
gfortran-14 -o bin/fpm fpm-$FPM_VERSION.F90
335+
echo "PATH=$PWD/bin:${PATH}" >> "$GITHUB_ENV"
335336
336337
- name: Version info
337338
run: |
@@ -362,11 +363,21 @@ jobs:
362363
( set +e ; eval fpm run --example invoke-via-macro ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
363364
364365
- name: Test Assertions w/ Parallel Callbacks
365-
if: ${{ matrix.compiler != 'lfortran' || matrix.version != '0.54.0' }} # issue #68, fixed in 0.55
366366
env:
367-
FPM_FLAGS: ${{ env.FPM_FLAGS }} --flag -DASSERT_MULTI_IMAGE --flag -DASSERT_PARALLEL_CALLBACKS
367+
FPM_FLAGS: ${{ env.FPM_FLAGS }} --flag -DTEST_PARALLEL_CALLBACKS
368+
run: |
369+
fpm run --example false-assertion ${FPM_FLAGS} --flag "$FFLAGS"
370+
fpm run --example invoke-via-macro ${FPM_FLAGS} --flag "$FFLAGS"
371+
( set +e ; eval fpm run --example false-assertion ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
372+
( set +e ; eval fpm run --example invoke-via-macro ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
373+
374+
- name: Test Assertions w/ ASSERT_MULTI_IMAGE
375+
if: matrix.compiler == 'gfortran'
376+
env:
377+
FPM_FLAGS: ${{ env.FPM_FLAGS }} --flag -fcoarray=single --flag -DASSERT_MULTI_IMAGE
368378
run: |
369379
fpm run --example false-assertion ${FPM_FLAGS} --flag "$FFLAGS"
370380
fpm run --example invoke-via-macro ${FPM_FLAGS} --flag "$FFLAGS"
371381
( set +e ; eval fpm run --example false-assertion ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
372382
( set +e ; eval fpm run --example invoke-via-macro ${FPM_FLAGS} --flag \"$FFLAGS\" $CHECK_ASSERT )
383+

‎README.md‎

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ preprocessor ASSERTIONS to non-zero, e.g.,
3434
```
3535
fpm build --flag "-DASSERTIONS"
3636
```
37-
The program [example/invoke-via-macro.F90] demonstrates the preferred way to invoke assertions via the three provided macros.
37+
The program [example/invoke-via-macro.F90] demonstrates the preferred way to invoke assertions via the provided macros.
3838
Invoking assertions this way ensures such calls will be completely removed whenever the `ASSERTIONS` macro is undefined (or defined to zero) during compilation.
3939
Due to a limitation of `fpm`, this approach works best if the project using Assert is also a `fpm` project.
4040
If instead `fpm install` is used, then either the user must copy `include/assert_macros.h` to the installation directory (default: `~/.local/include`) or
@@ -84,7 +84,7 @@ Building and Testing
8484
- [GNU Compiler Collection (GCC) `gfortran`](#gnu-compiler-collection-gcc-gfortran))
8585
- [Intel `ifx`](#intel-ifx))
8686
- [LFortran `lfortran`](#lfortran-lfortran)
87-
- [LLVM `flang-new`](#llvm-flang-new)
87+
- [LLVM `flang`](#llvm-flang)
8888
- [Numerical Algorithms Group (NAG) `nagfor`](#numerical-algorithms-group-nag-nagfor)
8989

9090
### General Build Knobs
@@ -98,16 +98,19 @@ using syntax like: `fpm --flag "-DASSERTIONS=1"`
9898

9999
* `ASSERT_MULTI_IMAGE`: Controls whether the library attempts to use multi-image
100100
Fortran features (e.g. to report the image number of an assertion failure).
101-
The default is compiler-specific. Multi-image support can be disabled using
102-
`-DASSERT_MULTI_IMAGE=0`.
101+
Default is disabled, multi-image support can be enabled using `-DASSERT_MULTI_IMAGE`.
103102

104-
* `ASSERT_PARALLEL_CALLBACKS`: Controls the use of a callback interface for
105-
multi-process features. Contact us for more details.
103+
### Cray Compiler Environment (CCE) `crayftn`
106104

107-
### Cray Compiler Environment (CCE) `ftn`
108-
Because `fpm` uses the compiler name to determine the compiler identity and because
109-
CCE provides one compiler wrapper, `ftn`, for invoking all compilers, you will
110-
need to invoke `ftn` in a shell script named to identify CCE compiler. For example,
105+
The simplest way to compile with CCE is to invoke the Cray compiler
106+
directly:
107+
```
108+
fpm test --compiler crayftn --profile release
109+
```
110+
111+
If instead you prefer to use the Cray PE compiler wrappers, note that `fpm` uses
112+
the compiler name to determine the compiler identity, so you will
113+
need to invoke `ftn` in a shell script named to identify the CCE compiler. For example,
111114
place a script named `crayftn.sh` in your path with the following contents and with
112115
executable privileges set appropriately:
113116
```
@@ -136,11 +139,11 @@ The above commands build the Assert library (with the default of assertion enfor
136139
#### Multi-image (parallel) execution
137140
With `gfortran` 14 or later versions and OpenCoarrays installed, use
138141
```
139-
fpm test --compiler caf --profile release --runner "cafrun -n 2"
142+
fpm test --compiler caf --profile release --runner "cafrun -n 2" --flag -DASSERT_MULTI_IMAGE
140143
```
141144
With `gfortran` 13 or earlier versions and OpenCoarrays installed,
142145
```
143-
fpm test --compiler caf --profile release --runner "cafrun -n 2" --flag "-ffree-line-length-0"
146+
fpm test --compiler caf --profile release --runner "cafrun -n 2" --flag "-DASSERT_MULTI_IMAGE -ffree-line-length-0"
144147
```
145148

146149
### Intel `ifx`
@@ -156,16 +159,16 @@ With Intel Fortran and Intel MPI installed,
156159
fpm test --compiler ifx --profile release --flag "-coarray -DASSERT_MULTI_IMAGE"
157160
```
158161

159-
### LLVM `flang-new`
162+
### LLVM `flang`
160163

161164
#### Single-image (serial) execution
162-
With `flang-new` version 19, use
165+
With LLVM Flang version 19, use
163166
```
164167
fpm test --compiler flang-new --flag "-mmlir -allow-assumed-rank -O3"
165168
```
166-
With `flang-new` version 20 or later, use
169+
With LLVM Flang version 20 or later, use
167170
```
168-
fpm test --compiler flang-new --flag "-O3"
171+
fpm test --compiler flang --flag "-O3"
169172
```
170173

171174
### LFortran `lfortran`
@@ -180,17 +183,13 @@ fpm test --compiler lfortran --profile release --flag --cpp
180183
#### Single-image (serial) execution
181184
With `nagfor` version 7.1 or later, use
182185
```
183-
fpm test --compiler nagfor --flag -fpp
186+
fpm test --compiler nagfor -DASSERTIONS
184187
```
185188

186189
#### Multi-image execution
187-
With `nagfor` 7.1, use
188-
```
189-
fpm test --compiler nagfor --profile release --flag "-fpp -coarray=cosmp -f2018"
190-
```
191-
With `nagfor` 7.2 or later, use
190+
With `nagfor` 7.1 or later, use
192191
```
193-
fpm test --compiler nagfor --flag -fpp
192+
fpm test --compiler nagfor --flag -DASSERT_MULTI_IMAGE
194193
```
195194

196195
Documentation
@@ -242,15 +241,15 @@ In the case of gfortran, this appears to have been resolved by default starting
242241
#### Line breaks in macro invocations
243242

244243
The preprocessor is not currently specified by any Fortran standard, and
245-
as of 2025 its operation differs in subtle ways between compilers.
244+
as of 2026 its operation differs in subtle ways between compilers.
246245
One way in which compilers differ is how macro invocations can safely be broken
247246
across multiple lines.
248247

249-
For example, gfortran and flang-new both accept backslash `\` continuation
248+
For example, GNU `gfortran` and LLVM `flang` both accept backslash `\` continuation
250249
character for line-breaks in a macro invocation:
251250

252251
```fortran
253-
! OK for flang-new and gfortran
252+
! OK for flang and gfortran
254253
call_assert_describe( computed_checksum == expected_checksum, \
255254
"Checksum mismatch failure!" \
256255
)
@@ -276,7 +275,7 @@ Fortran does not support comments with an end delimiter,
276275
only to-end-of-line comments. As such, there is no portable way to safely insert a
277276
Fortran comment into the middle of a macro invocation. For example, the
278277
following seemingly reasonable code results in a syntax error
279-
after macro expansion (on gfortran and flang-new):
278+
after macro expansion (on gfortran and flang):
280279

281280
```fortran
282281
! INCORRECT: cannot use Fortran comments inside macro invocation

‎example/false-assertion.F90‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ program false_assertion
22
use assert_m
33
implicit none
44

5-
#if ASSERT_PARALLEL_CALLBACKS
5+
#if TEST_PARALLEL_CALLBACKS
66
assert_this_image => assert_callback_this_image
77
assert_error_stop => assert_callback_error_stop
88
#endif
99

1010
call assert(.false., "false-assertion: unconditionally failing test")
1111

12-
#if ASSERT_PARALLEL_CALLBACKS
12+
#if TEST_PARALLEL_CALLBACKS
1313
! By default, assert uses `THIS_IMAGE()` in multi-image mode while
1414
! composing assertion output, and invokes `ERROR STOP` to print the
1515
! assertion and terminate execution.
1616
!
17-
! The ASSERT_PARALLEL_CALLBACKS preprocessor flag enables the client to replace
17+
! The parallel callbacks features enables the client to replace
1818
! the default use of these two Fortran features with client-provided callbacks.
19-
! To use this feature, the client must build the library with `-DASSERT_PARALLEL_CALLBACKS`,
20-
! and then at startup set the `assert_this_image` and `assert_error_stop`
19+
! To use this feature, the client must ! set the `assert_this_image` and `assert_error_stop`
2120
! procedure pointers to reference the desired callbacks.
2221
contains
2322

‎include/assert_features.h‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,9 @@
22
#define _ASSERT_FEATURES_H
33

44
! Whether or not the assert library may use multi-image features
5-
! Default is compiler-dependent
5+
! Disabled by default since many compilers require extra arguments to enable multi-image features
66
#ifndef ASSERT_MULTI_IMAGE
7-
# if defined(__flang__) || defined(__INTEL_COMPILER) || defined(__LFORTRAN__)
8-
# define ASSERT_MULTI_IMAGE 0
9-
# else
10-
# define ASSERT_MULTI_IMAGE 1
11-
# endif
12-
#endif
13-
14-
! Whether the library should use client callbacks for parallel features
15-
#ifndef ASSERT_PARALLEL_CALLBACKS
16-
#define ASSERT_PARALLEL_CALLBACKS 0
7+
#define ASSERT_MULTI_IMAGE 0
178
#endif
189

1910
#endif

0 commit comments

Comments
 (0)