Skip to content

Commit acc5e87

Browse files
Change CL_MEM_USE_HOST_PTR buffer allocation scheme.
- Choose BUFFER type if local memory is present. - add CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL for allocations that require host pointer storage. Change-Id: Ifd3c74800cd53a2a9bb2171212a47ef5bcffe2a1
1 parent 5e91983 commit acc5e87

File tree

9 files changed

+106
-66
lines changed

9 files changed

+106
-66
lines changed

public/cl_ext_private.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ using cl_mem_flags_intel = cl_mem_flags;
5252
// Used with clEnqueueVerifyMemory
5353
#define CL_MEM_COMPARE_EQUAL 0u
5454
#define CL_MEM_COMPARE_NOT_EQUAL 1u
55+
56+
#define CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL (1 << 20)

runtime/gtpin/gtpin_helpers.cpp

Lines changed: 2 additions & 2 deletions
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
*
@@ -28,7 +28,7 @@ GTPIN_DI_STATUS GTPIN_DRIVER_CALLCONV gtpinCreateBuffer(context_handle_t context
2828
if (hostPtr == nullptr) {
2929
return GTPIN_DI_ERROR_ALLOCATION_FAILED;
3030
}
31-
cl_mem buffer = Buffer::create(pContext, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE, size, hostPtr, diag);
31+
cl_mem buffer = Buffer::create(pContext, CL_MEM_USE_HOST_PTR | CL_MEM_READ_WRITE | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL, size, hostPtr, diag);
3232
*pResource = (resource_handle_t)buffer;
3333
return GTPIN_DI_SUCCESS;
3434
}

runtime/mem_obj/buffer.cpp

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,14 @@ Buffer *Buffer::create(Context *context,
127127
bool alignementSatisfied = true;
128128
bool allocateMemory = true;
129129
bool copyMemoryFromHostPtr = false;
130+
MemoryManager *memoryManager = context->getMemoryManager();
131+
130132
GraphicsAllocation::AllocationType allocationType = getGraphicsAllocationType(
131133
properties.flags,
132134
context->isSharedContext,
133-
HwHelper::renderCompressedBuffersSupported(context->getDevice(0)->getHardwareInfo()));
135+
HwHelper::renderCompressedBuffersSupported(context->getDevice(0)->getHardwareInfo()),
136+
memoryManager->isLocalMemorySupported());
134137

135-
MemoryManager *memoryManager = context->getMemoryManager();
136138
UNRECOVERABLE_IF(!memoryManager);
137139

138140
checkMemory(properties.flags, size, hostPtr, errcodeRet, alignementSatisfied, copyMemoryFromHostPtr, memoryManager);
@@ -148,21 +150,22 @@ Buffer *Buffer::create(Context *context,
148150

149151
if (allocationType == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY) {
150152
if (properties.flags & CL_MEM_USE_HOST_PTR) {
151-
allocateMemory = false;
152-
if (!alignementSatisfied || DebugManager.flags.DisableZeroCopyForUseHostPtr.get()) {
153+
if (alignementSatisfied) {
154+
allocateMemory = false;
155+
zeroCopyAllowed = true;
156+
} else {
153157
zeroCopyAllowed = false;
154158
allocateMemory = true;
155159
}
156160
}
157161
}
158162

159-
if (context->isSharedContext) {
160-
zeroCopyAllowed = true;
161-
copyMemoryFromHostPtr = false;
162-
allocateMemory = false;
163-
}
164-
165163
if (properties.flags & CL_MEM_USE_HOST_PTR) {
164+
if (DebugManager.flags.DisableZeroCopyForUseHostPtr.get()) {
165+
zeroCopyAllowed = false;
166+
allocateMemory = true;
167+
}
168+
166169
memory = context->getSVMAllocsManager()->getSVMAlloc(hostPtr);
167170
if (memory) {
168171
allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
@@ -173,6 +176,12 @@ Buffer *Buffer::create(Context *context,
173176
}
174177
}
175178

179+
if (context->isSharedContext) {
180+
zeroCopyAllowed = true;
181+
copyMemoryFromHostPtr = false;
182+
allocateMemory = false;
183+
}
184+
176185
if (hostPtr && context->isProvidingPerformanceHints()) {
177186
if (zeroCopyAllowed) {
178187
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_BUFFER_MEETS_ALIGNMENT_RESTRICTIONS, hostPtr, size);
@@ -199,9 +208,8 @@ Buffer *Buffer::create(Context *context,
199208
memoryManager->addAllocationToHostPtrManager(memory);
200209
}
201210

202-
// if memory pointer should not be allcoated and graphics allocation is nullptr
203-
// and cl_mem flags allow, create non-zerocopy buffer
204-
if (!allocateMemory && !memory && Buffer::isReadOnlyMemoryPermittedByFlags(properties.flags)) {
211+
//if allocation failed for CL_MEM_USE_HOST_PTR case retry with non zero copy path
212+
if ((properties.flags & CL_MEM_USE_HOST_PTR) && !memory && Buffer::isReadOnlyMemoryPermittedByFlags(properties.flags)) {
205213
allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
206214
zeroCopyAllowed = false;
207215
copyMemoryFromHostPtr = true;
@@ -217,6 +225,9 @@ Buffer *Buffer::create(Context *context,
217225

218226
if (!MemoryPool::isSystemMemoryPool(memory->getMemoryPool())) {
219227
zeroCopyAllowed = false;
228+
if (hostPtr) {
229+
copyMemoryFromHostPtr = true;
230+
}
220231
} else if (allocationType == GraphicsAllocation::AllocationType::BUFFER) {
221232
allocationType = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
222233
}
@@ -322,19 +333,25 @@ void Buffer::checkMemory(cl_mem_flags flags,
322333
return;
323334
}
324335

325-
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers) {
326-
GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::BUFFER;
336+
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers, bool isLocalMemoryEnabled) {
327337
if (is32bit) {
328-
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
329-
} else if (flags & CL_MEM_USE_HOST_PTR) {
330-
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
331-
} else if (renderCompressedBuffers) {
332-
type = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
338+
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
333339
}
334340

335341
if (sharedContext) {
336-
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
342+
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
343+
}
344+
345+
GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::BUFFER;
346+
347+
if (flags & CL_MEM_USE_HOST_PTR) {
348+
if (flags & CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL || !isLocalMemoryEnabled) {
349+
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
350+
}
351+
} else if (renderCompressedBuffers) {
352+
type = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
337353
}
354+
338355
return type;
339356
}
340357

runtime/mem_obj/buffer.h

Lines changed: 2 additions & 2 deletions
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
*
@@ -138,7 +138,7 @@ class Buffer : public MemObj {
138138
bool &isZeroCopy,
139139
bool &copyMemoryFromHostPtr,
140140
MemoryManager *memMngr);
141-
static GraphicsAllocation::AllocationType getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers);
141+
static GraphicsAllocation::AllocationType getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers, bool localMemoryEnabled);
142142
static bool isReadOnlyMemoryPermittedByFlags(cl_mem_flags flags);
143143

144144
void transferData(void *dst, void *src, size_t copySize, size_t copyOffset);

unit_tests/context/driver_diagnostics_tests.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (C) 2017-2019 Intel Corporation
33
*
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:
4+
* SPDX-License-Identifier: MIT
105
*
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.
216
*/
227

238
#include "driver_diagnostics_tests.h"
@@ -93,9 +78,15 @@ TEST_P(PerformanceHintBufferTest, GivenHostPtrAndSizeAlignmentsWhenBufferIsCreat
9378
if (!alignedSize) {
9479
sizeForBuffer--;
9580
}
81+
auto flags = CL_MEM_USE_HOST_PTR;
82+
83+
if (alignedAddress && alignedSize) {
84+
flags |= CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL;
85+
}
86+
9687
buffer = Buffer::create(
9788
context,
98-
CL_MEM_USE_HOST_PTR,
89+
flags,
9990
sizeForBuffer,
10091
(void *)addressForBuffer,
10192
retVal);
@@ -499,4 +490,4 @@ INSTANTIATE_TEST_CASE_P(
499490

500491
TEST(PerformanceHintsDebugVariables, givenDefaultDebugManagerWhenPrintDriverDiagnosticsIsCalledThenMinusOneIsReturned) {
501492
EXPECT_EQ(-1, DebugManager.flags.PrintDriverDiagnostics.get());
502-
}
493+
}

unit_tests/mem_obj/buffer_pin_tests.cpp

Lines changed: 2 additions & 2 deletions
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
*
@@ -86,7 +86,7 @@ TEST(BufferTests, doPinIsSetForHostPtr) {
8686

8787
auto buffer = Buffer::create(
8888
&context,
89-
CL_MEM_USE_HOST_PTR,
89+
CL_MEM_USE_HOST_PTR | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL,
9090
size,
9191
bff,
9292
retVal);

unit_tests/mem_obj/buffer_tests.cpp

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ TEST(Buffer, givenAllocHostPtrFlagPassedToBufferCreateWhenNoSharedContextOrRende
288288
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, buffer->getGraphicsAllocation()->getAllocationType());
289289
}
290290

291-
TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) {
291+
TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturnedIn64Bit) {
292292
cl_mem_flags flags = 0;
293-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true);
293+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, false);
294294
if (is32bit) {
295295
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
296296
} else {
@@ -300,51 +300,77 @@ TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenB
300300

301301
TEST(Buffer, givenSharedContextWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
302302
cl_mem_flags flags = 0;
303-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, true, false);
303+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, true, false, false);
304304
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
305305
}
306306

307307
TEST(Buffer, givenSharedContextAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
308308
cl_mem_flags flags = 0;
309-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, true, true);
309+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, true, true, false);
310310
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
311311
}
312312

313-
TEST(Buffer, givenUseHostPtrFlagWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
313+
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
314314
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
315-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false);
315+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, false);
316316
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
317317
}
318318

319+
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) {
320+
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
321+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, true);
322+
if (is64bit) {
323+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
324+
} else {
325+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
326+
}
327+
}
328+
319329
TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) {
320330
cl_mem_flags flags = CL_MEM_ALLOC_HOST_PTR;
321-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false);
331+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, false);
322332
if (is64bit) {
323333
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
324334
} else {
325335
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
326336
}
327337
}
328338

329-
TEST(Buffer, givenUseHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
339+
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) {
330340
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
331-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true);
341+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, false);
342+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
343+
}
344+
345+
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferMemoryTypeIsReturned) {
346+
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
347+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, true);
348+
if (is64bit) {
349+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
350+
} else {
351+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
352+
}
353+
}
354+
355+
TEST(Buffer, givenUseHostPointerFlagAndForceSharedPhysicalStorageWhenLocalMemoryIsEnabledThenBufferHostMemoryTypeIsReturned) {
356+
cl_mem_flags flags = CL_MEM_USE_HOST_PTR | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL;
357+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, true);
332358
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
333359
}
334360

335361
TEST(Buffer, givenAllocHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) {
336362
cl_mem_flags flags = CL_MEM_ALLOC_HOST_PTR;
337-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true);
338-
if (is32bit) {
339-
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
340-
} else {
363+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true, false);
364+
if (is64bit) {
341365
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type);
366+
} else {
367+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
342368
}
343369
}
344370

345371
TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhenAllocationTypeIsQueriedThenBufferTypeIsReturned) {
346372
cl_mem_flags flags = 0;
347-
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false);
373+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, false, false);
348374
if (is32bit) {
349375
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
350376
} else {
@@ -397,7 +423,7 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyH
397423

398424
void *cacheAlignedHostPtr = alignedMalloc(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
399425

400-
buffer.reset(Buffer::create(context.get(), CL_MEM_USE_HOST_PTR, MemoryConstants::cacheLineSize, cacheAlignedHostPtr, retVal));
426+
buffer.reset(Buffer::create(context.get(), CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL | CL_MEM_USE_HOST_PTR, MemoryConstants::cacheLineSize, cacheAlignedHostPtr, retVal));
401427
EXPECT_EQ(cacheAlignedHostPtr, buffer->getGraphicsAllocation()->getUnderlyingBuffer());
402428
EXPECT_TRUE(buffer->isMemObjZeroCopy());
403429
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
@@ -415,7 +441,7 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyH
415441
}
416442

417443
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
418-
buffer.reset(Buffer::create(context.get(), CL_MEM_USE_HOST_PTR, MemoryConstants::cacheLineSize, cacheAlignedHostPtr, retVal));
444+
buffer.reset(Buffer::create(context.get(), CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL | CL_MEM_USE_HOST_PTR, MemoryConstants::cacheLineSize, cacheAlignedHostPtr, retVal));
419445
EXPECT_EQ(cacheAlignedHostPtr, buffer->getGraphicsAllocation()->getUnderlyingBuffer());
420446
EXPECT_TRUE(buffer->isMemObjZeroCopy());
421447
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);

unit_tests/mem_obj/sub_buffer_tests.cpp

Lines changed: 2 additions & 2 deletions
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
*
@@ -104,7 +104,7 @@ TEST_F(SubBufferTest, GivenBufferWithAlignedHostPtrAndSameMemoryStorageWhenSubBu
104104
cl_int retVal = 0;
105105

106106
void *alignedPointer = alignedMalloc(MemoryConstants::pageSize, MemoryConstants::preferredAlignment);
107-
Buffer *buffer = Buffer::create(&context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR,
107+
Buffer *buffer = Buffer::create(&context, CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL,
108108
MemoryConstants::pageSize, alignedPointer, retVal);
109109

110110
ASSERT_NE(nullptr, buffer);

unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe
900900
}
901901

902902
TEST_F(BufferWithWddmMemory, ValidHostPtr) {
903-
flags = CL_MEM_USE_HOST_PTR;
903+
flags = CL_MEM_USE_HOST_PTR | CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL;
904904

905905
auto ptr = alignedMalloc(MemoryConstants::preferredAlignment, MemoryConstants::preferredAlignment);
906906

@@ -915,7 +915,11 @@ TEST_F(BufferWithWddmMemory, ValidHostPtr) {
915915
ASSERT_NE(nullptr, buffer);
916916

917917
auto address = buffer->getCpuAddress();
918-
EXPECT_EQ(ptr, address);
918+
if (buffer->isMemObjZeroCopy()) {
919+
EXPECT_EQ(ptr, address);
920+
} else {
921+
EXPECT_NE(address, ptr);
922+
}
919923
EXPECT_NE(nullptr, buffer->getGraphicsAllocation());
920924
EXPECT_NE(nullptr, buffer->getGraphicsAllocation()->getUnderlyingBuffer());
921925

0 commit comments

Comments
 (0)