diff --git a/libcudacxx/include/cuda/__memory_resource/any_resource.h b/libcudacxx/include/cuda/__memory_resource/any_resource.h index f8410abdb13..72b13f5653b 100644 --- a/libcudacxx/include/cuda/__memory_resource/any_resource.h +++ b/libcudacxx/include/cuda/__memory_resource/any_resource.h @@ -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 @@ -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 @@ -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 @@ -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 @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/libcudacxx/include/cuda/__memory_resource/shared_resource.h b/libcudacxx/include/cuda/__memory_resource/shared_resource.h index 1a2afc59e05..9326af38a54 100644 --- a/libcudacxx/include/cuda/__memory_resource/shared_resource.h +++ b/libcudacxx/include/cuda/__memory_resource/shared_resource.h @@ -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); } @@ -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); } @@ -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); } @@ -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); } diff --git a/libcudacxx/include/cuda/__memory_resource/synchronous_resource_adapter.h b/libcudacxx/include/cuda/__memory_resource/synchronous_resource_adapter.h index 65eecbcbe0f..1569b3382e5 100644 --- a/libcudacxx/include/cuda/__memory_resource/synchronous_resource_adapter.h +++ b/libcudacxx/include/cuda/__memory_resource/synchronous_resource_adapter.h @@ -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>) { @@ -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>) { @@ -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); }