Skip to content

Commit

Permalink
Fix warnings in blas extensions during build on CUDA (#2225)
Browse files Browse the repository at this point in the history
This PR suggests using conditional logic in blas extensions **(gemm,
gemm_batch, gemv**) to fix the warning about `unused 'is_row_major'
parameter` during dpnp build on CUDA. The changes ensure that
`is_row_major` parameter is only passed when the backend requires it.
  • Loading branch information
vlad-perevezentsev authored Dec 11, 2024
1 parent b990bac commit c4997cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dpnp/backend/extensions/blas/gemm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ typedef sycl::event (*gemm_impl_fn_ptr_t)(sycl::queue &,
const std::int64_t,
char *,
const std::int64_t,
#if !defined(USE_ONEMKL_CUBLAS)
const bool,
#endif // !USE_ONEMKL_CUBLAS
const std::vector<sycl::event> &);

static gemm_impl_fn_ptr_t gemm_dispatch_table[dpctl_td_ns::num_types]
Expand All @@ -74,7 +76,9 @@ static sycl::event gemm_impl(sycl::queue &exec_q,
const std::int64_t ldb,
char *resultC,
const std::int64_t ldc,
#if !defined(USE_ONEMKL_CUBLAS)
const bool is_row_major,
#endif // !USE_ONEMKL_CUBLAS
const std::vector<sycl::event> &depends)
{
type_utils::validate_type_for_device<Tab>(exec_q);
Expand Down Expand Up @@ -236,6 +240,7 @@ std::tuple<sycl::event, sycl::event, bool>
std::int64_t lda;
std::int64_t ldb;

// cuBLAS supports only column-major storage
#if defined(USE_ONEMKL_CUBLAS)
const bool is_row_major = false;

Expand Down Expand Up @@ -315,9 +320,15 @@ std::tuple<sycl::event, sycl::event, bool>
const char *b_typeless_ptr = matrixB.get_data();
char *r_typeless_ptr = resultC.get_data();

#if defined(USE_ONEMKL_CUBLAS)
sycl::event gemm_ev =
gemm_fn(exec_q, transA, transB, m, n, k, a_typeless_ptr, lda,
b_typeless_ptr, ldb, r_typeless_ptr, ldc, depends);
#else
sycl::event gemm_ev = gemm_fn(exec_q, transA, transB, m, n, k,
a_typeless_ptr, lda, b_typeless_ptr, ldb,
r_typeless_ptr, ldc, is_row_major, depends);
#endif // USE_ONEMKL_CUBLAS

sycl::event args_ev = dpctl::utils::keep_args_alive(
exec_q, {matrixA, matrixB, resultC}, {gemm_ev});
Expand Down
12 changes: 12 additions & 0 deletions dpnp/backend/extensions/blas/gemm_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ typedef sycl::event (*gemm_batch_impl_fn_ptr_t)(
const char *,
const char *,
char *,
#if !defined(USE_ONEMKL_CUBLAS)
const bool,
#endif // !USE_ONEMKL_CUBLAS
const std::vector<sycl::event> &);

static gemm_batch_impl_fn_ptr_t
Expand All @@ -83,7 +85,9 @@ static sycl::event gemm_batch_impl(sycl::queue &exec_q,
const char *matrixA,
const char *matrixB,
char *resultC,
#if !defined(USE_ONEMKL_CUBLAS)
const bool is_row_major,
#endif // !USE_ONEMKL_CUBLAS
const std::vector<sycl::event> &depends)
{
type_utils::validate_type_for_device<Tab>(exec_q);
Expand Down Expand Up @@ -311,6 +315,7 @@ std::tuple<sycl::event, sycl::event, bool>
std::int64_t lda;
std::int64_t ldb;

// cuBLAS supports only column-major storage
#if defined(USE_ONEMKL_CUBLAS)
const bool is_row_major = false;

Expand Down Expand Up @@ -391,10 +396,17 @@ std::tuple<sycl::event, sycl::event, bool>
const char *b_typeless_ptr = matrixB.get_data();
char *r_typeless_ptr = resultC.get_data();

#if defined(USE_ONEMKL_CUBLAS)
sycl::event gemm_batch_ev =
gemm_batch_fn(exec_q, m, n, k, batch_size, lda, ldb, ldc, stridea,
strideb, stridec, transA, transB, a_typeless_ptr,
b_typeless_ptr, r_typeless_ptr, depends);
#else
sycl::event gemm_batch_ev =
gemm_batch_fn(exec_q, m, n, k, batch_size, lda, ldb, ldc, stridea,
strideb, stridec, transA, transB, a_typeless_ptr,
b_typeless_ptr, r_typeless_ptr, is_row_major, depends);
#endif // USE_ONEMKL_CUBLAS

sycl::event args_ev = dpctl::utils::keep_args_alive(
exec_q, {matrixA, matrixB, resultC}, {gemm_batch_ev});
Expand Down
11 changes: 11 additions & 0 deletions dpnp/backend/extensions/blas/gemv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ typedef sycl::event (*gemv_impl_fn_ptr_t)(sycl::queue &,
const std::int64_t,
char *,
const std::int64_t,
#if !defined(USE_ONEMKL_CUBLAS)
const bool,
#endif // !USE_ONEMKL_CUBLAS
const std::vector<sycl::event> &);

static gemv_impl_fn_ptr_t gemv_dispatch_vector[dpctl_td_ns::num_types];
Expand All @@ -69,7 +71,9 @@ static sycl::event gemv_impl(sycl::queue &exec_q,
const std::int64_t incx,
char *vectorY,
const std::int64_t incy,
#if !defined(USE_ONEMKL_CUBLAS)
const bool is_row_major,
#endif // !USE_ONEMKL_CUBLAS
const std::vector<sycl::event> &depends)
{
type_utils::validate_type_for_device<T>(exec_q);
Expand Down Expand Up @@ -190,6 +194,7 @@ std::pair<sycl::event, sycl::event>
oneapi::mkl::transpose transA;
std::size_t src_nelems;

// cuBLAS supports only column-major storage
#if defined(USE_ONEMKL_CUBLAS)
const bool is_row_major = false;
std::int64_t m;
Expand Down Expand Up @@ -299,9 +304,15 @@ std::pair<sycl::event, sycl::event>
y_typeless_ptr -= (y_shape[0] - 1) * std::abs(incy) * y_elemsize;
}

#if defined(USE_ONEMKL_CUBLAS)
sycl::event gemv_ev =
gemv_fn(exec_q, transA, m, n, a_typeless_ptr, lda, x_typeless_ptr, incx,
y_typeless_ptr, incy, depends);
#else
sycl::event gemv_ev =
gemv_fn(exec_q, transA, m, n, a_typeless_ptr, lda, x_typeless_ptr, incx,
y_typeless_ptr, incy, is_row_major, depends);
#endif // USE_ONEMKL_CUBLAS

sycl::event args_ev = dpctl::utils::keep_args_alive(
exec_q, {matrixA, vectorX, vectorY}, {gemv_ev});
Expand Down

0 comments on commit c4997cc

Please sign in to comment.