Restricted USM: malloc_shared (1)

sycl::malloc_shared

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

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

const sycl::context& ctxt

The SYCL context to which device belongs

Return Value

Returns a pointer to the newly allocated shared memory on the specified device on success. Memory allocated by sycl::malloc_shared must be deallocated with sycl::free in order to avoid memory leaks.

Returns nullptr on failure.