Skip to content

Commit 5ed13d7

Browse files
KMD Notfy: Multiply timeout by taskCount diff only on Linux
Change-Id: Idb75dcc02cd218ff097f29d6881c97bb8feb25da
1 parent 6eec238 commit 5ed13d7

File tree

8 files changed

+80
-23
lines changed

8 files changed

+80
-23
lines changed

runtime/helpers/kmd_notify_properties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput,
4242
} else if (quickKmdSleepRequest && properties->enableQuickKmdSleep) {
4343
timeoutValueOutput = properties->delayQuickKmdSleepMicroseconds;
4444
} else {
45-
timeoutValueOutput = properties->delayKmdNotifyMicroseconds * multiplier;
45+
timeoutValueOutput = getBaseTimeout(multiplier);
4646
}
4747

4848
return flushStampToWait != 0 && (properties->enableKmdNotify || !acLineConnected);

runtime/helpers/kmd_notify_properties.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class KmdNotifyHelper {
6464

6565
protected:
6666
bool applyQuickKmdSleepForSporadicWait() const;
67+
int64_t getBaseTimeout(const int64_t &multiplier) const;
6768

6869
const KmdNotifyProperties *properties = nullptr;
6970
std::chrono::high_resolution_clock::time_point lastWaitForCompletionTimestamp;

runtime/helpers/linux/kmd_notify_properties_linux.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@
2222

2323
#include "runtime/helpers/kmd_notify_properties.h"
2424

25-
void OCLRT::KmdNotifyHelper::updateAcLineStatus() {}
25+
using namespace OCLRT;
26+
27+
void KmdNotifyHelper::updateAcLineStatus() {}
28+
29+
int64_t KmdNotifyHelper::getBaseTimeout(const int64_t &multiplier) const {
30+
return properties->delayKmdNotifyMicroseconds * multiplier;
31+
}

runtime/helpers/windows/kmd_notify_properties_windows.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@
2323
#include "runtime/helpers/kmd_notify_properties.h"
2424
#include "runtime/os_interface/windows/sys_calls.h"
2525

26-
void OCLRT::KmdNotifyHelper::updateAcLineStatus() {
26+
using namespace OCLRT;
27+
28+
void KmdNotifyHelper::updateAcLineStatus() {
2729
SYSTEM_POWER_STATUS systemPowerStatus = {};
2830
auto powerStatusRetValue = SysCalls::getSystemPowerStatus(&systemPowerStatus);
2931
if (powerStatusRetValue == 1) {
3032
acLineConnected = (systemPowerStatus.ACLineStatus == 1);
3133
}
3234
}
35+
36+
int64_t KmdNotifyHelper::getBaseTimeout(const int64_t &multiplier) const {
37+
return properties->delayKmdNotifyMicroseconds;
38+
}

unit_tests/helpers/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,15 @@ set(IGDRCL_SRCS_tests_helpers_windows
5959
${CMAKE_CURRENT_SOURCE_DIR}/windows/kmd_notify_windows_tests.cpp
6060
)
6161

62+
set(IGDRCL_SRCS_tests_helpers_linux
63+
${CMAKE_CURRENT_SOURCE_DIR}/linux/kmd_notify_linux_tests.cpp
64+
)
65+
6266
if(WIN32)
6367
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers_windows})
64-
endif()
68+
else()
69+
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers_linux})
70+
endif()
6571

6672
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers})
73+
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_helpers_linux ${IGDRCL_SRCS_tests_helpers_linux})

unit_tests/helpers/kmd_notify_tests.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,6 @@ HWTEST_F(KmdNotifyTests, givenQuickSleepRequestWhenItsSporadicWaitOptimizationIs
221221
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true);
222222
}
223223

224-
HWTEST_F(KmdNotifyTests, givenComputeTimeoutMultiplierWhenWaitCalledThenUseNewTimeout) {
225-
auto csr = createMockCsr<FamilyType>();
226-
227-
*device->getTagAddress() = taskCountToWait;
228-
taskCountToWait += 5;
229-
230-
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds *
231-
(taskCountToWait - *device->getTagAddress());
232-
233-
auto updateHwTag = [&](bool, int64_t, uint32_t) {
234-
*device->getTagAddress() = taskCountToWait;
235-
return true;
236-
};
237-
238-
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, expectedTimeout, ::testing::_)).Times(1).WillOnce(::testing::Invoke(updateHwTag));
239-
240-
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false);
241-
}
242-
243224
HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultiplyTimeout) {
244225
auto csr = createMockCsr<FamilyType>();
245226
*device->getTagAddress() = taskCountToWait;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2018, Intel Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included
12+
* in all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+
* OTHER DEALINGS IN THE SOFTWARE.
21+
*/
22+
23+
#include "runtime/helpers/kmd_notify_properties.h"
24+
#include "runtime/helpers/options.h"
25+
26+
#include "test.h"
27+
28+
namespace OCLRT {
29+
30+
class MockKmdNotifyHelper : public KmdNotifyHelper {
31+
public:
32+
using KmdNotifyHelper::getBaseTimeout;
33+
34+
MockKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
35+
};
36+
37+
TEST(KmdNotifyLinuxTests, givenTaskCountDiffGreaterThanOneWhenBaseTimeoutRequestedThenMultiply) {
38+
auto localProperties = (platformDevices[0]->capabilityTable.kmdNotifyProperties);
39+
localProperties.delayKmdNotifyMicroseconds = 10;
40+
const int64_t multiplier = 10;
41+
42+
MockKmdNotifyHelper helper(&localProperties);
43+
EXPECT_EQ(localProperties.delayKmdNotifyMicroseconds * multiplier, helper.getBaseTimeout(multiplier));
44+
}
45+
} // namespace OCLRT

unit_tests/helpers/windows/kmd_notify_windows_tests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern BYTE systemPowerStatusACLineStatusOverride;
3737
class MockKmdNotifyHelper : public KmdNotifyHelper {
3838
public:
3939
using KmdNotifyHelper::acLineConnected;
40+
using KmdNotifyHelper::getBaseTimeout;
4041
using KmdNotifyHelper::updateAcLineStatus;
4142

4243
MockKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
@@ -74,4 +75,14 @@ TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnErrorThenDontUpdateAcL
7475
helper.updateAcLineStatus();
7576
EXPECT_TRUE(helper.acLineConnected);
7677
}
78+
79+
TEST(KmdNotifyWindowsTests, givenTaskCountDiffGreaterThanOneWhenBaseTimeoutRequestedThenDontMultiply) {
80+
auto localProperties = (platformDevices[0]->capabilityTable.kmdNotifyProperties);
81+
localProperties.delayKmdNotifyMicroseconds = 10;
82+
const int64_t multiplier = 10;
83+
84+
MockKmdNotifyHelper helper(&localProperties);
85+
EXPECT_EQ(localProperties.delayKmdNotifyMicroseconds, helper.getBaseTimeout(multiplier));
86+
}
87+
7788
} // namespace OCLRT

0 commit comments

Comments
 (0)