Skip to content

[SYCL] Introduce extension for asynchronous memory allocation #14800

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

Open
wants to merge 17 commits into
base: sycl
Choose a base branch
from

Conversation

AerialMantis
Copy link
Contributor

Introduce a proposed extension for an interface for memory pools and asynchronous allocation and freeing of USM memory.

@AerialMantis AerialMantis requested a review from a team as a code owner July 26, 2024 12:40
@AerialMantis AerialMantis force-pushed the add-async-memory-management-ext branch from a7a3ffe to 9425161 Compare July 26, 2024 12:41
@AerialMantis AerialMantis changed the title [SYCL] Introduce extension proposal for asynchornous memory management [SYCL] Introduce extension proposal for asynchornous memory allocation Jul 26, 2024
@AerialMantis AerialMantis changed the title [SYCL] Introduce extension proposal for asynchornous memory allocation [SYCL] Introduce extension for asynchornous memory allocation Jul 26, 2024
@AerialMantis AerialMantis changed the title [SYCL] Introduce extension for asynchornous memory allocation [SYCL] Introduce extension for asynchronous memory allocation Aug 2, 2024
alloc spec

* Refactor the memory pool behaviour and lifetime sections into a new
  section, with less prescriptive wording.
* Add new `get_current_size` and `get_free_size` member functions to the
  `memory_pool` class.
* Add new `get_allocation_chunk_size` member function to the
  `memory_pool` class.
* Remove mention of source.
* Remove `get_free_size()`
* Remove `get_max_size()`
* Rename `set_new_threshold()` to `increase_threshold_to()`
* Rename `get_current_size()` to `get_reserved_size_current()`
* Change behaviour of `increase_threshold_to()` in case of size not being
  greater than the current size from exception to a no-op
* Add `usm::alloc` parameter to the host `memory_pool` constructor
* Add `use::alloc` parameter to the `ext_oneapi_get_default_memory_pool` free
  function
* Correct the behaviour of updating amount of free memory when calling
  `async_free()` to once the asynchronous free command has completed
* Add device aspect; `ext_oneapi_async_memory_alloc`
* Add a note to clarify the behaviour of the `read_only` property
* Clarified behaviour of `async_malloc()` and `async_malloc_from_pool()` when
  allocating zero bytes to align with regular `malloc_*()` functions
* Add `get_used_size_current()` can be used in combination with
  `get_reserved_size_current()`, in place of `get_free_size()`
* Removed over-prescriptive wording from `async_free()` definition
@AerialMantis AerialMantis force-pushed the add-async-memory-management-ext branch from f53598e to 0ebc79b Compare March 17, 2025 15:03
* Remove `get_allocation_chunk_size()`
* Add `property::memory_pool` namespace to property types
* Change parameter passing conversion for SYCL objects to const ref
* Move some specified behaviour of the memory pool to implementation nodes
* Introduce the term reserve to referred to the memory allocated to the
  memory pool
* Replace wording around current and free memory with reserved and used
  memory
* Change wording around allocation chunk size to be an implementation detail
martygrant pushed a commit that referenced this pull request Mar 27, 2025
…the sycl_ext_oneapi_async_memory_alloc extension (#16900)

Implement the
[sycl_ext_oneapi_async_memory_alloc](#14800)
extension for asynchronous memory allocation and freeing in CUDA, for
device allocated pools only.

SYCL entrypoints which specify host or shared side pools, or pools
created by pre-existing allocations will throw.

co-authored-by: Sean Stirling <sean.stirling@codeplay.com>
co-authored-by: Hugh Delaney <hugh.delaney@codeplay.com>

---------

Co-authored-by: Hugh Delaney <hugh.delaney@codeplay.com>
Co-authored-by: Nicolas Miller <nicolas.miller@codeplay.com>
RossBrunton pushed a commit to oneapi-src/unified-runtime that referenced this pull request Mar 27, 2025
…ry_alloc extension (#16900)

Implement the
[sycl_ext_oneapi_async_memory_alloc](intel/llvm#14800)
extension for asynchronous memory allocation and freeing in CUDA, for
device allocated pools only.

SYCL entrypoints which specify host or shared side pools, or pools
created by pre-existing allocations will throw.

co-authored-by: Sean Stirling <sean.stirling@codeplay.com>
co-authored-by: Hugh Delaney <hugh.delaney@codeplay.com>

---------

Co-authored-by: Hugh Delaney <hugh.delaney@codeplay.com>
Co-authored-by: Nicolas Miller <nicolas.miller@codeplay.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.

This is looking a lot better, but I have a few comments. Mostly they are wording improvements, not changes to the API.

KornevNikita pushed a commit that referenced this pull request May 27, 2025
…the sycl_ext_oneapi_async_memory_alloc extension (#16900)

Implement the
[sycl_ext_oneapi_async_memory_alloc](#14800)
extension for asynchronous memory allocation and freeing in CUDA, for
device allocated pools only.

SYCL entrypoints which specify host or shared side pools, or pools
created by pre-existing allocations will throw.

co-authored-by: Sean Stirling <sean.stirling@codeplay.com>
co-authored-by: Hugh Delaney <hugh.delaney@codeplay.com>

---------

Co-authored-by: Hugh Delaney <hugh.delaney@codeplay.com>
Co-authored-by: Nicolas Miller <nicolas.miller@codeplay.com>
* Remove memory_pool constructor for host USM allocations
* Remove memory_pool constructor for user provided allocations
* Remove host variant of ext_oneapi_get_default_memory_pool
* Update wording to state that only device USM allocations are supported
* Add known issues about reintroducing host/shared USM allocations and user provided allocations in the future
* Remove the read_only property as this is only used for shared USM allocations
* Add throw clauses for when the device aspect is not supported

|1
|The APIs of this experimental extension are not versioned, so the
feature-test macro always has this value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this extension be versioned if it is growing over time? Or are experimental specs not versioned as they're expected to change?

Copy link
Contributor

Choose a reason for hiding this comment

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

We generally do not version experimental extensions because they often change in non-backward-compatible ways. (Versioning doesn't help in this case.) However, there is no rule prohibiting versioning. If you think it's valuable to add a version, that's fine. If you do that, you must clearly document which APIs are added in each version.

I think it's sort of a moot issue for now, though. At this point, you only have one version which is version 1. If you decide to add new APIs later, you can decide at that time to leave the spec version at 1 (in which case the spec is unversioned) or bump the version to 2.

Copy link
Contributor

Choose a reason for hiding this comment

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

If experimental extensions are not generally versioned I do not have a reason to deviate from that here.

* Clarify wording to remove mention of shared USM.
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.