mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +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
@@ -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