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

Replace ALPAKA_DECAY_T by std::decay_t #2104

Merged
merged 1 commit into from
Aug 29, 2023
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
4 changes: 2 additions & 2 deletions include/alpaka/atomic/AtomicUniformCudaHipBuiltIn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace alpaka
T const& value) -> T
{
auto* const addressAsIntegralType = reinterpretAddress(addr);
using EmulatedType = ALPAKA_DECAY_T(decltype(*addressAsIntegralType));
using EmulatedType = std::decay_t<decltype(*addressAsIntegralType)>;

// Emulating atomics with atomicCAS is mentioned in the programming guide too.
// http://docs.nvidia.com/cuda/cuda-c-programming-guide/#atomic-functions
Expand Down Expand Up @@ -117,7 +117,7 @@ namespace alpaka
T const& value) -> T
{
auto* const addressAsIntegralType = reinterpretAddress(addr);
using EmulatedType = ALPAKA_DECAY_T(decltype(*addressAsIntegralType));
using EmulatedType = std::decay_t<decltype(*addressAsIntegralType)>;
EmulatedType reinterpretedCompare = reinterpretValue(compare);
EmulatedType reinterpretedValue = reinterpretValue(value);

Expand Down
21 changes: 2 additions & 19 deletions include/alpaka/core/Decay.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2022 Sergei Bastrakov, Jan Stephan
/* Copyright 2023 Sergei Bastrakov, Jan Stephan, Bernhard Manfred Gruber
* SPDX-License-Identifier: MPL-2.0
*/

Expand All @@ -8,26 +8,9 @@

#include <type_traits>

//! Wrapper around std::decay_t for parameter pack expansion expressions
//
// Works around PGI compiler internal error when used in empty template pack
// extension as discussed in #995. It seems not possible to make a workaround
// with pure C++ tools, like an alias template, so macro it is. Note that
// there is no known issue outside of empty parameter pack expansions,
// so the normal std::decay_t can and should be used there.
//
// The choice of macro over writing typename std::decay<Type>::type explicitly
// in parameter pack expansion expressions is to avoid warnings from diagnostic
// tools, and also for brevity.
#if BOOST_COMP_PGI
# define ALPAKA_DECAY_T(Type) typename std::decay<Type>::type
#else
# define ALPAKA_DECAY_T(Type) std::decay_t<Type>
#endif

namespace alpaka
{
//! Provides a decaying wrapper around std::is_same. Example: is_decayed_v<volatile float, float> returns true.
template<typename T, typename U>
inline constexpr auto is_decayed_v = std::is_same_v<ALPAKA_DECAY_T(T), ALPAKA_DECAY_T(U)>;
inline constexpr auto is_decayed_v = std::is_same_v<std::decay_t<T>, std::decay_t<U>>;
} // namespace alpaka
4 changes: 2 additions & 2 deletions include/alpaka/kernel/TaskKernelCpuOmp2Blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ namespace alpaka

// Get the size of the block shared dynamic memory.
auto const blockSharedMemDynSizeBytes = std::apply(
[&](ALPAKA_DECAY_T(TArgs) const&... args)
[&](std::decay_t<TArgs> const&... args)
{
return getBlockSharedMemDynSizeBytes<AccCpuOmp2Blocks<TDim, TIdx>>(
m_kernelFnObj,
Expand All @@ -831,7 +831,7 @@ namespace alpaka

// Get the OpenMP schedule information for the given kernel and parameter types
auto const schedule = std::apply(
[&](ALPAKA_DECAY_T(TArgs) const&... args) {
[&](std::decay_t<TArgs> const&... args) {
return getOmpSchedule<AccCpuOmp2Blocks<TDim, TIdx>>(
m_kernelFnObj,
blockThreadExtent,
Expand Down
2 changes: 1 addition & 1 deletion include/alpaka/kernel/TaskKernelCpuOmp2Threads.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace alpaka

// Get the size of the block shared dynamic memory.
auto const blockSharedMemDynSizeBytes = std::apply(
[&](ALPAKA_DECAY_T(TArgs) const&... args)
[&](std::decay_t<TArgs> const&... args)
{
return getBlockSharedMemDynSizeBytes<AccCpuOmp2Threads<TDim, TIdx>>(
m_kernelFnObj,
Expand Down
2 changes: 1 addition & 1 deletion include/alpaka/kernel/TaskKernelCpuSerial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace alpaka

// Get the size of the block shared dynamic memory.
auto const blockSharedMemDynSizeBytes = std::apply(
[&](ALPAKA_DECAY_T(TArgs) const&... args)
[&](std::decay_t<TArgs> const&... args)
{
return getBlockSharedMemDynSizeBytes<AccCpuSerial<TDim, TIdx>>(
m_kernelFnObj,
Expand Down
2 changes: 1 addition & 1 deletion include/alpaka/kernel/TaskKernelCpuTbbBlocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace alpaka

// Get the size of the block shared dynamic memory.
auto const blockSharedMemDynSizeBytes = std::apply(
[&](ALPAKA_DECAY_T(TArgs) const&... args)
[&](std::decay_t<TArgs> const&... args)
{
return getBlockSharedMemDynSizeBytes<AccCpuTbbBlocks<TDim, TIdx>>(
m_kernelFnObj,
Expand Down
8 changes: 4 additions & 4 deletions include/alpaka/kernel/TaskKernelGpuUniformCudaHipRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ namespace alpaka

// Get the size of the block shared dynamic memory.
auto const blockSharedMemDynSizeBytes = std::apply(
[&](remove_restrict_t<ALPAKA_DECAY_T(TArgs)> const&... args) {
[&](remove_restrict_t<std::decay_t<TArgs>> const&... args) {
return getBlockSharedMemDynSizeBytes<TAcc>(
task.m_kernelFnObj,
blockThreadExtent,
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace alpaka
// (MSVC). If not given by value, the kernel launch code does not copy the value but the pointer to the
// value location.
std::apply(
[&](remove_restrict_t<ALPAKA_DECAY_T(TArgs)> const&... args)
[&](remove_restrict_t<std::decay_t<TArgs>> const&... args)
{
kernelName<<<
gridDim,
Expand Down Expand Up @@ -327,7 +327,7 @@ namespace alpaka

// Get the size of the block shared dynamic memory.
auto const blockSharedMemDynSizeBytes = std::apply(
[&](remove_restrict_t<ALPAKA_DECAY_T(TArgs)> const&... args) {
[&](remove_restrict_t<std::decay_t<TArgs>> const&... args) {
return getBlockSharedMemDynSizeBytes<TAcc>(
task.m_kernelFnObj,
blockThreadExtent,
Expand Down Expand Up @@ -361,7 +361,7 @@ namespace alpaka

// Enqueue the kernel execution.
std::apply(
[&](remove_restrict_t<ALPAKA_DECAY_T(TArgs)> const&... args)
[&](remove_restrict_t<std::decay_t<TArgs>> const&... args)
{
kernelName<<<
gridDim,
Expand Down