Skip to content

Commit b0e89f1

Browse files
authored
Added fill method to the handler (#15)
1 parent bc0a804 commit b0e89f1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

asynchronous-data-flow/sycl-2.2/03_interacting_with_data_on_the_host.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,25 @@ auto cgH = [=] (handler& h) {
139139
qA.submit(cgH);
140140
```
141141

142+
### Filling data on the device
143+
144+
A special case of updating the data directly on the device is when
145+
a certain pattern is to be replicated across a range of values in
146+
the accessor.
147+
In C++, this is implemented via the std::fill function in the
148+
algorithm headers.
149+
150+
The example shows how to fill buffer A contents with an scalar.
151+
Note that at least write access is required.
152+
153+
```cpp
154+
auto cgH = [=] (handler& h) {
155+
auto accA = bufA.get_access<access::mode::write>(h);
156+
h.fill(accB, 10);
157+
};
158+
qA.submit(cgH);
159+
```
160+
142161
#### Access restrictions
143162

144163
The following restrictions apply to access mode and target of the accessor
@@ -164,3 +183,4 @@ data, the only valid accessor modes are the following:
164183
| `template <typename T, int dims, access::mode accessMode, access::target accessTarget> void copy(shared_ptr<T> hostPtr, accessor<T, dims, accessMode, accessTarget> acc)` | Update the contents of the host pointer with the data in accessor `acc`. `hostPtr` must have enough space allocated to hold the data. |
165184
| `template <typename T, int dims, access::mode accessMode, access::target accessTarget> void copy(accessor<T, dims, accessMode, accessTarget> acc, shared_ptr<T> hostPtr)` | Update the the data in accessor `acc` with the contents of the host pointer. `hostPtr` must have enough space allocated to hold the data. |
166185
| `template <typename AccessorD, typename AccessorO> void copy(AccessorD acc, AccessorO acc)` | Update the the data in accessor `accD` with the contents of the buffer pointed by `accO` |
186+
| `template <typename AccessorD, typename T> void fill(AccessorD acc, T val)` | Special case of copy from host to device where the origin is a scalar value that will be replicated across the range of the accessor. |

0 commit comments

Comments
 (0)