diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index 22bfa454ab..d399c0b90b 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -106,6 +106,7 @@ std::vector roc::Device::gpu_agents_; std::vector roc::Device::cpu_agents_; address Device::mg_sync_ = nullptr; +amd::Monitor Device::lockP2P_("Lock P2P ON/OFF"); bool NullDevice::create(const amd::Isa &isa) { if (!isa.runtimeRocSupported()) { @@ -2016,7 +2017,7 @@ void Device::hostFree(void* ptr, size_t size) const { memFree(ptr, size); } bool Device::enableP2P(amd::Device* ptrDev) { assert(ptrDev != nullptr); - + amd::ScopedLock lock(lockP2P_); Device* peerDev = static_cast(ptrDev); if (std::find(enabled_p2p_devices_.begin(), enabled_p2p_devices_.end(), peerDev) == enabled_p2p_devices_.end()) { @@ -2029,7 +2030,7 @@ bool Device::enableP2P(amd::Device* ptrDev) { bool Device::disableP2P(amd::Device* ptrDev) { assert(ptrDev != nullptr); - + amd::ScopedLock lock(lockP2P_); Device* peerDev = static_cast(ptrDev); //if device is present then remove auto it = std::find(enabled_p2p_devices_.begin(), enabled_p2p_devices_.end(), peerDev); diff --git a/rocclr/device/rocm/rocdevice.hpp b/rocclr/device/rocm/rocdevice.hpp index 15a47b398e..492910f3a6 100644 --- a/rocclr/device/rocm/rocdevice.hpp +++ b/rocclr/device/rocm/rocdevice.hpp @@ -586,6 +586,7 @@ class Device : public NullDevice { static std::vector gpu_agents_; static std::vector cpu_agents_; + static amd::Monitor lockP2P_; hsa_agent_t cpu_agent_; uint32_t preferred_numa_node_; std::vector p2p_agents_; //!< List of P2P agents available for this device