Skip to content

Commit ba25d2a

Browse files
committed
allow OpenMP to be disabled
1 parent 824e1ec commit ba25d2a

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

CMakeLists.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ enable_testing()
66

77
set(CMAKE_CXX_STANDARD 11)
88

9+
option(OPENACC "Enable OpenACC support" OFF)
10+
option(OPENMP "Enable OpenMP support" ON)
11+
option(OPENMP_OFFLOAD "Enable OpenMP offloading to GPU support" OFF)
12+
option(ROCM "Enable ROCm, offloading to MI100 using OpenMPI 4.5" OFF)
13+
option(INTEL_ANALYZER "Add compiler options for Intel Analyzer" OFF)
14+
915
set(OPT_FLAGS "" CACHE STRING "compiler optimization flags")
1016

1117
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPT_FLAGS}")
@@ -26,12 +32,7 @@ set(NUM_PROCS "4" CACHE STRING "Number of processes when running tests")
2632

2733
set(EXTRA_LIBS "" CACHE STRING "Extra libraries to link against")
2834

29-
option(OPENACC "Enable OpenACC support" OFF)
30-
option(OPENMP_OFFLOAD "Enable OpenMP offloading to GPU support" OFF)
31-
option(ROCM "Enable ROCm, offloading to MI100 using OpenMPI 4.5" OFF)
32-
option(INTEL_ANALYZER "Add compiler options for Intel Analyzer" OFF)
33-
34-
set(ROCM_COMPILER_PATH "/opt/rocm/llvm/bin" CACHE STRING "Path to the ROCm compilers (only used ith ROCM is set)")
35+
set(ROCM_COMPILER_PATH "/opt/rocm/llvm/bin" CACHE STRING "Path to the ROCm compilers (only used if ROCM is set)")
3536
if (${ROCM})
3637
list(APPEND CMAKE_PREFIX_INSTALL /opt/rocm/hip /opt/rocm)
3738
set(CMAKE_CXX_COMPILER "${ROCM_COMPILER_PATH}/clang++")
@@ -90,14 +91,15 @@ if ((NOT OPENACC) AND OPENMP_FOUND)
9091
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
9192
else ()
9293
# OpenACC is incompatible with OpenMP, either one or the other or none
93-
if (OPENACC AND ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^NVHPC|PGI"))
94+
if (OPENACC)
95+
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^NVHPC|PGI")
96+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc -Minfo=acc")
97+
message(STATUS "Using PGI or Nvidia C++ compiler, added OpenACC compiler switches")
98+
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^GNU")
99+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenacc -fopt-info-optimized-omp")
100+
message(STATUS "Using GNU C++ compiler, added OpenACC compiler switches")
101+
endif ()
94102
message(STATUS "OpenACC enabled")
95-
# These are the PGI openACC flags -- need to find out what the
96-
# corresponding options are for the CRAY, gcc, ... compilers
97-
# (if they exist)
98-
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -acc -Minfo=acc")
99-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc -Minfo=acc")
100-
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc -Minfo=acc")
101103
endif ()
102104
endif ()
103105

upwind/cxx/CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,23 @@ if (INTEL_ANALYZER)
1919
message(STATUS "Extra libraries are ${EXTRA_LIBS}")
2020
endif()
2121

22-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
22+
add_executable(upwindAccCxx upwindAcc.cxx)
23+
target_link_libraries(upwindAccCxx fidibench "${EXTRA_LIBS}")
24+
25+
add_executable(upwindAcc2Cxx upwindAcc2.cxx)
26+
target_link_libraries(upwindAcc2Cxx fidibench "${EXTRA_LIBS}")
27+
28+
if (OPENMP)
29+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
30+
endif ()
31+
2332
add_executable(upwindCxx upwind.cxx)
2433
install(TARGETS upwindCxx)
2534
target_link_libraries(upwindCxx PUBLIC fidibench "${EXTRA_LIBS}" OpenMP::OpenMP_CXX)
2635

2736
add_executable(upwindOMPTasksCxx upwindOMPTasks.cxx)
2837
target_link_libraries(upwindOMPTasksCxx PUBLIC fidibench "${EXTRA_LIBS}" OpenMP::OpenMP_CXX)
2938

30-
add_executable(upwindAccCxx upwindAcc.cxx)
31-
target_link_libraries(upwindAccCxx fidibench "${EXTRA_LIBS}")
32-
33-
add_executable(upwindAcc2Cxx upwindAcc2.cxx)
34-
target_link_libraries(upwindAcc2Cxx fidibench "${EXTRA_LIBS}")
35-
3639
if (OPENMP_OFFLOAD OR ROCM)
3740
add_executable(upwindOMP5Cxx upwindOMP5.cxx)
3841
if (ROCM)

0 commit comments

Comments
 (0)