Skip to content

Commit 5411d71

Browse files
vlad-perevezentsevantonwolfy
authored andcommitted
Move all logic with cyl_bessel_i0 support in i0.hpp
1 parent 2b30bab commit 5411d71

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This release achieves 100% compliance with Python Array API specification (revis
3434
* Resolved an issue with an incorrect result returned due to missing dependency from the strided kernel on a copy event in `dpnp.erf` [#2378](https://github.com/IntelPython/dpnp/pull/2378)
3535
* Updated `conda create` commands build and install instructions of `Quick start guide` to avoid a compilation error [#2395](https://github.com/IntelPython/dpnp/pull/2395)
3636
* Added handling of empty string passed to a test env variable defining data type scope as a `False` value [#2415](https://github.com/IntelPython/dpnp/pull/2415)
37+
* Resolved build issues on non-Intel targets in `dpnp.i0` and `dpnp.kaiser` [#2439](https://github.com/IntelPython/dpnp/pull/2439)
3738

3839

3940
## [0.17.0] - 02/26/2025

dpnp/backend/extensions/window/kaiser.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@
3232

3333
#include <sycl/sycl.hpp>
3434

35-
/**
36-
* Version of SYCL DPC++ 2025.1 compiler where an issue with
37-
* sycl::ext::intel::math::cyl_bessel_i0(x) is fully resolved.
38-
*/
39-
#ifndef __SYCL_COMPILER_BESSEL_I0_SUPPORT
40-
#define __SYCL_COMPILER_BESSEL_I0_SUPPORT 20241208L
41-
#endif
42-
43-
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT
44-
#include <sycl/ext/intel/math.hpp>
45-
#endif
46-
4735
#include "../kernels/elementwise_functions/i0.hpp"
4836

4937
namespace dpnp::extensions::window
@@ -74,11 +62,7 @@ class KaiserFunctor
7462

7563
void operator()(sycl::id<1> id) const
7664
{
77-
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT
78-
using sycl::ext::intel::math::cyl_bessel_i0;
79-
#else
80-
using dpnp::kernels::i0::impl::cyl_bessel_i0;
81-
#endif
65+
using dpnp::kernels::i0::cyl_bessel_i0;
8266

8367
const auto i = id.get(0);
8468
const T alpha = (N - 1) / T(2);

dpnp/backend/kernels/elementwise_functions/i0.hpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,28 @@
3535
#define __SYCL_COMPILER_BESSEL_I0_SUPPORT 20241208L
3636
#endif
3737

38-
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT
38+
/**
39+
* Include <sycl/ext/intel/math.hpp> only when targeting to Intel devices.
40+
* This header relies on intel-specific types like _iml_half_internal,
41+
* which are not suppose to work with other targets (e.g., CUDA, AMD).
42+
*/
43+
#if defined(__SPIR__) && defined(__INTEL_LLVM_COMPILER)
44+
#define __SYCL_EXT_INTEL_MATH_SUPPORT
45+
#endif
46+
47+
#if defined(__SYCL_EXT_INTEL_MATH_SUPPORT) && \
48+
(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT)
3949
#include <sycl/ext/intel/math.hpp>
4050
#endif
4151

4252
namespace dpnp::kernels::i0
4353
{
54+
#if defined(__SYCL_EXT_INTEL_MATH_SUPPORT) && \
55+
(__SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT)
56+
using sycl::ext::intel::math::cyl_bessel_i0;
57+
58+
#else
59+
4460
/**
4561
* The below implementation of Bessel function of order 0
4662
* is based on the source code from https://github.com/gcc-mirror/gcc
@@ -239,6 +255,10 @@ inline Tp cyl_bessel_i0(Tp x)
239255
}
240256
} // namespace impl
241257

258+
using impl::cyl_bessel_i0;
259+
260+
#endif
261+
242262
template <typename argT, typename resT>
243263
struct I0Functor
244264
{
@@ -253,12 +273,6 @@ struct I0Functor
253273

254274
resT operator()(const argT &x) const
255275
{
256-
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT
257-
using sycl::ext::intel::math::cyl_bessel_i0;
258-
#else
259-
using impl::cyl_bessel_i0;
260-
#endif
261-
262276
if constexpr (std::is_same_v<resT, sycl::half>) {
263277
return static_cast<resT>(cyl_bessel_i0<float>(float(x)));
264278
}

0 commit comments

Comments
 (0)