oneapi-src / oneapi-src/unified-memory-framework

Extend memory provider API with commit/decommit and free/dalloc functions

Open
#283 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C
Stars
98
Forks
48
Avg merge
3d 20h
Merged PRs (30d)
6

Description

Extend memory provider API with commit/decommit and free/dalloc functions.

Rationale

This is needed to properly manage OS allocations on Windows and Linux.
We should have 1:1 mapping with Jemalloc extent API and distinguish between free() which just annotates the memory as unavailable and destroy() which does the actual unmapping. Note that this API would also be useful to Coarse Provider that implements some kind of memory virtualization by itself. After the changes the OS provider should implement the following allocation and deallocation flows:

allocate <- zero memory (if needed) <- commit (windows only) <- mmap
deallocate (mark page as inaccessible or NOP) -> decommit (windows only) -> purge lazy/force (linux) -> destroy (unmap)

API Changes

  • dalloc() should invalidate pages - this could be done by either NOP or adding a page to the free list
  • free() should do the unmap (release virtual addresses)
  • in the deallocation flow, the providers should implement at least free() function. For if dalloc(), decommit(), or purge() are not implemented, UMF pools implementation should call a more "aggressive" version of the deallocation function up to the destroy()
  • to handle scenarios, where the user expects or doesn't care if memory is zeroed after the alloc, we should add a flag UMF_PROVIDER_ZERO_MEMORY_ON_ALLOC that, if set guarantees that memory is zeroed. On Level Zero provider this would require calling memset kernel (using zeCommandListAppendMemoryFill)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the provider API and the OS and Level Zero provider implementations, then trace their current allocation and deallocation paths. The work is done when the requested commit/decommit, free/dalloc, purge/destroy, and zero-memory behavior are represented consistently across the affected providers and their existing validation passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, linux
Domain
api, backend, operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.