Skip to content
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

feature: enabling oneMKL instead of FPKs #2756

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f90b177
init commit
Alexandr-Solovev Apr 30, 2024
5364acc
fixes
Alexandr-Solovev May 2, 2024
8903664
fix
Alexandr-Solovev May 2, 2024
29f12fe
fixes for make build
Alexandr-Solovev May 6, 2024
b60da72
fix for building
Alexandr-Solovev May 6, 2024
747668d
chagnes for 2025 rls
Alexandr-Solovev May 6, 2024
5744eb8
fix for host+backward compatibility the latest compiler
Alexandr-Solovev May 7, 2024
8c299aa
minor fix
Alexandr-Solovev May 7, 2024
8ebea69
minor fixes
Alexandr-Solovev May 7, 2024
c2be094
fixes
Alexandr-Solovev May 8, 2024
d8399bb
fix syevd deps
Alexandr-Solovev May 10, 2024
11c5a2c
fixes for syevd and undef references
Alexandr-Solovev May 13, 2024
d5ba78e
adding syevd
Alexandr-Solovev May 13, 2024
fbc0d47
minor fix
Alexandr-Solovev May 13, 2024
ca0c011
Merge branch 'oneapi-src:main' into dev/asolovev_mkl_support
Alexandr-Solovev Jun 24, 2024
11b804b
add mkl sparse
Alexandr-Solovev Jun 26, 2024
cbb6e86
sparse formats fix
Alexandr-Solovev Jun 26, 2024
e1ac3b8
reduce the library size
Alexandr-Solovev Jun 27, 2024
867b172
onedal_sycl reminder
Alexandr-Solovev Jun 27, 2024
75aca67
initial adding mkl rng + minor refactoring makefile for mklgpu
Alexandr-Solovev Jun 28, 2024
f6757eb
fixes
Alexandr-Solovev Jun 28, 2024
523197b
minor fixes
Alexandr-Solovev Jul 1, 2024
882c4e5
initial replacement for mkl fpk header
Alexandr-Solovev Jul 3, 2024
09b8fb3
Revert "initial replacement for mkl fpk header"
Alexandr-Solovev Jul 15, 2024
425e13f
fix for rf
Alexandr-Solovev Jul 15, 2024
b1bdb99
fix forest for no weights
Alexandr-Solovev Jul 15, 2024
e8ab142
minor optimizations for forest
Alexandr-Solovev Jul 15, 2024
3bde6c4
fix for forest
Alexandr-Solovev Jul 15, 2024
9fc5145
fix for forest
Alexandr-Solovev Jul 18, 2024
a765ae8
minor fix
Alexandr-Solovev Jul 22, 2024
6eb78b9
fixes and merging rng cpu + gpu
Alexandr-Solovev Jul 22, 2024
72c9671
fix
Alexandr-Solovev Jul 26, 2024
9bc24dc
fixes for bazel
Alexandr-Solovev Jul 26, 2024
f180b87
Merge branch 'main' into dev/asolovev_mkl_support
Alexandr-Solovev Jul 26, 2024
5d04de5
fixes for ci
Alexandr-Solovev Jul 26, 2024
58d438b
fixes for build
Alexandr-Solovev Jul 26, 2024
1cc8777
fixes
Alexandr-Solovev Jul 31, 2024
2cc9025
Merge branch 'oneapi-src:main' into dev/asolovev_mkl_support
Alexandr-Solovev Aug 8, 2024
4255660
adding engline_list
Alexandr-Solovev Aug 8, 2024
e51dc53
minor fix
Alexandr-Solovev Aug 9, 2024
cf002f9
adding backward comp cpu gpu gen
Alexandr-Solovev Aug 9, 2024
891ec4b
add init dispatcher
Alexandr-Solovev Aug 12, 2024
101ef24
adding shared memory
Alexandr-Solovev Aug 12, 2024
f9dced9
minor fix
Alexandr-Solovev Aug 16, 2024
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
15 changes: 0 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@ opencl_repo(
name = "opencl",
)

load("@onedal//dev/bazel/deps:micromkl.bzl", "micromkl_repo", "micromkl_dpc_repo")
micromkl_repo(
name = "micromkl",
root_env_var = "MKLFPKROOT",
url = "https://github.com/oneapi-src/oneDAL/releases/download/Dependencies/mklfpk_lnx_20230413.tgz",
sha256 = "e99dd6fb18f1fda382c53373262d1bb44c1b58aa6edff94cfb0e9d8dcd3395ed",
)

micromkl_dpc_repo(
name = "micromkl_dpc",
root_env_var = "MKLGPUFPKROOT",
url = "https://github.com/oneapi-src/oneDAL/releases/download/Dependencies/mklgpufpk_lnx_20240605.tgz",
sha256 = "0787a92e9580ed6b9fb97d054a0ed77994dbc18b4b3fb099451cb1e6ebdf4f16",
)

load("@onedal//dev/bazel/deps:openblas.bzl", "openblas_repo")
openblas_repo(
name = "openblas",
Expand Down
12 changes: 4 additions & 8 deletions cpp/daal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ daal_module(
deps = select({
"@config//:backend_ref": [ ],
"//conditions:default": [
"@micromkl//:vml_ipp",
# TODO: Currently vml_ipp lib depends on TBB, but it shouldn't
# Remove TBB from deps once problem with vml_ipp is resolved
"@tbb//:tbb_binary",
"@mkl//:mkl_thr",
],
}),
)
Expand All @@ -32,7 +29,7 @@ daal_module(
deps = select({
"@config//:backend_ref": [ "@openblas//:openblas",
],
"//conditions:default": [ "@micromkl//:mkl_thr",
"//conditions:default": [ "@mkl//:mkl_thr",
],
}),
)
Expand Down Expand Up @@ -64,8 +61,7 @@ daal_module(
],
"//conditions:default": [
":public_includes",
"@micromkl//:headers",
"@micromkl_dpc//:headers",
"@mkl//:headers",
],
}),
)
Expand Down Expand Up @@ -134,7 +130,7 @@ daal_module(
"//conditions:default": [
":services",
"@onedal//cpp/daal/src/algorithms/engines:kernel",
"@micromkl_dpc//:headers",
"@mkl//:headers",
],
}),
)
Expand Down
37 changes: 19 additions & 18 deletions cpp/daal/include/services/internal/sycl/math/mkl_blas.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace math
{
namespace interface1
{

namespace mkl = ::oneapi::mkl;

/** @ingroup oneapi_internal
* @{
*/
Expand Down Expand Up @@ -76,7 +79,7 @@ struct MKLGemm
auto c_ptr = c_usm.get() + offsetC;

status |= catchSyclExceptions([&]() mutable {
::oneapi::fpk::blas::gemm(_queue, transamkl, transbmkl, m, n, k, alpha, a_ptr, lda, b_ptr, ldb, beta, c_ptr, ldc);
mkl::blas::gemm(_queue, transamkl, transbmkl, m, n, k, alpha, a_ptr, lda, b_ptr, ldb, beta, c_ptr, ldc);
_queue.wait_and_throw();
});
#else
Expand All @@ -87,26 +90,25 @@ struct MKLGemm

private:
template <typename T>
void innerGemm(MKL_TRANSPOSE transa, MKL_TRANSPOSE transb, int64_t m, int64_t n, int64_t k, T alpha, ::sycl::buffer<T, 1> a, int64_t lda,
::sycl::buffer<T, 1> b, int64_t ldb, T beta, ::sycl::buffer<T, 1> c, int64_t ldc, int64_t offset_a, int64_t offset_b,
int64_t offset_c);
DAAL_DEPRECATED void innerGemm(MKL_TRANSPOSE transa, MKL_TRANSPOSE transb, int64_t m, int64_t n, int64_t k, T alpha, ::sycl::buffer<T, 1> a,
int64_t lda, ::sycl::buffer<T, 1> b, int64_t ldb, T beta, ::sycl::buffer<T, 1> c, int64_t ldc, int64_t offset_a,
int64_t offset_b, int64_t offset_c);

template <>
void innerGemm<double>(MKL_TRANSPOSE transa, MKL_TRANSPOSE transb, int64_t m, int64_t n, int64_t k, double alpha, ::sycl::buffer<double, 1> a,
int64_t lda, ::sycl::buffer<double, 1> b, int64_t ldb, double beta, ::sycl::buffer<double, 1> c, int64_t ldc,
int64_t offset_a, int64_t offset_b, int64_t offset_c)
DAAL_DEPRECATED void innerGemm<double>(MKL_TRANSPOSE transa, MKL_TRANSPOSE transb, int64_t m, int64_t n, int64_t k, double alpha,
::sycl::buffer<double, 1> a, int64_t lda, ::sycl::buffer<double, 1> b, int64_t ldb, double beta,
::sycl::buffer<double, 1> c, int64_t ldc, int64_t offset_a, int64_t offset_b, int64_t offset_c)
{
::oneapi::fpk::gpu::dgemm_sycl(&_queue, transa, transb, m, n, k, alpha, &a, lda, &b, ldb, beta, &c, ldc, offset_a, offset_b, offset_c);
//mkl::blas::gpu::dgemm_sycl(&_queue, transa, transb, m, n, k, alpha, &a, lda, &b, ldb, beta, &c, ldc, offset_a, offset_b, offset_c);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please consider using a special deprivation error for such cases

}

template <>
void innerGemm<float>(MKL_TRANSPOSE transa, MKL_TRANSPOSE transb, int64_t m, int64_t n, int64_t k, float alpha, ::sycl::buffer<float, 1> a,
int64_t lda, ::sycl::buffer<float, 1> b, int64_t ldb, float beta, ::sycl::buffer<float, 1> c, int64_t ldc, int64_t offset_a,
int64_t offset_b, int64_t offset_c)
DAAL_DEPRECATED void innerGemm<float>(MKL_TRANSPOSE transa, MKL_TRANSPOSE transb, int64_t m, int64_t n, int64_t k, float alpha,
::sycl::buffer<float, 1> a, int64_t lda, ::sycl::buffer<float, 1> b, int64_t ldb, float beta,
::sycl::buffer<float, 1> c, int64_t ldc, int64_t offset_a, int64_t offset_b, int64_t offset_c)
{
::oneapi::fpk::gpu::sgemm_sycl(&_queue, transa, transb, m, n, k, alpha, &a, lda, &b, ldb, beta, &c, ldc, offset_a, offset_b, offset_c);
//mkl::blas::gpu::sgemm_sycl(&_queue, transa, transb, m, n, k, alpha, &a, lda, &b, ldb, beta, &c, ldc, offset_a, offset_b, offset_c);
}

::sycl::queue & _queue;
};

Expand Down Expand Up @@ -138,7 +140,7 @@ struct MKLSyrk
auto c_ptr = c_usm.get() + offsetC;

status |= catchSyclExceptions([&]() mutable {
::oneapi::fpk::blas::syrk(_queue, uplomkl, transmkl, n, k, alpha, a_ptr, lda, beta, c_ptr, ldc);
mkl::blas::syrk(_queue, uplomkl, transmkl, n, k, alpha, a_ptr, lda, beta, c_ptr, ldc);
_queue.wait_and_throw();
});
#else
Expand All @@ -156,16 +158,15 @@ struct MKLSyrk
void innerSyrk(MKL_UPLO uplo, MKL_TRANSPOSE trans, int64_t n, int64_t k, double alpha, ::sycl::buffer<double, 1> a, int64_t lda, double beta,
::sycl::buffer<double, 1> c, int64_t ldc, int64_t offset_a, int64_t offset_c)
{
::oneapi::fpk::gpu::dsyrk_sycl(&_queue, uplo, trans, n, k, alpha, &a, lda, beta, &c, ldc, offset_a, offset_c);
//mkl::gpu::dsyrk_sycl(&_queue, uplo, trans, n, k, alpha, &a, lda, beta, &c, ldc, offset_a, offset_c);
}

template <>
void innerSyrk(MKL_UPLO uplo, MKL_TRANSPOSE trans, int64_t n, int64_t k, float alpha, ::sycl::buffer<float, 1> a, int64_t lda, float beta,
::sycl::buffer<float, 1> c, int64_t ldc, int64_t offset_a, int64_t offset_c)
{
::oneapi::fpk::gpu::ssyrk_sycl(&_queue, uplo, trans, n, k, alpha, &a, lda, beta, &c, ldc, offset_a, offset_c);
//mkl::gpu::ssyrk_sycl(&_queue, uplo, trans, n, k, alpha, &a, lda, beta, &c, ldc, offset_a, offset_c);
}

::sycl::queue & _queue;
};

Expand All @@ -191,7 +192,7 @@ struct MKLAxpy
DAAL_CHECK_STATUS_VAR(status);

status |= catchSyclExceptions([&]() mutable {
::oneapi::fpk::blas::axpy(_queue, n, a, x_usm.get(), incx, y_usm.get(), incy);
mkl::blas::axpy(_queue, n, a, x_usm.get(), incx, y_usm.get(), incy);
_queue.wait_and_throw();
});
#else
Expand Down
2 changes: 1 addition & 1 deletion cpp/daal/include/services/internal/sycl/math/mkl_dal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#endif

DISABLE_MKL_DAL_SYCL_WARNINGS_BEGIN()
#include "mkl_dal_sycl.hpp"
#include <oneapi/mkl.hpp>
DISABLE_MKL_DAL_SYCL_WARNINGS_END()

#undef DISABLE_MKL_DAL_SYCL_WARNINGS_BEGIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ namespace math
{
namespace interface1
{
inline ::oneapi::fpk::transpose to_fpk_transpose(const math::Transpose & trans)
namespace mkl = ::oneapi::mkl;
inline mkl::transpose to_fpk_transpose(const math::Transpose & trans)
{
using fpk_transpose = ::oneapi::fpk::transpose;
using fpk_transpose = mkl::transpose;
return trans == math::Transpose::Trans ? fpk_transpose::trans : fpk_transpose::nontrans;
}

inline ::oneapi::fpk::uplo to_fpk_uplo(const math::UpLo & uplo)
inline mkl::uplo to_fpk_uplo(const math::UpLo & uplo)
{
using fpk_uplo = ::oneapi::fpk::uplo;
using fpk_uplo = mkl::uplo;
return uplo == math::UpLo::Upper ? fpk_uplo::upper : fpk_uplo::lower;
}

Expand Down
9 changes: 5 additions & 4 deletions cpp/daal/include/services/internal/sycl/math/mkl_lapack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace math
{
namespace interface1
{
namespace mkl = ::oneapi::mkl;
/** @ingroup oneapi_internal
* @{
*/
Expand All @@ -55,7 +56,7 @@ struct MKLPotrf
Status operator()(const math::UpLo uplo, const size_t n, Buffer<algorithmFPType> & a, const size_t lda)
{
const auto uplomkl = to_fpk_uplo(uplo);
const std::int64_t minimalScratchpadSize = ::oneapi::fpk::lapack::potrf_scratchpad_size<algorithmFPType>(_queue, uplomkl, n, lda);
const std::int64_t minimalScratchpadSize = mkl::lapack::potrf_scratchpad_size<algorithmFPType>(_queue, uplomkl, n, lda);
return this->operator()(uplo, n, a, lda, minimalScratchpadSize);
}

Expand All @@ -79,7 +80,7 @@ struct MKLPotrf
}

status |= catchSyclExceptions([&]() mutable {
::oneapi::fpk::lapack::potrf(_queue, uplomkl, n, a_usm.get(), lda, scratchpad, scratchpadSize);
mkl::lapack::potrf(_queue, uplomkl, n, a_usm.get(), lda, scratchpad, scratchpadSize);
_queue.wait_and_throw();
});

Expand Down Expand Up @@ -109,7 +110,7 @@ struct MKLPotrs
Buffer<algorithmFPType> & b, const size_t ldb)
{
const auto uplomkl = to_fpk_uplo(uplo);
const std::int64_t minimalScratchpadSize = ::oneapi::fpk::lapack::potrs_scratchpad_size<algorithmFPType>(_queue, uplomkl, n, ny, lda, ldb);
const std::int64_t minimalScratchpadSize = mkl::lapack::potrs_scratchpad_size<algorithmFPType>(_queue, uplomkl, n, ny, lda, ldb);
return this->operator()(uplo, n, ny, a, lda, b, ldb, minimalScratchpadSize);
}

Expand Down Expand Up @@ -137,7 +138,7 @@ struct MKLPotrs
}

status |= catchSyclExceptions([&]() mutable {
::oneapi::fpk::lapack::potrs(_queue, uplomkl, n, ny, a_usm.get(), lda, b_usm.get(), ldb, scratchpad, scratchpadSize);
mkl::lapack::potrs(_queue, uplomkl, n, ny, a_usm.get(), lda, b_usm.get(), ldb, scratchpad, scratchpadSize);
_queue.wait_and_throw();
});

Expand Down
1 change: 1 addition & 0 deletions cpp/daal/src/externals/config_mkl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "services/daal_defines.h"
#include "services/env_detect.h"

#include "src/externals/service_thread_declar_mkl.h"
#include "src/externals/service_blas_mkl.h"
#include "src/externals/service_lapack_mkl.h"
#include "src/externals/service_math_mkl.h"
Expand Down
Loading