Skip to content

Commit 2783bb1

Browse files
committed
CI: add DO CONCURRENT offloading tests for fpm examples
1 parent e6779cd commit 2783bb1

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

.github/workflows/CI-CD.yml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,30 @@ jobs:
156156
uses: gha3mi/setup-fortran-conda@latest
157157
with:
158158
fortitude-check: true
159-
fortitude-settings: "--output-format github"
159+
fortitude-settings: "--output-format github"
160+
161+
162+
do_concurrent_fpm:
163+
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
164+
name: ${{ matrix.os }}_${{ matrix.compiler }}_fpm
165+
runs-on: ${{ matrix.os }}
166+
strategy:
167+
fail-fast: false
168+
matrix:
169+
include:
170+
- {os: ubuntu-latest, compiler: gfortran }
171+
- {os: ubuntu-latest, compiler: ifx }
172+
- {os: ubuntu-latest, compiler: nvfortran}
173+
- {os: windows-latest, compiler: gfortran }
174+
- {os: windows-latest, compiler: ifx }
175+
- {os: macos-latest, compiler: gfortran }
176+
steps:
177+
- name: Setup Fortran
178+
uses: gha3mi/setup-fortran-conda@latest
179+
with:
180+
compiler: ${{ matrix.compiler }}
181+
platform: ${{ matrix.os }}
182+
183+
- name: fpm example (do concurrent)
184+
if: always()
185+
run: fpm @${{ matrix.os }}_${{ matrix.compiler }}_example --verbose

fpm.rsp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## ubuntu
2+
@ubuntu-latest_gfortran_example
3+
options run --example --all
4+
options --compiler gfortran
5+
options --profile release
6+
options --flag "-fopenmp -ftree-parallelize-loops=8"
7+
8+
@ubuntu-latest_ifx_example
9+
options run --example --all
10+
options --compiler ifx
11+
options --profile release
12+
options --flag "-qopenmp -fopenmp-target-do-concurrent"
13+
14+
@ubuntu-latest_nvfortran_example
15+
options run --example --all
16+
options --compiler nvfortran
17+
options --profile release
18+
options --flag "-stdpar=multicore,gpu -Minfo=stdpar,accel"
19+
20+
21+
## macOS
22+
@macos-latest_gfortran_example
23+
options run --example --all
24+
options --compiler gfortran
25+
options --profile release
26+
options --flag "-fopenmp -ftree-parallelize-loops=8"
27+
28+
29+
## windows
30+
@windows-latest_gfortran_example
31+
options run --example --all
32+
options --compiler gfortran
33+
options --profile release
34+
options --flag "-fopenmp -ftree-parallelize-loops=8"
35+
36+
@windows-latest_ifx_example
37+
options run --example --all
38+
options --compiler ifx
39+
options --profile release
40+
options --flag "/Qopenmp /Qopenmp-target-do-concurrent"

fpm.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ auto-tests = true
5858
auto-examples = false
5959
module-naming = false
6060

61+
[preprocess]
62+
[preprocess.cpp]
63+
6164
[install]
6265
library = false
6366

src/forcolormap.f90

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,11 @@ impure subroutine write_ppm_colorbar(self, filename, width, height, encoding)
869869
end if
870870

871871
allocate(rgb_image(pixheight,pixwidth*3))
872-
872+
#if defined(__NVCOMPILER)
873+
do i = 0, pixwidth-1
874+
#else
873875
do concurrent (i = 0:pixwidth-1) local(z, red, green, blue, j)
876+
#endif
874877
z = self%zmin + i / real(pixwidth-1, kind=wp) * (self%zmax - self%zmin)
875878
call self%compute_RGB(z, red, green, blue)
876879
do concurrent (j = 0: pixheight-1)
@@ -923,7 +926,11 @@ impure subroutine write_ppm_colormap_1d(self, filename, zfun, xmin, xmax, width,
923926
end if
924927

925928
allocate(rgb_image(pixheight, pixwidth*3))
929+
#if defined(__NVCOMPILER)
930+
do i = 0, pixwidth-1
931+
#else
926932
do concurrent (i = 0:pixwidth-1) local(t, x, red, green, blue, j)
933+
#endif
927934
t = real(i, wp) / real(max(1, pixwidth-1), wp)
928935
x = xmin + t*(xmax - xmin)
929936
z = zfun(x)
@@ -978,7 +985,12 @@ impure subroutine write_ppm_colormap_2d(self, filename, zfun, xmin, xmax, width,
978985
end if
979986

980987
allocate(rgb_image(pixheight, pixwidth*3))
988+
#if defined(__NVCOMPILER)
989+
do i = 0, pixwidth-1
990+
do j = 0, pixheight-1
991+
#else
981992
do concurrent (j = 0:pixheight-1, i = 0:pixwidth-1) local(ti, tj, x, y, red, green, blue)
993+
#endif
982994
tj = real(j, wp) / real(max(1, pixheight-1), wp)
983995
ti = real(i, wp) / real(max(1, pixwidth-1), wp)
984996
y = xmin(2) + tj*(xmax(2) - xmin(2))
@@ -988,6 +1000,9 @@ impure subroutine write_ppm_colormap_2d(self, filename, zfun, xmin, xmax, width,
9881000
rgb_image(pixheight-j, 3*(i+1)-2) = red
9891001
rgb_image(pixheight-j, 3*(i+1)-1) = green
9901002
rgb_image(pixheight-j, 3*(i+1) ) = blue
1003+
#if defined(__NVCOMPILER)
1004+
end do
1005+
#endif
9911006
end do
9921007

9931008
if (present(encoding)) then
@@ -1010,7 +1025,7 @@ impure subroutine write_ppm_colormap_2d(self, filename, zfun, xmin, xmax, width,
10101025
pure subroutine reverse(self, name)
10111026
class(Colormap), intent(inout) :: self
10121027
character(*), intent(in), optional :: name
1013-
self%map = self%map(size(self%map,1)-1:0:-1, :)
1028+
self%map(0:self%levels-1, :) = self%map(self%levels-1:0:-1, :)
10141029
if (present(name)) then
10151030
self%name = trim(name)
10161031
else

0 commit comments

Comments
 (0)