-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathSetupCompilerFlags.cmake
More file actions
98 lines (81 loc) · 2.61 KB
/
SetupCompilerFlags.cmake
File metadata and controls
98 lines (81 loc) · 2.61 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
##############################################################################
# Copyright (c) 2016-26, Lawrence Livermore National Security, LLC and Umpire
# project contributors. See the COPYRIGHT file for details.
#
# SPDX-License-Identifier: (MIT)
##############################################################################
if((NOT DEFINED CMAKE_C_STANDARD) OR (CMAKE_C_STANDARD VERSION_EQUAL 90))
message(STATUS "Setting C standard to 99")
set(CMAKE_C_STANDARD 99)
endif()
message(STATUS "Checking for std::filesystem")
blt_check_code_compiles(CODE_COMPILES UMPIRE_ENABLE_FILESYSTEM
SOURCE_STRING
[=[
#include <iostream>
#include <filesystem>
int main(int, char**)
{
auto path = std::filesystem::path(\".\");
(void)(path);
return 0;
}
]=])
if (UMPIRE_ENABLE_FILESYSTEM)
message(STATUS "std::filesystem found")
else ()
message(STATUS "std::filesystem NOT found, using POSIX")
endif ()
if (ENABLE_HIP)
set(HIP_HIPCC_FLAGS "${HIP_HIPCC_FLAGS} -Wno-inconsistent-missing-override")
blt_check_code_compiles(CODE_COMPILES UMPIRE_ENABLE_HIP_COHERENCE_GRANULARITY
VERBOSE_OUTPUT OFF
DEPENDS_ON hip::host
SOURCE_STRING
[=[
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
int main(int, char**)
{
const std::size_t bytes{1024};
void* ptr1{nullptr};
::hipHostMalloc(&ptr1, bytes, hipHostMallocDefault);
if (ptr1 != nullptr) {
void* ptr2{nullptr};
::hipHostMalloc(&ptr2, bytes, hipHostMallocNonCoherent);
if (ptr2 != nullptr) {
int device;
::hipGetDevice(&device);
::hipMemAdvise(ptr1, bytes, hipMemAdviseSetCoarseGrain, device);
}
}
return 0;
}
]=])
if (UMPIRE_ENABLE_HIP_COHERENCE_GRANULARITY)
message(STATUS "HIP memory coherence granularity: Enabled")
else ()
message(STATUS "HIP memory coherence granularity: Disabled, not supported")
endif ()
endif()
if (ENABLE_PEDANTIC_WARNINGS)
blt_append_custom_compiler_flag(
FLAGS_VAR UMPIRE_PEDANTIC_FLAG
DEFAULT ""
GNU "-Wpedantic"
CLANG "-Wpedantic"
INTEL "-Wall -Wcheck -wd2259"
XL "-Wpedantic"
MSVC "/Wall /WX"
)
set(CMAKE_CXX_FLAGS "${UMPIRE_PEDANTIC_FLAG} ${CMAKE_CXX_FLAGS}")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
endif()
blt_append_custom_compiler_flag(
FLAGS_VAR UMPIRE_DISABLE_DEPRECATED_WARNINGS_FLAG
DEFAULT "-Wno-deprecated-declarations"
PGI "-Minform=severe"
INTEL "-diag-disable=1786"
MSVC "/wd4996")