Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 11)

option(OPENACC "Enable OpenACC support" OFF)
option(ACC_MULTICORE "Whether for OpenACC to compile for multicore" OFF)
option(ACC_KERNELS "Whether for OpenACC to use the kernels directives" OFF)
option(OPENMP "Enable OpenMP support" ON)
option(OPENMP_OFFLOAD "Enable OpenMP offloading to GPU support" OFF)
option(ROCM "Enable ROCm, offloading to MI100 using OpenMPI 4.5" OFF)
Expand Down Expand Up @@ -110,23 +111,28 @@ if ((NOT OPENACC) AND OPENMP_FOUND)
else ()
# OpenACC is incompatible with OpenMP, either one or the other or none
if (OPENACC)
add_definitions(-DHAVE_OPENACC)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^NVHPC|PGI")
if (ACC_MULTICORE)
message(STATUS "Apply OpenACC directives for offloading to multicore CPU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc=multicore -Minfo=acc")
add_definitions(-DHAVE_OPENACC)
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^NVHPC|PGI")
if (ACC_KERNELS)
message(STATUS "Apply OpenACC kernels directives")
add_definitions(-DHAVE_OPENACC_KERNELS)
endif ()
if (ACC_MULTICORE)
message(STATUS "Apply OpenACC directives for offloading to multicore CPU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc=multicore -Minfo=acc")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc=multicore -Minfo=acc")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc -gpu=mem:managed -Minfo=acc")
else ()
message(STATUS "Apply OpenACC directives for offloading to GPU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -acc -gpu=mem:managed -Minfo=acc")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -acc -gpu=mem:managed -Minfo=acc")
endif ()
message(STATUS "Using PGI or Nvidia C++ compiler, added OpenACC compiler switches")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenacc -fopt-info-optimized-omp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenacc -fopt-info-optimized-omp")
message(STATUS "Using GNU C++ compiler, added OpenACC compiler switches")
endif ()
message(STATUS "OpenACC enabled")
endif ()
message(STATUS "Using PGI or Nvidia C++ compiler, added OpenACC compiler switches")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "^GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenacc -fopt-info-optimized-omp")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenacc -fopt-info-optimized-omp")
message(STATUS "Using GNU C++ compiler, added OpenACC compiler switches")
endif ()
message(STATUS "OpenACC enabled")
endif ()
endif ()

Expand Down
17 changes: 5 additions & 12 deletions upwind/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
configure_file(upwindF08Acc.sl.in upwindF08Acc.sl)
configure_file(upwindF08OmpGpu.sl.in upwindF08OmpGpu.sl)
configure_file(upwindF08Gpu.sl.in upwindF08Gpu.sl)

if (HAVE_OPENMP)
add_definitions(-DHAVE_OPENMP)
Expand All @@ -12,8 +11,7 @@ endif()
add_executable(upwindFortran upwind.F90)
add_executable(upwindF03 upwindF03.F90)
add_executable(upwindF08 upwindF08.F90)
add_executable(upwindF08Acc upwindF08Acc.f90)
add_executable(upwindF08OmpGpu upwindF08OmpGpu.f90)
add_executable(upwindF08Gpu upwindF08Gpu.F90)


add_test(NAME upwindFortran1
Expand Down Expand Up @@ -56,16 +54,11 @@ add_test(NAME upwindF08
COMMAND upwindF08
"${NUM_CELLS}" "${NUM_TIME_STEPS}")

add_test(NAME upwindF08Acc
COMMAND upwindF08Acc
add_test(NAME upwindF08Gpu
COMMAND upwindF08Gpu
"${NUM_CELLS}" "${NUM_TIME_STEPS}")


add_test(NAME upwindF08OmpGpu
COMMAND upwindF08OmpGpu
"${NUM_CELLS}" "${NUM_TIME_STEPS}")

set_tests_properties(upwindF03 upwindF08 upwindF08Acc
set_tests_properties(upwindF03 upwindF08 upwindF08Gpu
PROPERTIES
PASS_REGULAR_EXPRESSION "[Cc]heck sum:[ ]*[1|0\\.999]")

Expand Down
Loading