Skip to content

Commit 9486dba

Browse files
Kmd notify improvements [2/n]: Use QuickKmdSleep for sporadic waits
- Measure time between wait calls. If delay is exeeded use QuickKmdSleep - Kmd Notify helper functions - Refactor overriding from debug variables - Refactor Kmd Notify tests Change-Id: I123c31f492d98fd304184f99ee0bf7d733d06f04
1 parent c0a8522 commit 9486dba

27 files changed

+377
-242
lines changed

runtime/command_stream/command_stream_receiver_hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
9292

9393
const HardwareInfo &hwInfo;
9494
CsrSizeRequestFlags csrSizeRequestFlags = {};
95+
96+
std::chrono::high_resolution_clock::time_point lastWaitForCompletionTimestamp;
9597
};
9698

9799
template <typename GfxFamily>

runtime/command_stream/command_stream_receiver_hw.inl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ namespace OCLRT {
4040
template <typename GfxFamily>
4141
CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(const HardwareInfo &hwInfoIn) : hwInfo(hwInfoIn) {
4242
requiredThreadArbitrationPolicy = PreambleHelper<GfxFamily>::getDefaultThreadArbitrationPolicy();
43+
if (hwInfo.capabilityTable.kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits) {
44+
lastWaitForCompletionTimestamp = std::chrono::high_resolution_clock::now();
45+
}
4346
}
4447

4548
template <typename GfxFamily>
@@ -561,18 +564,22 @@ template <typename GfxFamily>
561564
inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) {
562565
const auto &kmdNotifyProperties = this->hwInfo.capabilityTable.kmdNotifyProperties;
563566

564-
const auto &kmdNotifyDelay = useQuickKmdSleep && kmdNotifyProperties.enableQuickKmdSleep ? kmdNotifyProperties.delayQuickKmdSleepMicroseconds
565-
: kmdNotifyProperties.delayKmdNotifyMicroseconds;
567+
useQuickKmdSleep |= kmdNotifyProperties.applyQuickKmdSleepForSporadicWait(lastWaitForCompletionTimestamp);
568+
569+
const auto &kmdNotifyDelay = kmdNotifyProperties.selectDelay(useQuickKmdSleep);
566570

567571
auto status = waitForCompletionWithTimeout(kmdNotifyProperties.enableKmdNotify && flushStampToWait != 0,
568572
kmdNotifyDelay, taskCountToWait);
569573
if (!status) {
570574
waitForFlushStamp(flushStampToWait);
571575
//now call blocking wait, this is to ensure that task count is reached
572-
waitForCompletionWithTimeout(false, kmdNotifyDelay, taskCountToWait);
576+
waitForCompletionWithTimeout(false, 0, taskCountToWait);
573577
}
574-
575578
UNRECOVERABLE_IF(*getTagAddress() < taskCountToWait);
579+
580+
if (kmdNotifyProperties.enableQuickKmdSleepForSporadicWaits) {
581+
lastWaitForCompletionTimestamp = std::chrono::high_resolution_clock::now();
582+
}
576583
}
577584

578585
template <typename GfxFamily>

runtime/gen8/hw_info_bdw.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ const RuntimeCapabilityTable BDW::capabilityTable{
6969
{false, false},
7070
&isSimulationBDW,
7171
true,
72-
true, // forceStatelessCompilationFor32Bit
73-
{false, 0, false, 0}, // KmdNotifyProperties
74-
false, // ftr64KBpages
75-
EngineType::ENGINE_RCS, // defaultEngineType
76-
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
72+
true, // forceStatelessCompilationFor32Bit
73+
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
74+
false, // ftr64KBpages
75+
EngineType::ENGINE_RCS, // defaultEngineType
76+
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
7777
};
7878

7979
const HardwareInfo BDW_1x2x6::hwInfo = {

runtime/gen9/hw_info_bxt.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ const RuntimeCapabilityTable BXT::capabilityTable{
6565
{true, false},
6666
&isSimulationBXT,
6767
true,
68-
false, // forceStatelessCompilationFor32Bit
69-
{false, 0, false, 0}, // KmdNotifyProperties
70-
false, // ftr64KBpages
71-
EngineType::ENGINE_RCS, // defaultEngineType
72-
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
68+
false, // forceStatelessCompilationFor32Bit
69+
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
70+
false, // ftr64KBpages
71+
EngineType::ENGINE_RCS, // defaultEngineType
72+
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
7373
};
7474

7575
const HardwareInfo BXT_1x2x6::hwInfo = {

runtime/gen9/hw_info_cfl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ const RuntimeCapabilityTable CFL::capabilityTable{
6060
{true, false},
6161
&isSimulationCFL,
6262
true,
63-
true, // forceStatelessCompilationFor32Bit
64-
{false, 0, false, 0}, // KmdNotifyProperties
65-
true, // ftr64KBpages
66-
EngineType::ENGINE_RCS, // defaultEngineType
67-
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
63+
true, // forceStatelessCompilationFor32Bit
64+
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
65+
true, // ftr64KBpages
66+
EngineType::ENGINE_RCS, // defaultEngineType
67+
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
6868
};
6969

7070
const HardwareInfo CFL_1x2x6::hwInfo = {

runtime/gen9/hw_info_glk.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ const RuntimeCapabilityTable GLK::capabilityTable{
6060
{true, false},
6161
&isSimulationGLK,
6262
true,
63-
false, // forceStatelessCompilationFor32Bit
64-
{true, 30000, false, 0}, // KmdNotifyProperties
65-
false, // ftr64KBpages
66-
EngineType::ENGINE_RCS, // defaultEngineType
67-
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
63+
false, // forceStatelessCompilationFor32Bit
64+
{true, 30000, false, 0, false, 0}, // KmdNotifyProperties
65+
false, // ftr64KBpages
66+
EngineType::ENGINE_RCS, // defaultEngineType
67+
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
6868
};
6969

7070
const HardwareInfo GLK_1x3x6::hwInfo = {

runtime/gen9/hw_info_kbl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ const RuntimeCapabilityTable KBL::capabilityTable{
6060
{true, false},
6161
&isSimulationKBL,
6262
true,
63-
true, // forceStatelessCompilationFor32Bit
64-
{false, 0, false, 0}, // KmdNotifyProperties
65-
true, // ftr64KBpages
66-
EngineType::ENGINE_RCS, // defaultEngineType
67-
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
63+
true, // forceStatelessCompilationFor32Bit
64+
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
65+
true, // ftr64KBpages
66+
EngineType::ENGINE_RCS, // defaultEngineType
67+
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
6868
};
6969

7070
const HardwareInfo KBL_1x2x6::hwInfo = {

runtime/gen9/hw_info_skl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ const RuntimeCapabilityTable SKL::capabilityTable{
6868
{true, false},
6969
&isSimulationSKL,
7070
true,
71-
true, // forceStatelessCompilationFor32Bit
72-
{false, 0, false, 0}, // KmdNotifyProperties
73-
true, // ftr64KBpages
74-
EngineType::ENGINE_RCS, // defaultEngineType
75-
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
71+
true, // forceStatelessCompilationFor32Bit
72+
{false, 0, false, 0, false, 0}, // KmdNotifyProperties
73+
true, // ftr64KBpages
74+
EngineType::ENGINE_RCS, // defaultEngineType
75+
MemoryConstants::pageSize //requiredPreemptionSurfaceSize
7676
};
7777

7878
const HardwareInfo SKL_1x2x6::hwInfo = {

runtime/helpers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ set(RUNTIME_SRCS_HELPERS_BASE
5454
${CMAKE_CURRENT_SOURCE_DIR}/kernel_commands.h
5555
${CMAKE_CURRENT_SOURCE_DIR}/kernel_commands.inl
5656
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties.h
57+
${CMAKE_CURRENT_SOURCE_DIR}/kmd_notify_properties.cpp
5758
${CMAKE_CURRENT_SOURCE_DIR}/mipmap.h
5859
${CMAKE_CURRENT_SOURCE_DIR}/options.cpp
5960
${CMAKE_CURRENT_SOURCE_DIR}/options.h
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 <cstdint>
24+
#include "runtime/helpers/kmd_notify_properties.h"
25+
26+
using namespace OCLRT;
27+
28+
bool KmdNotifyProperties::applyQuickKmdSleepForSporadicWait(std::chrono::high_resolution_clock::time_point &lastWaitTimestamp) const {
29+
if (enableQuickKmdSleepForSporadicWaits) {
30+
auto now = std::chrono::high_resolution_clock::now();
31+
auto timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(now - lastWaitTimestamp).count();
32+
if (timeDiff > delayQuickKmdSleepForSporadicWaitsMicroseconds) {
33+
return true;
34+
}
35+
}
36+
return false;
37+
}
38+
39+
const int64_t &KmdNotifyProperties::selectDelay(bool useQuickKmdSleep) const {
40+
return (useQuickKmdSleep && enableQuickKmdSleep) ? delayQuickKmdSleepMicroseconds
41+
: delayKmdNotifyMicroseconds;
42+
}
43+
44+
void KmdNotifyProperties::overrideFromDebugVariable(int32_t debugVariableValue, int64_t &destination) {
45+
if (debugVariableValue >= 0) {
46+
destination = static_cast<int64_t>(debugVariableValue);
47+
}
48+
}
49+
50+
void KmdNotifyProperties::overrideFromDebugVariable(int32_t debugVariableValue, bool &destination) {
51+
if (debugVariableValue >= 0) {
52+
destination = !!(debugVariableValue);
53+
}
54+
}

0 commit comments

Comments
 (0)