Function: device_can_access_peer

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas training product

Atlas inference product

Atlas 200I/500 A2 inference product

x

Description

Queries whether memory copy is supported between 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)
    

Parameters

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

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.
  • 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).