Skip to content

Commit 36a9ee2

Browse files
authored
[SYCL][DOC] Update buffer_location spec to unblock USM host/shared allocations (#6219)
Spec states that the runtime buffer_location property will not have an effect on shared/host allocations. This is incorrect as the property is meant to be used with host/shared allocations with the same behavior as device allocations. #6218 #6220
1 parent defc38b commit 36a9ee2

File tree

1 file changed

+54
-13
lines changed

1 file changed

+54
-13
lines changed

sycl/doc/extensions/proposed/sycl_ext_intel_runtime_buffer_location.asciidoc

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,59 @@ supports.
7777

7878
== Examples
7979

80+
.Device allocation example
8081
[source,c++]
8182
----
82-
array = (int *)sycl::malloc_device<int>(
83-
N, q,
84-
sycl::property_list{sycl::ext::intel::experimental::property::usm::buffer_location(2)});
83+
using namespace sycl;
84+
using namespace sycl::ext::intel::experimental;
85+
...
86+
queue q;
87+
88+
auto device_array = malloc_device<int>(kN, q, property_list{property::usm::buffer_location(2)});
89+
90+
int host_array[kN];
91+
92+
for(int i=0; i<kN; i++) {
93+
host_array[i] = ...
94+
}
95+
96+
q.copy(host_array, device_array, kN).wait();
97+
98+
q.submit([=] {
99+
...
100+
... = device_array[index];
101+
device_array[index] = ...;
102+
...
103+
}).wait();
104+
105+
q.copy(device_array, host_array, kN).wait();
106+
107+
...
108+
... = host_array[index];
109+
----
85110

86-
sycl::queue q;
87-
q.parallel_for(sycl::range<1>(N), [=] (sycl::id<1> i){
88-
data[i] *= 2;
111+
.Shared allocation example
112+
[source,c++]
113+
----
114+
using namespace sycl;
115+
using namespace sycl::ext::intel::experimental;
116+
...
117+
queue q;
118+
119+
auto array = malloc_shared<int>(kN, q, property_list{property::usm::buffer_location(2)});
120+
for(int i=0; i<kN; i++) {
121+
array = ...
122+
}
123+
124+
q.submit([=] {
125+
...
126+
... = array[index];
127+
array[index] = ...;
128+
...
89129
}).wait();
130+
131+
...
132+
... = array[index];
90133
----
91134

92135

@@ -96,9 +139,7 @@ This extension adds the new property
96139
`sycl::ext::intel::experimental::property::usm::buffer_location` which
97140
applications can pass in the property_list parameter to all overloads of the
98141
`sycl::malloc_device()`, `sycl::malloc_shared()`, and `sycl::malloc_host()`
99-
functions. However, this property has no effect when passed to
100-
`sycl::malloc_shared()` or `sycl::malloc_host()`. Following is a synopsis of
101-
this property.
142+
functions. Following is a synopsis of this property.
102143

103144
[source,c++]
104145
----
@@ -114,14 +155,13 @@ class buffer_location {
114155
----
115156

116157
On targets that provide more than one type of global memory, `buffer_location`
117-
allows user to specify which of the global memory to allocate memory to. This
118-
provide user the flexibility to choose the global memory that satisfy
158+
allows users to specify which global memory to allocate memory to. This
159+
provides users the flexibility to choose the global memory that satisfies their
119160
requirements for bandwidth and throughput.
120161

121-
This property is ignored for non-FPGA devices. Attempting to use this
162+
This property is ignored for non-FPGA devices. Attempting to use this
122163
extension on other devices or backends will result in no effect.
123164

124-
125165
== Issues
126166

127167
== Revision History
@@ -132,4 +172,5 @@ extension on other devices or backends will result in no effect.
132172
|========================================
133173
|Rev|Date|Author|Changes
134174
|1|2022-03-01|Sherry Yuan|*Initial public draft*
175+
|2|2022-05-31|Abhishek Tiwari|*Updates for shared/host malloc*
135176
|========================================

0 commit comments

Comments
 (0)