Skip to content

Commit 083a4ff

Browse files
Always enable L3 cache for non zero copy buffers.
Change-Id: Ie83a2b6b040bd0bab2cfd5dbb0e788af881f966f
1 parent 325b702 commit 083a4ff

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

runtime/mem_obj/buffer.inl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode) {
6565
surfaceState->setVerticalLineStride(0);
6666
surfaceState->setVerticalLineStrideOffset(0);
6767
if ((isAligned<MemoryConstants::cacheLineSize>(bufferAddress) && isAligned<MemoryConstants::cacheLineSize>(bufferSize)) ||
68-
((getFlags() & CL_MEM_READ_ONLY)) != 0) {
68+
((getFlags() & CL_MEM_READ_ONLY)) != 0 || !this->isMemObjZeroCopy()) {
6969
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER));
7070
} else {
7171
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));

unit_tests/gen9/kernel_tests_gen9.cpp

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
/*
2-
* Copyright (C) 2018 Intel Corporation
2+
* Copyright (C) 2018-2019 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

8+
#include "runtime/gmm_helper/gmm_helper.h"
9+
#include "runtime/mem_obj/buffer.h"
810
#include "runtime/helpers/kernel_commands.h"
911
#include "unit_tests/fixtures/device_fixture.h"
1012
#include "unit_tests/mocks/mock_kernel.h"
@@ -22,3 +24,29 @@ using Gen9KernelCommandsTest = testing::Test;
2224
GEN9TEST_F(Gen9KernelCommandsTest, givenGen9PlatformWhenDoBindingTablePrefetchIsCalledThenReturnsTrue) {
2325
EXPECT_TRUE(KernelCommandsHelper<FamilyType>::doBindingTablePrefetch());
2426
}
27+
28+
GEN9TEST_F(Gen9KernelCommandsTest, givenBufferThatIsNotZeroCopyWhenSurfaceStateisSetThenL3IsTurnedOn) {
29+
MockContext context;
30+
31+
auto retVal = CL_SUCCESS;
32+
char ptr[16u] = {};
33+
34+
std::unique_ptr<Buffer> buffer(Buffer::create(
35+
&context,
36+
CL_MEM_USE_HOST_PTR,
37+
16u,
38+
ptr,
39+
retVal));
40+
41+
EXPECT_FALSE(buffer->isMemObjZeroCopy());
42+
43+
using RENDER_SURFACE_STATE = typename SKLFamily::RENDER_SURFACE_STATE;
44+
RENDER_SURFACE_STATE surfaceState = {};
45+
46+
auto gmmHelper = context.getDevice(0)->getExecutionEnvironment()->getGmmHelper();
47+
gmmHelper->setSimplifiedMocsTableUsage(true);
48+
49+
buffer->setArgStateful(&surfaceState, false);
50+
//make sure proper mocs is selected
51+
EXPECT_EQ(2u, surfaceState.getMemoryObjectControlStateIndexToMocsTables());
52+
}

0 commit comments

Comments
 (0)