aclrtRegDeviceStateCallback

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Description

Registers the callback function for the device status. Repeated registration is not supported.

When the device status changes (for example, after aclrtSetDevice or aclrtResetDevice is called), the Runtime module triggers the callback function.

Prototype

1
aclError aclrtRegDeviceStateCallback(const char *regName, aclrtDeviceStateCallback callback, void *args)

Parameters

Parameter

Input/Output

Description

regName

Input

Registered name, which must be unique and cannot be empty. Ensure that the input string ends with \0.

callback

Input

Callback function. If callback is not NULL, the callback function is registered. If callback is NULL, the callback function is deregistered.

Prototype:

typedef enum {
    ACL_RT_DEVICE_STATE_SET_PRE = 0, // Before the set API (for example, aclrtSetDevice) is called
    ACL_RT_DEVICE_STATE_SET_POST,    // After the set API (for example, aclrtSetDevice) is called
    ACL_RT_DEVICE_STATE_RESET_PRE,   // Before the reset API (for example, aclrtResetDevice) is called
    ACL_RT_DEVICE_STATE_RESET_POST, // After the reset API (for example, aclrtResetDevice) is called
} aclrtDeviceState;
typedef void (*aclrtDeviceStateCallback)(uint32_t devId, aclrtDeviceState state, void *args);

args

Input

Pointer to the user data to be passed to the callback function.

Returns

0 on success; otherwise, failure. For details, see aclError.