Function: memset

Applicable Products

Product

Supported (√/x)

Ascend 950PR/Ascend 950DT

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

Description

Initializes memory to a specified value.

The system determines whether the memory to be initialized is on the host or device based on the address. If the host memory is not allocated by calling an acl API (for example, acl.rt.malloc_host), undefined behavior will occur.

Prototype

  • C Prototype
    1
    aclError aclrtMemset(void *devPtr, size_t maxCount, int32_t value, size_t count)
    
  • Python Function
    1
    ret = acl.rt.memset(dev_ptr, max_count, value, count)
    

Parameters

Parameter

Description

dev_ptr

Int, start address of the memory.

max_count

Int, maximum memory size, in bytes.

value

Int, value to be set.

count

Int, memory length to be set to a specified value, in bytes.

Return Values

Return Value

Description

ret

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

Restrictions

This API initializes the memory immediately. No implicit device synchronization or stream synchronization is performed within the function.