@@ -30,51 +30,71 @@ option(USE_NVIDIA_BACKEND "Build for NVIDIA backend" OFF)
30
30
option (USE_AMDHIP_BACKEND "Build for AMD HIP backend" OFF )
31
31
option (USE_SM "Build for specific SM" OFF )
32
32
33
- set (INTEL_GPU_CXX_FLAGS " -O2 -fsycl -Wall -Wextra -Wno-unused-parameter " )
34
- set (NVIDIA_GPU_CXX_FLAGS " -O3 -fsycl -Wall -Wextra -Wno-unused-parameter " )
35
- set (AMD_GPU_CXX_FLAGS " -O3 -fsycl -Wall -Wextra -Wno-unused-parameter " )
33
+ set (DEF_INTEL_WL_CXX_FLAGS " " )
34
+ set (DEF_NVIDIA_WL_CXX_FLAGS " " )
35
+ set (DEF_AMD_WL_CXX_FLAGS " " )
36
36
37
- set (USE_DEFAULT_FLAGS ON )
38
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
37
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O2 -fsycl -Wall -Wextra -Wno-unused-parameter " )
38
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O3 -fsycl -Wall -Wextra -Wno-unused-parameter " )
39
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O3 -fsycl -Wall -Wextra -Wno-unused-parameter " )
40
+
41
+ # -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
42
+ # -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
43
+ # passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
44
+
45
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
46
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
47
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
39
48
message (STATUS "Using DEFAULT compilation flags" )
40
- else ()
41
- message (STATUS "Overriding DEFAULT compilation flags" )
42
- set (USE_DEFAULT_FLAGS OFF )
49
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
50
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
51
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
52
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
53
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
54
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
55
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
56
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
57
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
58
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
59
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
60
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
61
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
43
62
endif ()
44
63
45
- # AOT compilation
46
64
if (GPU_AOT )
47
65
message (STATUS "Enabling INTEL backend" )
48
- if (USE_DEFAULT_FLAGS )
49
- set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
50
- endif ()
51
- if ( (${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ) )
66
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
67
+ if ((${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ))
52
68
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
53
69
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 0x2f -options -ze-opt-large-register-file\" " )
54
70
else ()
55
71
message (STATUS "Using custom AOT compilation flag ${GPU_AOT} " )
56
- string (APPEND CMAKE_CXX_FLAGS " ${GPU_AOT} " )
72
+ string (APPEND CMAKE_CXX_FLAGS " ${GPU_AOT} " ) # User should be aware of advanced AOT compilation flags
57
73
endif ()
58
74
elseif (USE_NVIDIA_BACKEND )
59
75
message (STATUS "Enabling NVIDIA backend" )
60
- if (USE_DEFAULT_FLAGS )
61
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
62
- endif ()
76
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
63
77
if (USE_SM )
64
78
message ("-- Building for SM_${USE_SM} compatibility" )
65
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
79
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
66
80
else ()
67
81
message ("-- Building for SM_80 compatibility (DEFAULT)" )
68
- string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_80" )
82
+ string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --cuda-gpu-arch=sm_80 " )
69
83
endif ()
84
+ string (APPEND CMAKE_CXX_FLAGS " -DUSE_NVIDIA_BACKEND" )
70
85
elseif (USE_AMDHIP_BACKEND )
71
86
message (STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture" )
72
- if (USE_DEFAULT_FLAGS )
73
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " ) # Default flags for AMD backend (gfx908 for MI100)
74
- endif ()
87
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
75
88
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} " )
89
+ string (APPEND CMAKE_CXX_FLAGS " -DUSE_AMDHIP_BACKEND" )
90
+ else ()
91
+ # JIT case
92
+ message (STATUS "Enabling INTEL backend" )
93
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
76
94
endif ()
77
95
96
+ message (STATUS "CXX Compilation flags set to: ${CMAKE_CXX_FLAGS} " )
97
+
78
98
set (SOURCES
79
99
${CMAKE_SOURCE_DIR} /src/main.cpp
80
100
${CMAKE_SOURCE_DIR} /src/utils.cpp
0 commit comments