feature: add peer access check on driver init

Related-To: NEO-14885, HSD-14024947073

Signed-off-by: Alicja Lukaszewicz <alicja.lukaszewicz@intel.com>
This commit is contained in:
Alicja Lukaszewicz
2025-08-27 13:54:40 +00:00
committed by Compute-Runtime-Automation
parent 2e58669fe9
commit bca503548a
54 changed files with 486 additions and 86 deletions

View File

@@ -1363,18 +1363,42 @@ bool Device::canAccessPeer(QueryPeerAccessFunc queryPeerAccess, Device *peerDevi
return retVal;
}
auto setPeerAccess = [&](bool value) {
this->crossAccessEnabledDevices[peerRootDeviceIndex] = value;
peerDevice->crossAccessEnabledDevices[rootDeviceIndex] = value;
};
auto lock = executionEnvironment->obtainPeerAccessQueryLock();
if (this->crossAccessEnabledDevices.find(peerRootDeviceIndex) == this->crossAccessEnabledDevices.end()) {
retVal = queryPeerAccess(*this, *peerDevice, canAccess);
setPeerAccess(canAccess);
this->updatePeerAccessCache(peerDevice, canAccess);
}
canAccess = this->crossAccessEnabledDevices[peerRootDeviceIndex];
return retVal;
}
void Device::initializePeerAccessForDevices(QueryPeerAccessFunc queryPeerAccess, const std::vector<NEO::Device *> &devices) {
for (auto &device : devices) {
if (device->getReleaseHelper() && device->getReleaseHelper()->shouldQueryPeerAccess()) {
device->hasPeerAccess = false;
auto rootDeviceIndex = device->getRootDeviceIndex();
for (auto &peerDevice : devices) {
auto peerRootDeviceIndex = peerDevice->getRootDeviceIndex();
if (rootDeviceIndex == peerRootDeviceIndex) {
continue;
}
bool canAccess = false;
if (device->crossAccessEnabledDevices.find(peerRootDeviceIndex) == device->crossAccessEnabledDevices.end()) {
auto lock = device->getExecutionEnvironment()->obtainPeerAccessQueryLock();
queryPeerAccess(*device, *peerDevice, canAccess);
device->updatePeerAccessCache(peerDevice, canAccess);
} else {
canAccess = device->crossAccessEnabledDevices[peerRootDeviceIndex];
}
if (canAccess) {
device->hasPeerAccess = true;
}
}
}
}
}
} // namespace NEO

View File

@@ -264,6 +264,16 @@ class Device : public ReferenceTrackedObject<Device>, NEO::NonCopyableAndNonMova
std::unordered_map<uint32_t, bool> crossAccessEnabledDevices;
bool canAccessPeer(QueryPeerAccessFunc queryPeerAccess, Device *peerDevice, bool &canAccess);
static void initializePeerAccessForDevices(QueryPeerAccessFunc queryPeerAccess, const std::vector<NEO::Device *> &devices);
std::optional<bool> hasAnyPeerAccess() const {
return hasPeerAccess;
}
void updatePeerAccessCache(Device *peerDevice, bool value) {
this->crossAccessEnabledDevices[peerDevice->getRootDeviceIndex()] = value;
peerDevice->crossAccessEnabledDevices[this->getRootDeviceIndex()] = value;
}
protected:
Device() = delete;
@@ -348,6 +358,8 @@ class Device : public ReferenceTrackedObject<Device>, NEO::NonCopyableAndNonMova
uint32_t maxBufferPoolCount = 0u;
uint32_t microsecondResolution = 1000u;
std::optional<bool> hasPeerAccess = std::nullopt;
struct {
bool isValid = false;
std::array<uint8_t, ProductHelper::uuidSize> id;