@@ -70,18 +70,41 @@ link_directories(${DNNLROOT}/lib)
70
70
71
71
message (STATUS "DNNLROOT set to: ${DNNLROOT} " )
72
72
73
- set (INTEL_GPU_CXX_FLAGS " -O2 -fsycl -ffast-math" )
74
- set (NVIDIA_GPU_CXX_FLAGS " -O2 -fsycl -ffast-math" )
75
- set (AMD_GPU_CXX_FLAGS " -O2 -fsycl -ffast-math" )
76
73
77
- set (USE_DEFAULT_FLAGS ON )
78
- if ("${CMAKE_CXX_FLAGS} " STREQUAL "" )
74
+ set (DEF_INTEL_WL_CXX_FLAGS " " )
75
+ set (DEF_NVIDIA_WL_CXX_FLAGS " " )
76
+ set (DEF_AMD_WL_CXX_FLAGS " -D__HIP_PLATFORM_AMD__ " )
77
+
78
+ set (DEF_INTEL_GENERAL_CXX_FLAGS " -O2 -fsycl -ffast-math " )
79
+ set (DEF_NVIDIA_GENERAL_CXX_FLAGS " -O2 -fsycl -ffast-math " )
80
+ set (DEF_AMD_GENERAL_CXX_FLAGS " -O2 -fsycl -ffast-math " )
81
+
82
+
83
+ # -DCMAKE_CXX_FLAGS=" -blah -blah " overrides the default flags (BOTH general and WL specific)
84
+ # -DOVERRIDE_GENERAL_CXX_FLAGS=" -blah -blah " overrides the general flags only (and not the workload specific flags)
85
+ # passing in both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS is not allowed, in order to prevent ambiguity
86
+
87
+ #set(USE_DEFAULT_FLAGS OFF)
88
+ if (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" AND NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
89
+ message (FATAL_ERROR "Both CMAKE_CXX_FLAGS and OVERRIDE_GENERAL_CXX_FLAGS cannot be passed in together" )
90
+ elseif ("${CMAKE_CXX_FLAGS} " STREQUAL "" AND "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
79
91
message (STATUS "Using DEFAULT compilation flags" )
80
- else ()
81
- message (STATUS "OVERRIDING DEFAULT compilation flags" )
82
- set (USE_DEFAULT_FLAGS OFF )
92
+ set (INTEL_GPU_CXX_FLAGS "${DEF_INTEL_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
93
+ set (NVIDIA_GPU_CXX_FLAGS "${DEF_NVIDIA_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
94
+ set (AMD_GPU_CXX_FLAGS "${DEF_AMD_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
95
+ elseif (NOT "${OVERRIDE_GENERAL_CXX_FLAGS} " STREQUAL "" )
96
+ message (STATUS "OVERRIDING GENERAL compilation flags" )
97
+ set (INTEL_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_INTEL_WL_CXX_FLAGS} " )
98
+ set (NVIDIA_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_NVIDIA_WL_CXX_FLAGS} " )
99
+ set (AMD_GPU_CXX_FLAGS "${OVERRIDE_GENERAL_CXX_FLAGS} ${DEF_AMD_WL_CXX_FLAGS} " )
100
+ elseif (NOT "${CMAKE_CXX_FLAGS} " STREQUAL "" )
101
+ message (STATUS "OVERRIDING GENERAL and WORKLOAD SPECIFIC compilation flags" )
102
+ set (INTEL_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
103
+ set (NVIDIA_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
104
+ set (AMD_GPU_CXX_FLAGS "${CMAKE_CXX_FLAGS} " )
83
105
endif ()
84
106
107
+
85
108
add_compile_options (-DRUN_ON_GPU )
86
109
#add_compile_options(-DKERNEL_USE_PROFILE "0")
87
110
if (DEVICE_TIMER )
@@ -92,9 +115,7 @@ endif()
92
115
# JIT compilation
93
116
if (GPU_AOT )
94
117
message (STATUS "Enabling INTEL backend" )
95
- if (USE_DEFAULT_FLAGS )
96
- set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " ) # Default flags for Intel backend
97
- endif ()
118
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
98
119
if ( (${GPU_AOT} STREQUAL "pvc" ) OR (${GPU_AOT} STREQUAL "PVC" ) )
99
120
message (STATUS "Enabling Intel GPU AOT compilation for ${GPU_AOT} " )
100
121
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=spir64_gen -Xs \" -device 0x0bd5 -revision_id 0x2f\" " )
@@ -104,20 +125,20 @@ if(GPU_AOT)
104
125
endif ()
105
126
elseif (USE_NVIDIA_BACKEND )
106
127
message (STATUS "Enabling NVIDIA backend" )
107
- if (USE_DEFAULT_FLAGS )
108
- set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " ) # Default flags for NV backend
109
- endif ()
128
+ set (CMAKE_CXX_FLAGS "${NVIDIA_GPU_CXX_FLAGS} " )
110
129
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=nvptx64-nvidia-cuda " )
111
130
if (USE_SM )
112
131
message (STATUS "Building for SM_${USE_SM} architecture" )
113
132
string (APPEND CMAKE_CXX_FLAGS " -Xsycl-target-backend --cuda-gpu-arch=sm_${USE_SM} " )
114
133
endif ()
115
134
elseif (USE_AMDHIP_BACKEND )
116
135
message (STATUS "Enabling AMD HIP backend for ${USE_AMDHIP_BACKEND} AMD architecture" )
117
- if (USE_DEFAULT_FLAGS )
118
- set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " ) # Default flags for AMD backend (gfx908 for MI100)
119
- endif ()
136
+ set (CMAKE_CXX_FLAGS "${AMD_GPU_CXX_FLAGS} " )
120
137
string (APPEND CMAKE_CXX_FLAGS " -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${USE_AMDHIP_BACKEND} " )
138
+ else ()
139
+ # JIT case
140
+ message (STATUS "Enabling INTEL backend" )
141
+ set (CMAKE_CXX_FLAGS "${INTEL_GPU_CXX_FLAGS} " )
121
142
endif ()
122
143
123
144
message (STATUS "Compilation flags set to: ${CMAKE_CXX_FLAGS} " )
0 commit comments