@@ -40,31 +40,48 @@ option(ENABLE_KERNEL_PROFILING "Build using kernel profiling" OFF)
40
40
option (GPU_AOT "Build AOT for Intel GPU" OFF )
41
41
option (USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF )
42
42
option (USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF )
43
+ option (USE_SM "Build for specific SM" OFF )
43
44
44
45
if (ENABLE_KERNEL_PROFILING )
45
46
message ("-- Enabling kernel profiling" )
46
47
add_compile_options (-DENABLE_KERNEL_PROFILING )
47
48
endif ()
48
49
49
- set (INTEL_GPU_CXX_FLAGS " -O2 -std=c++17 -fsycl -ffast-math -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-local-typedef " )
50
- set (NVIDIA_GPU_CXX_FLAGS " -O3 -std=c++17 -fsycl -ffast-math -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-local-typedef " )
51
- set (AMD_GPU_CXX_FLAGS " -O3 -std=c++17 -fsycl -ffast-math -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-local-typedef " )
50
+ set (DEF_INTEL_WL_CXX_FLAGS " " )
51
+ set (DEF_NVIDIA_WL_CXX_FLAGS " " )
52
+ set (DEF_AMD_WL_CXX_FLAGS " " )
52
53
53
- set (USE_DEFAULT_FLAGS ON )
54
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
54
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O2 -std=c++17 -fsycl -ffast-math -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-local-typedef " )
55
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -std=c++17 -fsycl -ffast-math -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-local-typedef " )
56
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O3 -std=c++17 -fsycl -ffast-math -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unknown-pragmas -Wno-unused-local-typedef " )
57
+
58
+ # -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
59
+ # -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
60
+ # passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
61
+
62
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
63
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
64
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
55
65
message (STATUS "Using DEFAULT compilation flags" )
56
- else ()
57
- message (STATUS "OVERRIDING DEFAULT compilation flags" )
58
- set (USE_DEFAULT_FLAGS OFF )
66
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
67
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
68
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
69
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
70
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
71
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
72
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
73
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
74
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
75
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
76
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
77
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
78
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
59
79
endif ()
60
80
61
- # JIT compilation
62
81
if (GPU_AOT )
63
82
message (STATUS "Enabling INTEL backend" )
64
- if (USE_DEFAULT_FLAGS )
65
- set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
66
- endif ()
67
- if ( (${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ) )
83
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
84
+ if ((${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ))
68
85
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
69
86
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 0x2f\" " )
70
87
else ()
@@ -73,18 +90,28 @@ if(GPU_AOT)
73
90
endif ()
74
91
elseif (USE_NVIDIA_BACKEND )
75
92
message (STATUS "Enabling NVIDIA backend" )
76
- if (USE_DEFAULT_FLAGS )
77
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
93
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
94
+ if (USE_SM )
95
+ message ("-- Building for SM_${USE_SM} compatibility" )
96
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
97
+ else ()
98
+ message ("-- Building for SM_80 compatibility (DEFAULT)" )
99
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_80 " )
78
100
endif ()
79
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda " ) # -O3 will be used, even though -O2 was set earlier
101
+ string (APPEND CMAKE_CXX_FLAGS " -DUSE_NVIDIA_BACKEND" )
80
102
elseif (USE_AMDHIP_BACKEND )
81
103
message (STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture" )
82
- if (USE_DEFAULT_FLAGS )
83
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " ) # Default flags for AMD backend (gfx908 for MI100)
84
- endif ()
104
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
85
105
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} " )
106
+ string (APPEND CMAKE_CXX_FLAGS " -DUSE_AMDHIP_BACKEND" )
107
+ else ()
108
+ # JIT case
109
+ message (STATUS "Enabling INTEL backend" )
110
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
86
111
endif ()
87
112
113
+ message (STATUS "CXX Compilation flags set to: ${CMAKE_CXX_FLAGS} " )
114
+
88
115
if (GPU_AOT )
89
116
set (MKL_LINK static )
90
117
set (MKL_THREADING sequential )
0 commit comments