General USM: malloc (1)

sycl::malloc

void *sycl::malloc(
    size_t num_bytes,
    const sycl::device& dev,
    const sycl::context& ctxt,
    usm::alloc kind
);
template <typename T>
T *sycl::malloc(
    size_t count, 
    const sycl::device& dev,
    const sycl::context& ctxt,
    usm::alloc kind
);

Parameters

size_t num_bytes

Number of bytes to allocate

size_t count

Number of elements of type T to allocate

const sycl::device& dev

The SYCL device on which to allocate (if applicable)

const sycl::context& ctxt

The SYCL context to which device belongs

usm::alloc kind

The type of allocation to perform

Return Value

Returns a pointer to the newly allocated kind memory on the specified device on success. If kind is alloc::host, dev is ignored. Memory allocated by sycl::malloc must be deallocated with sycl::free in order to avoid memory leaks.

Returns nullptr on failure.