Compute resource manager
Compute resource manager API
Manage attributes

Functions

static int HAP_compute_res_attr_init (compute_res_attr_t *attr)
 
static int HAP_compute_res_attr_set_serialize (compute_res_attr_t *attr, unsigned char b_serialize)
 
static int HAP_compute_res_attr_set_vtcm_param (compute_res_attr_t *attr, unsigned int vtcm_size, unsigned char b_single_page)
 
static void * HAP_compute_res_attr_get_vtcm_ptr (compute_res_attr_t *attr)
 
static int HAP_compute_res_attr_set_vtcm_param_v2 (compute_res_attr_t *attr, unsigned int vtcm_size, unsigned int min_page_size, unsigned int min_vtcm_size)
 
static int HAP_compute_res_attr_set_vtcm_backup (compute_res_attr_t *attr, void *buffer, unsigned int buffer_size)
 
static int HAP_compute_res_attr_set_threads (compute_res_attr_t *attr, unsigned int *threads, unsigned int num_threads)
 
static int HAP_compute_res_cached_set_threads (compute_res_threads_cmd_id command, unsigned int context_id, unsigned int *threads, unsigned int num_threads)
 
static int HAP_compute_res_attr_set_vtcm_clear_on_release (compute_res_attr_t *attr, unsigned char enable)
 
static int HAP_compute_res_attr_get_vtcm_ptr_v2 (compute_res_attr_t *attr, void **vtcm_ptr, unsigned int *vtcm_size)
 
static int HAP_compute_res_attr_set_hmx_param (compute_res_attr_t *attr, unsigned char b_enable)
 
static int HAP_compute_res_attr_set_cache_mode (compute_res_attr_t *attr, unsigned char b_enable)
 
static int HAP_compute_res_attr_set_app_type (compute_res_attr_t *attr, unsigned int application_id)
 

Detailed Description

Manage parameters affecting the requested shared resources

Function Documentation

◆ HAP_compute_res_attr_get_vtcm_ptr()

static void* HAP_compute_res_attr_get_vtcm_ptr ( compute_res_attr_t attr)
inlinestatic

Reads the VTCM memory pointer from the given attribute structure.

On a successful VTCM resource request placed via HAP_compute_res_acquire() using HAP_compute_res_attr_set_vtcm_param(), a user can invoke this helper function to retrieve the allocated VTCM address by passing the same attribute structure used in the respective HAP_compute_res_acquire() call.

Parameters
[in]attrPointer to compute the resource attribute structure compute_res_attr_t.
Returns
Void pointer to the allocated VTCM section.
0 signifies no allocation.

◆ HAP_compute_res_attr_get_vtcm_ptr_v2()

static int HAP_compute_res_attr_get_vtcm_ptr_v2 ( compute_res_attr_t attr,
void **  vtcm_ptr,
unsigned int *  vtcm_size 
)
inlinestatic

On a successful VTCM resource request placed via HAP_compute_res_acquire() or HAP_compute_res_acquire_cached() using HAP_compute_res_attr_set_vtcm_param_v2(), users invoke this helper function to retrieve the allocated VTCM address and size by passing the same attribute structure used in the respective acquire call.

Supported starting with Lahaina.

Parameters
[in]attrPointer to compute the resource attribute structure compute_res_attr_t.
[out]vtcm_ptrAssigned VTCM address; NULL for no allocation.
[out]vtcm_sizeSize of the allocated VTCM memory from the assigned pointer.
Returns
0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_attr_init()

static int HAP_compute_res_attr_init ( compute_res_attr_t attr)
inlinestatic

Initializes the attribute structure for a resource request.

The user must call this function before setting any specific resource property via other helper functions.

Parameters
[in]attrPointer to compute resource attribute structure, compute_res_attr_t.
Returns
0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED if unsupported.

◆ HAP_compute_res_attr_set_app_type()

static int HAP_compute_res_attr_set_app_type ( compute_res_attr_t attr,
unsigned int  application_id 
)
inlinestatic

Sets the application ID parameter in the resource structure used to select the appropriate VTCM partition.

If this application ID parameter is not explicitly set, the default partition is selected. The default application ID (0) is set when the attribute structure is initialized. Application IDs are defined in the kernel device tree configuration. If the given ID is not specified in the tree, the primary VTCM partition is selected.

Call this function after HAP_compute_res_attr_init().

Supported starting with Lahaina.

Parameters
[in]attrPointer to compute the resource attribute structure compute_res_attr_t.
[in]application_idApplication ID used to specify the VTCM partition.
Returns
0 upon success.
Nonzero upon failure.

◆ HAP_compute_res_attr_set_cache_mode()

static int HAP_compute_res_attr_set_cache_mode ( compute_res_attr_t attr,
unsigned char  b_enable 
)
inlinestatic

Sets or resets cacheable mode in the attribute structure.

A cacheable request allows users to allocate and release based on the context ID of the request. On a successful cacheable request via HAP_compute_res_acquire(), users get the same VTCM address and size across calls of HAP_compute_res_acquire_cached() and HAP_compute_res_release_cached() until the context is explicitly released via HAP_compute_res_release().

After a successful cacheable request via HAP_compute_res_acquire(), users can get the assigned VTCM pointer (if requested) by passing the attribute structure to HAP_compute_res_attr_get_vtcm_ptr() for v1 and HAP_compute_res_attr_get_vtcm_ptr_v2() for v2, and they must call HAP_compute_res_acquire_cached() before using the assigned resources.

Supported starting with Lahaina.

Parameters
[in]attrPointer to compute resource attribute structure, compute_res_attr_t.
[in]b_enable0 - Do not request cacheable mode (resets option).
1 - Request cacheable mode (sets option).
Returns
0 upon success.
Nonzero upon failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_attr_set_hmx_param()

static int HAP_compute_res_attr_set_hmx_param ( compute_res_attr_t attr,
unsigned char  b_enable 
)
inlinestatic

On chipsets with HMX, sets/resets the HMX request parameter in the attribute structure for acquiring the HMX resource.

Call this function after HAP_compute_res_attr_init().

Supported starting with Lahaina.

Parameters
[in]attrPointer to compute the resource attribute structure, compute_res_attr_t.
[in]b_enable0 - do not request HMX resource (resets option).
1 - request HMX resource (sets option).
Returns
0 upon success.
Nonzero upon failure.

◆ HAP_compute_res_attr_set_serialize()

static int HAP_compute_res_attr_set_serialize ( compute_res_attr_t attr,
unsigned char  b_serialize 
)
inlinestatic

Sets or clears the serialization option in the request resource structure.

Serialization allows participating use cases to run with mutually exclusive access to the entire cDSP which helps, for example, in avoiding cache thrashing while trying to run simultaneously on different hardware threads. Participating use cases issue blocking acquires on the serialization resource when ready to run, and each runs in turn when it is granted that resource.

Acquiring the serialization resource only ensures mutual exclusion from other cooperating use cases that also block on acquisition of that resource, it does not guarantee exclusion from concurrent use cases that do not request the serialization resource.

Parameters
[in]attrPointer to the compute resource attribute structure, compute_res_attr_t.
[in]b_serialize1 (TRUE) to participate in serialization.
0 (FALSE) otherwise.
Returns
0 upon success
Nonzero upon failure.

◆ HAP_compute_res_attr_set_threads()

static int HAP_compute_res_attr_set_threads ( compute_res_attr_t attr,
unsigned int *  threads,
unsigned int  num_threads 
)
inlinestatic

Updates provided attribute structure with user-provided thread id array.

On architectures supporting HAP_COMPUTE_RES_THREADS_FOR_AUTONOMOUS_PREEMPTION, Compute resource manager requires users to register the threads that will be using the compute resources requested via HAP_compute_res_acquire().

Call this function after HAP_compute_res_attr_init().

Parameters
[in]attrPointer to the compute resource attribute structure, compute_res_attr_t.
[in]threadsPointer to an array of QuRT thread identifiers associated with the resource request. This array should be valid till HAP_compute_res_acquire() is called on the prepared attribute.
[in]num_threadsNumber of QuRT thread identifiers in the provided threads array #threads. A maximum of HAP_COMPUTE_RES_MAX_NUM_THREADS number of threads can be provided.
Returns
0 for success.
Non-zero for failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_attr_set_vtcm_backup()

static int HAP_compute_res_attr_set_vtcm_backup ( compute_res_attr_t attr,
void *  buffer,
unsigned int  buffer_size 
)
inlinestatic

Sets VTCM backup buffer in the provided attribute structure.

Compute resource manager uses the provided buffer to backup VTCM allocated to the user during preemption of the associated request/context. The backup buffer provided should be able to accomodate all of the requested VTCM size. VTCM backup buffer is essential for preemption to work on architectures supporting HAP_COMPUTE_RES_THREADS_FOR_AUTONOMOUS_PREEMPTION (use HAP_compute_res_query_capability() to query preemption model supported)

Call this function after HAP_compute_res_attr_init().

Parameters
[in]attrPointer to the compute resource attribute structure, compute_res_attr_t.
[in]bufferPointer to the backup buffer in main memory (DDR). The pointer shall be aligned to 256Bytes. To be used by the compute resource manager for saving/restoring user allocated VTCM region during preemption.
[in]buffer_sizeSize of the backup buffer in main memory (DDR) pointed to by the #buffer argument. Size shall be aligned to 256Bytes. The provided buffer should be sufficiently sized to accommodate user requested VTCM size.
Returns
0 for success.
Non-zero for failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_attr_set_vtcm_clear_on_release()

static int HAP_compute_res_attr_set_vtcm_clear_on_release ( compute_res_attr_t attr,
unsigned char  enable 
)
inlinestatic

Sets VTCM clear on release option in the provided attribute structure.

The compute resource manager by default initializes the VTCM memory to 0 when VTCM is released by the caller either at the time of release or when it's allocated to another process. For performance considerations (also considering security implications if any), client can intimate the compute resource manager not to clear out (zero-initialize) the allocated VTCM on release.

Call this function after HAP_compute_res_attr_init().

Parameters
[in]attrPointer to the compute resource attribute structure, compute_res_attr_t.
[in]enable1 - zero-initialize VTCM memory after release (default) 0 - Do not zero-initialize VTCM memory after release.
Returns
0 for success.
Non-zero for failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_attr_set_vtcm_param()

static int HAP_compute_res_attr_set_vtcm_param ( compute_res_attr_t attr,
unsigned int  vtcm_size,
unsigned char  b_single_page 
)
inlinestatic

Sets VTCM request parameters in the provided resource attribute structure.

The user calls this function to request the specified VTCM size in the acquire call. These VTCM request attributes are reset to 0 (no VTCM request) in the resource attribute structure by HAP_compute_res_attr_init().

Parameters
[in]attrPointer to compute resource attribute structure, compute_res_attr_t.
[in]vtcm_sizeSize of the VTCM request in bytes; 0 if VTCM allocation is not required.
[in]b_single_page1 - Requested VTCM size to be allocated in a single page.
0 - No page requirement (allocation can spread across multiple pages. VTCM manager always attempts the best fit).
Returns
0 upon success.
Non-zero upon failure.

◆ HAP_compute_res_attr_set_vtcm_param_v2()

static int HAP_compute_res_attr_set_vtcm_param_v2 ( compute_res_attr_t attr,
unsigned int  vtcm_size,
unsigned int  min_page_size,
unsigned int  min_vtcm_size 
)
inlinestatic

Sets an extended set of VTCM request parameters in the attribute structure, specifically VTCM Size, the minimum required page size, and the minimum required VTCM size.

This function cannot be used with HAP_compute_res_attr_set_vtcm_param(). Call this function after HAP_compute_res_attr_init().

Supported starting with Lahaina.

Parameters
[in]attrPointer to compute the resource attribute structure, compute_res_attr_t.
[in]vtcm_sizeSize of the VTCM request in bytes. 0 if VTCM allocation is NOT required.
[in]min_page_sizeMinimum page size required in bytes. Valid pages include 4 KB, 16 KB, 64 KB, 256 KB, 1 MB, 4 MB, 16 MB. Setting 0 will select best possible fit (least page mappings)
[in]min_vtcm_sizeMinimum VTCM size in bytes, if the specified size (vtcm_size) is not available. 0 means the size is an absolute requirement.
Returns
0 for success.
Non-zero for failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.

◆ HAP_compute_res_cached_set_threads()

static int HAP_compute_res_cached_set_threads ( compute_res_threads_cmd_id  command,
unsigned int  context_id,
unsigned int *  threads,
unsigned int  num_threads 
)
inlinestatic

Updates thread id array for the associated cached context.

Compute resource manager uses the QuRT thread identifiers provided by the user during preemption of the associated context. For cached allocations, the thread identifiers can either be provided at the time of HAP_compute_res_acquire() call using HAP_compute_res_attr_set_threads(), or using this API with the context_id returned by a successful HAP_compute_res_acquire() call when the cached attribute is set via HAP_compute_res_attr_set_cache_mode(). The API has to be called before HAP_compute_res_acquire_cached() call.

Parameters
[in]commandspecifies a command from compute_res_threads_cmd_id: HAP_COMPUTE_RES_THREADS_OVERRIDE : To provide a new set of threads. HAP_COMPUTE_RES_THREADS_APPEND : To append to previously provided list of threads. HAP_COMPUTE_RES_THREADS_REMOVE : To remove given threads from previoulsy provided list of threads.
[in]context_idContext ID returned by HAP_compute_res_acquire().
[in]threadsPointer to an array of QuRT thread identifiers associated with the resource request.
[in]num_threadsNumber of QuRT thread identifiers in the provided threads array #threads. A maximum of HAP_COMPUTE_RES_MAX_NUM_THREADS number of threads can be provided.
Returns
0 for success.
Non-zero for failure.
HAP_COMPUTE_RES_NOT_SUPPORTED when not supported.