aclrtDeviceEnablePeerAccess

Applicable Products

Product

Supported

Ascend 950PR / Ascend 950DT

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Function

Enables data exchange between the current device and a specified device. This API enables device-level data exchange.

Calling this API to enable data exchange between devices is unidirectional. For example, if the current device ID is 0 and aclrtDeviceEnablePeerAccess is called to specify device ID 1, only data exchange from device 0 to device 1 is feasible. To enable data exchange from device 1 to device 0, you need to switch the current device to device 1 and call aclrtDeviceEnablePeerAccess again to specify device ID 0. In this case, data exchange from device 1 to device 0 can be implemented.

Call aclrtDeviceCanAccessPeer in advance to check whether data exchange is available between the current device and the specified device. To disable data exchange between devices, call aclrtDeviceDisablePeerAccess.

Prototype

1
aclError aclrtDeviceEnablePeerAccess(int32_t peerDeviceId, uint32_t flags)

Parameters

Parameter

Input/Output

Description

peerDeviceId

Input

Device ID, which must be different from the current device ID.

The value must be in the range of [0, (Available device count – 1)]. Call aclrtGetDeviceCount to obtain the device count.

flags

Input

This parameter is reserved and must be set to 0.

Returns

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

Restrictions

When your application runs on the Control CPU on the device of the Atlas inference products in Open Ctrl CPU form, this API does not support data exchange between devices.

API Call Example

For the API call example, see Cross-Device Data Exchange.