Explicit USM: aligned_alloc (2)

aligned_alloc_device

void* sycl::aligned_alloc_device(
    size_t alignment,
    size_t size,
    const sycl::queue& q
);
template <typename T>
T* sycl::aligned_alloc_device(
    size_t alignment,
    size_t count,
    const sycl::queue& q
);

Parameters

size_t alignment

Specifies the byte alignment. Must be a valid alignment supported by the implementation.

size_t size

Number of bytes to allocate.

size_t count

Number of elements of type T to allocate.

const sycl::queue& q

The SYCL q that provides the device and context to allocate against.

Return Value

Returns a pointer to the newly allocated memory on the device associated with q on success. Memory allocated by sycl::aligned_alloc_device must be deallocated with sycl::free to avoid memory leaks.

Returns nullptr on failure.