@@ -29,29 +29,59 @@ option(USE_DPC "Use DPC++ technology" OFF)
29
29
option (USE_CUDA "Use CUDA" OFF )
30
30
option (USE_HIP "Use AMD" OFF )
31
31
32
- option (USE_INTEL_CPU "Build AOT for Intel CPU" OFF )
33
32
option (GPU_AOT "Build AOT for Intel GPU" OFF )
34
33
option (USE_NVIDIA_BACKEND "Use DPC++ technology with NVIDIA backend" OFF )
35
- option (USE_AMDHIP_BACKEND "Use DPC++ technology with AMD HIP backend" OFF )
34
+ option (USE_AMD_BACKEND "Use DPC++ technology with AMD HIP backend" OFF )
36
35
option (ENABLE_GPU_TIMINGS "Show GPU timings at end of execution" OFF )
37
36
38
- set (USE_DEFAULT_FLAGS ON )
39
- set (INTEL_GPU_CXX_FLAGS "-O3 -fsycl " )
40
- set (NVIDIA_GPU_CXX_FLAGS "-O3 -fsycl " ) # For DPC++ NVIDIA_BACKEND
41
- set (AMD_GPU_CXX_FLAGS "-O3 -fsycl " )
42
- set (NVCC_GPU_CXX_FLAGS "-O3 " ) # For NVCC
43
- set (ROCM_CXX_FLAGS "-O3 " ) # For AMDHIP
37
+ ### SYCL RELATED FLAGS START HERE
38
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O2 -fsycl -ffast-math " )
39
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
40
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
41
+
42
+ set (DEF_INTEL_WL_CXX_FLAGS " " )
43
+ set (DEF_NVIDIA_WL_CXX_FLAGS " " )
44
+ set (DEF_AMD_WL_CXX_FLAGS " " )
45
+
46
+ set (DEF_INTEL_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
47
+ set (DEF_NVIDIA_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEFT_NVIDIA_WL_CXX_FLAGS} " )
48
+ set (DEF_AMD_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
49
+
50
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
51
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
52
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
53
+ message (STATUS "Using DEFAULT compilation flags" )
54
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
55
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
56
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
57
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
58
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
59
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
60
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
61
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
62
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
63
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
64
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
65
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
66
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
67
+ endif ()
68
+ #END OF SYCL RELATED FLAGS
44
69
45
70
46
- message (STATUS "Use DPC++ ${USE_DPC} and Use CUDA ${USE_CUDA} and Use HIP ${USE_HIP} " )
71
+ ### NVCC RELATED FLAGS START HERE
72
+ set (NVCC_WL_CXX_FLAGS "" )
73
+ set (NVCC_DEF_CXX_FLAGS "-O3 " ) # For NVCC
74
+ set (NVCC_DEF_COMBINED_FLAGS "${NVCC_WL_CXX_FLAGS} ${NVCC_DEF_CXX_FLAGS} " )
75
+ ### END OF NVCC RELATED FLAGS
47
76
48
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
49
- message (STATUS "Using DEFAULT compilation flags for the application" )
50
- string (APPEND CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for NV backend
51
- else ()
52
- message (STATUS "OVERRIDING compilation flags" )
53
- set (USE_DEFAULT_FLAGS OFF )
54
- endif ()
77
+
78
+ ### ROCM RELATED FLAGS START HERE
79
+ set (ROCM_WL_CXX_FLAGS "" )
80
+ set (ROCM_DEF_CXX_FLAGS "-O3 -D__HIP_PLATFORM_AMD__ " )
81
+ set (ROCM_DEF_COMBINED_FLAGS "${ROCM_WL_CXX_FLAGS} ${ROCM_DEF_CXX_FLAGS} " )
82
+ ### END OF ROCM RELATED FLAGS
83
+
84
+ message (STATUS "Use DPC++ ${USE_DPC} and Use CUDA ${USE_CUDA} and Use HIP ${USE_HIP} " )
55
85
56
86
if (ENABLE_GPU_TIMINGS )
57
87
message (STATUS "GPU Timings will be displayed" )
@@ -63,40 +93,64 @@ if (NOT USE_DPC AND NOT USE_CUDA AND NOT USE_HIP)
63
93
elseif (USE_DPC AND USE_CUDA AND USE_HIP OR USE_DPC AND USE_CUDA OR USE_CUDA AND USE_HIP )
64
94
message (FATAL_ERROR "Please specify only one technology using the config.sh script" )
65
95
elseif (USE_DPC )
96
+ message (STATUS "Compiling for DPC++" )
66
97
if (GPU_AOT )
98
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
67
99
if ( (${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ) )
68
100
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
69
101
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 0x2f\" " )
70
102
else ()
71
103
message (STATUS "Using custom AOT compilation flag ${GPU_AOT} " )
72
104
string (APPEND CMAKE_CXX_FLAGS " ${GPU_AOT} " ) # User should be aware of advanced AOT compilation flags
73
105
endif ()
74
- elseif (USE_INTEL_CPU )
75
- message (STATUS "Compiling for Intel CPU" )
76
- string (APPEND CMAKE_CXX_FLAGS " -ffast-math -mprefer-vector-width=512 -mfma -fsycl-targets=spir64_x86_64--linux \" -device avx512\" " )
77
106
elseif (USE_NVIDIA_BACKEND )
78
107
message (STATUS "Enabling NVIDIA backend" )
79
- if (USE_DEFAULT_FLAGS )
80
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
81
- endif ()
82
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda " ) # -O3 will be used, even though -O2 was set earlier
108
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
109
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda " )
83
110
if (USE_SM )
84
111
message (STATUS "Building for SM_${USE_SM} architecture" )
85
112
string (APPEND CMAKE_CXX_FLAGS " -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
86
113
endif ()
87
- elseif (USE_AMDHIP_BACKEND )
88
- message (STATUS "Enabling AMD HIP backend for ${USE_HIP_BACKEND} AMD architecture" )
89
- if (USE_DEFAULT_FLAGS )
90
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
114
+ elseif (USE_AMD_BACKEND )
115
+ if ("${USE_AMD_ARCH} " STREQUAL "" )
116
+ message (FATAL_ERROR "Must specify AMD arch, e.g., -DUSE_AMD_ARCH=gfx90a" )
91
117
endif ()
92
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} " )
93
- add_compile_options (-DUSE_AMDHIP_BACKEND )
118
+ message (STATUS "Enabling AMD backend for ${USE_AMD_ARCH} AMD architecture" )
119
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
120
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMD_ARCH} " )
121
+ add_compile_options (-DUSE_AMD_BACKEND )
122
+ else ()
123
+ message (STATUS "Enabling INTEL backend" )
124
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
94
125
endif ()
95
126
elseif (USE_CUDA )
96
- set (CMAKE_CXX_FLAGS "${NVCC_GPU_CXX_FLAGS} " )
127
+ message (STATUS "Compiling for NVCC" )
128
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
129
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
130
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
131
+ message (STATUS "Using DEFAULT compilation flags" )
132
+ set (CMAKE_CXX_FLAGS "${NVCC_DEF_COMBINED_FLAGS} " )
133
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
134
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
135
+ set (CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} " )
136
+ string (APPEND CMAKE_CXX_FLAGS ${NVCC_WL_CXX_FLAGS} )
137
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
138
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
139
+ endif ()
97
140
add_compile_options (-DENABLE_CUDA_LOGGING )
98
141
elseif (USE_HIP )
99
- set (CMAKE_CXX_FLAGS "${ROCM_CXX_FLAGS} " )
142
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
143
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
144
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
145
+ message (STATUS "Using DEFAULT compilation flags" )
146
+ set (CMAKE_CXX_FLAGS "${ROCM_DEF_COMBINED_FLAGS} " )
147
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
148
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
149
+ set (CMAKE_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} " )
150
+ string (APPEND CMAKE_CXX_FLAGS ${ROCM_WL_CXX_FLAGS} )
151
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
152
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
153
+ endif ()
100
154
add_compile_options (-DENABLE_HIP_LOGGING )
101
155
endif ()
102
156
@@ -224,8 +278,6 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/SeismicOperations)
224
278
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /libs/Thoth )
225
279
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /src )
226
280
227
- message (STATUS "Compilation flags set to: ${CMAKE_CXX_FLAGS} " )
228
- #message(STATUS "Flags : ${CMAKE_CXX_FLAGS}")
229
281
##############################################################################
230
282
# EXECUTABLES
231
283
##############################################################################
@@ -264,3 +316,6 @@ if (BUILD_TESTS)
264
316
COMMAND seismic-toolbox-tests
265
317
)
266
318
endif ()
319
+
320
+
321
+ message (STATUS "Compilation flags set to: ${CMAKE_CXX_FLAGS} " )
0 commit comments