@@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 11)
8
8
9
9
option (OPENACC "Enable OpenACC support" OFF )
10
10
option (ACC_MULTICORE "Whether for OpenACC to compile for multicore" OFF )
11
+ option (ACC_KERNELS "Whether for OpenACC to use the kernels directives" OFF )
11
12
option (OPENMP "Enable OpenMP support" ON )
12
13
option (OPENMP_OFFLOAD "Enable OpenMP offloading to GPU support" OFF )
13
14
option (ROCM "Enable ROCm, offloading to MI100 using OpenMPI 4.5" OFF )
@@ -110,23 +111,28 @@ if ((NOT OPENACC) AND OPENMP_FOUND)
110
111
else ()
111
112
# OpenACC is incompatible with OpenMP, either one or the other or none
112
113
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" )
118
123
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" )
121
127
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" )
130
136
endif ()
131
137
endif ()
132
138
0 commit comments