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