mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
KMD Notfy: Multiply timeout by taskCount diff only on Linux
Change-Id: Idb75dcc02cd218ff097f29d6881c97bb8feb25da
This commit is contained in:

committed by
sys_ocldev

parent
6eec23844b
commit
5ed13d7c88
@ -42,7 +42,7 @@ bool KmdNotifyHelper::obtainTimeoutParams(int64_t &timeoutValueOutput,
|
||||
} else if (quickKmdSleepRequest && properties->enableQuickKmdSleep) {
|
||||
timeoutValueOutput = properties->delayQuickKmdSleepMicroseconds;
|
||||
} else {
|
||||
timeoutValueOutput = properties->delayKmdNotifyMicroseconds * multiplier;
|
||||
timeoutValueOutput = getBaseTimeout(multiplier);
|
||||
}
|
||||
|
||||
return flushStampToWait != 0 && (properties->enableKmdNotify || !acLineConnected);
|
||||
|
@ -64,6 +64,7 @@ class KmdNotifyHelper {
|
||||
|
||||
protected:
|
||||
bool applyQuickKmdSleepForSporadicWait() const;
|
||||
int64_t getBaseTimeout(const int64_t &multiplier) const;
|
||||
|
||||
const KmdNotifyProperties *properties = nullptr;
|
||||
std::chrono::high_resolution_clock::time_point lastWaitForCompletionTimestamp;
|
||||
|
@ -22,4 +22,10 @@
|
||||
|
||||
#include "runtime/helpers/kmd_notify_properties.h"
|
||||
|
||||
void OCLRT::KmdNotifyHelper::updateAcLineStatus() {}
|
||||
using namespace OCLRT;
|
||||
|
||||
void KmdNotifyHelper::updateAcLineStatus() {}
|
||||
|
||||
int64_t KmdNotifyHelper::getBaseTimeout(const int64_t &multiplier) const {
|
||||
return properties->delayKmdNotifyMicroseconds * multiplier;
|
||||
}
|
||||
|
@ -23,10 +23,16 @@
|
||||
#include "runtime/helpers/kmd_notify_properties.h"
|
||||
#include "runtime/os_interface/windows/sys_calls.h"
|
||||
|
||||
void OCLRT::KmdNotifyHelper::updateAcLineStatus() {
|
||||
using namespace OCLRT;
|
||||
|
||||
void KmdNotifyHelper::updateAcLineStatus() {
|
||||
SYSTEM_POWER_STATUS systemPowerStatus = {};
|
||||
auto powerStatusRetValue = SysCalls::getSystemPowerStatus(&systemPowerStatus);
|
||||
if (powerStatusRetValue == 1) {
|
||||
acLineConnected = (systemPowerStatus.ACLineStatus == 1);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t KmdNotifyHelper::getBaseTimeout(const int64_t &multiplier) const {
|
||||
return properties->delayKmdNotifyMicroseconds;
|
||||
}
|
||||
|
@ -59,8 +59,15 @@ set(IGDRCL_SRCS_tests_helpers_windows
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/windows/kmd_notify_windows_tests.cpp
|
||||
)
|
||||
|
||||
set(IGDRCL_SRCS_tests_helpers_linux
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linux/kmd_notify_linux_tests.cpp
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers_windows})
|
||||
endif()
|
||||
else()
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers_linux})
|
||||
endif()
|
||||
|
||||
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_helpers})
|
||||
set_property(GLOBAL PROPERTY IGDRCL_SRCS_tests_helpers_linux ${IGDRCL_SRCS_tests_helpers_linux})
|
||||
|
@ -221,25 +221,6 @@ HWTEST_F(KmdNotifyTests, givenQuickSleepRequestWhenItsSporadicWaitOptimizationIs
|
||||
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, true);
|
||||
}
|
||||
|
||||
HWTEST_F(KmdNotifyTests, givenComputeTimeoutMultiplierWhenWaitCalledThenUseNewTimeout) {
|
||||
auto csr = createMockCsr<FamilyType>();
|
||||
|
||||
*device->getTagAddress() = taskCountToWait;
|
||||
taskCountToWait += 5;
|
||||
|
||||
auto expectedTimeout = device->getHardwareInfo().capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds *
|
||||
(taskCountToWait - *device->getTagAddress());
|
||||
|
||||
auto updateHwTag = [&](bool, int64_t, uint32_t) {
|
||||
*device->getTagAddress() = taskCountToWait;
|
||||
return true;
|
||||
};
|
||||
|
||||
EXPECT_CALL(*csr, waitForCompletionWithTimeout(true, expectedTimeout, ::testing::_)).Times(1).WillOnce(::testing::Invoke(updateHwTag));
|
||||
|
||||
csr->waitForTaskCountWithKmdNotifyFallback(taskCountToWait, 1, false);
|
||||
}
|
||||
|
||||
HWTEST_F(KmdNotifyTests, givenTaskCountEqualToHwTagWhenWaitCalledThenDontMultiplyTimeout) {
|
||||
auto csr = createMockCsr<FamilyType>();
|
||||
*device->getTagAddress() = taskCountToWait;
|
||||
|
45
unit_tests/helpers/linux/kmd_notify_linux_tests.cpp
Normal file
45
unit_tests/helpers/linux/kmd_notify_linux_tests.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/helpers/kmd_notify_properties.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
||||
#include "test.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
class MockKmdNotifyHelper : public KmdNotifyHelper {
|
||||
public:
|
||||
using KmdNotifyHelper::getBaseTimeout;
|
||||
|
||||
MockKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
|
||||
};
|
||||
|
||||
TEST(KmdNotifyLinuxTests, givenTaskCountDiffGreaterThanOneWhenBaseTimeoutRequestedThenMultiply) {
|
||||
auto localProperties = (platformDevices[0]->capabilityTable.kmdNotifyProperties);
|
||||
localProperties.delayKmdNotifyMicroseconds = 10;
|
||||
const int64_t multiplier = 10;
|
||||
|
||||
MockKmdNotifyHelper helper(&localProperties);
|
||||
EXPECT_EQ(localProperties.delayKmdNotifyMicroseconds * multiplier, helper.getBaseTimeout(multiplier));
|
||||
}
|
||||
} // namespace OCLRT
|
@ -37,6 +37,7 @@ extern BYTE systemPowerStatusACLineStatusOverride;
|
||||
class MockKmdNotifyHelper : public KmdNotifyHelper {
|
||||
public:
|
||||
using KmdNotifyHelper::acLineConnected;
|
||||
using KmdNotifyHelper::getBaseTimeout;
|
||||
using KmdNotifyHelper::updateAcLineStatus;
|
||||
|
||||
MockKmdNotifyHelper(const KmdNotifyProperties *newProperties) : KmdNotifyHelper(newProperties){};
|
||||
@ -74,4 +75,14 @@ TEST(KmdNotifyWindowsTests, whenGetSystemPowerStatusReturnErrorThenDontUpdateAcL
|
||||
helper.updateAcLineStatus();
|
||||
EXPECT_TRUE(helper.acLineConnected);
|
||||
}
|
||||
|
||||
TEST(KmdNotifyWindowsTests, givenTaskCountDiffGreaterThanOneWhenBaseTimeoutRequestedThenDontMultiply) {
|
||||
auto localProperties = (platformDevices[0]->capabilityTable.kmdNotifyProperties);
|
||||
localProperties.delayKmdNotifyMicroseconds = 10;
|
||||
const int64_t multiplier = 10;
|
||||
|
||||
MockKmdNotifyHelper helper(&localProperties);
|
||||
EXPECT_EQ(localProperties.delayKmdNotifyMicroseconds, helper.getBaseTimeout(multiplier));
|
||||
}
|
||||
|
||||
} // namespace OCLRT
|
||||
|
Reference in New Issue
Block a user