-
Notifications
You must be signed in to change notification settings - Fork 74
[KHR] Prefetch host #960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[KHR] Prefetch host #960
Changes from all commits
aadf152
cdc9682
a8a9a2c
39dad70
4ddf0dd
9df00a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| [[sec:khr-prefetch-host]] | ||
| = sycl_khr_prefetch_host | ||
|
|
||
| This extension allows developers to prefetch data from the device to the host. | ||
|
|
||
| [[sec:khr-prefetch-host-dependencies]] | ||
| == Dependencies | ||
|
|
||
| This extension has no dependencies on other extensions. | ||
|
|
||
| [[sec:khr-prefetch-host-feature-test]] | ||
| == Feature test macro | ||
|
|
||
| An implementation supporting this extension must predefine the macro | ||
| [code]#SYCL_KHR_PREFETCH_HOST# to one of the values defined in the table below. | ||
|
|
||
| [%header,cols="1,5"] | ||
| |=== | ||
| |Value | ||
| |Description | ||
|
|
||
| |1 | ||
| |Initial version of this extension. | ||
| |=== | ||
|
|
||
| [[sec:khr-prefetch-host-handler]] | ||
| == Extensions to the handler class | ||
|
|
||
| This extension adds the following function to the [code]#sycl::handler# class. | ||
|
|
||
| [[sec:khr-prefetch-host-handler-member-funcs]] | ||
| === Member functions | ||
|
|
||
| .[apidef]#handler::khr_prefetch_host# | ||
| [source,role=synopsis,id=api:handler-khr-prefetch-host] | ||
| ---- | ||
| void khr_prefetch_host(void* ptr, size_t numBytes) | ||
| ---- | ||
|
|
||
| _Effects:_ Enqueues a prefetch host of [code]#num_bytes# of data starting at | ||
| address [code]#ptr#. | ||
| The [code]#ptr# must point within a USM allocation from the same context as the | ||
| handler's queue, and the pointer must be accessible from the queue's device. | ||
| For more detail on USM, please see <<sec:usm>>. | ||
|
|
||
| {note} [code]#prefetch_host# inform the SYCL runtime that the specified shared | ||
| allocation is likely to be accessed on the host in the future, and that it is | ||
| free to migrate the allocation to the host. | ||
| {endnote} | ||
|
|
||
| ''' | ||
|
|
||
| [[sec:khr-prefetch-host-queue]] | ||
| == Extensions to the queue class | ||
|
|
||
| This extension adds the following function to the [code]#sycl::queue# class. | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also here, add a high-level synopsis of the member functions added to |
||
| [[sec:khr-prefetch-host-queue-member-funcs]] | ||
| === Member functions | ||
|
|
||
| .[apidef]#queue::khr_prefetch_host# | ||
| [source,role=synopsis,id=api:queue-khr-prefetch-host] | ||
| ---- | ||
| event khr_prefetch_host(void* ptr, size_t numBytes) (1) | ||
|
|
||
| event khr_prefetch_host(void* ptr, size_t numBytes, event depEvent) (2) | ||
|
|
||
| event khr_prefetch_host(void* ptr, size_t numBytes, const std::vector<event>& depEvents) (3) | ||
|
|
||
| ---- | ||
|
|
||
| _Effects (1)_: Equivalent to calling [code]#queue::submit# with a command group | ||
| function that calls [code]#handler::khr_prefetch_host(ptr, numBytes)#. | ||
|
|
||
| _Effects (2)_: Equivalent to calling [code]#queue::submit# with a command group | ||
| function that calls [code]#handler::depends_on(depEvent)# and | ||
| [code]#handler::khr_prefetch_host(ptr, numBytes)#. | ||
|
|
||
| _Effects (3)_: Equivalent to calling [code]#queue::submit# with a command group | ||
| function that calls [code]#handler::depends_on(depEvents)# and | ||
| [code]#handler::khr_prefetch_host(ptr, numBytes)#. | ||
|
|
||
| _Returns_: An event which represents the command which is submitted to the | ||
| queue. | ||
|
|
||
| ''' | ||
|
|
||
| [[sec:khr-prefetch-host-example]] | ||
| == Example | ||
|
|
||
| The example below demonstrates the usage of this extension. | ||
|
|
||
| [source,,linenums] | ||
| ---- | ||
| #include <sycl/sycl.hpp> | ||
|
|
||
| int main() { | ||
| sycl::queue Q; | ||
| int *A = Q.malloc_shared<int>(1,Q); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no such member function to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ashamed : ( Good catch! |
||
| Q.prefetch_host(A, sizeof(int)).wait(); | ||
| A[0] = 10; // Maybe faster than without the prefetch_host | ||
| } | ||
| ---- | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should show a high level synopsis here of the additions to the
handlerclass like:This is consistent with the other KHR's that add member functions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it but then remove it due to
Can put it back if you prefer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think sycl_khr_queue_empty_query is the outlier. We should add the high level synopsis there too to make them all consistent.