Skip to content

Commit 645f256

Browse files
committed
[KHR] Queue flush
Cherry pick KhronosGroup#809 from main (cherry picked from commit 9ffe540)
1 parent fd851f9 commit 645f256

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

adoc/extensions/index.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ include::sycl_khr_default_context.adoc[leveloffset=2]
1414
include::sycl_khr_queue_empty_query.adoc[leveloffset=2]
1515
include::sycl_khr_group_interface.adoc[leveloffset=2]
1616
include::sycl_khr_max_work_group_queries.adoc[leveloffset=2]
17+
include::sycl_khr_queue_flush.adoc[leveloffset=2]

adoc/extensions/sycl_khr_queue_empty_query.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ below.
3232
This extension adds the following function to the [code]#sycl::queue# class,
3333
which provides information about the emptiness of the queue.
3434

35+
{note} This feature is most useful when used in conjunction with
36+
[api]#queue::khr_flush#.
37+
{endnote}
38+
3539
'''
3640

3741
.[apidef]#queue::khr_empty#
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[[sec:khr-queue-flush]]
2+
= sycl_khr_queue_flush
3+
4+
This extension allows developers to ensure that device code is able to make
5+
forward progress without the need to call [api]#queue::wait#.
6+
7+
[[sec:khr-queue-flush-dependencies]]
8+
== Dependencies
9+
10+
This extension has no dependencies on other extensions.
11+
12+
[[sec:khr-queue-flush-feature-test]]
13+
== Feature test macro
14+
15+
An implementation supporting this extension must predefine the macro
16+
[code]#SYCL_KHR_QUEUE_FLUSH# to one of the values defined in the table below.
17+
18+
[%header,cols="1,5"]
19+
|===
20+
|Value
21+
|Description
22+
23+
|1
24+
|Initial version of this extension.
25+
|===
26+
27+
[[sec:khr-queue-flush-queue]]
28+
== Extensions to the queue class
29+
30+
This extension adds the following function to the [code]#sycl::queue# class.
31+
32+
'''
33+
[source,role=synopsis,id=api:khr-queue-flush-queue]
34+
----
35+
namespace sycl {
36+
class queue {
37+
void khr_flush() const;
38+
// ...
39+
};
40+
}
41+
----
42+
43+
[[sec:khr-queue-flush-queue-menber-funcs]]
44+
=== Member functions
45+
46+
.[apidef]#queue::khr_flush#
47+
[source,role=synopsis,id=api:queue-khr-flush]
48+
----
49+
void khr_flush() const
50+
----
51+
52+
_Effects:_ Ensure that device code is able to make forward progress, as if an
53+
unspecified host thread providing concurrent forward progress guarantees called
54+
[api]#queue::wait#.
55+
56+
{note} Calling this function is an implementation-independent way to ensure that
57+
pending commands can start executing on the device without blocking the calling
58+
thread.
59+
Exactly when pending commands start executing is unspecified, as it depends on
60+
the scheduling behavior(s) of implementations and individual devices.
61+
However, if a call to [api]#queue::wait# would have been unblocked in a finite
62+
amount of time, a call to [api]#queue::khr_flush# guarantees that pending
63+
commands on that queue will execute in a finite amount of time.
64+
{endnote}
65+
66+
'''
67+
68+
[[sec:khr-queue-flush-example]]
69+
== Example
70+
71+
The example below demonstrates the usage of this extension.
72+
73+
[source,,linenums]
74+
----
75+
#include <sycl/sycl.hpp>
76+
77+
int main() {
78+
sycl::queue Q;
79+
auto e = Q.single_task([] {});
80+
Q.khr_flush();
81+
// Note: there's no wait.
82+
// Without flushing, whether the event is marked as complete is implementation-defined.
83+
while (e.get_info<sycl::info::event::command_execution_status>() !=
84+
sycl::info::event_command_status::complete) {
85+
};
86+
}
87+
----

0 commit comments

Comments
 (0)