Skip to content

Commit

Permalink
[CUDA] Make min/max shims host+device.
Browse files Browse the repository at this point in the history
Summary:
Fixes PR37753: min/max can't be called from __host__ __device__
functions in C++14 mode.

Testcase in a separate test-suite commit.

Reviewers: rsmith

Subscribers: sanjoy, lahwaacz, cfe-commits

Differential Revision: https://reviews.llvm.org/D48036

llvm-svn: 336025
  • Loading branch information
Justin Lebar committed Jun 29, 2018
1 parent 68e1919 commit 5cb41c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clang/lib/Headers/cuda_wrappers/algorithm
Expand Up @@ -69,28 +69,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

template <class __T, class __Cmp>
__attribute__((enable_if(true, "")))
inline __device__ const __T &
inline __host__ __device__ const __T &
max(const __T &__a, const __T &__b, __Cmp __cmp) {
return __cmp(__a, __b) ? __b : __a;
}

template <class __T>
__attribute__((enable_if(true, "")))
inline __device__ const __T &
inline __host__ __device__ const __T &
max(const __T &__a, const __T &__b) {
return __a < __b ? __b : __a;
}

template <class __T, class __Cmp>
__attribute__((enable_if(true, "")))
inline __device__ const __T &
inline __host__ __device__ const __T &
min(const __T &__a, const __T &__b, __Cmp __cmp) {
return __cmp(__b, __a) ? __b : __a;
}

template <class __T>
__attribute__((enable_if(true, "")))
inline __device__ const __T &
inline __host__ __device__ const __T &
min(const __T &__a, const __T &__b) {
return __a < __b ? __a : __b;
}
Expand Down

0 comments on commit 5cb41c2

Please sign in to comment.