Skip to content

Commit 5a911c9

Browse files
ULT coverage gap on Sysman PCI
Signed-off-by: Kanhaiya Singh <[email protected]>
1 parent 24bc854 commit 5a911c9

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

level_zero/tools/source/sysman/pci/os_pci.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 Intel Corporation
2+
* Copyright (C) 2019-2021 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -14,6 +14,7 @@
1414
#include <vector>
1515

1616
namespace L0 {
17+
int64_t convertPcieSpeedFromGTsToBs(double maxLinkSpeedInGt);
1718
int32_t convertLinkSpeedToPciGen(double speed);
1819
double convertPciGenToLinkSpeed(uint32_t gen);
1920
class OsPci {

level_zero/tools/test/unit_tests/sources/sysman/pci/linux/test_zes_pci.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ constexpr int32_t expectedWidth = 1u;
2828
constexpr int32_t expectedGen = 1u; // As mockMaxLinkSpeed = 2.5, hence expectedGen should be 1
2929
// As mockMaxLinkSpeed = 2.5, hence, pcieSpeedWithEnc = mockMaxLinkWidth * (2.5 * 1000 * 8/10 * 125000) = 250000000
3030
constexpr int64_t expectedBandwidth = 250000000u;
31+
constexpr int convertMegabitsPerSecondToBytesPerSecond = 125000;
32+
constexpr int convertGigabitToMegabit = 1000;
33+
constexpr double encodingGen1Gen2 = 0.8;
34+
constexpr double encodingGen3andAbove = 0.98461538461;
3135

3236
struct MockMemoryManagerPci : public MemoryManagerMock {
3337
MockMemoryManagerPci(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerMock(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
@@ -223,5 +227,24 @@ TEST_F(ZesPciFixture, WhenConvertingLinkSpeedThenResultIsCorrect) {
223227
EXPECT_EQ(0.0, convertPciGenToLinkSpeed(0));
224228
}
225229

230+
// This test validates convertPcieSpeedFromGTsToBs method.
231+
// convertPcieSpeedFromGTsToBs(double maxLinkSpeedInGt) method will
232+
// return real PCIe speed in bytes per second as per below formula:
233+
// maxLinkSpeedInGt * (Gigabit to Megabit) * Encoding * (Mb/s to bytes/second) =
234+
// maxLinkSpeedInGt * convertGigabitToMegabit * Encoding * convertMegabitsPerSecondToBytesPerSecond;
235+
236+
TEST_F(ZesPciFixture, WhenConvertingLinkSpeedFromGigatransfersPerSecondToBytesPerSecondThenResultIsCorrect) {
237+
int64_t speedPci160 = convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci16_0GigatransfersPerSecond);
238+
EXPECT_EQ(speedPci160, static_cast<int64_t>(PciLinkSpeeds::Pci16_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen3andAbove));
239+
int64_t speedPci80 = convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci8_0GigatransfersPerSecond);
240+
EXPECT_EQ(speedPci80, static_cast<int64_t>(PciLinkSpeeds::Pci8_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen3andAbove));
241+
int64_t speedPci50 = convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci5_0GigatransfersPerSecond);
242+
EXPECT_EQ(speedPci50, static_cast<int64_t>(PciLinkSpeeds::Pci5_0GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen1Gen2));
243+
int64_t speedPci25 = convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci2_5GigatransfersPerSecond);
244+
EXPECT_EQ(speedPci25, static_cast<int64_t>(PciLinkSpeeds::Pci2_5GigatransfersPerSecond * convertMegabitsPerSecondToBytesPerSecond * convertGigabitToMegabit * encodingGen1Gen2));
245+
EXPECT_EQ(0, convertPcieSpeedFromGTsToBs(0.0));
246+
EXPECT_EQ(0, convertPcieSpeedFromGTsToBs(PciLinkSpeeds::Pci32_0GigatransfersPerSecond));
247+
}
248+
226249
} // namespace ult
227250
} // namespace L0

0 commit comments

Comments
 (0)