@@ -21,7 +21,7 @@ option(ENABLE_KERNEL_PROFILING "Build using kernel profiling"
21
21
option (GPU_AOT "Build AOT for Intel GPU" OFF )
22
22
option (USE_INTEL_CPU "Build AOT for Intel CPU" OFF )
23
23
option (USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF )
24
- option (USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF )
24
+ option (USE_AMD_BACKEND "Build for AMD backend" OFF )
25
25
option (SHOW_GRID "Show intermediate grid size during propagation" OFF )
26
26
option (ENABLE_GPU_TIMINGS "Show GPU timings at end of execution" OFF )
27
27
@@ -68,47 +68,61 @@ endif()
68
68
# Use either default or user defined CXX flags
69
69
# -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags
70
70
71
- set (USE_DEFAULT_FLAGS ON )
72
- set (INTEL_GPU_CXX_FLAGS " -O2 -fsycl -ffast-math " )
73
- set (NVIDIA_GPU_CXX_FLAGS " -O3 -fsycl -ffast-math " )
74
- set (AMD_GPU_CXX_FLAGS " -O3 -fsycl -ffast-math " )
71
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O2 -fsycl -ffast-math " )
72
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
73
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O3 -fsycl -ffast-math " )
75
74
76
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
77
- message (STATUS "Using DEFAULT compilation flags for the application" )
78
- string (APPEND CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for NV backend
79
- else ()
80
- message (STATUS "OVERRIDING compilation flags" )
81
- set (USE_DEFAULT_FLAGS OFF )
75
+ set (DEF_INTEL_WL_CXX_FLAGS " " )
76
+ set (DEF_NVIDIA_WL_CXX_FLAGS " " )
77
+ set (DEF_AMD_WL_CXX_FLAGS " " )
78
+
79
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
80
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
81
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
82
+ message (STATUS "Using DEFAULT compilation flags" )
83
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
84
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
85
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
86
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
87
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
88
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
89
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
90
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
91
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
92
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
93
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
94
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
95
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
82
96
endif ()
83
97
84
98
# JIT compilation
85
- if (GPU_AOT )
99
+ if (GPU_AOT )
100
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
86
101
if ( (${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ) )
87
102
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
88
103
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 0x2f\" " )
89
104
else ()
90
105
message (STATUS "Using custom AOT compilation flag ${GPU_AOT} " )
91
106
string (APPEND CMAKE_CXX_FLAGS " ${GPU_AOT} " ) # User should be aware of advanced AOT compilation flags
92
107
endif ()
93
- elseif (USE_INTEL_CPU )
94
- message (STATUS "Compiling for Intel CPU" )
95
- string (APPEND CMAKE_CXX_FLAGS " -ffast-math -mprefer-vector-width=512 -mfma -fsycl-targets=spir64_x86_64 \" -device avx512\" " )
96
108
elseif (USE_NVIDIA_BACKEND )
97
109
message (STATUS "Enabling NVIDIA backend" )
98
- if (USE_DEFAULT_FLAGS )
99
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
100
- endif ()
110
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
101
111
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda " ) # -O3 will be used, even though -O2 was set earlier
102
112
if (USE_SM )
103
113
message (STATUS "Building for SM_${USE_SM} architecture" )
104
114
string (APPEND CMAKE_CXX_FLAGS " -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
105
115
endif ()
106
- elseif (USE_AMDHIP_BACKEND )
107
- message (STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture" )
108
- if (USE_DEFAULT_FLAGS )
109
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
116
+ elseif (USE_AMD_BACKEND )
117
+ if ("${USE_AMD_ARCH} " STREQUAL "" )
118
+ message (FATAL_ERROR "Must specify AMD arch, e.g., -DUSE_AMD_ARCH=gfx90a" )
110
119
endif ()
111
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} " )
120
+ message (STATUS "Enabling AMD backend for ${USE_AMD_ARCH} AMD architecture" )
121
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
122
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMD_ARCH} " )
123
+ else ()
124
+ message (STATUS "Enabling INTEL backend" )
125
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
112
126
endif ()
113
127
114
128
# Output the compiler flags that were constructed for visual inspection
0 commit comments