Skip to content

Commit 0bfaaf4

Browse files
authored
Merge pull request #2 from ProGTX/ProGTX/host_task_rules
Multiple in-order host tasks with data guarantees
2 parents aa90540 + 7e576cc commit 0bfaaf4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ runtime to perform further optimizations when available.
3434
For example, a SYCL runtime may decide to map / unmap instead of copy operations,
3535
or performing asynchronous transfers while data is being computed.
3636

37+
It is possible to run multiple host tasks in the same command group - the host
38+
tasks are executed in-order within the command group.
39+
3740
```cpp
3841
auto cgH = [=] (handler& h) {
3942
auto accA = bufA.get_access<access::mode::read>(h);
@@ -42,10 +45,20 @@ or performing asynchronous transfers while data is being computed.
4245
h.host_task([=]() {
4346
accB[0] = accA[0] * std::rand();
4447
}
45-
};
48+
49+
auto accC = bufC.get_access<access::mode::read>(h);
50+
h.host_task([=]() {
51+
accC[0] += accA[0] * accB[0];
52+
}
53+
};
4654
qA.submit(cgH);
4755
```
4856
57+
Note that in the code above `accC` was created after the first host task has
58+
been scheduled, but the actual data may already be available before the first
59+
host task starts executing. In the second host task, the value of `accB` is
60+
consistent with the value set in the first host task.
61+
4962
#### API changes
5063
5164
| Method | Description |

0 commit comments

Comments
 (0)