File: fabric_device_mdfi.cpp

package info (click to toggle)
intel-compute-runtime 25.48.36300.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,652 kB
  • sloc: cpp: 939,022; lisp: 2,090; sh: 722; makefile: 162; python: 21
file content (61 lines) | stat: -rw-r--r-- 2,379 bytes parent folder | download | duplicates (2)
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