Skip to content

[SYCL][Docs] Add sycl_ext_oneapi_virtual_mem extension and implementation#8954

Merged
steffenlarsen merged 135 commits intointel:syclfrom
steffenlarsen:steffen/virtual_mem_ext
Jul 1, 2024
Merged

[SYCL][Docs] Add sycl_ext_oneapi_virtual_mem extension and implementation#8954
steffenlarsen merged 135 commits intointel:syclfrom
steffenlarsen:steffen/virtual_mem_ext

Conversation

@steffenlarsen
Copy link
Contributor

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.

…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>
@steffenlarsen steffenlarsen requested a review from a team April 5, 2023 15:27
@steffenlarsen
Copy link
Contributor Author

/testwin

@steffenlarsen steffenlarsen temporarily deployed to aws April 5, 2023 15:33 — with GitHub Actions Inactive
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use the feature test macro as well.

@steffenlarsen steffenlarsen temporarily deployed to aws April 5, 2023 16:06 — with GitHub Actions Inactive
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried rephrasing it. Is this what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that. I've changed it a little to refer to common SYCL concepts but otherwise I'm good with the message. Thanks!

@steffenlarsen steffenlarsen temporarily deployed to aws April 5, 2023 17:34 — with GitHub Actions Inactive
@steffenlarsen steffenlarsen temporarily deployed to aws April 5, 2023 20:17 — with GitHub Actions Inactive
@steffenlarsen steffenlarsen temporarily deployed to aws April 5, 2023 21:31 — with GitHub Actions Inactive
Larsen, Steffen added 4 commits April 6, 2023 00:25
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>
@steffenlarsen steffenlarsen temporarily deployed to aws April 6, 2023 08:13 — with GitHub Actions Inactive
Copy link
Contributor

@EwanC EwanC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very minor spec comments from a quick read through to understand what this extension is about.

@steffenlarsen steffenlarsen temporarily deployed to aws April 6, 2023 08:45 — with GitHub Actions Inactive
Larsen, Steffen added 2 commits April 6, 2023 01:49
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
@steffenlarsen steffenlarsen temporarily deployed to aws April 6, 2023 09:25 — with GitHub Actions Inactive
@steffenlarsen steffenlarsen temporarily deployed to aws April 6, 2023 09:57 — with GitHub Actions Inactive
Larsen, Steffen added 3 commits April 6, 2023 04:01
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>
@steffenlarsen steffenlarsen temporarily deployed to aws April 6, 2023 13:29 — with GitHub Actions Inactive
@steffenlarsen steffenlarsen temporarily deployed to aws April 6, 2023 14:00 — with GitHub Actions Inactive
Larsen, Steffen added 2 commits April 11, 2023 06:21
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Larsen, Steffen added 11 commits May 29, 2024 05:55
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>
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion offline: The wording about all physical memory regions is the confusing part. It has been changed.


|`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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check your wording, then? The wording says:

ptr must be aligned to the minimum memory granularity of syclContext and numBytes must be a multiple of the minimum memory granularity of syclContext.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Larsen, Steffen added 5 commits June 20, 2024 03:01
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>
Copy link
Contributor

@gmlueck gmlueck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spec changes LGTM

Larsen, Steffen added 3 commits June 27, 2024 05:57
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Larsen, Steffen added 2 commits June 27, 2024 06:09
Signed-off-by: Larsen, Steffen <steffen.larsen@intel.com>
Steffen Larsen added 2 commits July 1, 2024 12:28
@AllanZyne
Copy link
Contributor

Hi, I found "read-only" mapped VM doesn't work #19189, do we have plan to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.