diff --git a/.gitmodules b/.gitmodules index 3d5153f..f8b4be1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "steps/kernel_density_estimation_cpp/argparse"] path = steps/kernel_density_estimation_cpp/argparse url = https://github.com/p-ranav/argparse -[submodule "steps/mkl_interface/oneMKL"] - path = steps/mkl_interface/oneMKL - url = https://github.com/oneapi-src/oneMKL +[submodule "steps/mkl_interface/oneMath"] + path = steps/mkl_interface/oneMath + url = https://github.com/uxlfoundation/oneMath diff --git a/steps/mkl_interface/README.md b/steps/mkl_interface/README.md index 80931d7..cd7182d 100644 --- a/steps/mkl_interface/README.md +++ b/steps/mkl_interface/README.md @@ -1,6 +1,6 @@ # Python data-parallel native extension -Here we build Python extension for a QR decomposition using `oneMKL` LAPACK routines. +Here we build Python extension for a QR decomposition using `oneMath` LAPACK routines. ## Building diff --git a/steps/mkl_interface/building.md b/steps/mkl_interface/building.md index 26840f8..e8dff4f 100644 --- a/steps/mkl_interface/building.md +++ b/steps/mkl_interface/building.md @@ -1,24 +1,24 @@ -# oneMKL Interface +# oneMath Interface -[oneMKL Interfaces](https://github.com/oneapi-src/oneMKL) is an open-source implementation of the oneMKL Data Parallel C++ (DPC++) interface according to the [oneMKL specification](https://spec.oneapi.com/versions/latest/elements/oneMKL/source/index.html). It works with multiple devices (backends) using device-specific libraries underneath. +[oneMath Interfaces](https://github.com/uxlfoundation/oneMath) is an open-source implementation of the oneMath Data Parallel C++ (DPC++) interface according to the [oneMath specification](https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onemath/source). It works with multiple devices (backends) using device-specific libraries underneath. -oneMKL is part of the [UXL Foundation](http://www.uxlfoundation.org/). +oneMath is part of the [UXL Foundation](http://www.uxlfoundation.org/). ## Getting the library The library can be cloned from GitHub: ```bash -git clone https://github.com/oneapi-src/oneMKL.git +git clone https://github.com/uxlfoundation/oneMath.git ``` -but it is also included in this repo as a git submodule, in "./oneMKL" subfolder. +but it is also included in this repo as a git submodule, in "./oneMath" subfolder. ## Building -oneMKL interface library allows for many ways to be built, please see [building oneMKL interface](https://oneapi-src.github.io/oneMKL/building_the_project_with_dpcpp.html) for full details. +oneMath interface library allows for many ways to be built, please see [building oneMath interface](https://uxlfoundation.github.io/oneMath/building_the_project_with_dpcpp.html) for full details. -Note that building oneMKL interfaces requires cmake, which may also be required to build the extension or dpctl (if targeting NVidia(R)). As such, it may be a good idea to install requirements for the chosen build path ([`scikit-build-core`](#building-c-extension-using-scikit-build-core) or [`meson-python`](#building-c-extension-using-meson-python)) ahead of time. +Note that building oneMath interfaces requires cmake, which may also be required to build the extension or dpctl (if targeting NVidia(R)). As such, it may be a good idea to install requirements for the chosen build path ([`scikit-build-core`](#building-c-extension-using-scikit-build-core) or [`meson-python`](#building-c-extension-using-meson-python)) ahead of time. In order to target Intel(R) GPUs, CPUs, and NVidia(R) GPUs for BLAS, LAPACK, FFT, and RNG domains configure it as follows: @@ -61,7 +61,7 @@ cd .. A set of examples is included with the library. Let's build an LAPACK example of solving general triangular linear system. We use `-fsycl-targets` to specify targets to generate offload sections for, and link to the -library dynamically using `-lonemkl`: +library dynamically using `-lonemath`: ```bash cd examples/lapack/run_time_dispatching/ @@ -69,7 +69,7 @@ icpx -fsycl getrs_usm.cpp \ -fsycl-targets=nvptx64-nvidia-cuda,spir64-unknown-unknown \ -I${MKL_INTERFACE_ROOT}/include \ -I${MKL_INTERFACE_ROOT}/../examples/include \ - -L${MKL_INTERFACE_ROOT}/lib -lonemkl \ + -L${MKL_INTERFACE_ROOT}/lib -lonemath \ -Wl,-rpath,${MKL_INTERFACE_ROOT}/lib -o run ``` @@ -153,11 +153,11 @@ See the [`dpctl` documentation](https://intelpython.github.io/dpctl/latest/begin ### Building C++ extension manually -We chose to demonstrate use of oneMKL interface library from Python by building +We chose to demonstrate use of oneMath interface library from Python by building pybind11 extension that computes QR decomposition for a stack of real floating-point matrices. -Since oneMKL LAPACK functions [require](https://spec.oneapi.io/versions/latest/elements/oneMKL/source/domains/lapack/lapack.html) +Since oneMath LAPACK functions [require](https://oneapi-spec.uxlfoundation.org/specifications/oneapi/latest/elements/onemath/source/domains/lapack/lapack) column-major layout and modify input arrays in place, the extension must copy the input stack of matrices accordingly. If requirements are not installed, install requirements. @@ -178,14 +178,14 @@ Now build and install icpx -fsycl -fPIC -shared -fno-approx-func -fno-fast-math \ $(python -m pybind11 --includes) -I$MKL_INTERFACE_ROOT/include \ $(python -m dpctl --includes) $(python -m dpctl --tensor-includes) \ - -L$MKL_INTERFACE_ROOT/lib -lonemkl -Wl,-rpath,$MKL_INTERFACE_ROOT/lib \ + -L$MKL_INTERFACE_ROOT/lib -lonemath -Wl,-rpath,$MKL_INTERFACE_ROOT/lib \ src/py.cpp -o mkl_interface_ext/_qr.so ``` Tests of the extension can be executed as follows: ```bash -# work-around a problem with oneMKL library linkage +# work-around a problem with oneMath library linkage export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MKL_INTERFACE_ROOT}/lib PYTHONPATH=$PYTHONPATH:$(pwd)/mkl_interface_ext pytest tests ``` @@ -209,8 +209,8 @@ pip install -r scikit_build_core_mkl_ext/requirements.txt Now build and install ```bash -# help cmake to find oneMKL library -export ONEMKL_ROOT=$MKL_INTERFACE_ROOT +# help cmake to find oneMath library +export ONEMATH_ROOT=$MKL_INTERFACE_ROOT # help cmake to find dpctl package if built in-place export Dpctl_ROOT=$(python -m dpctl --cmakedir) export VERBOSE=1 diff --git a/steps/mkl_interface/environment.yml b/steps/mkl_interface/environment.yml index d0c88f3..55c484d 100644 --- a/steps/mkl_interface/environment.yml +++ b/steps/mkl_interface/environment.yml @@ -6,7 +6,7 @@ name: mkl-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - dpctl diff --git a/steps/mkl_interface/meson_mkl_ext/environment.yml b/steps/mkl_interface/meson_mkl_ext/environment.yml index f24c843..4951cfb 100644 --- a/steps/mkl_interface/meson_mkl_ext/environment.yml +++ b/steps/mkl_interface/meson_mkl_ext/environment.yml @@ -6,7 +6,7 @@ name: mkl-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - dpctl diff --git a/steps/mkl_interface/meson_mkl_ext/meson.build b/steps/mkl_interface/meson_mkl_ext/meson.build index 7bde48d..acc09e7 100644 --- a/steps/mkl_interface/meson_mkl_ext/meson.build +++ b/steps/mkl_interface/meson_mkl_ext/meson.build @@ -57,9 +57,9 @@ if not pybind11_dep.found() pybind11_dep = pybind11_proj.get_variable('pybind11_dep') endif -mkl_dir = fs.parent(meson.current_source_dir()) + '/oneMKL' +mkl_dir = fs.parent(meson.current_source_dir()) + '/oneMath' mkl_lib_dir = mkl_dir + '/install/lib' -mkl_lib = compiler.find_library('onemkl', dirs: mkl_lib_dir) +mkl_lib = compiler.find_library('onemath', dirs: mkl_lib_dir) mkl_incl_dir = mkl_dir + '/install/include' mkl_incl = include_directories(mkl_incl_dir) diff --git a/steps/mkl_interface/meson_mkl_ext/pyproject.toml b/steps/mkl_interface/meson_mkl_ext/pyproject.toml index 37afa59..5ea90e1 100644 --- a/steps/mkl_interface/meson_mkl_ext/pyproject.toml +++ b/steps/mkl_interface/meson_mkl_ext/pyproject.toml @@ -10,7 +10,7 @@ requires = [ [project] name = "mkl_interface_ext" version = "0.0.1" -description="An example of a pybind11 extension for dpctl using oneMKL interface library" +description="An example of a pybind11 extension for dpctl using oneMath interface library" authors=[ {name = "Oleksandr Pavlyk", email="oleksandr.pavlyk@intel.com"}, {name = "Nikita Grigorian", email="nikita.grigorian@intel.com"} diff --git a/steps/mkl_interface/mkl_interface_ext/__init__.py b/steps/mkl_interface/mkl_interface_ext/__init__.py index 1676c70..40fc3d5 100644 --- a/steps/mkl_interface/mkl_interface_ext/__init__.py +++ b/steps/mkl_interface/mkl_interface_ext/__init__.py @@ -1,7 +1,7 @@ from ._qr_impl import qr __doc__ = """ -Sample Python extension built with oneAPI DPC++ and oneMKL interface library +Sample Python extension built with oneAPI DPC++ and oneMath interface library prepared for SciPy 2024 poster 'Portable data-parallel native Python extensions with oneAPI' by Nikita Grigorian and Oleksandr Pavlyk, Intel Corp. diff --git a/steps/mkl_interface/mkl_interface_ext/_qr_impl.py b/steps/mkl_interface/mkl_interface_ext/_qr_impl.py index 95aec71..973b1c3 100644 --- a/steps/mkl_interface/mkl_interface_ext/_qr_impl.py +++ b/steps/mkl_interface/mkl_interface_ext/_qr_impl.py @@ -13,7 +13,7 @@ class QRDecompositionResult(NamedTuple): def qr(x : dpt.usm_ndarray) -> tuple[dpt.usm_ndarray, dpt.usm_ndarray]: """ Compute QR decomposition for a stack of matrices using - oneMKL interface library calls. + oneMath interface library calls. """ if not isinstance(x, dpt.usm_ndarray): raise TypeError( diff --git a/steps/mkl_interface/oneMKL b/steps/mkl_interface/oneMKL deleted file mode 160000 index 577a279..0000000 --- a/steps/mkl_interface/oneMKL +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 577a279de09cec1a9c9974a4b163fd707bf44c4c diff --git a/steps/mkl_interface/oneMath b/steps/mkl_interface/oneMath new file mode 160000 index 0000000..5c7e1e7 --- /dev/null +++ b/steps/mkl_interface/oneMath @@ -0,0 +1 @@ +Subproject commit 5c7e1e7a710556e51f70ecc8dd26dfd04e3abf41 diff --git a/steps/mkl_interface/scikit_build_core_mkl_ext/CMakeLists.txt b/steps/mkl_interface/scikit_build_core_mkl_ext/CMakeLists.txt index f4d35cd..8481b5e 100644 --- a/steps/mkl_interface/scikit_build_core_mkl_ext/CMakeLists.txt +++ b/steps/mkl_interface/scikit_build_core_mkl_ext/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.27...3.29 FATAL_ERROR) project(${SKBUILD_PROJECT_NAME} VERSION ${SKBUILD_PROJECT_VERSION} LANGUAGES CXX - DESCRIPTION "A sample pybind11 extension using portable oneMKL interface library" + DESCRIPTION "A sample pybind11 extension using portable oneMath interface library" ) option(TARGET_CUDA "Whether to additionally target NVPTX64" OFF) @@ -31,7 +31,7 @@ FetchContent_MakeAvailable(pybind11) find_package(Dpctl CONFIG REQUIRED) -find_package(oneMKL CONFIG REQUIRED) +find_package(oneMath CONFIG REQUIRED) set(py_module_name _qr) set(_mkl_iface_ext_sources @@ -47,7 +47,7 @@ target_compile_options(${py_module_name} PRIVATE -O3 -fno-approx-func -fno-fast- target_include_directories(${py_module_name} PRIVATE ${Dpctl_INCLUDE_DIRS}) target_include_directories(${py_module_name} PRIVATE ${Dpctl_TENSOR_INCLUDE_DIR}) -target_link_libraries(${py_module_name} PRIVATE MKL::onemkl) +target_link_libraries(${py_module_name} PRIVATE ONEMATH::onemath) set(_sycl_targets) set(_hip_targets) diff --git a/steps/mkl_interface/scikit_build_core_mkl_ext/environment.yml b/steps/mkl_interface/scikit_build_core_mkl_ext/environment.yml index 758ed97..63d61aa 100644 --- a/steps/mkl_interface/scikit_build_core_mkl_ext/environment.yml +++ b/steps/mkl_interface/scikit_build_core_mkl_ext/environment.yml @@ -6,7 +6,7 @@ name: mkl-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - dpctl diff --git a/steps/mkl_interface/scikit_build_core_mkl_ext/pyproject.toml b/steps/mkl_interface/scikit_build_core_mkl_ext/pyproject.toml index 9f83b0f..809277e 100644 --- a/steps/mkl_interface/scikit_build_core_mkl_ext/pyproject.toml +++ b/steps/mkl_interface/scikit_build_core_mkl_ext/pyproject.toml @@ -11,7 +11,7 @@ requires = [ [project] name = "mkl_interface_ext" version = "0.0.1" -description="An example of a pybind11 extension for dpctl using oneMKL interface library" +description="An example of a pybind11 extension for dpctl using oneMath interface library" authors=[ {name = "Oleksandr Pavlyk", email="oleksandr.pavlyk@intel.com"}, {name = "Nikita Grigorian", email="nikita.grigorian@intel.com"} diff --git a/steps/mkl_interface/src/py.cpp b/steps/mkl_interface/src/py.cpp index d0ca084..9ddef35 100644 --- a/steps/mkl_interface/src/py.cpp +++ b/steps/mkl_interface/src/py.cpp @@ -1,5 +1,5 @@ #include -#include "oneapi/mkl.hpp" +#include "oneapi/math.hpp" #include #include @@ -61,10 +61,10 @@ do_qr( std::int64_t n_linear_streams = (b > 16) ? 4 : ((b > 4 ? 2 : 1)); std::int64_t scratch_sz_geqrf = - oneapi::mkl::lapack::geqrf_scratchpad_size(exec_q, m, n, lda); + oneapi::math::lapack::geqrf_scratchpad_size(exec_q, m, n, lda); std::int64_t scratch_sz_orgqr = - oneapi::mkl::lapack::orgqr_scratchpad_size(exec_q, m, m, tau_size, lda); + oneapi::math::lapack::orgqr_scratchpad_size(exec_q, m, m, tau_size, lda); std::int64_t padding = 256 / sizeof(T); size_t alloc_tau_sz = round_up_mult(n_linear_streams * tau_size, padding); @@ -106,9 +106,9 @@ do_qr( // overwrites memory in current_a sycl::event e_geqrf; try { - e_geqrf = oneapi::mkl::lapack::geqrf( + e_geqrf = oneapi::math::lapack::geqrf( exec_q, m, n, current_a, lda, current_tau, current_scratch_geqrf, scratch_sz_geqrf, current_dep); - } catch (const oneapi::mkl::lapack::exception &e) { + } catch (const oneapi::math::lapack::exception &e) { std::cerr << "Exception raised by geqrf: " << e.what() << ", info = " << e.info() << std::endl; e_ptr = std::current_exception(); @@ -152,9 +152,9 @@ do_qr( sycl::event e_orgqr; try { - e_orgqr = oneapi::mkl::lapack::orgqr( + e_orgqr = oneapi::math::lapack::orgqr( exec_q, m, m, tau_size, current_q, lda, current_tau, current_scratch_orgqr, scratch_sz_orgqr, {e_copy_q}); - } catch (const oneapi::mkl::lapack::exception &e) { + } catch (const oneapi::math::lapack::exception &e) { std::cerr << "Exception raised by orgqr: " << e.what() << ", info = " << e.info() << std::endl; e_ptr = std::current_exception(); diff --git a/steps/sycl_python_extension/environment.yml b/steps/sycl_python_extension/environment.yml index b6fa0d7..ad6c6a9 100644 --- a/steps/sycl_python_extension/environment.yml +++ b/steps/sycl_python_extension/environment.yml @@ -6,7 +6,7 @@ name: kde-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - dpctl diff --git a/steps/sycl_python_extension/meson_sycl_python_extension/environment.yml b/steps/sycl_python_extension/meson_sycl_python_extension/environment.yml index 90cdba5..836f219 100644 --- a/steps/sycl_python_extension/meson_sycl_python_extension/environment.yml +++ b/steps/sycl_python_extension/meson_sycl_python_extension/environment.yml @@ -6,7 +6,7 @@ name: kde-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - dpctl diff --git a/steps/sycl_python_extension/meson_sycl_python_extension/environment_build.yml b/steps/sycl_python_extension/meson_sycl_python_extension/environment_build.yml index 5a47df9..4848bca 100644 --- a/steps/sycl_python_extension/meson_sycl_python_extension/environment_build.yml +++ b/steps/sycl_python_extension/meson_sycl_python_extension/environment_build.yml @@ -6,7 +6,7 @@ name: kde-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - cython diff --git a/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment.yml b/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment.yml index 525bb5a..cccc5c4 100644 --- a/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment.yml +++ b/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment.yml @@ -6,7 +6,7 @@ name: kde-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - dpctl diff --git a/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment_build.yml b/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment_build.yml index f857463..dee6922 100644 --- a/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment_build.yml +++ b/steps/sycl_python_extension/scikit_build_core_sycl_python_extension/environment_build.yml @@ -6,7 +6,7 @@ name: kde-ext channels: - conda-forge - - intel + - https://software.repos.intel.com/python/conda/ dependencies: - python - cython