You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sycl/doc/extensions/proposed/sycl_ext_oneapi_usm_malloc_properties.asciidoc
+40-10Lines changed: 40 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
7
7
== Notice
8
8
9
-
Copyright (c) 2022 Intel Corporation. All rights reserved.
9
+
Copyright (c) 2023 Intel Corporation. All rights reserved.
10
10
11
11
NOTE: Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are
12
12
trademarks of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc.
@@ -292,7 +292,7 @@ contained by `syclContext` or it must be a descendent device of some
292
292
device that is contained by that context, otherwise this function throws a
293
293
synchronous `exception` with the `errc::invalid` error code.
294
294
295
-
And error is reported if `propList` contains
295
+
An error is reported if `propList` contains
296
296
a `usm_kind` property with value different than `sycl::usm::alloc::device`.
297
297
298
298
Available only if `propertyListA` and `propertyListB` are specializations of the `properties` class.
@@ -1556,23 +1556,53 @@ The `sycl::ext::oneapi::experimental::usm_kind` property is supported by `annota
1556
1556
1557
1557
=== Deallocation
1558
1558
1559
-
To avoid memory leaks, USM memory allocated using the USM memory allocation functions with `properties` support defined in this extension, must be deallocated using one of the `sycl::free` functions listed in Table 107 "USM Deallocation Functions" of Section 4.8.3.6 "Memory deallocation functions" of the core SYCL specification.
1559
+
This extension introduces two new functions called `sycl::ext::oneapi::experimental::free` that take an `annotated_ptr` as argument. These functions deallocate the memory pointed to by the raw pointer belonging to the `annotated_ptr`. The new deallocation functions are listed in Table <<table.usm.malloc.free>>. These functions belong to the namespace `sycl::ext::oneapi::experimental`.
1560
+
To avoid memory leaks, USM memory allocated using the USM memory allocation functions with `properties` support defined in this extension, must be deallocated using `sycl::ext::oneapi::experimental::free` or `sycl::free`.
1560
1561
1561
-
The following example shows how USM memory allocated using one of the functions defined in this extension should be deallocated, to avoid memory leaks.
1562
+
The following example shows how USM memory allocated using one of the functions defined in this extension can be deallocated, to avoid memory leaks.
1562
1563
1563
1564
==== Example
1564
1565
1565
1566
[source,c++]
1566
1567
----
1567
1568
using namespace sycl::ext::oneapi::experimental;
1568
1569
1569
-
properties P1{alignment<512>};
1570
-
// APtr is of type annotated_ptr<int*, decltype(properties{alignment<512>, usm_kind<sycl::usm::alloc::device>})>
1571
-
auto APtr = annotated_malloc_device<int>(N, q, P1);
// Deallocate the memory pointed to by the raw pointer of APtr
1576
+
free(APtr, q);
1577
+
1578
+
// Deallocate the memory pointed to by the raw pointer of BPtr, using sycl::free
1579
+
free(BPtr.get(), q);
1580
+
----
1572
1581
1573
-
// Deallocate the memory using the raw pointer of APtr
1574
-
sycl::free(APtr.get(), q);
1582
+
[[table.usm.malloc.free]]
1583
+
.New USM memory deallocation functions introduced by this extension
1584
+
[options="header"]
1585
+
|====
1586
+
|Function|Description
1587
+
a|
1588
+
[source,c++]
1589
+
----
1590
+
template<typename T, typename propList>
1591
+
void free(annotated_ptr<T, propList> &ptr,
1592
+
const context& syclContext)
1575
1593
----
1594
+
| Frees an allocation. The memory pointed to by the raw pointer belonging to `ptr` must have been allocated using one of the USM memory allocation functions with `properties` support defined in this extension, or one of the
1595
+
SYCL USM allocation routines. `syclContext` must be the same `context` that was used to allocate the memory. The memory is freed without waiting for `commands` operating on it to be completed. If `commands` that use this memory
1596
+
are in-progress or are enqueued the behavior is undefined.
1597
+
a|
1598
+
[source,c++]
1599
+
----
1600
+
template<typename T, typename propList>
1601
+
void free(annotated_ptr<T, propList> &ptr,
1602
+
const queue& syclQueue)
1603
+
----
1604
+
| Alternate form where `syclQueue` provides the `context`.
1605
+
|====
1576
1606
1577
1607
== Revision History
1578
1608
@@ -1581,5 +1611,5 @@ sycl::free(APtr.get(), q);
1581
1611
[options="header"]
1582
1612
|========================================
1583
1613
|Rev|Date|Author|Changes
1584
-
|1|2022-12-15|Jessica Davies|*Initial public working draft*
1614
+
|1|2023-01-25|Jessica Davies|*Initial public working draft*
0 commit comments