Skip to content

Commit 8a11f4d

Browse files
authored
Merge pull request #902 from psychocoderHPC/topic-importBackport
backport to 0.3.6
2 parents e35f9d7 + f652e15 commit 8a11f4d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+649
-321
lines changed

include/alpaka/core/Cuda.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ namespace alpaka
8585
std::cerr << sError << std::endl;
8686
#endif
8787
ALPAKA_DEBUG_BREAK;
88+
// reset the last error to allow user side error handling
89+
cudaGetLastError();
8890
throw std::runtime_error(sError);
8991
}
9092
}

include/alpaka/math/abs/AbsCudaBuiltIn.hpp

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
#ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
2525

2626
#include <alpaka/core/Common.hpp>
27+
#include <alpaka/core/Unused.hpp>
2728

2829
#if !BOOST_LANG_CUDA
2930
#error If ALPAKA_ACC_GPU_CUDA_ENABLED is set, the compiler has to support CUDA!
3031
#endif
3132

3233
#include <alpaka/math/abs/Traits.hpp>
3334

34-
//#include <boost/core/ignore_unused.hpp>
35-
3635
#include <cuda_runtime.h>
3736
#include <type_traits>
3837

@@ -42,7 +41,7 @@ namespace alpaka
4241
namespace math
4342
{
4443
//#############################################################################
45-
//! The standard library abs.
44+
//! The CUDA built in abs.
4645
class AbsCudaBuiltIn
4746
{
4847
public:
@@ -62,14 +61,44 @@ namespace alpaka
6261
std::is_floating_point<TArg>::value>::type>
6362
{
6463
ALPAKA_FN_ACC_CUDA_ONLY static auto abs(
65-
AbsCudaBuiltIn const & /*abs*/,
64+
AbsCudaBuiltIn const & abs_ctx,
6665
TArg const & arg)
6766
-> decltype(::abs(arg))
6867
{
69-
//boost::ignore_unused(abs);
68+
alpaka::ignore_unused(abs_ctx);
7069
return ::abs(arg);
7170
}
7271
};
72+
//! The CUDA built in abs double specialization.
73+
template<>
74+
struct Abs<
75+
AbsCudaBuiltIn,
76+
double>
77+
{
78+
__device__ static auto abs(
79+
AbsCudaBuiltIn const & abs_ctx,
80+
double const & arg)
81+
-> decltype(::fabs(arg))
82+
{
83+
alpaka::ignore_unused(abs_ctx);
84+
return ::fabs(arg);
85+
}
86+
};
87+
//! The CUDA built in abs float specialization.
88+
template<>
89+
struct Abs<
90+
AbsCudaBuiltIn,
91+
float>
92+
{
93+
__device__ static auto abs(
94+
AbsCudaBuiltIn const & abs_ctx,
95+
float const & arg)
96+
-> float
97+
{
98+
alpaka::ignore_unused(abs_ctx);
99+
return ::fabsf(arg);
100+
}
101+
};
73102
}
74103
}
75104
}

include/alpaka/math/abs/Traits.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ namespace alpaka
5151
//!
5252
//! \tparam T The type of the object specializing Abs.
5353
//! \tparam TArg The arg type.
54-
//! \param abs The object specializing Abs.
54+
//! \param abs_ctx The object specializing Abs.
5555
//! \param arg The arg.
5656
ALPAKA_NO_HOST_ACC_WARNING
5757
template<
5858
typename T,
5959
typename TArg>
6060
ALPAKA_FN_HOST_ACC auto abs(
61-
T const & abs,
61+
T const & abs_ctx,
6262
TArg const & arg)
6363
#ifdef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
6464
-> decltype(
6565
traits::Abs<
6666
T,
6767
TArg>
6868
::abs(
69-
abs,
69+
abs_ctx,
7070
arg))
7171
#endif
7272
{
@@ -75,7 +75,7 @@ namespace alpaka
7575
T,
7676
TArg>
7777
::abs(
78-
abs,
78+
abs_ctx,
7979
arg);
8080
}
8181

@@ -99,19 +99,19 @@ namespace alpaka
9999
//-----------------------------------------------------------------------------
100100
ALPAKA_NO_HOST_ACC_WARNING
101101
ALPAKA_FN_HOST_ACC static auto abs(
102-
T const & abs,
102+
T const & abs_ctx,
103103
TArg const & arg)
104104
#ifdef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
105105
-> decltype(
106106
math::abs(
107-
static_cast<typename T::AbsBase const &>(abs),
107+
static_cast<typename T::AbsBase const &>(abs_ctx),
108108
arg))
109109
#endif
110110
{
111111
// Delegate the call to the base class.
112112
return
113113
math::abs(
114-
static_cast<typename T::AbsBase const &>(abs),
114+
static_cast<typename T::AbsBase const &>(abs_ctx),
115115
arg);
116116
}
117117
};

include/alpaka/math/acos/AcosCudaBuiltIn.hpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@
2424
#ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
2525

2626
#include <alpaka/core/Common.hpp>
27+
#include <alpaka/core/Unused.hpp>
2728

2829
#if !BOOST_LANG_CUDA
2930
#error If ALPAKA_ACC_GPU_CUDA_ENABLED is set, the compiler has to support CUDA!
3031
#endif
3132

3233
#include <alpaka/math/acos/Traits.hpp>
3334

34-
#include <boost/core/ignore_unused.hpp>
35-
3635
#include <cuda_runtime.h>
3736
#include <type_traits>
3837

@@ -42,7 +41,7 @@ namespace alpaka
4241
namespace math
4342
{
4443
//#############################################################################
45-
//! The standard library acos.
44+
//! The CUDA built in acos.
4645
class AcosCudaBuiltIn
4746
{
4847
public:
@@ -52,7 +51,7 @@ namespace alpaka
5251
namespace traits
5352
{
5453
//#############################################################################
55-
//! The standard library acos trait specialization.
54+
//! The CUDA acos trait specialization.
5655
template<
5756
typename TArg>
5857
struct Acos<
@@ -63,14 +62,29 @@ namespace alpaka
6362
{
6463
ALPAKA_NO_HOST_ACC_WARNING
6564
ALPAKA_FN_ACC_CUDA_ONLY static auto acos(
66-
AcosCudaBuiltIn const & /*acos*/,
65+
AcosCudaBuiltIn const & acos_ctx,
6766
TArg const & arg)
6867
-> decltype(::acos(arg))
6968
{
70-
//boost::ignore_unused(acos);
69+
alpaka::ignore_unused(acos_ctx);
7170
return ::acos(arg);
7271
}
7372
};
73+
74+
template<>
75+
struct Acos<
76+
AcosCudaBuiltIn,
77+
float>
78+
{
79+
__device__ static auto acos(
80+
AcosCudaBuiltIn const & acos_ctx,
81+
float const & arg)
82+
-> float
83+
{
84+
alpaka::ignore_unused(acos_ctx);
85+
return ::acosf(arg);
86+
}
87+
};
7488
}
7589
}
7690
}

include/alpaka/math/acos/Traits.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ namespace alpaka
4848
//! Computes the principal value of the arc cosine.
4949
//!
5050
//! \tparam TArg The arg type.
51-
//! \param acos The object specializing Acos.
51+
//! \param acos_ctx The object specializing Acos.
5252
//! \param arg The arg.
5353
ALPAKA_NO_HOST_ACC_WARNING
5454
template<
5555
typename T,
5656
typename TArg>
5757
ALPAKA_FN_HOST_ACC auto acos(
58-
T const & acos,
58+
T const & acos_ctx,
5959
TArg const & arg)
6060
#ifdef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
6161
-> decltype(
6262
traits::Acos<
6363
T,
6464
TArg>
6565
::acos(
66-
acos,
66+
acos_ctx,
6767
arg))
6868
#endif
6969
{
@@ -72,7 +72,7 @@ namespace alpaka
7272
T,
7373
TArg>
7474
::acos(
75-
acos,
75+
acos_ctx,
7676
arg);
7777
}
7878

@@ -96,19 +96,19 @@ namespace alpaka
9696
//-----------------------------------------------------------------------------
9797
ALPAKA_NO_HOST_ACC_WARNING
9898
ALPAKA_FN_HOST_ACC static auto acos(
99-
T const & acos,
99+
T const & acos_ctx,
100100
TArg const & arg)
101101
#ifdef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
102102
-> decltype(
103103
math::acos(
104-
static_cast<typename T::AcosBase const &>(acos),
104+
static_cast<typename T::AcosBase const &>(acos_ctx),
105105
arg))
106106
#endif
107107
{
108108
// Delegate the call to the base class.
109109
return
110110
math::acos(
111-
static_cast<typename T::AcosBase const &>(acos),
111+
static_cast<typename T::AcosBase const &>(acos_ctx),
112112
arg);
113113
}
114114
};

include/alpaka/math/asin/AsinCudaBuiltIn.hpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#ifdef ALPAKA_ACC_GPU_CUDA_ENABLED
2525

2626
#include <alpaka/core/Common.hpp>
27+
#include <alpaka/core/Unused.hpp>
2728

2829
#if !BOOST_LANG_CUDA
2930
#error If ALPAKA_ACC_GPU_CUDA_ENABLED is set, the compiler has to support CUDA!
@@ -42,7 +43,7 @@ namespace alpaka
4243
namespace math
4344
{
4445
//#############################################################################
45-
//! The standard library asin.
46+
//! The CUDA built in asin.
4647
class AsinCudaBuiltIn
4748
{
4849
public:
@@ -52,7 +53,7 @@ namespace alpaka
5253
namespace traits
5354
{
5455
//#############################################################################
55-
//! The standard library asin trait specialization.
56+
//! The CUDA asin trait specialization.
5657
template<
5758
typename TArg>
5859
struct Asin<
@@ -62,14 +63,29 @@ namespace alpaka
6263
std::is_floating_point<TArg>::value>::type>
6364
{
6465
ALPAKA_FN_ACC_CUDA_ONLY static auto asin(
65-
AsinCudaBuiltIn const & /*asin*/,
66+
AsinCudaBuiltIn const & asin_ctx,
6667
TArg const & arg)
6768
-> decltype(::asin(arg))
6869
{
69-
//boost::ignore_unused(asin);
70+
alpaka::ignore_unused(asin_ctx);
7071
return ::asin(arg);
7172
}
7273
};
74+
75+
template<>
76+
struct Asin<
77+
AsinCudaBuiltIn,
78+
float>
79+
{
80+
__device__ static auto asin(
81+
AsinCudaBuiltIn const & asin_ctx,
82+
float const & arg)
83+
-> float
84+
{
85+
alpaka::ignore_unused(asin_ctx);
86+
return ::asinf(arg);
87+
}
88+
};
7389
}
7490
}
7591
}

include/alpaka/math/asin/Traits.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,22 @@ namespace alpaka
4848
//! Computes the principal value of the arc sine.
4949
//!
5050
//! \tparam TArg The arg type.
51-
//! \param asin The object specializing Asin.
51+
//! \param asin_ctx The object specializing Asin.
5252
//! \param arg The arg.
5353
ALPAKA_NO_HOST_ACC_WARNING
5454
template<
5555
typename T,
5656
typename TArg>
5757
ALPAKA_FN_HOST_ACC auto asin(
58-
T const & asin,
58+
T const & asin_ctx,
5959
TArg const & arg)
6060
#ifdef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
6161
-> decltype(
6262
traits::Asin<
6363
T,
6464
TArg>
6565
::asin(
66-
asin,
66+
asin_ctx,
6767
arg))
6868
#endif
6969
{
@@ -72,7 +72,7 @@ namespace alpaka
7272
T,
7373
TArg>
7474
::asin(
75-
asin,
75+
asin_ctx,
7676
arg);
7777
}
7878

@@ -96,19 +96,19 @@ namespace alpaka
9696
//-----------------------------------------------------------------------------
9797
ALPAKA_NO_HOST_ACC_WARNING
9898
ALPAKA_FN_HOST_ACC static auto asin(
99-
T const & asin,
99+
T const & asin_ctx,
100100
TArg const & arg)
101101
#ifdef BOOST_NO_CXX14_RETURN_TYPE_DEDUCTION
102102
-> decltype(
103103
math::asin(
104-
static_cast<typename T::AsinBase const &>(asin),
104+
static_cast<typename T::AsinBase const &>(asin_ctx),
105105
arg))
106106
#endif
107107
{
108108
// Delegate the call to the base class.
109109
return
110110
math::asin(
111-
static_cast<typename T::AsinBase const &>(asin),
111+
static_cast<typename T::AsinBase const &>(asin_ctx),
112112
arg);
113113
}
114114
};

0 commit comments

Comments
 (0)