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

GPU Batch 13 #1201

Merged
merged 3 commits into from
Sep 19, 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
32 changes: 16 additions & 16 deletions doc/sf/airy.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
namespace boost { namespace math {

template <class T>
``__sf_result`` airy_ai(T x);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai(T x);

template <class T, class Policy>
``__sf_result`` airy_ai(T x, const Policy&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai(T x, const Policy&);

}} // namespaces

Expand Down Expand Up @@ -78,10 +78,10 @@ This function is implemented in terms of the Bessel functions using the relation
namespace boost { namespace math {

template <class T>
``__sf_result`` airy_bi(T x);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi(T x);

template <class T, class Policy>
``__sf_result`` airy_bi(T x, const Policy&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi(T x, const Policy&);

}} // namespaces

Expand Down Expand Up @@ -132,10 +132,10 @@ This function is implemented in terms of the Bessel functions using the relation
namespace boost { namespace math {

template <class T>
``__sf_result`` airy_ai_prime(T x);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai_prime(T x);

template <class T, class Policy>
``__sf_result`` airy_ai_prime(T x, const Policy&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_ai_prime(T x, const Policy&);

}} // namespaces

Expand Down Expand Up @@ -186,10 +186,10 @@ This function is implemented in terms of the Bessel functions using the relation
namespace boost { namespace math {

template <class T>
``__sf_result`` airy_bi_prime(T x);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi_prime(T x);

template <class T, class Policy>
``__sf_result`` airy_bi_prime(T x, const Policy&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` airy_bi_prime(T x, const Policy&);

}} // namespaces

Expand Down Expand Up @@ -242,49 +242,49 @@ by providing an output iterator.
The signature of the single value functions are:

template <class T>
T airy_ai_zero(
BOOST_MATH_GPU_ENABLED T airy_ai_zero(
int m); // 1-based index of zero.

template <class T>
T airy_bi_zero(
BOOST_MATH_GPU_ENABLED T airy_bi_zero(
int m); // 1-based index of zero.

and for multiple zeros:

template <class T, class OutputIterator>
OutputIterator airy_ai_zero(
BOOST_MATH_GPU_ENABLED OutputIterator airy_ai_zero(
int start_index, // 1-based index of first zero.
unsigned number_of_zeros, // How many zeros to generate.
OutputIterator out_it); // Destination for zeros.

template <class T, class OutputIterator>
OutputIterator airy_bi_zero(
BOOST_MATH_GPU_ENABLED OutputIterator airy_bi_zero(
int start_index, // 1-based index of zero.
unsigned number_of_zeros, // How many zeros to generate
OutputIterator out_it); // Destination for zeros.

There are also versions which allow control of the __policy_section for error handling and precision.

template <class T>
T airy_ai_zero(
BOOST_MATH_GPU_ENABLED T airy_ai_zero(
int m, // 1-based index of zero.
const Policy&); // Policy to use.

template <class T>
T airy_bi_zero(
BOOST_MATH_GPU_ENABLED T airy_bi_zero(
int m, // 1-based index of zero.
const Policy&); // Policy to use.


template <class T, class OutputIterator>
OutputIterator airy_ai_zero(
BOOST_MATH_GPU_ENABLED OutputIterator airy_ai_zero(
int start_index, // 1-based index of first zero.
unsigned number_of_zeros, // How many zeros to generate.
OutputIterator out_it, // Destination for zeros.
const Policy& pol); // Policy to use.

template <class T, class OutputIterator>
OutputIterator airy_bi_zero(
BOOST_MATH_GPU_ENABLED OutputIterator airy_bi_zero(
int start_index, // 1-based index of zero.
unsigned number_of_zeros, // How many zeros to generate.
OutputIterator out_it, // Destination for zeros.
Expand Down
16 changes: 8 additions & 8 deletions doc/sf/expint.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
namespace boost{ namespace math{

template <class T>
``__sf_result`` expint(unsigned n, T z);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(unsigned n, T z);

template <class T, class ``__Policy``>
``__sf_result`` expint(unsigned n, T z, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(unsigned n, T z, const ``__Policy``&);

}} // namespaces

Expand All @@ -26,10 +26,10 @@ the return type is `double` if T is an integer type, and T otherwise.
[h4 Description]

template <class T>
``__sf_result`` expint(unsigned n, T z);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(unsigned n, T z);

template <class T, class ``__Policy``>
``__sf_result`` expint(unsigned n, T z, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(unsigned n, T z, const ``__Policy``&);

Returns the [@http://mathworld.wolfram.com/En-Function.html exponential integral En]
of z:
Expand Down Expand Up @@ -100,10 +100,10 @@ is used.
namespace boost{ namespace math{

template <class T>
``__sf_result`` expint(T z);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(T z);

template <class T, class ``__Policy``>
``__sf_result`` expint(T z, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(T z, const ``__Policy``&);

}} // namespaces

Expand All @@ -115,10 +115,10 @@ the return type is `double` if T is an integer type, and T otherwise.
[h4 Description]

template <class T>
``__sf_result`` expint(T z);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(T z);

template <class T, class ``__Policy``>
``__sf_result`` expint(T z, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` expint(T z, const ``__Policy``&);

Returns the [@http://mathworld.wolfram.com/ExponentialIntegral.html exponential integral]
of z:
Expand Down
6 changes: 3 additions & 3 deletions doc/sf/gegenbauer.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
namespace boost{ namespace math{

template<typename Real>
Real gegenbauer(unsigned n, Real lambda, Real x);
BOOST_MATH_GPU_ENABLED Real gegenbauer(unsigned n, Real lambda, Real x);

template<typename Real>
Real gegenbauer_prime(unsigned n, Real lambda, Real x);
BOOST_MATH_GPU_ENABLED Real gegenbauer_prime(unsigned n, Real lambda, Real x);

template<typename Real>
Real gegenbauer_derivative(unsigned n, Real lambda, Real x, unsigned k);
BOOST_MATH_GPU_ENABLED Real gegenbauer_derivative(unsigned n, Real lambda, Real x, unsigned k);

}} // namespaces

Expand Down
51 changes: 43 additions & 8 deletions doc/sf/hankel.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,36 @@

[h4 Synopsis]

#if !defined(__CUDACC__) && !defined(__CUDACC_RTC__)

template <class T1, class T2>
std::complex<``__sf_result``> cyl_hankel_1(T1 v, T2 x);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> cyl_hankel_1(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
std::complex<``__sf_result``> cyl_hankel_1(T1 v, T2 x, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> cyl_hankel_1(T1 v, T2 x, const ``__Policy``&);

template <class T1, class T2>
std::complex<``__sf_result``> cyl_hankel_2(T1 v, T2 x);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> cyl_hankel_2(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
std::complex<``__sf_result``> cyl_hankel_2(T1 v, T2 x, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> cyl_hankel_2(T1 v, T2 x, const ``__Policy``&);

#else // When using cuda we use namespace cuda::std:: instead of std::

template <class T1, class T2>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> cyl_hankel_1(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> cyl_hankel_1(T1 v, T2 x, const ``__Policy``&);

template <class T1, class T2>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> cyl_hankel_2(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> cyl_hankel_2(T1 v, T2 x, const ``__Policy``&);

#endif


[h4 Description]

Expand Down Expand Up @@ -77,18 +95,35 @@ routines for integer order are used.

[h4 Synopsis]

#if !defined(__CUDACC__) && !defined(__CUDACC_RTC__)

template <class T1, class T2>
std::complex<``__sf_result``> sph_hankel_1(T1 v, T2 x);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> sph_hankel_1(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
std::complex<``__sf_result``> sph_hankel_1(T1 v, T2 x, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> sph_hankel_1(T1 v, T2 x, const ``__Policy``&);

template <class T1, class T2>
std::complex<``__sf_result``> sph_hankel_2(T1 v, T2 x);
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> sph_hankel_2(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
BOOST_MATH_GPU_ENABLED std::complex<``__sf_result``> sph_hankel_2(T1 v, T2 x, const ``__Policy``&);

#else // When using cuda we use namespace cuda::std:: instead of std::

template <class T1, class T2>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> sph_hankel_1(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
std::complex<``__sf_result``> sph_hankel_2(T1 v, T2 x, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> sph_hankel_1(T1 v, T2 x, const ``__Policy``&);

template <class T1, class T2>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> sph_hankel_2(T1 v, T2 x);

template <class T1, class T2, class ``__Policy``>
BOOST_MATH_GPU_ENABLED cuda::std::complex<``__sf_result``> sph_hankel_2(T1 v, T2 x, const ``__Policy``&);

#endif

[h4 Description]

Expand Down
12 changes: 6 additions & 6 deletions doc/sf/hermite.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
namespace boost{ namespace math{

template <class T>
``__sf_result`` hermite(unsigned n, T x);
BOOST_MATH_GPU_ENABLED ``__sf_result`` hermite(unsigned n, T x);

template <class T, class ``__Policy``>
``__sf_result`` hermite(unsigned n, T x, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` hermite(unsigned n, T x, const ``__Policy``&);

template <class T1, class T2, class T3>
``__sf_result`` hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);
BOOST_MATH_GPU_ENABLED ``__sf_result`` hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);

}} // namespaces

Expand All @@ -26,10 +26,10 @@ note than when there is a single template argument the result is the same type
as that argument or `double` if the template argument is an integer type.

template <class T>
``__sf_result`` hermite(unsigned n, T x);
BOOST_MATH_GPU_ENABLED ``__sf_result`` hermite(unsigned n, T x);

template <class T, class ``__Policy``>
``__sf_result`` hermite(unsigned n, T x, const ``__Policy``&);
BOOST_MATH_GPU_ENABLED ``__sf_result`` hermite(unsigned n, T x, const ``__Policy``&);

Returns the value of the Hermite Polynomial of order /n/ at point /x/:

Expand All @@ -43,7 +43,7 @@ Hermite Polynomials:
[graph hermite]

template <class T1, class T2, class T3>
``__sf_result`` hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);
BOOST_MATH_GPU_ENABLED ``__sf_result`` hermite_next(unsigned n, T1 x, T2 Hn, T3 Hnm1);

Implements the three term recurrence relation for the Hermite
polynomials, this function can be used to create a sequence of
Expand Down
44 changes: 0 additions & 44 deletions include/boost/math/special_functions/bessel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,50 +47,6 @@

namespace boost{ namespace math{

// Since we cannot pull this in from math fwd we need a copy
#ifdef BOOST_MATH_HAS_NVRTC

namespace detail{

typedef boost::math::integral_constant<int, 0> bessel_no_int_tag; // No integer optimisation possible.
typedef boost::math::integral_constant<int, 1> bessel_maybe_int_tag; // Maybe integer optimisation.
typedef boost::math::integral_constant<int, 2> bessel_int_tag; // Definite integer optimisation.

template <class T1, class T2, class Policy>
struct bessel_traits
{
using result_type = typename boost::math::conditional<
boost::math::is_integral<T1>::value,
typename tools::promote_args<T2>::type,
tools::promote_args_t<T1, T2>
>::type;

typedef typename policies::precision<result_type, Policy>::type precision_type;

using optimisation_tag = typename boost::math::conditional<
(precision_type::value <= 0 || precision_type::value > 64),
bessel_no_int_tag,
typename boost::math::conditional<
boost::math::is_integral<T1>::value,
bessel_int_tag,
bessel_maybe_int_tag
>::type
>::type;

using optimisation_tag128 = typename boost::math::conditional<
(precision_type::value <= 0 || precision_type::value > 113),
bessel_no_int_tag,
typename boost::math::conditional<
boost::math::is_integral<T1>::value,
bessel_int_tag,
bessel_maybe_int_tag
>::type
>::type;
};
} // detail

#endif

namespace detail{

template <class T, class Policy>
Expand Down
Loading