Skip to content

Rename USE_ONEMKL as USE_ONEMKL_XPU and set it as default ON #1642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
Merged
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
1 change: 0 additions & 1 deletion .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ git submodule sync && git submodule update --init --recursive
python -m pip install -r requirements.txt
python -m pip install mkl-static mkl-include
export USE_STATIC_MKL=1
export USE_ONEMKL=1
export USE_XCCL=1
export PYTORCH_EXTRA_INSTALL_REQUIREMENTS=" \
intel-cmplr-lib-rt==2025.1.1 | \
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/_windows_ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ jobs:
pip install cmake setuptools==72.1.0 clang-format
pip install mkl-static mkl-include
set USE_STATIC_MKL=1
set USE_ONEMKL=1
copy "%CONDA_PREFIX%\Library\bin\libiomp*5md.dll" .\torch\lib
copy "%CONDA_PREFIX%\Library\bin\uv.dll" .\torch\lib
if defined CMAKE_PREFIX_PATH (
Expand Down
10 changes: 5 additions & 5 deletions cmake/ONEMKL.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
option(USE_ONEMKL "Build with ONEMKL XPU support" OFF)
option(USE_ONEMKL_XPU "Build with ONEMKL XPU support" ON)

if(DEFINED ENV{USE_ONEMKL})
set(USE_ONEMKL $ENV{USE_ONEMKL})
if(DEFINED ENV{USE_ONEMKL_XPU})
set(USE_ONEMKL_XPU $ENV{USE_ONEMKL_XPU})
endif()

message(STATUS "USE_ONEMKL is set to ${USE_ONEMKL}")
message(STATUS "USE_ONEMKL_XPU is set to ${USE_ONEMKL_XPU}")

if(NOT USE_ONEMKL)
if(NOT USE_ONEMKL_XPU)
return()
endif()

Expand Down
28 changes: 14 additions & 14 deletions src/ATen/native/xpu/SpectralOps.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
#include <ATen/native/xpu/mkl/SpectralOps.h>
#else
#include <ATen/native/Resize.h>
#include <ATen/ops/_fft_c2c_native.h>
#include <ATen/ops/_fft_c2r_native.h>
#include <ATen/ops/_fft_r2c_native.h>
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU

namespace at::native {

Expand All @@ -16,13 +16,13 @@ Tensor _fft_c2c_xpu(
bool forward) {
TORCH_CHECK(self.is_complex());

#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
return native::xpu::_fft_c2c_mkl(self, dim, normalization, forward);
#else
Tensor out_cpu = native::_fft_c2c_mkl(
self.to(Device(at::kCPU)), dim, normalization, forward);
return out_cpu.to(Device(at::kXPU));
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
}

Tensor& _fft_c2c_xpu_out(
Expand All @@ -33,15 +33,15 @@ Tensor& _fft_c2c_xpu_out(
Tensor& out) {
TORCH_CHECK(self.is_complex());

#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
return native::xpu::_fft_c2c_mkl_out(self, dim, normalization, forward, out);
#else
Tensor out_cpu = native::_fft_c2c_mkl(
self.to(Device(at::kCPU)), dim, normalization, forward);
at::native::resize_output(out, out_cpu.sizes());
out.copy_(out_cpu);
return out;
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
}

Tensor _fft_c2r_xpu(
Expand All @@ -51,13 +51,13 @@ Tensor _fft_c2r_xpu(
int64_t last_dim_size) {
TORCH_CHECK(self.is_complex());

#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
return native::xpu::_fft_c2r_mkl(self, dim, normalization, last_dim_size);
#else
Tensor out_cpu = native::_fft_c2r_mkl(
self.to(Device(at::kCPU)), dim, normalization, last_dim_size);
return out_cpu.to(Device(at::kXPU));
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
}

Tensor& _fft_c2r_xpu_out(
Expand All @@ -68,7 +68,7 @@ Tensor& _fft_c2r_xpu_out(
Tensor& out) {
TORCH_CHECK(self.is_complex());

#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
return native::xpu::_fft_c2r_mkl_out(
self, dim, normalization, last_dim_size, out);
#else
Expand All @@ -77,7 +77,7 @@ Tensor& _fft_c2r_xpu_out(
at::native::resize_output(out, out_cpu.sizes());
out.copy_(out_cpu);
return out;
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
}

Tensor _fft_r2c_xpu(
Expand All @@ -87,13 +87,13 @@ Tensor _fft_r2c_xpu(
bool onesided) {
TORCH_CHECK(self.is_floating_point());

#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
return native::xpu::_fft_r2c_mkl(self, dim, normalization, onesided);
#else
Tensor out_cpu = native::_fft_r2c_mkl(
self.to(Device(at::kCPU)), dim, normalization, onesided);
return out_cpu.to(Device(at::kXPU));
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
}

Tensor& _fft_r2c_xpu_out(
Expand All @@ -104,15 +104,15 @@ Tensor& _fft_r2c_xpu_out(
Tensor& out) {
TORCH_CHECK(self.is_floating_point());

#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
return native::xpu::_fft_r2c_mkl_out(self, dim, normalization, onesided, out);
#else
Tensor out_cpu = native::_fft_r2c_mkl(
self.to(Device(at::kCPU)), dim, normalization, onesided);
at::native::resize_output(out, out_cpu.sizes());
out.copy_(out_cpu);
return out;
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
}

} // namespace at::native
4 changes: 2 additions & 2 deletions src/ATen/native/xpu/mkl/SpectralOps.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if defined(USE_ONEMKL)
#if defined(USE_ONEMKL_XPU)
#include <ATen/native/Resize.h>
#include <ATen/native/SpectralOpsUtils.h>
#include <ATen/native/xpu/mkl/SpectralOps.h>
Expand Down Expand Up @@ -591,4 +591,4 @@ Tensor& _fft_r2c_mkl_out(
}

} // namespace at::native::xpu
#endif // USE_ONEMKL
#endif // USE_ONEMKL_XPU
6 changes: 3 additions & 3 deletions src/BuildOnLinux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ foreach(lib ${TORCH_XPU_OPS_LIBRARIES})
target_link_libraries(${lib} PUBLIC ${SYCL_LIBRARY})
endforeach()

if(USE_ONEMKL)
target_compile_options(torch_xpu_ops PRIVATE "-DUSE_ONEMKL")
if(USE_ONEMKL_XPU)
target_compile_options(torch_xpu_ops PRIVATE "-DUSE_ONEMKL_XPU")
target_include_directories(torch_xpu_ops PUBLIC ${TORCH_XPU_OPS_ONEMKL_INCLUDE_DIR})
target_link_libraries(torch_xpu_ops PUBLIC ${TORCH_XPU_OPS_ONEMKL_LIBRARIES})
endif()
endif()
6 changes: 3 additions & 3 deletions src/BuildOnWindows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ foreach(lib ${TORCH_XPU_OPS_LIBRARIES})
target_link_libraries(${lib} PUBLIC torch_cpu)
endforeach()

if(USE_ONEMKL)
target_compile_options(torch_xpu_ops PRIVATE "-DUSE_ONEMKL")
if(USE_ONEMKL_XPU)
target_compile_options(torch_xpu_ops PRIVATE "-DUSE_ONEMKL_XPU")
target_include_directories(torch_xpu_ops PUBLIC ${TORCH_XPU_OPS_ONEMKL_INCLUDE_DIR})
target_link_libraries(torch_xpu_ops PUBLIC ${TORCH_XPU_OPS_ONEMKL_LIBRARIES})
endif()
endif()