unified-memory-framework icon indicating copy to clipboard operation
unified-memory-framework copied to clipboard

Expose umfMemoryTrackerGetAllocInfo

Open igchor opened this issue 1 year ago • 1 comments

Expose a function that returns information about coarse-grain allocations, including:

  • size
  • base address

Rationale

UR validation layer uses urUSMGetMemAllocInfo to obtain information about size and base address for an allocation to do bounds checking: https://github.com/oneapi-src/unified-runtime/blob/main/source/loader/layers/validation/ur_validation_layer.cpp#L41 For L0 adapters, urUSMGetMemAllocInfo gets this information by asking the driver which is costly: https://github.com/oneapi-src/unified-runtime/blob/d61cf6680c7f620bd5092e2bb22524106fbdef63/source/adapters/level_zero/usm.cpp#L621

We should expose a function that would allow users to query this information directly from UMF.

API Changes

struct umf_alloc_info_t {
   void* baseAddr;
   size_t size;
   umf_memory_pool_handle_t hPool;
};

umf_result_t umfGetAllocInfo(void *ptr, umf_alloc_info_t* info);

Implementation details

Use umfMemoryTrackerGetAllocInfo

Meta

igchor avatar Aug 16 '24 20:08 igchor

I agree with the problem description. UMF tacker has all the required information and UR can ask UMF instead of L0 and UMF should perform better than L0. Regarding the solution, we should design the API before implementing it - need to discuss if exposing umfMemoryTrackerGetAllocInfo is the best way (perhaps yes). As a first, we need to capture all relevant use cases and their requirements, e.g. MPI needs functionality to get allocation properties. We will schedule this topic at UMF technical meeting.

vinser52 avatar Aug 19 '24 12:08 vinser52