-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Contributes to #110 Depends on #314 This PR: - deprecates `cuco::pair_type` alias - fixes issues with `cuco::make_pair` - separates `pair` declarations and implementation details
- Loading branch information
1 parent
c0cce86
commit 88ff1e4
Showing
40 changed files
with
567 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <type_traits> | ||
#include <utility> | ||
|
||
namespace cuco { | ||
|
||
template <typename First, typename Second> | ||
__host__ __device__ constexpr pair<First, Second>::pair(First const& f, Second const& s) | ||
: first{f}, second{s} | ||
{ | ||
} | ||
|
||
template <typename First, typename Second> | ||
template <typename F, typename S> | ||
__host__ __device__ constexpr pair<First, Second>::pair(pair<F, S> const& p) | ||
: first{p.first}, second{p.second} | ||
{ | ||
} | ||
|
||
template <typename F, typename S> | ||
__host__ __device__ constexpr pair<std::decay_t<F>, std::decay_t<S>> make_pair(F&& f, | ||
S&& s) noexcept | ||
{ | ||
return pair<std::decay_t<F>, std::decay_t<S>>(std::forward<F>(f), std::forward<S>(s)); | ||
} | ||
|
||
template <class T1, class T2, class U1, class U2> | ||
__host__ __device__ constexpr bool operator==(cuco::pair<T1, T2> const& lhs, | ||
cuco::pair<U1, U2> const& rhs) noexcept | ||
{ | ||
return lhs.first == rhs.first and lhs.second == rhs.second; | ||
} | ||
|
||
} // namespace cuco |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <thrust/device_reference.h> | ||
#include <thrust/tuple.h> | ||
|
||
#include <cuda/std/tuple> | ||
#include <cuda/std/type_traits> | ||
|
||
namespace cuco::detail { | ||
|
||
template <typename T, typename = void> | ||
struct is_std_pair_like : cuda::std::false_type { | ||
}; | ||
|
||
template <typename T> | ||
struct is_std_pair_like<T, | ||
cuda::std::void_t<decltype(cuda::std::get<0>(cuda::std::declval<T>())), | ||
decltype(cuda::std::get<1>(cuda::std::declval<T>()))>> | ||
: cuda::std::conditional_t<cuda::std::tuple_size<T>::value == 2, | ||
cuda::std::true_type, | ||
cuda::std::false_type> { | ||
}; | ||
|
||
template <typename T, typename = void> | ||
struct is_thrust_pair_like_impl : cuda::std::false_type { | ||
}; | ||
|
||
template <typename T> | ||
struct is_thrust_pair_like_impl< | ||
T, | ||
cuda::std::void_t<decltype(thrust::get<0>(cuda::std::declval<T>())), | ||
decltype(thrust::get<1>(cuda::std::declval<T>()))>> | ||
: cuda::std::conditional_t<thrust::tuple_size<T>::value == 2, | ||
cuda::std::true_type, | ||
cuda::std::false_type> { | ||
}; | ||
|
||
template <typename T> | ||
struct is_thrust_pair_like | ||
: is_thrust_pair_like_impl<cuda::std::remove_reference_t<decltype(thrust::raw_reference_cast( | ||
cuda::std::declval<T>()))>> { | ||
}; | ||
|
||
} // namespace cuco::detail |
Oops, something went wrong.