Skip to content

Commit 6e1cfd1

Browse files
authored
Merge pull request #9 from pletzer/consolidate
Consolidate
2 parents a36ce74 + 1586b68 commit 6e1cfd1

File tree

6 files changed

+68
-435
lines changed

6 files changed

+68
-435
lines changed

CMakeLists.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 11)
88

99
option(OPENACC "Enable OpenACC support" OFF)
1010
option(ACC_MULTICORE "Whether for OpenACC to compile for multicore" OFF)
11+
option(ACC_KERNELS "Whether for OpenACC to use the kernels directives" OFF)
1112
option(OPENMP "Enable OpenMP support" ON)
1213
option(OPENMP_OFFLOAD "Enable OpenMP offloading to GPU support" OFF)
1314
option(ROCM "Enable ROCm, offloading to MI100 using OpenMPI 4.5" OFF)
@@ -110,23 +111,28 @@ if ((NOT OPENACC) AND OPENMP_FOUND)
110111
else ()
111112
# OpenACC is incompatible with OpenMP, either one or the other or none
112113
if (OPENACC)
113-
add_definitions(-DHAVE_OPENACC)
114-
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^NVHPC|PGI")
115-
if (ACC_MULTICORE)
116-
message(STATUS "Apply OpenACC directives for offloading to multicore CPU")
117-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc=multicore -Minfo=acc")
114+
add_definitions(-DHAVE_OPENACC)
115+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^NVHPC|PGI")
116+
if (ACC_KERNELS)
117+
message(STATUS "Apply OpenACC kernels directives")
118+
add_definitions(-DHAVE_OPENACC_KERNELS)
119+
endif ()
120+
if (ACC_MULTICORE)
121+
message(STATUS "Apply OpenACC directives for offloading to multicore CPU")
122+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc=multicore -Minfo=acc")
118123
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc=multicore -Minfo=acc")
119-
else ()
120-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc -gpu=mem:managed -Minfo=acc")
124+
else ()
125+
message(STATUS "Apply OpenACC directives for offloading to GPU")
126+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc -gpu=mem:managed -Minfo=acc")
121127
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc -gpu=mem:managed -Minfo=acc")
122-
endif ()
123-
message(STATUS "Using PGI or Nvidia C++ compiler, added OpenACC compiler switches")
124-
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^GNU")
125-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenacc -fopt-info-optimized-omp")
126-
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenacc -fopt-info-optimized-omp")
127-
message(STATUS "Using GNU C++ compiler, added OpenACC compiler switches")
128-
endif ()
129-
message(STATUS "OpenACC enabled")
128+
endif ()
129+
message(STATUS "Using PGI or Nvidia C++ compiler, added OpenACC compiler switches")
130+
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^GNU")
131+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenacc -fopt-info-optimized-omp")
132+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenacc -fopt-info-optimized-omp")
133+
message(STATUS "Using GNU C++ compiler, added OpenACC compiler switches")
134+
endif ()
135+
message(STATUS "OpenACC enabled")
130136
endif ()
131137
endif ()
132138

upwind/fortran/CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
configure_file(upwindF08Acc.sl.in upwindF08Acc.sl)
2-
configure_file(upwindF08OmpGpu.sl.in upwindF08OmpGpu.sl)
1+
configure_file(upwindF08Gpu.sl.in upwindF08Gpu.sl)
32

43
if (HAVE_OPENMP)
54
add_definitions(-DHAVE_OPENMP)
@@ -12,8 +11,7 @@ endif()
1211
add_executable(upwindFortran upwind.F90)
1312
add_executable(upwindF03 upwindF03.F90)
1413
add_executable(upwindF08 upwindF08.F90)
15-
add_executable(upwindF08Acc upwindF08Acc.f90)
16-
add_executable(upwindF08OmpGpu upwindF08OmpGpu.f90)
14+
add_executable(upwindF08Gpu upwindF08Gpu.F90)
1715

1816

1917
add_test(NAME upwindFortran1
@@ -56,16 +54,11 @@ add_test(NAME upwindF08
5654
COMMAND upwindF08
5755
"${NUM_CELLS}" "${NUM_TIME_STEPS}")
5856

59-
add_test(NAME upwindF08Acc
60-
COMMAND upwindF08Acc
57+
add_test(NAME upwindF08Gpu
58+
COMMAND upwindF08Gpu
6159
"${NUM_CELLS}" "${NUM_TIME_STEPS}")
6260

63-
64-
add_test(NAME upwindF08OmpGpu
65-
COMMAND upwindF08OmpGpu
66-
"${NUM_CELLS}" "${NUM_TIME_STEPS}")
67-
68-
set_tests_properties(upwindF03 upwindF08 upwindF08Acc
61+
set_tests_properties(upwindF03 upwindF08 upwindF08Gpu
6962
PROPERTIES
7063
PASS_REGULAR_EXPRESSION "[Cc]heck sum:[ ]*[1|0\\.999]")
7164

0 commit comments

Comments
 (0)