Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions cmake/configuring_primitive_list.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ else()
endif()
message(STATUS "Enabled primitive CPU ISA: ${DNNL_ENABLE_PRIMITIVE_CPU_ISA}")

if (DNNL_ENABLE_PRIMITIVE_GPU_ISA STREQUAL "ALL")
set(BUILD_PRIMITIVE_GPU_ISA_ALL TRUE)
else()
foreach(isa ${DNNL_ENABLE_PRIMITIVE_GPU_ISA})
string(TOUPPER ${isa} uisa)
if(NOT "${uisa}" MATCHES "^(XELP|XEHP|XEHPG|XEHPC|XE2|XE3|XE3P)$")
message(FATAL_ERROR "Unsupported primitive GPU ISA: ${uisa}")
endif()
# "ALL" excludes ISAs with preview support, opt in via "ALL;<ISA>".
foreach(isa ${DNNL_ENABLE_PRIMITIVE_GPU_ISA})
string(TOUPPER ${isa} uisa)
if("${uisa}" STREQUAL "ALL")
set(BUILD_PRIMITIVE_GPU_ISA_ALL TRUE)
elseif("${uisa}" MATCHES "^(XELP|XEHP|XEHPG|XEHPC|XE2|XE3|XE3P)$")
set(BUILD_${uisa} TRUE)
endforeach()
endif()
else()
message(FATAL_ERROR "Unsupported primitive GPU ISA: ${uisa}")
endif()
endforeach()
message(STATUS "Enabled primitive GPU ISA: ${DNNL_ENABLE_PRIMITIVE_GPU_ISA}")

if (ONEDNN_ENABLE_GEMM_KERNELS_ISA STREQUAL "ALL")
Expand All @@ -86,6 +86,7 @@ message(STATUS "Enabled GeMM kernels ISA: ${ONEDNN_ENABLE_GEMM_KERNELS_ISA}")
# such cases.
if (NOT DNNL_ENABLE_PRIMITIVE STREQUAL "ALL" OR
NOT DNNL_ENABLE_PRIMITIVE_CPU_ISA STREQUAL "ALL" OR
NOT DNNL_ENABLE_PRIMITIVE_GPU_ISA STREQUAL "ALL")
NOT BUILD_PRIMITIVE_GPU_ISA_ALL OR
NOT BUILD_XE3P)
append(CMAKE_CCXX_FLAGS "-Wno-error=unused-function -Wno-unused-function")
endif()
6 changes: 4 additions & 2 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ set(DNNL_ENABLE_PRIMITIVE_GPU_ISA "ALL" CACHE STRING
"Specifies a set of implementations using specific GPU ISA to be available
at build time. Regardless of value chosen, reference OpenCL-based
implementations will always be available. Valid values:
- ALL (the default). Includes all ISA to be enabled.
- <ISA_NAME>;<ISA_NAME>;... Includes only selected ISA to be enabled.
- ALL (the default). Enables all ISA with full library support;
ISAs with preview support are excluded.
- <ISA_NAME>;<ISA_NAME>;... Enables the listed ISA. ALL may be combined
with explicit ISAs (e.g. ALL;<ISA>) to opt into preview ISAs.
Possible values are: XELP, XEHP, XEHPG, XEHPC, XE2, XE3, XE3P.")

set(ONEDNN_ENABLE_GEMM_KERNELS_ISA "ALL" CACHE STRING
Expand Down
8 changes: 5 additions & 3 deletions doc/build/build_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ Example that enables SSE41 and AVX2 sets:

#### ONEDNN_ENABLE_PRIMITIVE_GPU_ISA
This option supports several values: `ALL` (the default) which enables all
ISA implementations or any set of `XELP`, `XEHP`, `XEHPG`, `XEHPC`, `XE2`,
and `XE3`. Selected ISA will enable correspondent parts in just-in-time
kernel generation based implementations. OpenCL based kernels and
ISA implementations with full library support, or any set of `XELP`, `XEHP`,
`XEHPG`, `XEHPC`, `XE2`, `XE3`, and `XE3P`. ISAs with preview support are
excluded from `ALL` and may be opted in by combining `ALL` with explicit ISAs
(e.g. `ALL;<ISA>`). Selected ISA will enable correspondent parts in
just-in-time kernel generation based implementations. OpenCL based kernels and
implementations will always be available. Example that enables XeLP and XeHP
set:
```
Expand Down
3 changes: 2 additions & 1 deletion src/common/impl_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@
#define REG_XE3_ISA(...)
#endif

#if BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XE3P
// XE3P is excluded from BUILD_PRIMITIVE_GPU_ISA_ALL, opt in explicitly.
#if BUILD_XE3P
Copy link
Copy Markdown
Contributor

@rjoursler rjoursler May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need any gating on OpenCL implementations? For the most part, I would expect those to just work, but there are some workarounds for driver issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any control on driver version at the user end, so I'd say no.

#define REG_XE3P_ISA(...) __VA_ARGS__
#else
#define REG_XE3P_ISA(...)
Expand Down
20 changes: 11 additions & 9 deletions src/gpu/intel/gemm/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ endif()

# Use oneDNN names for ALL to ensure string replacement functions correctly
set(GPUS ${DNNL_ENABLE_PRIMITIVE_GPU_ISA})
string(REPLACE "ALL" "XELP;XEHP;XEHPG;XEHPC;XE2;XE3;XE3P" GPUS "${GPUS}")
string(REPLACE "ALL" "XELP;XEHP;XEHPG;XEHPC;XE2;XE3" GPUS "${GPUS}")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be reasonable to use a runtime guard (via environment variable) rather than compile time? This way we can still use the same build for testing purpose.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my perspective runtime opt-in is the best choice. It would be challenging to design and implement it in time for v3.12 RTM.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What we can do before the RTM is opt-in via ONEDNN_ENABLE_MAX_GPU_ISA environment variable (similar to CPU). But to limit the scope:

  1. No API, just the environment variable
  2. Opt-in is only via the environment variable - no changes in DNNL_ENABLE_PRIMITIVE_GPU_ISA behavior

@vpirogov @rjoursler Do you see issues with any of the bullets? Are frameworks fine with environment variable control for opt-in (if they still want to enable Xe3p platforms)?

Copy link
Copy Markdown
Contributor

@vpirogov vpirogov May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather focus on developing proper guard consistent with the way we handle environment variables for v3.13. Build time opt-in looks adequate for v3.12.

string(REPLACE "XELP" "12LP" GPUS "${GPUS}")
string(REPLACE "XEHPG" "12p7" GPUS "${GPUS}")
string(REPLACE "XEHPC" "12p8" GPUS "${GPUS}")
Expand Down Expand Up @@ -63,14 +63,16 @@ if(DPCPP_HOST_COMPILER_KIND STREQUAL "DEFAULT")
${ONEDNN_GEMMSTONE_DIR}/generator/generator.cpp
)

if (DNNL_ENABLE_PRIMITIVE_GPU_ISA STREQUAL "ALL")
set(DNNL_GPU_ISA_LIST "XELP;XEHP;XEHPG;XEHPC;XE2;XE3;XE3P")
else()
foreach(isa ${DNNL_ENABLE_PRIMITIVE_GPU_ISA})
string(TOUPPER ${isa} ISA)
set(DNNL_GPU_ISA_LIST "${DNNL_GPU_ISA_LIST};${ISA}")
endforeach()
endif()
set(DNNL_GPU_ISA_LIST "")
foreach(isa ${DNNL_ENABLE_PRIMITIVE_GPU_ISA})
string(TOUPPER ${isa} ISA)
if("${ISA}" STREQUAL "ALL")
list(APPEND DNNL_GPU_ISA_LIST XELP XEHP XEHPG XEHPC XE2 XE3)
else()
list(APPEND DNNL_GPU_ISA_LIST ${ISA})
endif()
endforeach()
list(REMOVE_DUPLICATES DNNL_GPU_ISA_LIST)

foreach(isa ${DNNL_GPU_ISA_LIST})
if(${isa} STREQUAL "XE3P")
Expand Down
61 changes: 50 additions & 11 deletions src/gpu/intel/ocl/hw_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*******************************************************************************/

#include "oneapi/dnnl/dnnl_config.h"

#include "gpu/intel/ocl/hw_info.hpp"
#include "gpu/intel/ocl/utils.hpp"

Expand Down Expand Up @@ -56,6 +58,53 @@ xpu::runtime_version_t get_driver_version(cl_device_id device) {
return runtime_version;
}

status_t init_mayiuse_ngen_kernels(
impl::engine_t *engine, ngen::HW hw, bool &mayiuse_ngen_kernels) {
mayiuse_ngen_kernels = false;

// Bail out if the detected architecture is disabled at build time.
bool arch_enabled = false;
switch (hw) {
case ngen::HW::XeLP:
arch_enabled = BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XELP;
break;
case ngen::HW::XeHP:
arch_enabled = BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XEHP;
break;
case ngen::HW::XeHPG:
arch_enabled = BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XEHPG;
break;
case ngen::HW::XeHPC:
arch_enabled = BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XEHPC;
break;
case ngen::HW::Xe2:
arch_enabled = BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XE2;
break;
case ngen::HW::Xe3:
arch_enabled = BUILD_PRIMITIVE_GPU_ISA_ALL || BUILD_XE3;
break;
case ngen::HW::XE3P_35_10:
case ngen::HW::XE3P_35_11:
case ngen::HW::XE3P_UNKNOWN: arch_enabled = BUILD_XE3P; break;
default: break;
}
if (!arch_enabled) return status::success;

if (hw <= ngen::HW::Xe3) {
auto status = jit::gpu_supports_binary_format(
&mayiuse_ngen_kernels, engine);
if (status != status::success) {
VWARN(common, runtime,
"ngen fallback (gpu does not support binary format "
"kernels)");
mayiuse_ngen_kernels = false;
}
} else {
mayiuse_ngen_kernels = true;
}
return status::success;
}

status_t init_gpu_hw_info(impl::engine_t *engine, cl_device_id device,
cl_context ctx, uint32_t &ip_version, compute::gpu_arch_t &gpu_arch,
compute::gpu_product_t &product_, uint64_t &native_extensions,
Expand All @@ -76,17 +125,7 @@ status_t init_gpu_hw_info(impl::engine_t *engine, cl_device_id device,
CHECK(get_ocl_device_enabled_native_float_atomics(
device, native_extensions, is_xelpg));

if (hw <= ngen::HW::Xe3) {
auto status = jit::gpu_supports_binary_format(
&mayiuse_ngen_kernels, engine);
if (status != status::success) {
VWARN(common, runtime,
"ngen fallback (gpu does not support binary format "
"kernels)");
mayiuse_ngen_kernels = false;
}
} else if (hw != ngen::HW::Unknown)
mayiuse_ngen_kernels = true;
CHECK(init_mayiuse_ngen_kernels(engine, hw, mayiuse_ngen_kernels));

is_efficient_64bit = OpenCLCodeGenerator<HW::Unknown>::detectEfficient64Bit(
ctx, device, hw);
Expand Down
Loading