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