General USM: aligned_alloc (2)

sycl::aligned_alloc

void *sycl::aligned_alloc(
    size_t alignment,
    size_t num_bytes,
    const sycl::queue& q,
    usm::alloc kind
);
template <typename T>
T* sycl::aligned_alloc(
    size_t alignment,
    size_t count,
    const sycl::queue& q,
    usm::alloc kind
);

Parameters

size_t alignment

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

size_t num_bytes

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 (if applicable) and context to allocate against.

usm::alloc kind

The type of allocation to perform.

Return Value

Returns a pointer to the newly allocated kind memory on success. Memory allocated by sycl::aligned_alloc must be deallocated with sycl::free to avoid memory leaks.

Returns nullptr on failure.