Skip to content

Use SYCL experimental extension for reduction properties #2211

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 2 commits into from
Dec 4, 2024
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
21 changes: 19 additions & 2 deletions dpnp/backend/kernels/dpnp_krnl_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,23 @@
#include "queue_sycl.hpp"
#include <dpnp_iface.hpp>

/**
* Version of SYCL DPC++ 2025.1 compiler where support of
* sycl::ext::oneapi::experimental::properties was added.
*/
#ifndef __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241129
#endif

namespace mkl_blas = oneapi::mkl::blas;
namespace mkl_blas_cm = oneapi::mkl::blas::column_major;
namespace mkl_blas_rm = oneapi::mkl::blas::row_major;
namespace mkl_lapack = oneapi::mkl::lapack;

#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
namespace syclex = sycl::ext::oneapi::experimental;
#endif

template <typename _KernelNameSpecialization1,
typename _KernelNameSpecialization2,
typename _KernelNameSpecialization3>
Expand Down Expand Up @@ -78,8 +90,13 @@ sycl::event dot(sycl::queue &queue,
cgh.parallel_for(
sycl::range<1>{size},
sycl::reduction(
result_out, std::plus<_DataType_output>(),
sycl::property::reduction::initialize_to_identity{}),
result_out, sycl::plus<_DataType_output>(),
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
syclex::properties(syclex::initialize_to_identity)
#else
sycl::property::reduction::initialize_to_identity {}
#endif
),
[=](sycl::id<1> idx, auto &sum) {
sum += static_cast<_DataType_output>(
input1_in[idx * input1_strides]) *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_linspace_float_overflow(self, xp):
dtype = cupy.default_float_type()
return xp.linspace(0.0, xp.finfo(dtype).max / 5, 10, dtype=dtype)

@testing.numpy_cupy_allclose()
@testing.numpy_cupy_allclose(rtol={numpy.float32: 1e-6, "default": 1e-7})
def test_linspace_float_underflow(self, xp):
# find minimum subnormal number
dtype = cupy.default_float_type()
Expand Down
Loading