API Documentation

Contents

API Documentation#

Globals#

Defines

UMF_MAKE_VERSION(_major,_minor)#

Generates generic ‘UMF’ API versions.

UMF_MAJOR_VERSION(_ver)#

Extracts ‘UMF’ API major version.

UMF_MINOR_VERSION(_ver)#

Extracts ‘UMF’ API minor version.

UMF_VERSION_CURRENT#

Current version of the UMF headers.

Enums

enumumf_result_t#

Operation results.

Values:

enumeratorUMF_RESULT_SUCCESS#

Success.

enumeratorUMF_RESULT_ERROR_OUT_OF_HOST_MEMORY#

Insufficient host memory to satisfy call.

enumeratorUMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC#

A provider specific warning/error has been reported and can be Retrieved via the umfMemoryProviderGetLastNativeError entry point.

enumeratorUMF_RESULT_ERROR_INVALID_ARGUMENT#

Generic error code for invalid arguments.

enumeratorUMF_RESULT_ERROR_INVALID_ALIGNMENT#

Invalid alignment of an argument.

enumeratorUMF_RESULT_ERROR_NOT_SUPPORTED#

Operation not supported.

enumeratorUMF_RESULT_ERROR_USER_SPECIFIC#

Failure in user provider code (i.e in user provided callback)

enumeratorUMF_RESULT_ERROR_DEPENDENCY_UNAVAILABLE#

External required dependency is unavailable or missing.

enumeratorUMF_RESULT_ERROR_OUT_OF_RESOURCES#

Out of internal resources.

enumeratorUMF_RESULT_ERROR_UNKNOWN#

Unknown error.

enumumf_ctl_query_type_t#

Type of the CTL query.

Values:

enumeratorCTL_QUERY_READ#
enumeratorCTL_QUERY_WRITE#
enumeratorCTL_QUERY_RUNNABLE#
enumumf_ctl_query_source_t#

Values:

enumeratorCTL_UNKNOWN_QUERY_SOURCE#
enumeratorCTL_QUERY_PROGRAMMATIC#
enumeratorCTL_QUERY_CONFIG_INPUT#

Pools#

The UMF memory pool is a combination of a pool allocator and a memory provider.The pool allocator controls the memory pool and handles fine-grained memoryallocations memory allocations.

UMF includes predefined pool allocators. UMF can also work with user-definedpools which implement the memory pool API.

Memory Pool#

The memory pool API provides a malloc-like API for allocating and deallocatingmemory as well as functions that create, destroy and operate on the pool.

Enums

enumumf_pool_create_flag_t#

Supported pool creation flags.

Values:

enumeratorUMF_POOL_CREATE_FLAG_NONE#

Pool will be created with no additional flags.

enumeratorUMF_POOL_CREATE_FLAG_OWN_PROVIDER#

Pool will own the specified provider and destroy it in umfPoolDestroy.

enumeratorUMF_POOL_CREATE_FLAG_DISABLE_TRACKING#

Pool will not track memory allocations

Typedefs

typedefstructumf_memory_pool_t*umf_memory_pool_handle_t#

A struct containing a memory pool handle alongside anops structure containing pointers to implementations of provider-specific functions.

typedefuint32_tumf_pool_create_flags_t#

Type for combinations of pool creation flags.

Functions

umf_result_tumfPoolCreate(constumf_memory_pool_ops_t*ops,umf_memory_provider_handle_tprovider,constvoid*params,umf_pool_create_flags_tflags,umf_memory_pool_handle_t*hPool)#

Creates new memory pool.

Parameters:
  • ops – instance of umf_memory_pool_ops_t

  • provider – memory provider that will be used for coarse-grain allocations.

  • params – pointer to pool-specific parameters, or NULL for defaults

  • flags – a combination of umf_pool_create_flag_t

  • hPool – [out] handle to the newly created memory pool

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfPoolDestroy(umf_memory_pool_handle_thPool)#

Destroys memory pool.

Parameters:
  • hPool – handle to the pool

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

void*umfPoolMalloc(umf_memory_pool_handle_thPool,size_tsize)#

Allocatessize bytes of uninitialized storage fromhPool.

Parameters:
  • hPool – specified memory hPool

  • size – number of bytes to allocate

Returns:

Pointer to the allocated memory.

void*umfPoolAlignedMalloc(umf_memory_pool_handle_thPool,size_tsize,size_talignment)#

Allocatessize bytes of uninitialized storage from the specifiedhPool with the specifiedalignment.

Parameters:
  • hPool – specified memory hPool

  • size – number of bytes to allocate

  • alignment – alignment of the allocation in bytes

Returns:

Pointer to the allocated memory

void*umfPoolCalloc(umf_memory_pool_handle_thPool,size_tnum,size_tsize)#

Allocates memory fromhPool for an array ofnum elements ofsize bytes each and initializes all bytes in the allocated storage to zero.

Parameters:
  • hPool – specified memory hPool

  • num – number of objects

  • size – number of bytes to allocate for each object

Returns:

Pointer to the allocated memory

void*umfPoolRealloc(umf_memory_pool_handle_thPool,void*ptr,size_tsize)#

Reallocates memory fromhPool.

Parameters:
  • hPool – specified memory hPool

  • ptr – pointer to the memory block to be reallocated

  • size – new size for the memory block in bytes

Returns:

Pointer to the allocated memory

umf_result_tumfPoolMallocUsableSize(umf_memory_pool_handle_thPool,constvoid*ptr,size_t*size)#

Obtains size of block of memory allocated from thehPool for a givenptr.

Parameters:
  • hPool – specified memory hPool

  • ptr – pointer to the allocated memory

  • size – [out] pointer to a variable that will receive the size of the memory block

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfPoolFree(umf_memory_pool_handle_thPool,void*ptr)#

Frees the memory space of the specifiedhPool pointed byptr.

Parameters:
  • hPool – specified memory hPool

  • ptr – pointer to the allocated memory to free

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. Whether any status other than UMF_RESULT_SUCCESS can be returned depends on the memory provider used by thehPool.

umf_result_tumfFree(void*ptr)#

Frees the memory space pointed by ptr if it belongs to UMF pool, does nothing otherwise.

Parameters:
  • ptr – pointer to the allocated memory

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. Whether any status other than UMF_RESULT_SUCCESS can be returned depends on the memory provider used by the pool.

umf_result_tumfPoolGetLastAllocationError(umf_memory_pool_handle_thPool)#

Retrieveumf_result_t representing the error of the last failed allocation operation in this thread (malloc, calloc, realloc, aligned_malloc).

  • Implementationsmust store the error code in thread-local storage prior to returning NULL from the allocation functions.

  • If the last allocation/deallocation operation succeeded, the value returned by this function is unspecified.

  • The applicationmay call this function from simultaneous threads.

  • The implementation of this functionshould be lock-free.

Parameters:
  • hPool – specified memory pool handle for which the last allocation error is returned

Returns:

Error code describing the failure of the last failed allocation operation. The value is undefined if the previous allocation was successful.

umf_result_tumfPoolByPtr(constvoid*ptr,umf_memory_pool_handle_t*pool)#

Retrieve memory pool associated with a given ptr. Only memory allocated with the usage of a memory provider is being tracked.

Parameters:
  • ptr – pointer to memory belonging to a memory pool

  • pool – [out] handle to the memory pool that contains ptr

Returns:

UMF_RESULT_SUCCESS on success UMF_RESULT_ERROR_INVALID_ARGUMENT if pool is NULL, or ptr do not belongs to any pool.

umf_result_tumfPoolGetMemoryProvider(umf_memory_pool_handle_thPool,umf_memory_provider_handle_t*hProvider)#

Retrieve memory provider associated with a given pool.

Parameters:
  • hPool – specified memory pool

  • hProvider – [out] memory providers handle

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_INVALID_ARGUMENT if hProvider is NULL

umf_result_tumfPoolGetName(umf_memory_pool_handle_tpool,constchar**name)#

Retrieve name of a given memorypool.

Parameters:
  • pool – handle to the memory pool

  • name – [out] pointer to a string containing the name of thepool

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfPoolSetTag(umf_memory_pool_handle_thPool,void*tag,void**oldTag)#

Set a custom tag on the memory pool that can be later retrieved using umfPoolGetTag.

Parameters:
  • hPool – specified memory pool

  • tag – tag to be set

  • oldTag – [out][optional] previous tag set on the memory pool

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfPoolGetTag(umf_memory_pool_handle_thPool,void**tag)#

Retrieve the tag associated with the memory pool or NULL if no tag is set.

Parameters:
  • hPool – specified memory pool

  • tag – [out] tag associated with the memory pool

Returns:

UMF_RESULT_SUCCESS on success.

Disjoint Pool#

The Disjoint Pool allocates user data using the configured provider, while alsopreserving metadata in DRAM.

Defines

UMF_DISJOINT_POOL_MIN_BUCKET_DEFAULT_SIZE#

Typedefs

typedefstructumf_disjoint_pool_shared_limits_t*umf_disjoint_pool_shared_limits_handle_t#

Memory limits that can be shared between multiple pool instances, i.e. if multiple pools use the same shared limits, sum of those pools’ sizes cannot exceed MaxSize.

typedefstructumf_disjoint_pool_params_t*umf_disjoint_pool_params_handle_t#

handle to the parameters of the disjoint pool.

Functions

umf_result_tumfDisjointPoolSharedLimitsCreate(size_tMaxSize,umf_disjoint_pool_shared_limits_handle_t*hSharedLimits)#

Create a pool limits struct.

Parameters:
  • MaxSize – specifies hard limit for memory allocated from a provider.

  • hSharedLimits – [out] handle to the newly created shared limits struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolSharedLimitsDestroy(umf_disjoint_pool_shared_limits_handle_thSharedLimits)#

Destroy previously created pool limits struct.

Parameters:
  • hSharedLimits – handle to the shared limits struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsCreate(umf_disjoint_pool_params_handle_t*hParams)#

Create a struct to store parameters of disjoint pool.

Parameters:
  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsDestroy(umf_disjoint_pool_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetSlabMinSize(umf_disjoint_pool_params_handle_thParams,size_tslabMinSize)#

Set minimum allocation size that will be requested from the memory provider.

Default value for minimum size of slab’s is 64KB.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • slabMinSize – minimum allocation size.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetMaxPoolableSize(umf_disjoint_pool_params_handle_thParams,size_tmaxPoolableSize)#

Set size limit for allocations that are subject to pooling.

Default value for maximum poolable size is 2MB.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • maxPoolableSize – maximum poolable size.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetCapacity(umf_disjoint_pool_params_handle_thParams,size_tmaxCapacity)#

Set maximum capacity of each bucket. Each bucket will hold a max ofmaxCapacity unfreed slabs.

Default value for capacity is 4.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • maxCapacity – maximum capacity of each bucket.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetMinBucketSize(umf_disjoint_pool_params_handle_thParams,size_tminBucketSize)#

Set minimum bucket allocation size.

Default value for minimum bucket size is 8.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • minBucketSize – minimum bucket size. Must be power of 2.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetTrace(umf_disjoint_pool_params_handle_thParams,intpoolTrace)#

Set trace level for pool usage statistics.

Default value for pool trace is 0 (no traces).

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • poolTrace – trace level.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetSharedLimits(umf_disjoint_pool_params_handle_thParams,umf_disjoint_pool_shared_limits_handle_thSharedLimits)#

Set shared limits for disjoint pool.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • hSharedLimits – handle to the shared limits.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDisjointPoolParamsSetName(umf_disjoint_pool_params_handle_thParams,constchar*name)#

Set custom name of the disjoint pool to be used in the traces.

Parameters:
  • hParams – handle to the parameters of the disjoint pool.

  • name – custom name of the pool. Name longer than 64 characters will be truncated.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_pool_ops_t*umfDisjointPoolOps(void)#

Jemalloc Pool#

A jemalloc-based memory pool manager. More info about jemalloc could be foundhere:jemalloc/jemalloc.

Typedefs

typedefstructumf_jemalloc_pool_params_t*umf_jemalloc_pool_params_handle_t#

handle to the optional parameters of the jemalloc pool.

Functions

umf_result_tumfJemallocPoolParamsCreate(umf_jemalloc_pool_params_handle_t*hParams)#

Create an optional struct to store parameters of jemalloc pool.

Parameters:
  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfJemallocPoolParamsDestroy(umf_jemalloc_pool_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the jemalloc pool.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfJemallocPoolParamsSetNumArenas(umf_jemalloc_pool_params_handle_thParams,size_tnumArenas)#

Customize number of arenas created for this pool. Default is the number of CPU cores * 4.

The number of arenas is limited by jemalloc; setting this value too high may reduce the number of pools available for creation.

Parameters:
  • hParams – handle to the parameters of the jemalloc pool.

  • numArenas – number of arenas.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_pool_ops_t*umfJemallocPoolOps(void)#

Proxy Pool#

Proxy Pool forwards all requests to the underlying memory provider. CurrentlyumfPoolRealloc, umfPoolCalloc and umfPoolMallocUsableSize functions are notsupported by the Proxy Pool.

Functions

constumf_memory_pool_ops_t*umfProxyPoolOps(void)#

Scalable Pool#

A oneTBB-based memory pool manager.

Typedefs

typedefstructumf_scalable_pool_params_t*umf_scalable_pool_params_handle_t#

handle to the parameters of the scalable pool.

Functions

umf_result_tumfScalablePoolParamsCreate(umf_scalable_pool_params_handle_t*hParams)#

Create a struct to store parameters of scalable pool.

Parameters:
  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfScalablePoolParamsDestroy(umf_scalable_pool_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the scalable pool.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfScalablePoolParamsSetGranularity(umf_scalable_pool_params_handle_thParams,size_tgranularity)#

Set granularity of allocations that scalable pool requests from a memory provider.

Parameters:
  • hParams – handle to the parameters of the scalable pool.

  • granularity – granularity in bytes.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfScalablePoolParamsSetKeepAllMemory(umf_scalable_pool_params_handle_thParams,boolkeepAllMemory)#

Set if scalable pool should keep all memory allocated from memory provider till destruction.

Parameters:
  • hParams – handle to the parameters of the scalable pool.

  • keepAllMemorytrue if the scalable pool should not callumfMemoryProviderFree until it is destroyed,false otherwise.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_pool_ops_t*umfScalablePoolOps(void)#

Returnops structure containing pointers to the scalable pool implementation.

Returns:

pointer to theumf_memory_pool_ops_t struct.

Providers#

The memory provider is responsible for coarse-grained memory allocations andmemory page management.

UMF includes predefined providers, but can also work with providers whichimplement the memory provider API.

Memory Provider#

The memory provider API provides a functions for allocating, deallocating andmanipulating coarse-grained memory as well as functions that create, destroyand operate on the provider.

Enums

enumumf_memory_visibility_t#

Memory visibility mode.

Values:

enumeratorUMF_MEM_MAP_PRIVATE#

private memory mapping

enumeratorUMF_MEM_MAP_SHARED#

shared memory mapping (Linux only)

enumumf_mem_protection_flag_t#

Protection of the memory allocations.

Values:

enumeratorUMF_PROTECTION_NONE#

Memory allocations can not be accessed.

enumeratorUMF_PROTECTION_READ#

Memory allocations can be read.

enumeratorUMF_PROTECTION_WRITE#

Memory allocations can be written.

enumeratorUMF_PROTECTION_EXEC#

Memory allocations can be executed.

Typedefs

typedefstructumf_memory_provider_t*umf_memory_provider_handle_t#

A struct containing memory provider specific set of functions.

Functions

umf_result_tumfMemoryProviderCreate(constumf_memory_provider_ops_t*ops,constvoid*params,umf_memory_provider_handle_t*hProvider)#

Creates new memory provider.

Parameters:
  • ops – instance of umf_memory_provider_ops_t

  • params – pointer to provider-specific parameters

  • hProvider – [out] pointer to the newly created memory provider

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderDestroy(umf_memory_provider_handle_thProvider)#

Destroys memory provider.

Parameters:
  • hProvider – handle to the memory provider

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderAlloc(umf_memory_provider_handle_thProvider,size_tsize,size_talignment,void**ptr)#

Allocatessize bytes of uninitialized storage from memoryhProvider with the specifiedalignment.

Parameters:
  • hProvider – handle to the memory provider

  • size – number of bytes to allocate

  • alignment – alignment of the allocation in bytes, it has to be a multiple or a divider of the minimum page size

  • ptr – [out] pointer to the allocated memory

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure

umf_result_tumfMemoryProviderFree(umf_memory_provider_handle_thProvider,void*ptr,size_tsize)#

Frees the memory space pointed byptr from the memoryhProvider.

Parameters:
  • hProvider – handle to the memory provider

  • ptr – pointer to the allocated memory to free

  • size – size of the allocation

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure

umf_result_tumfMemoryProviderGetLastNativeError(umf_memory_provider_handle_thProvider,constchar**ppMessage,int32_t*pError)#

Retrieve string representation of the underlying provider specific result reported by the last API that returned UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC. Allows for a provider independent way to return a provider specific result.

  • Implementationsmust store the message and error code in thread-local storage prior to returning UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC.

  • The message and error code will only be valid if a previously called entry-point returned UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC.

  • The memory pointed to by the C string returned inppMessage is owned by the adapter andmust be null terminated.

  • The applicationmay call this function from simultaneous threads.

  • The implementation of this functionshould be lock-free.

Parameters:
  • hProvider – handle to the memory provider

  • ppMessage – [out] pointer to a string containing provider specific result in string representation

  • pError – [out] pointer to an integer where the adapter specific error code will be stored

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderGetRecommendedPageSize(umf_memory_provider_handle_thProvider,size_tsize,size_t*pageSize)#

Retrieve recommended page size for a given allocation size.

Parameters:
  • hProvider – handle to the memory provider

  • size – allocation size

  • pageSize – [out] pointer to the recommended page size

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderGetMinPageSize(umf_memory_provider_handle_thProvider,constvoid*ptr,size_t*pageSize)#

Retrieve minimum possible page size used by memory region referenced by a givenptr or minimum possible page size that can be used by thehProvider ifptr is NULL.

Parameters:
  • hProvider – handle to the memory provider

  • ptr – [optional] pointer to memory allocated by the memoryhProvider

  • pageSize – [out] pointer to the minimum possible page size

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderPurgeLazy(umf_memory_provider_handle_thProvider,void*ptr,size_tsize)#

Discard physical pages within the virtual memory mapping associated at the given addr andsize. This call is asynchronous and may delay purging the pages indefinitely.

Parameters:
  • hProvider – handle to the memory provider

  • ptr – beginning of the virtual memory range

  • size – size of the virtual memory range

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider.

umf_result_tumfMemoryProviderPurgeForce(umf_memory_provider_handle_thProvider,void*ptr,size_tsize)#

Discard physical pages within the virtual memory mapping associated at the given addr andsize. This call is synchronous and if it succeeds, pages are guaranteed to be zero-filled on the next access.

Parameters:
  • hProvider – handle to the memory provider

  • ptr – beginning of the virtual memory range

  • size – size of the virtual memory range

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider.

umf_result_tumfMemoryProviderGetIPCHandleSize(umf_memory_provider_handle_thProvider,size_t*size)#

Retrieve the size of opaque data structure required to store IPC data.

Parameters:
  • hProvider – [in] handle to the memory provider.

  • size – [out] pointer to the size.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_NOT_SUPPORTED if IPC functionality is not supported by this provider.

umf_result_tumfMemoryProviderGetIPCHandle(umf_memory_provider_handle_thProvider,constvoid*ptr,size_tsize,void*providerIpcData)#

Retrieve an IPC memory handle for the specified allocation.

Parameters:
  • hProvider – [in] handle to the memory provider.

  • ptr – [in] beginning of the virtual memory range returned by umfMemoryProviderAlloc function.

  • size – [in] size of the memory address range.

  • providerIpcData – [out] pointer to the preallocated opaque data structure to store IPC handle.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_INVALID_ARGUMENT if ptr was not allocated by this provider. UMF_RESULT_ERROR_NOT_SUPPORTED if IPC functionality is not supported by this provider.

umf_result_tumfMemoryProviderPutIPCHandle(umf_memory_provider_handle_thProvider,void*providerIpcData)#

Release IPC handle retrieved with get_ipc_handle function.

Parameters:
  • hProvider – [in] handle to the memory provider.

  • providerIpcData – [in] pointer to the IPC opaque data structure.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_INVALID_ARGUMENT if providerIpcData was not created by this provider. UMF_RESULT_ERROR_NOT_SUPPORTED if IPC functionality is not supported by this provider.

umf_result_tumfMemoryProviderOpenIPCHandle(umf_memory_provider_handle_thProvider,void*providerIpcData,void**ptr)#

Open IPC handle.

Parameters:
  • hProvider – [in] handle to the memory provider.

  • providerIpcData – [in] pointer to the IPC opaque data structure.

  • ptr – [out] pointer to the memory to be used in the current process.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_INVALID_ARGUMENT if providerIpcData cannot be handled by the provider. UMF_RESULT_ERROR_NOT_SUPPORTED if IPC functionality is not supported by this provider.

umf_result_tumfMemoryProviderCloseIPCHandle(umf_memory_provider_handle_thProvider,void*ptr,size_tsize)#

Close an IPC memory handle.

Parameters:
  • hProvider – [in] handle to the memory provider.

  • ptr – [in] pointer returned by umfMemoryProviderOpenIPCHandle function.

  • size – [in] size of the memory address range.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. UMF_RESULT_ERROR_INVALID_ARGUMENT if invalidhProvider orptr are passed. UMF_RESULT_ERROR_NOT_SUPPORTED if IPC functionality is not supported by this provider.

umf_result_tumfMemoryProviderGetName(umf_memory_provider_handle_thProvider,constchar**name)#

Retrieve name of a given memoryhProvider.

Parameters:
  • hProvider – handle to the memory provider

  • name – [out] pointer to the provider name string

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure

umf_result_tumfGetLastFailedMemoryProvider(umf_memory_provider_handle_t*provider)#

Retrieve handle to the last memory provider that returned status other than UMF_RESULT_SUCCESS on the calling thread.

Handle to the memory provider is stored in the thread local storage. The handle is updated every time a memory provider returns status other than UMF_RESULT_SUCCESS.

Parameters:
  • provider – [out] pointer to the handle to the last failed memory provider

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderAllocationSplit(umf_memory_provider_handle_thProvider,void*ptr,size_ttotalSize,size_tfirstSize)#

Splits a coarse grain allocation into 2 adjacent allocations that can be managed (freed) separately.

Parameters:
  • hProvider – handle to the memory provider

  • ptr – pointer to the beginning of the allocation

  • totalSize – total size of the allocation to be split

  • firstSize – size of the first new allocation, second allocation

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure

umf_result_tumfMemoryProviderAllocationMerge(umf_memory_provider_handle_thProvider,void*lowPtr,void*highPtr,size_ttotalSize)#

Merges two coarse grain allocations into a single allocation that can be managed (freed) as a whole.

Parameters:
  • hProvider – handle to the memory provider

  • lowPtr – pointer to the first allocation

  • highPtr – pointer to the second allocation (should be > lowPtr)

  • totalSize – size of a new merged allocation. Should be equal to the sum of sizes of allocations beginning at lowPtr and highPtr

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure

Fixed Memory Provider#

A memory provider that can provide memory from a given preallocated buffer.

Enums

enumumf_fixed_memory_provider_native_error_t#

Fixed Memory Provider operation results.

Values:

enumeratorUMF_FIXED_RESULT_SUCCESS#

Success.

enumeratorUMF_FIXED_RESULT_ERROR_PURGE_FORCE_FAILED#

Force purging failed.

Typedefs

typedefstructumf_fixed_memory_provider_params_t*umf_fixed_memory_provider_params_handle_t#

Functions

umf_result_tumfFixedMemoryProviderParamsCreate(void*ptr,size_tsize,umf_fixed_memory_provider_params_handle_t*hParams)#

Create a struct to store parameters of the Fixed Memory Provider.

Parameters:
  • ptr – [in] pointer to the memory region.

  • size – [in] size of the memory region in bytes.

  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfFixedMemoryProviderParamsSetMemory(umf_fixed_memory_provider_params_handle_thParams,void*ptr,size_tsize)#

Set the memory region in params struct. Overwrites the previous value. It provides an ability to use the same instance of params to create multiple instances of the provider for different memory regions.

Parameters:
  • hParams – [in] handle to the parameters of the Fixed Memory Provider.

  • ptr – [in] pointer to the memory region.

  • size – [in] size of the memory region in bytes.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfFixedMemoryProviderParamsDestroy(umf_fixed_memory_provider_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – [in] handle to the parameters of the Fixed Memory Provider.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_provider_ops_t*umfFixedMemoryProviderOps(void)#

Retrieve the operations structure for the Fixed Memory Provider.

Returns:

Pointer to the umf_memory_provider_ops_t structure.

OS Memory Provider#

A memory provider that provides memory from an operating system.

Enums

enumumf_numa_mode_t#

Memory binding mode Specifies how memory is bound to NUMA nodes on systems that support NUMA. Not every mode is supported on every system.

Values:

enumeratorUMF_NUMA_MODE_DEFAULT#

Default binding mode. Actual binding policy is system-specific. On Linux this corresponds to MPOL_DEFAULT. If this mode is specified, nodemask must be NULL and maxnode must be 0.

enumeratorUMF_NUMA_MODE_BIND#

Restricts memory allocation to nodes specified in nodemask. Allocations might come from any of the allowed nodes. Nodemask must specify at

enumeratorUMF_NUMA_MODE_INTERLEAVE#

Interleaves memory allocations across the set of nodes specified in nodemask. Nodemask must specify at least one node.

enumeratorUMF_NUMA_MODE_PREFERRED#

Specifies preferred node for allocation. If allocation cannot be fulfilled, memory will be allocated from other nodes.

enumeratorUMF_NUMA_MODE_SPLIT#

Allocation will be split evenly across nodes specified in nodemask. umf_numa_split_partition_t can be passed in umf_os_memory_provider_params_t structure to specify other distribution.

enumeratorUMF_NUMA_MODE_LOCAL#

The memory is allocated on the node of the CPU that triggered the allocation. If this mode is specified, nodemask must be NULL and maxnode must be 0.

enumumf_os_memory_provider_native_error_t#

OS Memory Provider operation results.

Values:

enumeratorUMF_OS_RESULT_SUCCESS#

Success.

enumeratorUMF_OS_RESULT_ERROR_ALLOC_FAILED#

Memory allocation failed.

enumeratorUMF_OS_RESULT_ERROR_ADDRESS_NOT_ALIGNED#

Allocated address is not aligned.

enumeratorUMF_OS_RESULT_ERROR_BIND_FAILED#

Binding memory to NUMA node failed.

enumeratorUMF_OS_RESULT_ERROR_FREE_FAILED#

Memory deallocation failed.

enumeratorUMF_OS_RESULT_ERROR_PURGE_LAZY_FAILED#

Lazy purging failed.

enumeratorUMF_OS_RESULT_ERROR_PURGE_FORCE_FAILED#

Force purging failed.

enumeratorUMF_OS_RESULT_ERROR_TOPO_DISCOVERY_FAILED#

HWLOC topology discovery failed.

Typedefs

typedefstructumf_os_memory_provider_params_t*umf_os_memory_provider_params_handle_t#

Functions

umf_result_tumfOsMemoryProviderParamsCreate(umf_os_memory_provider_params_handle_t*hParams)#

Create a struct to store parameters of the OS memory provider.

Parameters:
  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsDestroy(umf_os_memory_provider_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetProtection(umf_os_memory_provider_params_handle_thParams,unsignedprotection)#

Set protection flags for the OS memory provider.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • protection – combination ofumf_mem_protection_flags_t flags.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetVisibility(umf_os_memory_provider_params_handle_thParams,umf_memory_visibility_tvisibility)#

Set visibility mode for the OS memory provider.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • visibility – memory visibility mode.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetShmName(umf_os_memory_provider_params_handle_thParams,constchar*shm_name)#

Set a name of a shared memory file for the OS memory provider.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • shm_name – a name of a shared memory file.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetNumaList(umf_os_memory_provider_params_handle_thParams,unsigned*numa_list,unsignednuma_list_len)#

Set NUMA nodes for the OS memory provider.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • numa_list – ordered list of NUMA nodes.

  • numa_list_len – length of the numa_list.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetNumaMode(umf_os_memory_provider_params_handle_thParams,umf_numa_mode_tnuma_mode)#

Set NUMA mode for the OS memory provider.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • numa_mode – NUMA mode. Describes how node list is interpreted.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetPartSize(umf_os_memory_provider_params_handle_thParams,size_tpart_size)#

Set part size for the interleave mode. 0 means default (system specific) It might be rounded up because of HW constraints.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • part_size – part size for interleave mode.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOsMemoryProviderParamsSetPartitions(umf_os_memory_provider_params_handle_thParams,umf_numa_split_partition_t*partitions,unsignedpartitions_len)#

Set partitions for the split mode.

Parameters:
  • hParams – handle to the parameters of the OS memory provider.

  • partitions – ordered list of the partitions for the split mode.

  • partitions_len – length of the partitions array.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_provider_ops_t*umfOsMemoryProviderOps(void)#

Level Zero Provider#

A memory provider that provides memory from L0 device.

Enums

enumumf_level_zero_memory_provider_free_policy_t#

Values:

enumeratorUMF_LEVEL_ZERO_MEMORY_PROVIDER_FREE_POLICY_DEFAULT#

Free memory immediately. Default.

enumeratorUMF_LEVEL_ZERO_MEMORY_PROVIDER_FREE_POLICY_BLOCKING_FREE#

Blocks until all commands using the memory are complete before freeing.

enumeratorUMF_LEVEL_ZERO_MEMORY_PROVIDER_FREE_POLICY_DEFER_FREE#

Schedules the memory to be freed but does not free immediately.

Typedefs

typedefstruct_ze_device_handle_t*ze_device_handle_t#
typedefstruct_ze_context_handle_t*ze_context_handle_t#
typedefstructumf_level_zero_memory_provider_params_t*umf_level_zero_memory_provider_params_handle_t#

handle to the parameters of the Level Zero Memory Provider.

Functions

umf_result_tumfLevelZeroMemoryProviderParamsCreate(umf_level_zero_memory_provider_params_handle_t*hParams)#

Create a struct to store parameters of the Level Zero Memory Provider.

Parameters:
  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsDestroy(umf_level_zero_memory_provider_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsSetContext(umf_level_zero_memory_provider_params_handle_thParams,ze_context_handle_thContext)#

Set the Level Zero context handle in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

  • hContext – handle to the Level Zero context. Cannot beNULL.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsSetDevice(umf_level_zero_memory_provider_params_handle_thParams,ze_device_handle_thDevice)#

Set the Level Zero device handle in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

  • hDevice – handle to the Level Zero device. Can beNULL if memory type isUMF_MEMORY_TYPE_HOST.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsSetMemoryType(umf_level_zero_memory_provider_params_handle_thParams,umf_usm_memory_type_tmemoryType)#

Set the memory type in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

  • memoryType – memory type.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsSetResidentDevices(umf_level_zero_memory_provider_params_handle_thParams,ze_device_handle_t*hDevices,uint32_tdeviceCount)#

Set the resident devices in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

  • hDevices – array of devices for which the memory should be made resident.

  • deviceCount – number of devices for which the memory should be made resident.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsSetFreePolicy(umf_level_zero_memory_provider_params_handle_thParams,umf_level_zero_memory_provider_free_policy_tpolicy)#

Set the memory free policy.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

  • policy – memory free policy.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfLevelZeroMemoryProviderParamsSetDeviceOrdinal(umf_level_zero_memory_provider_params_handle_thParams,uint32_tdeviceOrdinal)#

Set the device ordinal in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the Level Zero Memory Provider.

  • deviceOrdinal – device ordinal.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_provider_ops_t*umfLevelZeroMemoryProviderOps(void)#

CUDA Provider#

A memory provider that provides memory from CUDA device.

Typedefs

typedefstructumf_cuda_memory_provider_params_t*umf_cuda_memory_provider_params_handle_t#

Functions

umf_result_tumfCUDAMemoryProviderParamsCreate(umf_cuda_memory_provider_params_handle_t*hParams)#

Create a struct to store parameters of the CUDA Memory Provider.

Parameters:
  • hParams – [out] handle to the newly created parameters structure, initialized with the default (current) context and device ID.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfCUDAMemoryProviderParamsDestroy(umf_cuda_memory_provider_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the CUDA Memory Provider.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfCUDAMemoryProviderParamsSetContext(umf_cuda_memory_provider_params_handle_thParams,void*hContext)#

Set the CUDA context handle in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the CUDA Memory Provider.

  • hContext – handle to the CUDA context.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfCUDAMemoryProviderParamsSetDevice(umf_cuda_memory_provider_params_handle_thParams,inthDevice)#

Set the CUDA device handle in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the CUDA Memory Provider.

  • hDevice – handle to the CUDA device.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfCUDAMemoryProviderParamsSetMemoryType(umf_cuda_memory_provider_params_handle_thParams,umf_usm_memory_type_tmemoryType)#

Set the memory type in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the CUDA Memory Provider.

  • memoryType – memory type.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfCUDAMemoryProviderParamsSetAllocFlags(umf_cuda_memory_provider_params_handle_thParams,unsignedintflags)#

Set the allocation flags in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the CUDA Memory Provider.

  • flags – valid combination of CUDA allocation flags.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_provider_ops_t*umfCUDAMemoryProviderOps(void)#

DevDax Memory Provider#

A memory provider that provides memory from a device DAX (a character device file like /dev/daxX.Y).

Enums

enumumf_devdax_memory_provider_native_error_t#

Devdax Memory Provider operation results.

Values:

enumeratorUMF_DEVDAX_RESULT_SUCCESS#

Success.

enumeratorUMF_DEVDAX_RESULT_ERROR_ALLOC_FAILED#

Memory allocation failed.

enumeratorUMF_DEVDAX_RESULT_ERROR_ADDRESS_NOT_ALIGNED#

Allocated address is not aligned.

enumeratorUMF_DEVDAX_RESULT_ERROR_FREE_FAILED#

Memory deallocation failed.

enumeratorUMF_DEVDAX_RESULT_ERROR_PURGE_FORCE_FAILED#

Force purging failed.

Typedefs

typedefstructumf_devdax_memory_provider_params_t*umf_devdax_memory_provider_params_handle_t#

Functions

umf_result_tumfDevDaxMemoryProviderParamsCreate(constchar*path,size_tsize,umf_devdax_memory_provider_params_handle_t*hParams)#

Create a struct to store parameters of the Devdax Memory Provider.

Parameters:
  • path – [in] path of the device DAX.

  • size – [in] size of the device DAX in bytes.

  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDevDaxMemoryProviderParamsDestroy(umf_devdax_memory_provider_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – [in] handle to the parameters of the Devdax Memory Provider.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDevDaxMemoryProviderParamsSetDeviceDax(umf_devdax_memory_provider_params_handle_thParams,constchar*path,size_tsize)#

Set a device DAX in the parameters struct. Overwrites the previous value. It provides an ability to use the same instance of params to create multiple instances of the provider for different DAX devices.

Parameters:
  • hParams – [in] handle to the parameters of the Devdax Memory Provider.

  • path – [in] path of the device DAX.

  • size – [in] size of the device DAX in bytes.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfDevDaxMemoryProviderParamsSetProtection(umf_devdax_memory_provider_params_handle_thParams,unsignedprotection)#

Set the protection flags in the parameters struct.

Parameters:
  • hParams – [in] handle to the parameters of the Devdax Memory Provider.

  • protection – [in] combination of ‘umf_mem_protection_flags_t’ flags.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_provider_ops_t*umfDevDaxMemoryProviderOps(void)#

File Memory Provider#

A memory provider that provides memory by mapping a regular, extendable file.

Enums

enumumf_file_memory_provider_native_error_t#

File Memory Provider operation results.

Values:

enumeratorUMF_FILE_RESULT_SUCCESS#

Success.

enumeratorUMF_FILE_RESULT_ERROR_ALLOC_FAILED#

Memory allocation failed.

enumeratorUMF_FILE_RESULT_ERROR_FREE_FAILED#

Memory deallocation failed.

enumeratorUMF_FILE_RESULT_ERROR_PURGE_FORCE_FAILED#

Force purging failed.

Typedefs

typedefstructumf_file_memory_provider_params_t*umf_file_memory_provider_params_handle_t#

Functions

umf_result_tumfFileMemoryProviderParamsCreate(constchar*path,umf_file_memory_provider_params_handle_t*hParams)#

Create a struct to store parameters of the File Memory Provider.

Parameters:
  • path – path to the file.

  • hParams – [out] handle to the newly created parameters struct.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfFileMemoryProviderParamsDestroy(umf_file_memory_provider_params_handle_thParams)#

Destroy parameters struct.

Parameters:
  • hParams – handle to the parameters of the File Memory Provider.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfFileMemoryProviderParamsSetPath(umf_file_memory_provider_params_handle_thParams,constchar*path)#

Set the path in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the File Memory Provider.

  • path – path to the file.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfFileMemoryProviderParamsSetProtection(umf_file_memory_provider_params_handle_thParams,unsignedprotection)#

Set the protection in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the File Memory Provider.

  • protection – protection. Combination ofumf_mem_protection_flags_t flags

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfFileMemoryProviderParamsSetVisibility(umf_file_memory_provider_params_handle_thParams,umf_memory_visibility_tvisibility)#

Set the visibility in the parameters struct.

Parameters:
  • hParams – handle to the parameters of the File Memory Provider.

  • visibility – memory visibility mode.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

constumf_memory_provider_ops_t*umfFileMemoryProviderOps(void)#

Memspace#

TODO: Add general information about memspaces.

Note

The memspace APIs are experimental and may change in future releases.

Memspace#

Typedefs

typedefstructumf_memspace_t*umf_memspace_handle_t#
typedefconststructumf_memspace_t*umf_const_memspace_handle_t#
typedefint(*umf_memspace_filter_func_t)(umf_const_memspace_handle_thMemspace,umf_const_memtarget_handle_thMemtarget,void*args)#

Custom filter function for umfMemspaceUserFilter.

Param hMemspace:

handle to memspace

Param hMemtarget:

handle to memory target

Param args:

user provided arguments

Return:

zero if hMemtarget should be removed from memspace, positive otherwise, and negative on error

Functions

umf_result_tumfPoolCreateFromMemspace(umf_const_memspace_handle_thMemspace,umf_const_mempolicy_handle_thPolicy,umf_memory_pool_handle_t*hPool)#

Creates new memory pool from memspace and policy.

Parameters:
  • hMemspace – handle to memspace

  • hPolicy – handle to policy

  • hPool – [out] handle to the newly created memory pool

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemoryProviderCreateFromMemspace(umf_const_memspace_handle_thMemspace,umf_const_mempolicy_handle_thPolicy,umf_memory_provider_handle_t*hProvider)#

Creates new memory provider from memspace and policy.

Parameters:
  • hMemspace – handle to memspace

  • hPolicy – handle to policy

  • hProvider – [out] handle to the newly created memory provider

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemspaceCreateFromNumaArray(unsigned*nodeIds,size_tnumIds,umf_memspace_handle_t*hMemspace)#

Creates new memspace from an array of NUMA node ids.

Parameters:
  • nodeIds – array of NUMA node ids

  • numIds – size of the array; it has to be greater than 0

  • hMemspace – [out] handle to the newly created memspace

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemspaceDestroy(umf_memspace_handle_thMemspace)#

Destroys memspace.

Parameters:
  • hMemspace – handle to memspace

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_const_memspace_handle_tumfMemspaceHostAllGet(void)#

Retrieves predefined host all memspace.

Returns:

host all memspace handle on success or NULL on failure.

umf_const_memspace_handle_tumfMemspaceHighestCapacityGet(void)#

Retrieves predefined highest capacity memspace.

Returns:

highest capacity memspace handle on success or NULL on failure.

umf_const_memspace_handle_tumfMemspaceHighestBandwidthGet(void)#

Retrieves predefined highest bandwidth memspace.

Returns:

highest bandwidth memspace handle on success or NULL on failure (no HMAT support).

umf_const_memspace_handle_tumfMemspaceLowestLatencyGet(void)#

Retrieves predefined lowest latency memspace.

Returns:

lowest latency memspace handle on success or NULL on failure (no HMAT support).

umf_result_tumfMemspaceNew(umf_memspace_handle_t*hMemspace)#

Creates new empty memspace, which can be populated with umfMemspaceMemtargetAdd()

Parameters:
  • hMemspace – [out] handle to the newly created memspace

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

size_tumfMemspaceMemtargetNum(umf_const_memspace_handle_thMemspace)#

Returns number of memory targets in memspace.

Parameters:
  • hMemspace – handle to memspace

Returns:

number of memory targets in memspace

umf_const_memtarget_handle_tumfMemspaceMemtargetGet(umf_const_memspace_handle_thMemspace,unsignedtargetNum)#

Returns memory target by index.

Parameters:
  • hMemspace – handle to memspace

  • targetNum – index of the memory target

Returns:

memory target handle on success or NULL on invalid input.

umf_result_tumfMemspaceMemtargetAdd(umf_memspace_handle_thMemspace,umf_const_memtarget_handle_thMemtarget)#

Adds memory target to memspace.

This function duplicates the memory target and then adds it to the memspace. This means that original memtarget handle and the handle of the duplicated memtarget are different and you cannot use it interchangeably. You can useumfMemspaceMemtargetGet() to retrieve new handle.

Parameters:
  • hMemspace – handle to memspace

  • hMemtarget – handle to memory target

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemspaceMemtargetRemove(umf_memspace_handle_thMemspace,umf_const_memtarget_handle_thMemtarget)#

Removes memory target from memspace.

Parameters:
  • hMemspace – handle to memspace

  • hMemtarget – handle to memory target

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemspaceClone(umf_const_memspace_handle_thMemspace,umf_memspace_handle_t*hNewMemspace)#

Clones memspace.

Parameters:
  • hMemspace – handle to memspace

  • hNewMemspace – [out] handle to the newly created memspace

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemspaceFilterById(umf_memspace_handle_thMemspace,unsigned*ids,size_tsize)#

Removes all memory targets with non-matching numa node ids.

Parameters:
  • hMemspace – handle to memspace

  • ids – array of numa node ids

  • size – size of the array

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. If the error code is UMF_RESULT_UNKNOWN the memspace is corrupted, otherwise the memspace is not modified.

umf_result_tumfMemspaceFilterByCapacity(umf_memspace_handle_thMemspace,int64_tsize)#

Filters out memory targets that capacity is less than specified size.

Negative values of size parameters are reserved for future extension of functionality of this function.

Parameters:
  • hMemspace – handle to memspace

  • size – minimum capacity of memory target

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. If the error code is UMF_RESULT_UNKNOWN the memspace is corrupted, otherwise the memspace is not modified.

umf_result_tumfMemspaceUserFilter(umf_memspace_handle_thMemspace,umf_memspace_filter_func_tfilter,void*args)#

Filters out memory targets based on user provided function.

Parameters:
  • hMemspace – handle to memspace

  • filter – user provided function

  • args – user provided arguments

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure. If the error code is UMF_RESULT_UNKNOWN the memspace is corrupted, otherwise the memspace is not modified.

Mempolicy#

TODO: Add general information about mempolicies.

Note

The mempolicy APIs are experimental and may change in future releases.

Mempolicy#

Enums

enumumf_mempolicy_membind_t#

Values:

enumeratorUMF_MEMPOLICY_INTERLEAVE#

Interleave memory from all memory in memspace.

enumeratorUMF_MEMPOLICY_BIND#

Bind memory to memspace.

enumeratorUMF_MEMPOLICY_PREFERRED#

Prefer memory from memspace but fallback to other memory if not available.

enumeratorUMF_MEMPOLICY_SPLIT#

Allocation will be split evenly across nodes specified in nodemask. umf_mempolicy_split_partition_t can be used to specify different distribution.

Typedefs

typedefstructumf_mempolicy_t*umf_mempolicy_handle_t#
typedefconststructumf_mempolicy_t*umf_const_mempolicy_handle_t#

Functions

umf_result_tumfMempolicyCreate(umf_mempolicy_membind_tbind,umf_mempolicy_handle_t*hPolicy)#

Creates a new memory policy.

Parameters:
  • bind – memory binding policy

  • hPolicy – [out] handle to the newly created memory policy

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMempolicyDestroy(umf_mempolicy_handle_thPolicy)#

Destroys memory policy.

Parameters:
  • hPolicy – handle to memory policy

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMempolicySetInterleavePartSize(umf_mempolicy_handle_thPolicy,size_tpartSize)#

Sets custom part size for interleaved memory policy - by default it’s interleaved by pages.

Parameters:
  • hPolicy – handle to memory policy

  • partSize – size of the part or zero to use default part size (page size)

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMempolicySetCustomSplitPartitions(umf_mempolicy_handle_thPolicy,umf_mempolicy_split_partition_t*partList,size_tpartListLen)#

Sets custom split partitions.

Parameters:
  • hPolicy – handle to memory policy

  • partList – ordered array of partitions

  • partListLen – length of the partList array

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

Memtarget#

TODO: Add general information about memtargets.

Note

The memtarget APIs are experimental and may change in future releases.

Memtarget#

Enums

enumumf_memtarget_type_t#

Values:

enumeratorUMF_MEMTARGET_TYPE_UNKNOWN#
enumeratorUMF_MEMTARGET_TYPE_NUMA#

Typedefs

typedefstructumf_memtarget_t*umf_memtarget_handle_t#
typedefconststructumf_memtarget_t*umf_const_memtarget_handle_t#

Functions

umf_result_tumfMemtargetGetType(umf_const_memtarget_handle_thMemtarget,umf_memtarget_type_t*type)#

Gets the type of the memory target.

Parameters:
  • hMemtarget – handle to the memory target

  • type – [out] type of the memory target

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemtargetGetCapacity(umf_const_memtarget_handle_thMemtarget,size_t*capacity)#

Get size of the memory target in bytes.

Parameters:
  • hMemtarget – handle to the memory target

  • capacity – [out] capacity of the memory target

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfMemtargetGetId(umf_const_memtarget_handle_thMemtarget,unsigned*id)#

Get physical ID of the memory target.

Parameters:
  • hMemtarget – handle to the memory target

  • id – [out] id of the memory target

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

Inter-Process Communication#

IPC API allows retrieving IPC handles for the memory buffers allocated fromUMF memory pools. The memory provider used by the pool should support IPCoperations for this API to work. Otherwise IPC APIs return an error.

IPC caching#

UMF employs IPC caching to avoid multiple IPC handles being created for the samecoarse-grain memory region allocated by the memory provider. UMF guarantees thatfor each coarse-grain memory region allocated by the memory provider, only oneIPC handle is created when theumfGetIPCHandle function is called. Allsubsequent calls to theumfGetIPCHandle function for the pointer to thesame memory region will return the entry from the cache.

The same is true for theumfOpenIPCHandle function. The actual mappingof the IPC handle to the virtual address space is created only once, and allsubsequent calls to open the same IPC handle will return the entry from the cache.The size of the cache for opened IPC handles is controlled by theUMF_MAX_OPENED_IPC_HANDLESenvironment variable. By default, the cache size is unlimited. However, if the environmentvariable is set and the cache size exceeds the limit, old items will be evicted. UMF tracksthe ref count for each entry in the cache and can evict only items with the ref count equal to 0.The ref count is increased when theumfOpenIPCHandle function is called and decreasedwhen theumfCloseIPCHandle function is called for the corresponding IPC handle.

IPC API#

Typedefs

typedefstructumf_ipc_data_t*umf_ipc_handle_t#
typedefvoid*umf_ipc_handler_handle_t#

Functions

umf_result_tumfPoolGetIPCHandleSize(umf_memory_pool_handle_thPool,size_t*size)#

Returns the size of IPC handles for the specified pool.

Parameters:
  • hPool – [in] Pool handle

  • size – [out] size of IPC handle in bytes.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfGetIPCHandle(constvoid*ptr,umf_ipc_handle_t*ipcHandle,size_t*size)#

Creates an IPC handle for the specified UMF allocation.

Parameters:
  • ptr – pointer to the allocated memory.

  • ipcHandle – [out] returned IPC handle.

  • size – [out] size of IPC handle in bytes.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfPutIPCHandle(umf_ipc_handle_tipcHandle)#

Release IPC handle retrieved by umfGetIPCHandle.

Parameters:
  • ipcHandle – IPC handle.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfOpenIPCHandle(umf_ipc_handler_handle_thIPCHandler,umf_ipc_handle_tipcHandle,void**ptr)#

Open IPC handle retrieved by umfGetIPCHandle.

Parameters:
  • hIPCHandler – [in] IPC Handler handle used to open the IPC handle.

  • ipcHandle – [in] IPC handle.

  • ptr – [out] pointer to the memory in the current process.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfCloseIPCHandle(void*ptr)#

Close IPC handle.

Parameters:
  • ptr – [in] pointer to the memory.

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

umf_result_tumfPoolGetIPCHandler(umf_memory_pool_handle_thPool,umf_ipc_handler_handle_t*hIPCHandler)#

Get handle to the IPC handler from existing pool.

Parameters:
  • hPool – [in] Pool handle

  • hIPCHandler – [out] handle to the IPC handler

Returns:

UMF_RESULT_SUCCESS on success or appropriate error code on failure.

Contents