DeviceMallocFuncHookReg

Function Usage

Registers the API for customized memory management (device memory allocation). This API and DeviceFreeFuncHookReg must be used in pairs. If they are not used in pairs or only one of them is registered, the default mode is used, that is, the memory is directly allocated or released. Only Atlas inference product support this API.

For details, see Customized Memory Resource Pool Management.

Prototype

1
APP_ERROR DeviceMallocFuncHookReg(g_deviceMallocFuncType pFun);

Parameters

Parameter

Input/Output

Description

pFun

Input

Function type for device memory allocation. The input function must be of the same type as the following function:

1
APP_ERROR (*)(void**, unsigned int, MxMemMallocPolicy);

The input parameters are as follows:

  • dev_ptr: Pointer to the pointer to the allocated DVPP memory.
  • Size: Requested memory size in bytes.
  • Policy: Memory allocation rule. If the custom device memory allocation function does not involve the allocation policy for the CANN underlying device memory, any parameter can be passed.

For details about the definition of the MxMemMallocPolicy structure, see MxMemMallocPolicy.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.