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