Skip to content

Commit

Permalink
add type trait 'remove_restrict'
Browse files Browse the repository at this point in the history
fix alpaka-group#1472

Provide a type trait to remove __restrict__ from a type.
  • Loading branch information
psychocoderHPC committed Nov 26, 2021
1 parent c0510df commit ef8815a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/alpaka/alpaka.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include <alpaka/core/Hip.hpp>
#include <alpaka/core/OmpSchedule.hpp>
#include <alpaka/core/Positioning.hpp>
#include <alpaka/core/RemoveRestrict.hpp>
#include <alpaka/core/Unroll.hpp>
#include <alpaka/core/Unused.hpp>
#include <alpaka/core/Utility.hpp>
Expand Down
40 changes: 40 additions & 0 deletions include/alpaka/core/RemoveRestrict.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright 2021 Rene Widera
*
* This file is part of alpaka.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#pragma once

#include <alpaka/core/BoostPredef.hpp>

namespace alpaka
{
//! Removes __restrict__ from a type
template<typename T>
struct remove_restrict
{
using type = T;
};

#if BOOST_COMP_MSVC
template<typename T>
struct remove_restrict<T* __restrict>
{
using type = T*;
};
#else
template<typename T>
struct remove_restrict<T* __restrict__>
{
using type = T*;
};
#endif

//! Helper to remove __restrict__ from a type
template<typename T>
using remove_restrict_t = typename remove_restrict<T>::type;
} // namespace alpaka
3 changes: 2 additions & 1 deletion include/alpaka/kernel/TaskKernelGpuUniformCudaHipRt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
// Implementation details.
# include <alpaka/acc/AccGpuUniformCudaHipRt.hpp>
# include <alpaka/core/Decay.hpp>
# include <alpaka/core/RemoveRestrict.hpp>
# include <alpaka/core/Unused.hpp>
# include <alpaka/dev/DevUniformCudaHipRt.hpp>
# include <alpaka/kernel/Traits.hpp>
Expand Down Expand Up @@ -75,7 +76,7 @@ namespace alpaka
__global__ void uniformCudaHipKernel(
Vec<TDim, TIdx> const threadElemExtent,
TKernelFnObj const kernelFnObj,
TArgs... args)
remove_restrict_t<TArgs>... args)
{
# if BOOST_ARCH_PTX && (BOOST_ARCH_PTX < BOOST_VERSION_NUMBER(2, 0, 0))
# error "Device capability >= 2.0 is required!"
Expand Down

0 comments on commit ef8815a

Please sign in to comment.