@@ -77,16 +77,59 @@ supports.
77
77
78
78
== Examples
79
79
80
+ .Device allocation example
80
81
[source,c++]
81
82
----
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
+ ----
85
110
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
+ ...
89
129
}).wait();
130
+
131
+ ...
132
+ ... = array[index];
90
133
----
91
134
92
135
@@ -96,9 +139,7 @@ This extension adds the new property
96
139
`sycl::ext::intel::experimental::property::usm::buffer_location` which
97
140
applications can pass in the property_list parameter to all overloads of the
98
141
`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.
102
143
103
144
[source,c++]
104
145
----
@@ -114,14 +155,13 @@ class buffer_location {
114
155
----
115
156
116
157
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
119
160
requirements for bandwidth and throughput.
120
161
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
122
163
extension on other devices or backends will result in no effect.
123
164
124
-
125
165
== Issues
126
166
127
167
== Revision History
@@ -132,4 +172,5 @@ extension on other devices or backends will result in no effect.
132
172
|========================================
133
173
|Rev|Date|Author|Changes
134
174
|1|2022-03-01|Sherry Yuan|*Initial public draft*
175
+ |2|2022-05-31|Abhishek Tiwari|*Updates for shared/host malloc*
135
176
|========================================
0 commit comments