|
| 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