forked from QMCPACK/qmcpack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NVHPCCompilers.cmake
56 lines (50 loc) · 2.38 KB
/
NVHPCCompilers.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Enable OpenMP
# If just -mp is specified, OMP_NUM_THREADS must be set in order to run in parallel
# Specifying 'allcores' will run on all cores if OMP_NUM_THREADS is not set (which seems
# to be the default for other OpenMP implementations)
if(QMC_OMP)
set(ENABLE_OPENMP 1)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mp=allcores")
if(ENABLE_OFFLOAD AND NOT CMAKE_SYSTEM_NAME STREQUAL "CrayLinuxEnvironment")
message(WARNING "QMCPACK OpenMP offload is not ready for NVIDIA HPC compiler.")
if(NOT DEFINED OFFLOAD_ARCH AND DEFINED CMAKE_CUDA_ARCHITECTURES)
list(LENGTH CMAKE_CUDA_ARCHITECTURES NUMBER_CUDA_ARCHITECTURES)
if(NUMBER_CUDA_ARCHITECTURES EQUAL "1")
set(OFFLOAD_ARCH cc${CMAKE_CUDA_ARCHITECTURES})
else()
string(REPLACE ";" ",cc" OFFLOAD_ARCH "${CMAKE_CUDA_ARCHITECTURES}")
set(OFFLOAD_ARCH "cc${OFFLOAD_ARCH}")
endif()
endif()
if(DEFINED OFFLOAD_ARCH)
if(NOT OFFLOAD_ARCH MATCHES "cc")
message(FATAL_ERROR "NVIDIA HPC compiler requires -gpu=ccXX option set based on the target GPU architecture! "
"Please add -DOFFLOAD_ARCH=ccXX to cmake. For example, cc70 is for Volta.")
endif()
set(OPENMP_OFFLOAD_COMPILE_OPTIONS "-gpu=${OFFLOAD_ARCH}")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mp=gpu")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mp=allcores")
endif()
endif(QMC_OMP)
add_definitions(-Drestrict=__restrict__)
# Suppress compile warnings
# 177 variable "XX" was declared but never referenced
# 550 variable "XX" was set but never used
# 612 overloaded virtual function "AA" is only partially overridden in class "BB"
# 998 function "AA" is hidden by "BB" -- virtual function override intended?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --display_error_number --diag_suppress 177 --diag_suppress 550")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} --display_error_number --diag_suppress 177 --diag_suppress 550 --diag_suppress 612 --diag_suppress 998"
)
# Set extra optimization specific flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fast")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fast")
# Setting this to 'OFF' adds the -A flag, which enforces strict standard compliance
# and causes the compilation to fail with some GNU header files
set(CMAKE_CXX_EXTENSIONS ON)
# Add static flags if necessary
if(QMC_BUILD_STATIC)
set(CMAKE_CXX_LINK_FLAGS " -Bstatic")
endif(QMC_BUILD_STATIC)