Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 6e4a1f2

Browse files
committed
Use CORENEURON_PREFER_OPENMP_OFFLOAD.
1 parent 33d571e commit 6e4a1f2

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CMake/OpenAccHelper.cmake

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,24 @@ if(CORENRN_ENABLE_GPU)
7575
message(FATAL_ERROR "${CORENRN_ACCELERATOR_OFFLOAD} not supported with NVHPC compilers")
7676
endif()
7777
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "XLClang")
78-
set(NVHPC_ACC_COMP_FLAGS "-qsmp=omp -qoffload -qreport")
79-
set(NVHPC_ACC_LINK_FLAGS "-qcuda -lcaliper")
80-
81-
if(CORENRN_ENABLE_OPENMP AND CORENRN_ENABLE_OPENMP_OFFLOAD)
78+
if(CORENRN_ACCELERATOR_OFFLOAD STREQUAL "OpenMP")
79+
set(NVHPC_ACC_COMP_FLAGS "-qsmp=omp -qoffload -qreport")
80+
set(NVHPC_ACC_LINK_FLAGS "-qcuda -lcaliper")
8281
# Enable OpenMP target offload to GPU and if both OpenACC and OpenMP directives are available
8382
# for a region then prefer OpenMP.
84-
add_compile_definitions(CORENRN_PREFER_OPENMP_OFFLOAD)
83+
add_compile_definitions(CORENEURON_PREFER_OPENMP_OFFLOAD)
84+
else()
85+
message(FATAL_ERROR "${CORENRN_ACCELERATOR_OFFLOAD} not supported with XLClang compilers")
8586
endif()
8687
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
87-
set(NVHPC_ACC_COMP_FLAGS "-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -Wno-unknown-cuda-version -I${CUDAToolkit_INCLUDE_DIRS}")
88+
if(CORENRN_ACCELERATOR_OFFLOAD STREQUAL "OpenMP")
89+
set(NVHPC_ACC_COMP_FLAGS "-fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -Wno-unknown-cuda-version -I${CUDAToolkit_INCLUDE_DIRS}")
90+
# Enable OpenMP target offload to GPU and if both OpenACC and OpenMP directives are available
91+
# for a region then prefer OpenMP.
92+
add_compile_definitions(CORENEURON_PREFER_OPENMP_OFFLOAD)
93+
else()
94+
message(FATAL_ERROR "${CORENRN_ACCELERATOR_OFFLOAD} not supported with Clang compilers")
95+
endif()
8896
else()
8997
message(FATAL_ERROR "${CMAKE_CXX_COMPILER_ID} is not supported in GPU builds.")
9098
endif()

coreneuron/utils/offload.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <cstddef>
1010

1111
#define nrn_pragma_stringify(x) #x
12-
#if defined(CORENEURON_ENABLE_GPU) && defined(CORENRN_PREFER_OPENMP_OFFLOAD) && defined(_OPENMP)
12+
#if defined(CORENEURON_ENABLE_GPU) && defined(CORENEURON_PREFER_OPENMP_OFFLOAD) && defined(_OPENMP)
1313
#define nrn_pragma_acc(x)
1414
#define nrn_pragma_omp(x) _Pragma(nrn_pragma_stringify(omp x))
1515
#include <omp.h>

0 commit comments

Comments
 (0)