dvpp_malloc

Applicable Products

Product

Supported (√/x)

Ascend 950PR&950DT products

√

Atlas A3 products

√

Atlas A2 products

√

Atlas training products

x

Atlas inference products

√

Atlas 200I/500 A2 inference products

√

Description

Allocates device memory. The requested allocation must meet the media data processing requirements (for example,128-byte alignment of the start address).

Prototype

  • C Prototype
    1
    hi_s32 hi_mpi_dvpp_malloc(hi_u32 dev_id, hi_void **dev_ptr, hi_u64 size)
    
  • Python Function
    1
    dev_ptr, ret = acl.himpi.dvpp_malloc(dev_id, size)
    

Parameters

Parameter

Description

dev_id

Int, device ID. This parameter is reserved and invalid.

For Ascend EP, when this API is called on the host, DVPP allocates memory on the device specified by calling acl.rt.set_device.

size

Int, allocated memory size, in bytes.

Return Values

Return Value

Description

dev_ptr

Int, address of the pointer to the allocated device memory.

ret

Int, error code: 0 on success; else, failure.

Constraints

  • After calling this API to allocate memory, you manage the memory lifetime. Call acl.himpi.dvpp_free to free the memory if it is not required.
  • The memory allocated by this API applies to only a single process, not multiple processes.
  • Media data processing can access up to 16 GB of address space in each process.

    This constraint applies to the following products:

    Atlas A3 products

    Atlas A2 products

    Atlas inference products

  • When acl.himpi.dvpp_malloc is called to allocate memory, the input size is rounded up to the nearest multiple of 32, plus 32 bytes.
  • When the output of media data processing is used as the input of model inference, if you use this API to allocate a large memory block and divide and manage the memory, each memory segment must meet the following requirements:
    • The memory size is rounded up to the nearest multiple of 32 plus 32 bytes (m = ALIGN_UP[len,32] + 32 bytes).
    • The memory start address must be 128-byte aligned (ALIGN_UP[m,128]).

    len indicates the size of a memory segment. ALIGN_UP[len,k] indicates rounding up to a multiple of k bytes as in this formula: ((len – 1)/k + 1) x k.

Reference

For details about the API call sequence and examples, see Media Data Processing V2.