Function: device_can_access_peer

Applicability

Product

Supported (√/x)

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

x

Function Usage

Queries whether memory copy is supported between two devices.

Prototype

  • C Prototype
    1
    aclError aclrtDeviceCanAccessPeer(int32_t *canAccessPeer, int32_t deviceId, int32_t peerDeviceId)
    
  • Python Function
    1
    can_access_peer, ret = acl.rt.device_can_access_peer(dev_id, peer_dev_id)
    

Parameter Description

Parameter

Description

dev_id

Int, specified device ID, which must be different from that of peer_dev_id.

Must be in the range of [0, Device count – 1]. Call acl.rt.get_device_count to obtain the device count.

peer_dev_id

Int, specified device ID, which must be different from that of dev_id.

Must be in the range of [0, Device count – 1]. Call acl.rt.get_device_count to obtain the device count.

Return Value Description

Return Value

Description

can_access_peer

Int, whether memory copy is supported between the device specified by dev_id and the device specified by peer_dev_id. 1: supported; 0: not supported.

ret

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

Restrictions

  • This API supports memory copy only in physical machines and containers.
  • This API supports memory copy only between devices in the same PCIe switch. In AI Server applications, memory copy between devices is supported although they reside in different PCIe switches.
  • This API supports memory copy only between devices in the same physical machine or container.
  • This API supports memory copy only between devices of threads in the same process, it does not support memory copying between devices across different processes.
  • This API supports memory copy between devices in the same PCIe switch only when the related ports of the host are enabled (such as the host BIOS).