Skip to content

Commit 048098c

Browse files
jchodorCompute-Runtime-Automation
authored andcommitted
Refactor around cache flush after walker
Change-Id: If5c7399df91bd076b684bcab83f50b4852e53429
1 parent b36bcf6 commit 048098c

File tree

10 files changed

+87
-70
lines changed

10 files changed

+87
-70
lines changed

runtime/command_stream/command_stream_receiver_hw.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,9 @@ inline void CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
561561
surfacesForSubmit.push_back(surface);
562562
}
563563

564-
//make sure we flush DC
564+
//make sure we flush DC if needed
565565
if (epiloguePipeControlLocation) {
566-
((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(true);
566+
((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(false == HwHelper::cacheFlushAfterWalkerSupported(this->hwInfo));
567567
}
568568
auto flushStamp = this->flush(primaryCmdBuffer->batchBuffer, surfacesForSubmit);
569569

runtime/helpers/hw_helper.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017-2018 Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -29,4 +29,14 @@ bool HwHelper::renderCompressedImagesSupported(const HardwareInfo &hwInfo) {
2929
return hwInfo.capabilityTable.ftrRenderCompressedImages;
3030
}
3131

32+
bool HwHelper::cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo) {
33+
int32_t dbgFlag = DebugManager.flags.EnableCacheFlushAfterWalker.get();
34+
if (dbgFlag == 1) {
35+
return true;
36+
} else if (dbgFlag == 0) {
37+
return false;
38+
}
39+
return hwInfo.capabilityTable.supportCacheFlushAfterWalker;
40+
}
41+
3242
} // namespace OCLRT

runtime/helpers/hw_helper.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
*/
77

88
#pragma once
9-
#include "CL/cl.h"
9+
#include "runtime/built_ins/sip.h"
10+
#include "runtime/command_stream/linear_stream.h"
1011
#include "runtime/gen_common/aub_mapper.h"
1112
#include "runtime/gen_common/hw_cmds.h"
12-
#include "runtime/command_stream/linear_stream.h"
13-
#include "runtime/built_ins/sip.h"
13+
14+
#include "CL/cl.h"
1415

1516
#include <cstdint>
1617
#include <type_traits>
@@ -41,6 +42,7 @@ class HwHelper {
4142
virtual bool supportsYTiling() const = 0;
4243
static bool renderCompressedBuffersSupported(const HardwareInfo &hwInfo);
4344
static bool renderCompressedImagesSupported(const HardwareInfo &hwInfo);
45+
static bool cacheFlushAfterWalkerSupported(const HardwareInfo &hwInfo);
4446
virtual bool timestampPacketWriteSupported() const = 0;
4547
virtual size_t getRenderSurfaceStateSize() const = 0;
4648
virtual void setRenderSurfaceStateForBuffer(ExecutionEnvironment &executionEnvironment,

runtime/kernel/kernel.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,18 +2142,8 @@ void Kernel::fillWithBuffersForAuxTranslation(MemObjsForAuxTranslation &memObjsF
21422142
}
21432143
}
21442144

2145-
bool Kernel::platformSupportCacheFlushAfterWalker() const {
2146-
int32_t dbgFlag = DebugManager.flags.EnableCacheFlushAfterWalker.get();
2147-
if (dbgFlag == 1) {
2148-
return true;
2149-
} else if (dbgFlag == 0) {
2150-
return false;
2151-
}
2152-
return device.getHardwareInfo().capabilityTable.supportCacheFlushAfterWalker;
2153-
}
2154-
21552145
bool Kernel::requiresCacheFlushCommand() const {
2156-
if (false == platformSupportCacheFlushAfterWalker()) {
2146+
if (false == HwHelper::cacheFlushAfterWalkerSupported(device.getHardwareInfo())) {
21572147
return false;
21582148
}
21592149
if (getProgram()->getGlobalSurface() != nullptr) {
@@ -2172,7 +2162,7 @@ bool Kernel::requiresCacheFlushCommand() const {
21722162
}
21732163

21742164
void Kernel::getAllocationsForCacheFlush(CacheFlushAllocationsVec &out) const {
2175-
if (false == platformSupportCacheFlushAfterWalker()) {
2165+
if (false == HwHelper::cacheFlushAfterWalkerSupported(device.getHardwareInfo())) {
21762166
return;
21772167
}
21782168
for (GraphicsAllocation *alloc : this->kernelArgRequiresCacheFlush) {

runtime/kernel/kernel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ class Kernel : public BaseObject<_cl_kernel> {
468468

469469
void reconfigureKernel();
470470

471-
bool platformSupportCacheFlushAfterWalker() const;
472471
void addAllocationToCacheFlushVector(uint32_t argIndex, GraphicsAllocation *argAllocation);
473472
bool allocationForCacheFlush(GraphicsAllocation *argAllocation) const;
474473
Program *program;

unit_tests/helpers/cmd_buffer_validator.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ inline bool expectCmdBuff(GenCmdList::iterator begin, GenCmdList::iterator end,
217217
// proceed to next matcher if not matched
218218
if ((expectedCmdBuffMatchers[currentMatcher]->getExpectedCount() == AtLeastOne) && (currentMatcherCount < 1)) {
219219
failed = true;
220-
failReason = "Unmatched cmd#" + std::to_string(cmdNum) + " - expected " + std::string(expectedCmdBuffMatchers[currentMatcher]->getName()) + "(" + countToString(expectedCmdBuffMatchers[currentMatcher]->getExpectedCount()) + " - " + std::to_string(currentMatcherCount) + ") after : " + matchedCommandsString();
220+
failReason = "Unmatched cmd#" + std::to_string(cmdNum) + ":" + HardwareParse::getCommandName<FamilyType>(*it) + " - expected " + std::string(expectedCmdBuffMatchers[currentMatcher]->getName()) + "(" + countToString(expectedCmdBuffMatchers[currentMatcher]->getExpectedCount()) + " - " + std::to_string(currentMatcherCount) + ") after : " + matchedCommandsString();
221221
break;
222222
}
223223
++currentMatcher;
@@ -249,7 +249,7 @@ inline bool expectCmdBuff(GenCmdList::iterator begin, GenCmdList::iterator end,
249249

250250
if (false == expectedCmdBuffMatchers[currentMatcher]->matches(it)) {
251251
failed = true;
252-
failReason = "Unmatched cmd#" + std::to_string(cmdNum) + " - expected " + std::string(expectedCmdBuffMatchers[currentMatcher]->getName()) + "(" + countToString(expectedCmdBuffMatchers[currentMatcher]->getExpectedCount()) + " - " + std::to_string(currentMatcherCount) + ") after : " + matchedCommandsString();
252+
failReason = "Unmatched cmd#" + std::to_string(cmdNum) + ":" + HardwareParse::getCommandName<FamilyType>(*it) + " - expected " + std::string(expectedCmdBuffMatchers[currentMatcher]->getName()) + "(" + countToString(expectedCmdBuffMatchers[currentMatcher]->getExpectedCount()) + " - " + std::to_string(currentMatcherCount) + ") after : " + matchedCommandsString();
253253
break;
254254
}
255255

@@ -304,10 +304,28 @@ inline bool expectCmdBuff(GenCmdList::iterator begin, GenCmdList::iterator end,
304304
failReason = "Unexpected command buffer end at cmd#" + std::to_string(cmdNum) + " - expected " + expectedMatchers + " after : " + matchedCommandsString();
305305
failed = true;
306306
}
307+
} else {
308+
if ((it != end) && (++it != end)) {
309+
++cmdNum;
310+
failReason += "\n Unconsumed commands after failed one : ";
311+
while (it != end) {
312+
failReason += std::to_string(cmdNum) + ":" + HardwareParse::getCommandName<FamilyType>(*it) + " ";
313+
++cmdNum;
314+
++it;
315+
}
316+
}
307317
}
308318

309319
if (failed) {
310320
if (outReason != nullptr) {
321+
failReason += "\n Note : Input command buffer was : ";
322+
it = begin;
323+
cmdNum = 0;
324+
while (it != end) {
325+
failReason += std::to_string(cmdNum) + ":" + HardwareParse::getCommandName<FamilyType>(*it) + " ";
326+
++cmdNum;
327+
++it;
328+
}
311329
*outReason = failReason;
312330
}
313331
}

unit_tests/helpers/hw_helper_tests.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,3 +589,47 @@ HWTEST_F(HwHelperTest, DISABLED_profilingCreationOfRenderSurfaceStateVsMemcpyOfC
589589
alignedFree(copyBuffers[i]);
590590
}
591591
}
592+
593+
TEST(HwHelperCacheFlushTest, givenEnableCacheFlushFlagIsEnableWhenPlatformDoesNotSupportThenOverrideAndReturnSupportTrue) {
594+
DebugManagerStateRestore restore;
595+
DebugManager.flags.EnableCacheFlushAfterWalker.set(1);
596+
597+
HardwareInfo localHwInfo = *platformDevices[0];
598+
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = false;
599+
600+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
601+
EXPECT_TRUE(HwHelper::cacheFlushAfterWalkerSupported(device->getHardwareInfo()));
602+
}
603+
604+
TEST(HwHelperCacheFlushTest, givenEnableCacheFlushFlagIsDisableWhenPlatformSupportsThenOverrideAndReturnSupportFalse) {
605+
DebugManagerStateRestore restore;
606+
DebugManager.flags.EnableCacheFlushAfterWalker.set(0);
607+
608+
HardwareInfo localHwInfo = *platformDevices[0];
609+
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = true;
610+
611+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
612+
EXPECT_FALSE(HwHelper::cacheFlushAfterWalkerSupported(device->getHardwareInfo()));
613+
}
614+
615+
TEST(HwHelperCacheFlushTest, givenEnableCacheFlushFlagIsReadPlatformSettingWhenPlatformDoesNotSupportThenReturnSupportFalse) {
616+
DebugManagerStateRestore restore;
617+
DebugManager.flags.EnableCacheFlushAfterWalker.set(-1);
618+
619+
HardwareInfo localHwInfo = *platformDevices[0];
620+
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = false;
621+
622+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
623+
EXPECT_FALSE(HwHelper::cacheFlushAfterWalkerSupported(device->getHardwareInfo()));
624+
}
625+
626+
TEST(HwHelperCacheFlushTest, givenEnableCacheFlushFlagIsReadPlatformSettingWhenPlatformSupportsThenReturnSupportTrue) {
627+
DebugManagerStateRestore restore;
628+
DebugManager.flags.EnableCacheFlushAfterWalker.set(-1);
629+
630+
HardwareInfo localHwInfo = *platformDevices[0];
631+
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = true;
632+
633+
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
634+
EXPECT_TRUE(HwHelper::cacheFlushAfterWalkerSupported(device->getHardwareInfo()));
635+
}

unit_tests/kernel/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2017-2018 Intel Corporation
2+
# Copyright (C) 2017-2019 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -29,3 +29,4 @@ set(IGDRCL_SRCS_tests_kernel
2929
${CMAKE_CURRENT_SOURCE_DIR}/substitute_kernel_heap_tests.cpp
3030
)
3131
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_kernel})
32+
add_subdirectories()

unit_tests/kernel/kernel_tests.cpp

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "runtime/built_ins/builtins_dispatch_builder.h"
99
#include "runtime/command_stream/command_stream_receiver_hw.h"
1010
#include "runtime/helpers/flush_stamp.h"
11+
#include "runtime/helpers/hw_helper.h"
1112
#include "runtime/helpers/options.h"
1213
#include "runtime/helpers/surface_formats.h"
1314
#include "runtime/kernel/kernel.h"
@@ -2410,50 +2411,3 @@ TEST(KernelTest, whenAllocationReadOnlyNonFlushRequiredThenAssignNullPointerToCa
24102411
EXPECT_EQ(nullptr, kernel.mockKernel->kernelArgRequiresCacheFlush[0]);
24112412
}
24122413

2413-
TEST(KernelTest, givenEnableCacheFlushFlagIsEnableWhenPlatformDoesNotSupportThenOverrideAndReturnSupportTrue) {
2414-
DebugManagerStateRestore restore;
2415-
DebugManager.flags.EnableCacheFlushAfterWalker.set(1);
2416-
2417-
HardwareInfo localHwInfo = *platformDevices[0];
2418-
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = false;
2419-
2420-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
2421-
MockKernelWithInternals kernel(*device);
2422-
EXPECT_TRUE(kernel.mockKernel->platformSupportCacheFlushAfterWalker());
2423-
}
2424-
2425-
TEST(KernelTest, givenEnableCacheFlushFlagIsDisableWhenPlatformSupportsThenOverrideAndReturnSupportFalse) {
2426-
DebugManagerStateRestore restore;
2427-
DebugManager.flags.EnableCacheFlushAfterWalker.set(0);
2428-
2429-
HardwareInfo localHwInfo = *platformDevices[0];
2430-
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = true;
2431-
2432-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
2433-
MockKernelWithInternals kernel(*device);
2434-
EXPECT_FALSE(kernel.mockKernel->platformSupportCacheFlushAfterWalker());
2435-
}
2436-
2437-
TEST(KernelTest, givenEnableCacheFlushFlagIsReadPlatformSettingWhenPlatformDoesNotSupportThenReturnSupportFalse) {
2438-
DebugManagerStateRestore restore;
2439-
DebugManager.flags.EnableCacheFlushAfterWalker.set(-1);
2440-
2441-
HardwareInfo localHwInfo = *platformDevices[0];
2442-
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = false;
2443-
2444-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
2445-
MockKernelWithInternals kernel(*device);
2446-
EXPECT_FALSE(kernel.mockKernel->platformSupportCacheFlushAfterWalker());
2447-
}
2448-
2449-
TEST(KernelTest, givenEnableCacheFlushFlagIsReadPlatformSettingWhenPlatformSupportsThenReturnSupportTrue) {
2450-
DebugManagerStateRestore restore;
2451-
DebugManager.flags.EnableCacheFlushAfterWalker.set(-1);
2452-
2453-
HardwareInfo localHwInfo = *platformDevices[0];
2454-
localHwInfo.capabilityTable.supportCacheFlushAfterWalker = true;
2455-
2456-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
2457-
MockKernelWithInternals kernel(*device);
2458-
EXPECT_TRUE(kernel.mockKernel->platformSupportCacheFlushAfterWalker());
2459-
}

unit_tests/mocks/mock_kernel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class MockKernel : public Kernel {
3030
using Kernel::kernelArguments;
3131
using Kernel::kernelSvmGfxAllocations;
3232
using Kernel::numberOfBindingTableStates;
33-
using Kernel::platformSupportCacheFlushAfterWalker;
3433
using Kernel::svmAllocationsRequireCacheFlush;
3534

3635
struct BlockPatchValues {

0 commit comments

Comments
 (0)