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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace cuda
{
namespace std
{
inline __device__ void* aligned_alloc(__SIZE_TYPE__ __nbytes, __SIZE_TYPE__ __align) noexcept
inline __device__ void* aligned_alloc(__SIZE_TYPE__ __align, __SIZE_TYPE__ __nbytes) noexcept
{
return ::__cuda_syscall_aligned_malloc(__nbytes, __align);
}
Expand All @@ -59,13 +59,13 @@ namespace cuda
{
namespace std
{
inline void* __aligned_alloc_host(__SIZE_TYPE__ __nbytes, __SIZE_TYPE__) noexcept
inline void* __aligned_alloc_host(__SIZE_TYPE__, __SIZE_TYPE__ __nbytes) noexcept
{
return __builtin_malloc(__nbytes);
}
inline void* aligned_alloc(__SIZE_TYPE__ __nbytes, __SIZE_TYPE__ __align) noexcept
inline void* aligned_alloc(__SIZE_TYPE__ __align, __SIZE_TYPE__ __nbytes) noexcept
{
return ::cuda::std::__aligned_alloc_host(__nbytes, __align);
return ::cuda::std::__aligned_alloc_host(__align, __nbytes);
}
} // namespace std
} // namespace cuda
Expand Down
8 changes: 4 additions & 4 deletions libcudacxx/include/cuda/std/__cstdlib/aligned_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
#include <cuda/std/__cccl/prologue.h>

#if _CCCL_CUDA_COMPILATION()
extern "C" _CCCL_DEVICE void* __cuda_syscall_aligned_malloc(size_t, size_t);
extern "C" _CCCL_DEVICE void* __cuda_syscall_aligned_malloc(size_t __nbytes, size_t __align);
#endif // _CCCL_CUDA_COMPILATION()

_CCCL_BEGIN_NAMESPACE_CUDA_STD

#if !_CCCL_COMPILER(NVRTC)
[[nodiscard]] _CCCL_HOST_API inline void*
__aligned_alloc_host([[maybe_unused]] size_t __nbytes, [[maybe_unused]] size_t __align) noexcept
__aligned_alloc_host([[maybe_unused]] size_t __align, [[maybe_unused]] size_t __nbytes) noexcept
Comment thread
davebayer marked this conversation as resolved.
{
# if _CCCL_OS(WINDOWS)
_CCCL_ASSERT(false, "Use of aligned_alloc in host code is not supported on WIndows");
Expand All @@ -52,10 +52,10 @@ __aligned_alloc_host([[maybe_unused]] size_t __nbytes, [[maybe_unused]] size_t _
}
#endif // !_CCCL_COMPILER(NVRTC)

[[nodiscard]] _CCCL_API inline void* aligned_alloc(size_t __nbytes, size_t __align) noexcept
[[nodiscard]] _CCCL_API inline void* aligned_alloc(size_t __align, size_t __nbytes) noexcept
{
NV_IF_ELSE_TARGET(NV_IS_HOST,
(return ::cuda::std::__aligned_alloc_host(__nbytes, __align);),
(return ::cuda::std::__aligned_alloc_host(__align, __nbytes);),
(return ::__cuda_syscall_aligned_malloc(__nbytes, __align);))
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ TEST_DIAG_SUPPRESS_MSVC(4324) // padding was added at the end of a structure bec
template <class T>
TEST_FUNC void test_aligned_alloc(bool expect_success, cuda::std::size_t n, cuda::std::size_t align = alignof(T))
{
static_assert(noexcept(cuda::std::aligned_alloc(n * sizeof(T), align)));
T* ptr = static_cast<T*>(cuda::std::aligned_alloc(n * sizeof(T), align));
static_assert(noexcept(cuda::std::aligned_alloc(align, n * sizeof(T))));
T* ptr = static_cast<T*>(cuda::std::aligned_alloc(align, n * sizeof(T)));
if (expect_success)
{
// check that the memory was allocated
Expand Down
Loading