Skip to content
Open
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions libcudacxx/include/cuda/__memory_resource/any_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ struct __ibasic_resource : __basic_interface<__ibasic_resource>
"release.") _CCCL_PUBLIC_HOST_API void*
allocate_sync(size_t __bytes)
{
return allocate_sync(__bytes, alignof(::cuda::std::max_align_t));
return allocate_sync(__bytes, ::cuda::mr::default_cuda_malloc_alignment);
}

_CCCL_PUBLIC_HOST_API void deallocate_sync(void* __pv, size_t __bytes, size_t __alignment) noexcept
Expand All @@ -148,7 +148,7 @@ struct __ibasic_resource : __basic_interface<__ibasic_resource>
"release.") _CCCL_PUBLIC_HOST_API void
deallocate_sync(void* __pv, size_t __bytes) noexcept
{
return deallocate_sync(__pv, __bytes, alignof(::cuda::std::max_align_t));
return deallocate_sync(__pv, __bytes, ::cuda::mr::default_cuda_malloc_alignment);
}

template <class _Ty>
Expand All @@ -168,7 +168,7 @@ struct __ibasic_async_resource : __basic_interface<__ibasic_async_resource>
allocate(::cuda::stream_ref __stream, size_t __bytes)
{
return ::cuda::__virtcall<&__allocate_async<__ibasic_async_resource>>(
this, __stream, __bytes, alignof(::cuda::std::max_align_t));
this, __stream, __bytes, ::cuda::mr::default_cuda_malloc_alignment);
}

_CCCL_PUBLIC_HOST_API void
Expand All @@ -182,7 +182,7 @@ struct __ibasic_async_resource : __basic_interface<__ibasic_async_resource>
deallocate(::cuda::stream_ref __stream, void* __pv, size_t __bytes) noexcept
{
return ::cuda::__virtcall<&__deallocate_async<__ibasic_async_resource>>(
this, __stream, __pv, __bytes, alignof(::cuda::std::max_align_t));
this, __stream, __pv, __bytes, ::cuda::mr::default_cuda_malloc_alignment);
}

template <class _Ty>
Expand Down Expand Up @@ -604,7 +604,7 @@ class basic_any_resource
[[nodiscard]] void* allocate_sync(size_t __size, size_t __align);

//! @brief Calls `allocate_sync` on the wrapped object with
//! `alignof(::cuda::std::max_align_t)` as the alignment.
//! `::cuda::mr::default_cuda_malloc_alignment` as the alignment.
//! @deprecated Specify an explicit alignment argument.
//! @pre `has_value()` is `true`.
[[deprecated]] [[nodiscard]] void* allocate_sync(size_t __size);
Expand All @@ -619,7 +619,7 @@ class basic_any_resource
void deallocate_sync(void* __pv, size_t __size, size_t __align);

//! @brief Calls `deallocate_sync` on the wrapped object with
//! `alignof(::cuda::std::max_align_t)` as the alignment.
//! `::cuda::mr::default_cuda_malloc_alignment` as the alignment.
//! @deprecated Specify an explicit alignment argument.
//! @pre `has_value()` is `true`.
[[deprecated]] void deallocate_sync(void* __pv, size_t __size);
Expand All @@ -635,7 +635,7 @@ class basic_any_resource
[[nodiscard]] void* allocate(cuda::stream_ref __stream, size_t __size, size_t __align);

//! @brief Equivalent to `allocate(__stream, __size,
//! alignof(::cuda::std::max_align_t))`.
//! `::cuda::mr::default_cuda_malloc_alignment`).
//! @deprecated Specify an explicit alignment argument.
[[deprecated]] [[nodiscard]] void* allocate(cuda::stream_ref __stream, size_t __size);

Expand All @@ -650,7 +650,7 @@ class basic_any_resource
void deallocate(cuda::stream_ref __stream, void* __pv, size_t __size, size_t __align);

//! @brief Equivalent to `deallocate(__stream, __pv, __size,
//! alignof(::cuda::std::max_align_t), __stream)`.
//! `::cuda::mr::default_cuda_malloc_alignment`, __stream)`.
//! @deprecated Specify an explicit alignment argument.
[[deprecated]] void deallocate(cuda::stream_ref __stream, void* __pv, size_t __size);

Expand Down Expand Up @@ -783,7 +783,7 @@ class basic_resource_ref
[[nodiscard]] void* allocate_sync(size_t __size, size_t __align);

//! @brief Calls `allocate_sync` on the wrapped reference with
//! `alignof(::cuda::std::max_align_t)` as the alignment.
//! `::cuda::mr::default_cuda_malloc_alignment` as the alignment.
//! @deprecated Specify an explicit alignment argument.
[[deprecated]] [[nodiscard]] void* allocate_sync(size_t __size);

Expand All @@ -796,7 +796,7 @@ class basic_resource_ref
void deallocate_sync(void* __pv, size_t __size, size_t __align);

//! @brief Calls `deallocate_sync` on the wrapped reference with
//! `alignof(::cuda::std::max_align_t)` as the alignment.
//! `::cuda::mr::default_cuda_malloc_alignment` as the alignment.
//! @deprecated Specify an explicit alignment argument.
[[deprecated]] void deallocate_sync(void* __pv, size_t __size);

Expand All @@ -810,7 +810,7 @@ class basic_resource_ref
[[nodiscard]] void* allocate(cuda::stream_ref __stream, size_t __size, size_t __align);

//! @brief Equivalent to `allocate(__stream, __size,
//! alignof(::cuda::std::max_align_t))`.
//! `::cuda::mr::default_cuda_malloc_alignment`).
//! @deprecated Specify an explicit alignment argument.
[[deprecated]] [[nodiscard]] void* allocate(cuda::stream_ref __stream, size_t __size);

Expand All @@ -824,7 +824,7 @@ class basic_resource_ref
void deallocate(cuda::stream_ref __stream, void* __pv, size_t __size, size_t __align);

//! @brief Equivalent to `deallocate(__stream, __pv, __size,
//! alignof(::cuda::std::max_align_t), __stream)`.
//! `::cuda::mr::default_cuda_malloc_alignment`, __stream)`.
//! @deprecated Specify an explicit alignment argument.
[[deprecated]] void deallocate(cuda::stream_ref __stream, void* __pv, size_t __size);

Expand Down
13 changes: 9 additions & 4 deletions libcudacxx/include/cuda/__memory_resource/shared_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ struct shared_resource
//! @param __bytes The size in bytes of the allocation.
//! @param __alignment The requested alignment of the allocation.
//! @return Pointer to the newly allocated memory
[[nodiscard]] void* allocate_sync(size_t __bytes, size_t __alignment = alignof(::cuda::std::max_align_t))
[[nodiscard]] void* allocate_sync(size_t __bytes, size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment)
{
return __control_block->__resource.allocate_sync(__bytes, __alignment);
}
Expand All @@ -196,7 +196,8 @@ struct shared_resource
//! @param __ptr Pointer to be deallocated. Must have been allocated through a call to `allocate` or `allocate_sync`
//! @param __bytes The number of bytes that was passed to the allocation call that returned \p __ptr.
//! @param __alignment The alignment that was passed to the allocation call that returned \p __ptr.
void deallocate_sync(void* __ptr, size_t __bytes, size_t __alignment = alignof(::cuda::std::max_align_t)) noexcept
void
deallocate_sync(void* __ptr, size_t __bytes, size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment) noexcept
{
__control_block->__resource.deallocate_sync(__ptr, __bytes, __alignment);
}
Expand All @@ -212,7 +213,8 @@ struct shared_resource
//! operation has completed.
_CCCL_TEMPLATE(class _ThisResource = _Resource)
_CCCL_REQUIRES(::cuda::mr::resource<_ThisResource>)
[[nodiscard]] void* allocate(::cuda::stream_ref __stream, size_t __bytes, size_t __alignment)
[[nodiscard]] void*
allocate(::cuda::stream_ref __stream, size_t __bytes, size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment)
{
return this->__control_block->__resource.allocate(__stream, __bytes, __alignment);
}
Expand All @@ -228,7 +230,10 @@ struct shared_resource
//! operation has completed.
_CCCL_TEMPLATE(class _ThisResource = _Resource)
_CCCL_REQUIRES(::cuda::mr::resource<_ThisResource>)
void deallocate(::cuda::stream_ref __stream, void* __ptr, size_t __bytes, size_t __alignment) noexcept
void deallocate(::cuda::stream_ref __stream,
void* __ptr,
size_t __bytes,
size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment) noexcept
{
this->__control_block->__resource.deallocate(__stream, __ptr, __bytes, __alignment);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ struct synchronous_resource_adapter
{}

[[nodiscard]] _CCCL_HOST_API void*
allocate([[maybe_unused]] const ::cuda::stream_ref __stream, const size_t __bytes, const size_t __alignment)
allocate([[maybe_unused]] const ::cuda::stream_ref __stream,
const size_t __bytes,
const size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment)
{
if constexpr (__has_member_allocate<_Resource>)
{
Expand All @@ -76,13 +78,17 @@ struct synchronous_resource_adapter
}
}

[[nodiscard]] _CCCL_HOST_API void* allocate_sync(const size_t __bytes, const size_t __alignment)
[[nodiscard]] _CCCL_HOST_API void*
allocate_sync(const size_t __bytes, const size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment)
{
return __resource.allocate_sync(__bytes, __alignment);
}

_CCCL_HOST_API void
deallocate(const ::cuda::stream_ref __stream, void* __ptr, const size_t __bytes, const size_t __alignment) noexcept
_CCCL_HOST_API void deallocate(
const ::cuda::stream_ref __stream,
void* __ptr,
const size_t __bytes,
const size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment) noexcept
{
if constexpr (__has_member_deallocate<_Resource>)
{
Expand All @@ -95,7 +101,8 @@ struct synchronous_resource_adapter
}
}

_CCCL_HOST_API void deallocate_sync(void* __ptr, const size_t __bytes, const size_t __alignment) noexcept
_CCCL_HOST_API void deallocate_sync(
void* __ptr, const size_t __bytes, const size_t __alignment = ::cuda::mr::default_cuda_malloc_alignment) noexcept
{
__resource.deallocate_sync(__ptr, __bytes, __alignment);
}
Expand Down
Loading