Skip to content

Commit 0c32410

Browse files
jbrodmanbader
authored andcommitted
[SYCL][USM][Doc] Add USM alloc routines that take queues (#833)
Fix typos. Signed-off-by: James Brodman <[email protected]>
1 parent 25bbe42 commit 0c32410

File tree

1 file changed

+128
-17
lines changed

1 file changed

+128
-17
lines changed

sycl/doc/extensions/USM/USM.adoc

Lines changed: 128 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
= SYCL(TM) Proposals: Unified Shared Memory
22
James Brodman <james[email protected]>; Ben Ashbaugh <ben[email protected]>; Michael Kinsner <michael[email protected]>
3-
v0.9
3+
v0.99
44
:source-highlighter: pygments
55
:icons: font
66
:y: icon:check[role="green"]
@@ -145,6 +145,7 @@ public:
145145
146146
usm_allocator();
147147
usm_allocator(const context &ctxt, const device &dev);
148+
usm_allocator(const queue &q);
148149
usm_allocator(const usm_allocator &other);
149150
150151
// Construct an object
@@ -229,15 +230,27 @@ void* sycl::malloc_device(size_t size,
229230
Parameters::
230231
* `size_t size` - number of bytes to allocate
231232
* `const sycl::device& dev` - the SYCL `device` to allocate on
232-
* `const sycl::context& dev` - the SYCL `context` to which `device` belongs
233+
* `const sycl::context& ctxt` - the SYCL `context` to which `device` belongs
233234

234235
Return value:: Returns a pointer to the newly allocated memory on the specified `device` on success. Memory allocated by `sycl::malloc_device` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
235236

237+
[source,cpp]
238+
----
239+
void* sycl::malloc_device(size_t size,
240+
const sycl::queue& q);
241+
----
242+
243+
Parameters::
244+
* `size_t size` - number of bytes to allocate
245+
* `const sycl::queue& q` - the SYCL `q` that provides the `device` and `context` to allocate against
246+
247+
Return value:: Returns a pointer to the newly allocated memory on the `device` associated with `q` on success. Memory allocated by `sycl::malloc_device` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
248+
236249
===== aligned_alloc
237250
[source,cpp]
238251
----
239-
void* sycl::aligned_alloc_device(size_t alignment,
240-
size_t size,
252+
void* sycl::aligned_alloc_device(size_t alignment,
253+
size_t size,
241254
const sycl::device& dev,
242255
const sycl::context& ctxt);
243256
----
@@ -246,9 +259,23 @@ Parameters::
246259
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
247260
* `size_t size` - number of bytes to allocate
248261
* `const sycl::device& dev` - the `device` to allocate on
249-
* `const sycl::context& dev` - the SYCL `context` to which `device` belongs
262+
* `const sycl::context& ctxt` - the SYCL `context` to which `device` belongs
250263
Return value:: Returns a pointer to the newly allocated memory on the specified `device` on success. Memory allocated by `sycl::aligned_alloc_device` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
251264

265+
[source,cpp]
266+
----
267+
void* sycl::aligned_alloc_device(size_t alignment,
268+
size_t size,
269+
const sycl::queue& q);
270+
----
271+
272+
Parameters::
273+
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
274+
* `size_t size` - number of bytes to allocate
275+
* `const sycl::queue& q` - the SYCL `q` that provides the `device` and `context` to allocate against
276+
277+
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. On failure, returns `nullptr`.
278+
252279
===== memcpy
253280
[source,cpp]
254281
----
@@ -310,6 +337,16 @@ Parameters::
310337
* `const sycl::context& ctxt` - the SYCL `context` that contains the devices that will access the `host` allocation
311338
Return value:: Returns a pointer to the newly allocated `host` memory on success. Memory allocated by `sycl::malloc_host` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
312339

340+
[source,cpp]
341+
----
342+
void* sycl::malloc_host(size_t size, const sycl::queue& q);
343+
----
344+
345+
Parameters::
346+
* `size_t size` - number of bytes to allocate
347+
* `const sycl::queue& q` - the SYCL `queue` whose `context` contains the devices that will access the `host` allocation
348+
Return value:: Returns a pointer to the newly allocated `host` memory on success. Memory allocated by `sycl::malloc_host` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
349+
313350
[source,cpp]
314351
----
315352
void* sycl::malloc_shared(size_t size,
@@ -320,18 +357,42 @@ void* sycl::malloc_shared(size_t size,
320357
Parameters::
321358
* `size_t size` - number of bytes to allocate
322359
* `const sycl::device& dev` - the SYCL device to allocate on
323-
* `const sycl::context& dev` - the SYCL `context` to which `device` belongs
360+
* `const sycl::context& ctxt` - the SYCL `context` to which `device` belongs
324361
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` to avoid memory leaks. On failure, returns `nullptr`.
325362

363+
[source,cpp]
364+
----
365+
void* sycl::malloc_shared(size_t size,
366+
const sycl::queue& q);
367+
----
368+
369+
Parameters::
370+
* `size_t size` - number of bytes to allocate
371+
* `const sycl::queue& q` - the SYCL `q` that provides the `device` and `context` to allocate against
372+
373+
Return value:: Returns a pointer to the newly allocated `shared` memory on the `device` associated with `q` on success. Memory allocated by `sycl::malloc_shared` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
374+
326375
===== aligned_alloc
327376
[source,cpp]
328377
----
329-
void* sycl::aligned_alloc_host(size_t alignment, size_t size);
378+
void* sycl::aligned_alloc_host(size_t alignment, size_t size, const sycl::context& ctxt);
379+
----
380+
381+
Parameters::
382+
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
383+
* `size_t size` - number of bytes to allocate
384+
* `const sycl::context& ctxt` - the SYCL `context` that contains the devices that will access the `host` allocation
385+
Return value:: Returns a pointer to the newly allocated `host` memory on success. Memory allocated by `sycl::aligned_alloc_host` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
386+
387+
[source,cpp]
388+
----
389+
void* sycl::aligned_alloc_host(size_t alignment, size_t size, const sycl::queue& q);
330390
----
331391

332392
Parameters::
333393
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
334394
* `size_t size` - number of bytes to allocate
395+
* `const sycl::queue& q` - the SYCL `q` whose `context` contains the devices that will access the `host` allocation
335396
Return value:: Returns a pointer to the newly allocated `host` memory on success. Memory allocated by `sycl::aligned_alloc_host` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
336397

337398
[source,cpp]
@@ -346,9 +407,22 @@ Parameters::
346407
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
347408
* `size_t size` - number of bytes to allocate
348409
* `const sycl::device& dev` - the SYCL `device` to allocate on
349-
* `const sycl::context& dev` - the SYCL `context` to which `device` belongs
410+
* `const sycl::context& ctxt` - the SYCL `context` to which `device` belongs
350411
Return value:: Returns a pointer to the newly allocated `shared` memory on the specified `device` on success. Memory allocated by `sycl::aligned_alloc_shared` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
351412

413+
[source,cpp]
414+
----
415+
void* sycl::aligned_alloc_shared(size_t alignment,
416+
size_t size,
417+
const sycl::queue& q);
418+
----
419+
420+
Parameters::
421+
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
422+
* `size_t size` - number of bytes to allocate
423+
* `const sycl::queue& q` - the SYCL `q` that provides the `device` and `context` to allocate against
424+
Return value:: Returns a pointer to the newly allocated `shared` memory on the `device` associated with `q` on success. Memory allocated by `sycl::aligned_alloc_shared` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
425+
352426
===== Performance Hints
353427
Programmers may provide hints to the runtime that data should be made available on a device earlier than Unified Shared Memory would normally require it to be available. This can be accomplished through enqueueing prefetch commands. Prefetch commands may not be overlapped with kernel execution in Restricted USM.
354428

@@ -405,44 +479,81 @@ Return Value:: Returns an event representing the operation.
405479
[source,cpp]
406480
----
407481
void *sycl::malloc(size_t size,
408-
const device& dev,
409-
const context& ctxt,
482+
const sycl::device& dev,
483+
const sycl::context& ctxt,
410484
usm::alloc kind);
411485
----
412486

413487
Parameters::
414488
* `size_t size` - number of bytes to allocate
415-
* `const sycl::device& dev` - the SYCL device to allocate on
416-
* `const sycl::context& dev` - the SYCL `context` to which `device` belongs
489+
* `const sycl::device& dev` - the SYCL device to allocate on (if applicable)
490+
* `const sycl::context& ctxt` - the SYCL `context` to which `device` belongs
417491
* `usm::alloc kind` - the type of allocation to perform
418492
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` to avoid memory leaks. On failure, returns `nullptr`.
419493

494+
[source,cpp]
495+
----
496+
void *sycl::malloc(size_t size,
497+
const sycl::queue& q,
498+
usm::alloc kind);
499+
----
500+
501+
Parameters::
502+
* `size_t size` - number of bytes to allocate
503+
* `const sycl::queue& q` - the SYCL `q` that provides the `device` (if applicable) and `context` to allocate against
504+
* `usm::alloc kind` - the type of allocation to perform
505+
Return value:: Returns a pointer to the newly allocated `kind` memory on success. Memory allocated by `sycl::malloc` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
506+
420507
===== aligned_alloc
421508
[source,cpp]
422509
----
423510
void *sycl::aligned_alloc(size_t alignment,
424511
size_t size,
425-
const device& dev,
426-
const context& ctxt,
512+
const sycl::device& dev,
513+
const sycl::context& ctxt,
427514
usm::alloc kind);
428515
----
429516

430517
Parameters::
431518
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
432519
* `size_t size` - number of bytes to allocate
433-
* `const sycl::device& dev` - the SYCL device to allocate on
434-
* `const sycl::context& dev` - the SYCL `context` to which `device` belongs
520+
* `const sycl::device& dev` - the SYCL device to allocate on (if applicable)
521+
* `const sycl::context& ctxt` - the SYCL `context` to which `device` belongs
435522
* `usm::alloc kind` - the type of allocation to perform
436523
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::aligned_alloc` must be deallocated with `sycl::free` to avoid memory leaks. On failure, returns `nullptr`.
437524

525+
[source,cpp]
526+
----
527+
void *sycl::aligned_alloc(size_t alignment,
528+
size_t size,
529+
const sycl::queue& q,
530+
usm::alloc kind);
531+
----
532+
533+
Parameters::
534+
* `size_t alignment` - specifies the byte alignment. Must be a valid alignment supported by the implementation.
535+
* `size_t size` - number of bytes to allocate
536+
* `const sycl::queue& q` - the SYCL `q` that provides the `device` (if applicable) and `context` to allocate against.
537+
* `usm::alloc kind` - the type of allocation to perform
538+
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. On failure, returns `nullptr`.
539+
438540
===== free
439541
[source,cpp]
440542
----
441543
void sycl::free(void* ptr, sycl::context& context);
442544
----
443545
Parameters::
444546
* `void* ptr` - pointer to the memory to deallocate. Must have been allocated by a SYCL `malloc` or `aligned_alloc` function.
445-
* `const sycl::context& dev` - the SYCL `context` in which `ptr` was allocated
547+
* `const sycl::context& ctxt` - the SYCL `context` in which `ptr` was allocated
548+
Return value:: none
549+
550+
[source,cpp]
551+
----
552+
void sycl::free(void* ptr, sycl::queue& q);
553+
----
554+
Parameters::
555+
* `void* ptr` - pointer to the memory to deallocate. Must have been allocated by a SYCL `malloc` or `aligned_alloc` function.
556+
* `const sycl::queue& q` - the SYCL `queue` that provides the `context` in which `ptr` was allocated
446557
Return value:: none
447558

448559
'''

0 commit comments

Comments
 (0)