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

Fix try_reserve_shmem #540

Merged
merged 1 commit into from
Jul 13, 2024
Merged
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
23 changes: 15 additions & 8 deletions include/cuco/detail/hyperloglog/hyperloglog_ref.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,22 @@ class hyperloglog_ref {
* @returns True iff kernel configuration is succesful
*/
template <typename Kernel>
[[nodiscard]] __host__ constexpr bool try_reserve_shmem(Kernel kernel,
int shmem_bytes) const noexcept
[[nodiscard]] __host__ constexpr bool try_reserve_shmem(Kernel kernel, int shmem_bytes) const
{
bool const ret =
cudaSuccess == cudaFuncSetAttribute(reinterpret_cast<void const*>(kernel),
cudaFuncAttributeMaxDynamicSharedMemorySize,
shmem_bytes);
cudaGetLastError(); // flush CUDA error
return ret;
int device = -1;
CUCO_CUDA_TRY(cudaGetDevice(&device));
int max_shmem_bytes = 0;
CUCO_CUDA_TRY(
cudaDeviceGetAttribute(&max_shmem_bytes, cudaDevAttrMaxSharedMemoryPerBlockOptin, device));

if (shmem_bytes <= max_shmem_bytes) {
CUCO_CUDA_TRY(cudaFuncSetAttribute(reinterpret_cast<void const*>(kernel),
cudaFuncAttributeMaxDynamicSharedMemorySize,
shmem_bytes));
return true;
} else {
return false;
}
}

hasher hash_; ///< Hash function used to hash items
Expand Down
Loading