[SYCL][Docs] Add sycl_ext_oneapi_virtual_mem extension and implementation#8954
[SYCL][Docs] Add sycl_ext_oneapi_virtual_mem extension and implementation#8954steffenlarsen merged 135 commits intointel:syclfrom
Conversation
…tion This commit adds the sycl_ext_oneapi_virtual_mem experimental extension for reserving and mapping virtual address ranges. Accompanying it is the implementation in the SYCL runtime, together with CUDA and Level Zero backend support for the corresponding features. Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
|
/testwin |
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
| // RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
| // RUN: %ACC_RUN_PLACEHOLDER %t.out | ||
|
|
||
| // TODO: Require ext_oneapi_virtual_mem aspect here when supported. |
There was a problem hiding this comment.
maybe use the feature test macro as well.
| Working with virtual address ranges and the underlying physical memory requires | ||
| the user to align and adjust in accordance with a specified minimum granularity. | ||
| In addition, devices can have a recommended granularity which may different from | ||
| the minimum granularity and can be used instead of the minimum granularity. |
There was a problem hiding this comment.
In addition, devices can have a recommended granularity which may different from
the minimum granularity and can be used instead of the minimum granularity.
I would rephrase this to make it clearer.
There was a problem hiding this comment.
I tried rephrasing it. Is this what you had in mind?
There was a problem hiding this comment.
maybe:
-> In addition, adapters may return a recommended granularity to potentially achieve higher performance. Distinction between minimum and recommended is adapters-specific and may vary between devices.
There was a problem hiding this comment.
I like that. I've changed it a little to refer to common SYCL concepts but otherwise I'm good with the message. Thanks!
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
EwanC
left a comment
There was a problem hiding this comment.
Some very minor spec comments from a quick read through to understand what this extension is about.
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
| mapped through a call to `physical_mem::map()` prior to calling this. The range | ||
| must not be a proper sub-range of a previously mapped range. `syclContext` must | ||
| be the same as the context returned by the `get_context()` member function on | ||
| all the `physical_mem` the address ranges are currently mapped to. |
There was a problem hiding this comment.
The part about "all the physical_mem the address ranges are currently mapped to" is confusing. Under what circumstances could there be more than one physical_mem that maps this address range?
There was a problem hiding this comment.
I do believe it should be "all the physical_mem the address range is currently mapped to." The test in sycl/test-e2e/VirtualMem/vector_with_virtual_mem.cpp shows a case like this, where we keep allocating new physical memory chunks, that are all used under a single virtual memory range. They cannot overlap though.
There was a problem hiding this comment.
We have the following note two paragraphs below:
[Note: Unmapping ranges that span multiple contiguous mapped ranges is not supported. Doing so will result in undefined behavior. This restriction may be lifted in the future. — end note]
That seems to indicate that the range must correspond to exactly one physical_mem. Is the note wrong?
There was a problem hiding this comment.
No, the note just states that if you have a virtual range that spans multiple physical memory allocations, you have to unmap the the sub-ranges that is mapped to each physical memory allocation in separation.
There was a problem hiding this comment.
Discussion offline: The wording about all physical memory regions is the confusing part. It has been changed.
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
|
|
||
| |`void set_access_mode(const void *ptr, size_t numBytes, address_access_mode mode, const context &syclContext)` | | ||
| Sets the access mode of a virtual memory range specified by `ptr` and | ||
| `numBytes`. |
There was a problem hiding this comment.
Can you check your wording, then? The wording says:
ptrmust be aligned to the minimum memory granularity ofsyclContextandnumBytesmust be a multiple of the minimum memory granularity ofsyclContext.
This would correspond to the host page size, right? Not the value returned by zeVirtualMemQueryPageSize.
| `access_mode::read` results in undefined behavior. | ||
|
|
||
| An accessible pointer behaves the same as a pointer to device USM memory and can | ||
| be used in place of a device USM pointer in any interface accepting one. |
There was a problem hiding this comment.
Can you map a new virtual address over physical memory that is already mapped to a different address?
I see nothing in both CUDA and L0 disallowing this.
That's interesting. What happens in this case? Is the physical memory automatically unmapped from the old virtual address range?
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/experimental/sycl_ext_oneapi_virtual_mem.asciidoc
Outdated
Show resolved
Hide resolved
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
|
Hi, I found "read-only" mapped VM doesn't work #19189, do we have plan to fix it? |
This commit adds the sycl_ext_oneapi_virtual_mem experimental extension for reserving and mapping virtual address ranges. Accompanying it is the implementation in the SYCL runtime, together with CUDA and Level Zero backend support for the corresponding features.