Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add testing and fixes for SYCL
  • Loading branch information
mborland committed Aug 26, 2024
commit 6066680f59612c7f85220fa676b9518be000f71a
14 changes: 7 additions & 7 deletions include/boost/math/special_functions/pow1p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

// For cuda we would rather use builtin nextafter than unsupported boost::math::nextafter
// NVRTC does not support the forward declarations header
#ifndef BOOST_MATH_ENABLE_CUDA
#ifndef BOOST_MATH_HAS_GPU_SUPPORT
# include <boost/math/special_functions/next.hpp>
# ifndef BOOST_MATH_HAS_NVRTC
# include <utility>
Expand All @@ -31,7 +31,7 @@ namespace math {

namespace detail {

#ifndef BOOST_MATH_ENABLE_CUDA
#ifndef BOOST_MATH_HAS_GPU_SUPPORT

template <typename T>
using fma_t = decltype(fma(std::declval<T>(), std::declval<T>(), std::declval<T>()));
Expand All @@ -52,7 +52,7 @@ BOOST_MATH_FORCEINLINE BOOST_MATH_GPU_ENABLED T local_fma(const T x, const T y,
return x * y + z;
}

#endif // BOOST_MATH_ENABLE_CUDA
#endif // BOOST_MATH_HAS_GPU_SUPPORT

template <typename T, typename Policy>
BOOST_MATH_GPU_ENABLED T pow1p_imp(const T x, const T y, const Policy& pol)
Expand Down Expand Up @@ -150,7 +150,7 @@ BOOST_MATH_GPU_ENABLED T pow1p_imp(const T x, const T y, const Policy& pol)
t = x - (s - T(1));
if (t > 0)
{
#ifdef BOOST_MATH_ENABLE_CUDA
#ifdef BOOST_MATH_HAS_GPU_SUPPORT
s = ::nextafter(s, T(1));
#else
s = boost::math::nextafter(s, T(1));
Expand All @@ -165,7 +165,7 @@ BOOST_MATH_GPU_ENABLED T pow1p_imp(const T x, const T y, const Policy& pol)
t = x - (s - T(1));
if (t < 0)
{
#ifdef BOOST_MATH_ENABLE_CUDA
#ifdef BOOST_MATH_HAS_GPU_SUPPORT
s = ::nextafter(s, T(0));
#else
s = boost::math::nextafter(s, T(0));
Expand All @@ -180,7 +180,7 @@ BOOST_MATH_GPU_ENABLED T pow1p_imp(const T x, const T y, const Policy& pol)
t = T(1) - (s - x);
if (t < 0)
{
#ifdef BOOST_MATH_ENABLE_CUDA
#ifdef BOOST_MATH_HAS_GPU_SUPPORT
s = ::nextafter(s, T(0));
#else
s = boost::math::nextafter(s, T(0));
Expand All @@ -207,7 +207,7 @@ BOOST_MATH_GPU_ENABLED T pow1p_imp(const T x, const T y, const Policy& pol)
// Then exp(y*u) == exp(z)*exp(w).
T z = y * u;

#ifdef BOOST_MATH_ENABLE_CUDA
#ifdef BOOST_MATH_HAS_GPU_SUPPORT
T w = fma(y, u, -z);
#else
T w = local_fma(y, u, -z);
Expand Down
1 change: 1 addition & 0 deletions test/sycl_jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ run test_digamma_simple.cpp ;
run test_trigamma.cpp ;
run test_erf.cpp ;
run test_gamma.cpp ;
run test_pow1p.cpp ;
2 changes: 2 additions & 0 deletions test/test_pow1p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ void test()
CHECK_EQUAL(boost::math::pow1p(T(1), T(0)), T(1));

// pow(0, y)
#ifndef BOOST_MATH_NO_EXCEPTIONS
CHECK_THROW(boost::math::pow1p(T(-1), T(-1)), std::domain_error);
#endif
CHECK_EQUAL(boost::math::pow1p(T(-1), T(1)), T(0));

// pow(-1, inf)
Expand Down