1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
/*
* Copyright (C) 2022-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/string.h"
#include "level_zero/core/source/device/device.h"
#include "level_zero/core/source/device/device_imp.h"
#include "level_zero/core/source/fabric/fabric.h"
#include "level_zero/core/source/fabric/fabric_device_interface.h"
namespace L0 {
bool FabricDeviceMdfi::getEdgeProperty(FabricVertex *neighborVertex, ze_fabric_edge_exp_properties_t &edgeProperty) {
DeviceImp *currentDeviceImp = static_cast<DeviceImp *>(device);
DeviceImp *neighborDeviceImp = static_cast<DeviceImp *>(neighborVertex->device);
// Ignore root devices
if (!currentDeviceImp->isSubdevice || !neighborDeviceImp->isSubdevice) {
return false;
}
const uint32_t currRootDeviceIndex = device->getRootDeviceIndex();
const uint32_t neighborRootDeviceIndex = neighborVertex->device->getRootDeviceIndex();
const uint32_t currSubDeviceId = static_cast<DeviceImp *>(device)->getPhysicalSubDeviceId();
const uint32_t neighborSubDeviceId = static_cast<DeviceImp *>(neighborVertex->device)->getPhysicalSubDeviceId();
if (currRootDeviceIndex == neighborRootDeviceIndex &&
currSubDeviceId < neighborSubDeviceId) {
ze_uuid_t &uuid = edgeProperty.uuid;
std::memset(uuid.id, 0, ZE_MAX_UUID_SIZE);
// Copy current Root DeviceIndex and SubDeviceId
memcpy_s(&uuid.id[0], 4, &currRootDeviceIndex, 4);
memcpy_s(&uuid.id[4], 1, &currSubDeviceId, 1);
// Copy neighboring Root DeviceIndex and SubDeviceId
memcpy_s(&uuid.id[8], 4, &neighborRootDeviceIndex, 4);
memcpy_s(&uuid.id[12], 1, &neighborSubDeviceId, 1);
memcpy_s(edgeProperty.model, ZE_MAX_FABRIC_EDGE_MODEL_EXP_SIZE, "MDFI", 5);
edgeProperty.bandwidth = 0;
edgeProperty.bandwidthUnit = ZE_BANDWIDTH_UNIT_UNKNOWN;
edgeProperty.latency = 0;
edgeProperty.latencyUnit = ZE_LATENCY_UNIT_UNKNOWN;
edgeProperty.duplexity = ZE_FABRIC_EDGE_EXP_DUPLEXITY_FULL_DUPLEX;
return true;
}
return false;
}
std::unique_ptr<FabricDeviceInterface> FabricDeviceInterface::createFabricDeviceInterfaceMdfi(const FabricVertex *fabricVertex) {
return std::unique_ptr<FabricDeviceInterface>(new (std::nothrow) FabricDeviceMdfi(fabricVertex->device));
}
} // namespace L0
|