Skip to content

Commit 22028e6

Browse files
committed
Minor fixes
1 parent c40de5a commit 22028e6

2 files changed

Lines changed: 15 additions & 29 deletions

File tree

include/cuco/bucket_storage.cuh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <memory>
3131

3232
namespace cuco {
33+
3334
/**
3435
* @brief Non-owning array of slots storage reference type.
3536
*
@@ -40,10 +41,14 @@ namespace cuco {
4041
template <typename T, int32_t BucketSize, typename Extent = cuco::extent<std::size_t>>
4142
class bucket_storage_ref {
4243
public:
43-
static constexpr int32_t bucket_size = BucketSize; ///< Number of elements processed per bucket
44-
using bucket_type = cuda::std::array<T, BucketSize>; ///< Slot bucket type
45-
static constexpr std::size_t alignment = cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)),
46-
std::size_t{16}); ///< Required alignment
44+
static constexpr int32_t bucket_size = BucketSize; ///< Number of elements per bucket
45+
static constexpr std::size_t max_vector_load_bytes = 16; ///< Maximum vector load width in bytes
46+
47+
using bucket_type = cuda::std::array<T, BucketSize>; ///< Slot bucket type
48+
49+
static constexpr std::size_t alignment =
50+
cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)),
51+
max_vector_load_bytes); ///< Required alignment in bytes
4752

4853
using extent_type = Extent; ///< Storage extent type
4954
using size_type = typename extent_type::value_type; ///< Storage size type

tests/utility/storage_test.cu

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ TEMPLATE_TEST_CASE_SIG("utility storage tests",
107107
cuco::bucket_storage_ref<cuco::pair<Key, Value>, bucket_size, cuco::extent<std::size_t>>;
108108
using bucket_type = typename storage_ref_type::bucket_type;
109109

110-
constexpr auto alignment = storage_ref_type::alignment;
111-
constexpr auto expected_align =
112-
cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)), std::size_t{16});
110+
constexpr auto alignment = storage_ref_type::alignment;
111+
constexpr auto expected_align = cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)),
112+
storage_ref_type::max_vector_load_bytes);
113113

114114
STATIC_REQUIRE(alignment == expected_align);
115115
STATIC_REQUIRE(cuda::std::has_single_bit(alignment));
@@ -120,9 +120,9 @@ TEMPLATE_TEST_CASE_SIG("utility storage tests",
120120
using storage_ref_type = cuco::bucket_storage_ref<Key, bucket_size, cuco::extent<std::size_t>>;
121121
using bucket_type = typename storage_ref_type::bucket_type;
122122

123-
constexpr auto alignment = storage_ref_type::alignment;
124-
constexpr auto expected_align =
125-
cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)), std::size_t{16});
123+
constexpr auto alignment = storage_ref_type::alignment;
124+
constexpr auto expected_align = cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)),
125+
storage_ref_type::max_vector_load_bytes);
126126

127127
STATIC_REQUIRE(alignment == expected_align);
128128
STATIC_REQUIRE(cuda::std::has_single_bit(alignment));
@@ -172,28 +172,9 @@ TEMPLATE_TEST_CASE_SIG("bucket storage alignment with different bucket sizes",
172172
using storage_type =
173173
cuco::bucket_storage<T, BucketSize, cuco::extent<std::size_t>, allocator_type>;
174174
using storage_ref_type = typename storage_type::ref_type;
175-
using bucket_type = typename storage_ref_type::bucket_type;
176175

177176
auto allocator = allocator_type{};
178177

179-
SECTION("Alignment constant is power of 2 and capped at 16.")
180-
{
181-
constexpr auto alignment = storage_ref_type::alignment;
182-
183-
STATIC_REQUIRE(cuda::std::has_single_bit(alignment));
184-
STATIC_REQUIRE(alignment <= 16);
185-
STATIC_REQUIRE(alignment >= sizeof(T));
186-
}
187-
188-
SECTION("Alignment matches expected value.")
189-
{
190-
constexpr auto alignment = storage_ref_type::alignment;
191-
constexpr auto expected =
192-
cuda::std::min(cuda::std::bit_ceil(sizeof(bucket_type)), std::size_t{16});
193-
194-
STATIC_REQUIRE(alignment == expected);
195-
}
196-
197178
SECTION("Data pointer is aligned to bucket boundary.")
198179
{
199180
auto s = storage_type(cuco::extent{size}, allocator, cuda::stream_ref{cudaStream_t{nullptr}});

0 commit comments

Comments
 (0)