Update allocationForCacheFlush method

Related-To: NEO-2535

Change-Id: Ia24556814188263e2ebb54b6419feddd5d8ed707
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2019-04-03 11:22:04 +02:00
committed by sys_ocldev
parent e22b4069ac
commit b2e16b7897
30 changed files with 229 additions and 98 deletions

View File

@@ -181,7 +181,7 @@ TEST_F(clSetKernelExecInfoTests, success_SvmPtrListWithMultiplePointers) {
}
}
TEST_F(clSetKernelExecInfoTests, givenReadOnlySvmPtrListWhenUsedAsKernelPointersThenNoCacheFlushRequire) {
TEST_F(clSetKernelExecInfoTests, givenReadOnlySvmPtrListWhenUsedAsKernelPointersThenCacheFlushIsNotRequired) {
if (svmCapabilities != 0) {
void *ptrSvm1 = clSVMAlloc(pContext, CL_MEM_READ_ONLY, 256, 4);
EXPECT_NE(nullptr, ptrSvm1);

View File

@@ -25,9 +25,9 @@ struct EnqueueSvmMemCopyTest : public DeviceFixture,
void SetUp() override {
DeviceFixture::SetUp();
CommandQueueFixture::SetUp(pDevice, 0);
srcSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
srcSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
ASSERT_NE(nullptr, srcSvmPtr);
dstSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
dstSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
ASSERT_NE(nullptr, dstSvmPtr);
srcSvmAlloc = context->getSVMAllocsManager()->getSVMAlloc(srcSvmPtr);
ASSERT_NE(nullptr, srcSvmAlloc);

View File

@@ -27,7 +27,7 @@ struct EnqueueSvmMemFillTest : public DeviceFixture,
CommandQueueFixture::SetUp(pDevice, 0);
patternSize = (size_t)GetParam();
ASSERT_TRUE((0 < patternSize) && (patternSize <= 128));
svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, true, false);
svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, CL_MEM_SVM_FINE_GRAIN_BUFFER);
ASSERT_NE(nullptr, svmPtr);
svmAlloc = context->getSVMAllocsManager()->getSVMAlloc(svmPtr);
ASSERT_NE(nullptr, svmAlloc);

View File

@@ -34,7 +34,7 @@ struct EnqueueSvmTest : public DeviceFixture,
void SetUp() override {
DeviceFixture::SetUp();
CommandQueueFixture::SetUp(pDevice, 0);
ptrSVM = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
ptrSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
}
void TearDown() override {
@@ -239,7 +239,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_InvalidValueDstPtrIsNull) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableAsyncEventsHandler.set(false);
void *pDstSVM = nullptr;
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
retVal = this->pCmdQ->enqueueSVMMemcpy(
false, // cl_bool blocking_copy
pDstSVM, // void *dst_ptr
@@ -270,7 +270,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_InvalidValueSrcPtrIsNull) {
TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_Success) {
void *pDstSVM = ptrSVM;
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
retVal = this->pCmdQ->enqueueSVMMemcpy(
false, // cl_bool blocking_copy
pDstSVM, // void *dst_ptr
@@ -286,7 +286,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_Success) {
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlocking_Success) {
void *pDstSVM = ptrSVM;
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
retVal = this->pCmdQ->enqueueSVMMemcpy(
true, // cl_bool blocking_copy
pDstSVM, // void *dst_ptr
@@ -302,7 +302,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlocking_Success) {
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlockedOnEvent_Success) {
void *pDstSVM = ptrSVM;
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
auto uEvent = make_releaseable<UserEvent>();
cl_event eventWaitList[] = {uEvent.get()};
retVal = this->pCmdQ->enqueueSVMMemcpy(
@@ -321,7 +321,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlockedOnEvent_Success) {
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherent_Success) {
void *pDstSVM = ptrSVM;
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, true, false);
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, CL_MEM_SVM_FINE_GRAIN_BUFFER);
retVal = this->pCmdQ->enqueueSVMMemcpy(
false, // cl_bool blocking_copy
pDstSVM, // void *dst_ptr
@@ -337,7 +337,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherent_Success) {
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherentBlockedOnEvent_Success) {
void *pDstSVM = ptrSVM;
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, true, false);
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, CL_MEM_SVM_FINE_GRAIN_BUFFER);
auto uEvent = make_releaseable<UserEvent>();
cl_event eventWaitList[] = {uEvent.get()};
retVal = this->pCmdQ->enqueueSVMMemcpy(
@@ -527,7 +527,7 @@ TEST_F(EnqueueSvmTest, concurentMapAccess) {
auto allocSvm = [&](uint32_t from, uint32_t to) {
for (uint32_t i = from; i <= to; i++) {
svmPtrs[i] = context->getSVMAllocsManager()->createSVMAlloc(1, false, false);
svmPtrs[i] = context->getSVMAllocsManager()->createSVMAlloc(1, 0);
auto ga = context->getSVMAllocsManager()->getSVMAlloc(svmPtrs[i]);
EXPECT_NE(nullptr, ga);
EXPECT_EQ(ga->getUnderlyingBuffer(), svmPtrs[i]);

View File

@@ -756,8 +756,8 @@ HWTEST_F(ZeroSizeEnqueueHandlerTest, enqueueFillImageWhenZeroSizeEnqueueIsDetect
HWTEST_F(ZeroSizeEnqueueHandlerTest, enqueueSVMMemcpyWhenZeroSizeEnqueueIsDetectedThenCommandMarkerShouldBeEnqueued) {
auto mockCmdQ = std::unique_ptr<MockCommandQueueHw<FamilyType>>(new MockCommandQueueHw<FamilyType>(&context, pDevice, 0));
void *pSrcSVM = context.getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSrcSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
size_t zeroSize = 0;
mockCmdQ->enqueueSVMMemcpy(false, pSrcSVM, pDstSVM, zeroSize, 0, nullptr, nullptr);
EXPECT_EQ(static_cast<cl_command_type>(CL_COMMAND_MARKER), mockCmdQ->lastCommandType);
@@ -770,8 +770,8 @@ HWTEST_F(ZeroSizeEnqueueHandlerTest, enqueueSVMMemcpyWhenZeroSizeEnqueueIsDetect
auto mockCmdQ = std::unique_ptr<MockCommandQueueHw<FamilyType>>(new MockCommandQueueHw<FamilyType>(&context, pDevice, 0));
cl_event event;
void *pSrcSVM = context.getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSrcSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
size_t zeroSize = 0;
mockCmdQ->enqueueSVMMemcpy(false, pSrcSVM, pDstSVM, zeroSize, 0, nullptr, &event);
EXPECT_EQ(static_cast<cl_command_type>(CL_COMMAND_MARKER), mockCmdQ->lastCommandType);
@@ -792,7 +792,7 @@ HWTEST_F(ZeroSizeEnqueueHandlerTest, enqueueSVMMemcpyWhenZeroSizeEnqueueIsDetect
HWTEST_F(ZeroSizeEnqueueHandlerTest, enqueueSVMMemFillWhenZeroSizeEnqueueIsDetectedThenCommandMarkerShouldBeEnqueued) {
auto mockCmdQ = std::unique_ptr<MockCommandQueueHw<FamilyType>>(new MockCommandQueueHw<FamilyType>(&context, pDevice, 0));
void *pSVM = context.getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
const float pattern[1] = {1.2345f};
size_t zeroSize = 0;
mockCmdQ->enqueueSVMMemFill(pSVM, &pattern, sizeof(pattern), zeroSize, 0, nullptr, nullptr);
@@ -805,7 +805,7 @@ HWTEST_F(ZeroSizeEnqueueHandlerTest, enqueueSVMMemFillWhenZeroSizeEnqueueIsDetec
auto mockCmdQ = std::unique_ptr<MockCommandQueueHw<FamilyType>>(new MockCommandQueueHw<FamilyType>(&context, pDevice, 0));
cl_event event;
void *pSVM = context.getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *pSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
const float pattern[1] = {1.2345f};
size_t zeroSize = 0;
mockCmdQ->enqueueSVMMemFill(pSVM, &pattern, sizeof(pattern), zeroSize, 0, nullptr, &event);

View File

@@ -648,7 +648,7 @@ TEST_P(PerformanceHintEnqueueMapTest, GivenZeroCopyFlagWhenEnqueueUnmapIsCalling
TEST_F(PerformanceHintEnqueueTest, GivenSVMPointerWhenEnqueueSVMMapIsCallingThenContextProvidesProperHint) {
void *svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
pCmdQ->enqueueSVMMap(CL_FALSE, 0, svmPtr, 256, 0, nullptr, nullptr);

View File

@@ -7,17 +7,20 @@
#include "unit_tests/helpers/kernel_commands_tests.h"
#include "runtime/api/api.h"
#include "runtime/built_ins/builtins_dispatch_builder.h"
#include "runtime/command_queue/command_queue_hw.h"
#include "runtime/helpers/basic_math.h"
#include "runtime/helpers/kernel_commands.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "unit_tests/fixtures/execution_model_kernel_fixture.h"
#include "unit_tests/fixtures/hello_world_fixture.h"
#include "unit_tests/fixtures/image_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/hw_parse.h"
#include "unit_tests/indirect_heap/indirect_heap_fixture.h"
#include "unit_tests/mocks/mock_graphics_allocation.h"
#include "unit_tests/utilities/base_object_utils.h"
#include "hw_cmds.h"
@@ -1359,4 +1362,32 @@ TEST_F(KernelCommandsTest, givenCacheFlushAfterWalkerEnabledWhenPlatformNotSuppo
StackVec<GraphicsAllocation *, 32> allocationsForCacheFlush;
mockKernelWithInternal->mockKernel->getAllocationsForCacheFlush(allocationsForCacheFlush);
EXPECT_EQ(0U, allocationsForCacheFlush.size());
}
}
using KernelCacheFlushTests = Test<HelloWorldFixture<HelloWorldFixtureFactory>>;
HWTEST_F(KernelCacheFlushTests, givenLocallyUncachedBufferWhenGettingAllocationsForFlushThenEmptyVectorIsReturned) {
DebugManagerStateRestore dbgRestore;
DebugManager.flags.EnableCacheFlushAfterWalker.set(-1);
auto kernel = clUniquePtr(Kernel::create(pProgram, *pProgram->getKernelInfo("CopyBuffer"), &retVal));
cl_mem_properties_intel bufferPropertiesUncachedResource[] = {CL_MEM_FLAGS_INTEL, CL_MEM_LOCALLY_UNCACHED_RESOURCE, 0};
auto bufferLocallyUncached = clCreateBufferWithPropertiesINTEL(context, bufferPropertiesUncachedResource, 1, nullptr, nullptr);
kernel->setArg(0, sizeof(bufferLocallyUncached), &bufferLocallyUncached);
using CacheFlushAllocationsVec = StackVec<GraphicsAllocation *, 32>;
CacheFlushAllocationsVec cacheFlushVec;
kernel->getAllocationsForCacheFlush(cacheFlushVec);
EXPECT_EQ(0u, cacheFlushVec.size());
auto bufferRegular = clCreateBufferWithPropertiesINTEL(context, nullptr, 1, nullptr, nullptr);
kernel->setArg(1, sizeof(bufferRegular), &bufferRegular);
kernel->getAllocationsForCacheFlush(cacheFlushVec);
size_t expectedCacheFlushVecSize = (hwInfoHelper.capabilityTable.supportCacheFlushAfterWalker ? 1u : 0u);
EXPECT_EQ(expectedCacheFlushVecSize, cacheFlushVec.size());
clReleaseMemObject(bufferLocallyUncached);
clReleaseMemObject(bufferRegular);
}

View File

@@ -509,7 +509,7 @@ TEST_F(CloneKernelTest, cloneKernelWithArgImmediate) {
}
TEST_F(CloneKernelTest, cloneKernelWithExecInfo) {
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, 0);
ASSERT_NE(nullptr, ptrSVM);
GraphicsAllocation *pSvmAlloc = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSVM);

View File

@@ -169,7 +169,7 @@ TEST_F(KernelArgBufferTest, given32BitDeviceWhenArgPassedIsNullThenOnly4BytesAre
EXPECT_NE(expValue, *pKernelArg64bit);
}
TEST_F(KernelArgBufferTest, givenWritebleBufferWhenSettingAsArgThenExpectAllocationInCacheFlushVector) {
TEST_F(KernelArgBufferTest, givenWritebleBufferWhenSettingAsArgThenDoNotExpectAllocationInCacheFlushVector) {
auto buffer = std::make_unique<MockBuffer>();
buffer->mockGfxAllocation.setMemObjectsAllocationWithWritableFlags(true);
buffer->mockGfxAllocation.setFlushL3Required(false);
@@ -179,7 +179,7 @@ TEST_F(KernelArgBufferTest, givenWritebleBufferWhenSettingAsArgThenExpectAllocat
auto retVal = pKernel->setArg(0, sizeof(cl_mem *), pVal);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(&buffer->mockGfxAllocation, pKernel->kernelArgRequiresCacheFlush[0]);
EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]);
}
TEST_F(KernelArgBufferTest, givenCacheFlushBufferWhenSettingAsArgThenExpectAllocationInCacheFlushVector) {

View File

@@ -414,7 +414,7 @@ HWTEST_TYPED_TEST(KernelArgSvmTestTyped, GivenBufferKernelArgWhenBufferOffsetIsN
alignedFree(svmPtr);
}
TEST_F(KernelArgSvmTest, givenWritebleSvmAllocationWhenSettingAsArgThenExpectAllocationInCacheFlushVector) {
TEST_F(KernelArgSvmTest, givenWritebleSvmAllocationWhenSettingAsArgThenDoNotExpectAllocationInCacheFlushVector) {
size_t svmSize = 4096;
void *svmPtr = alignedMalloc(svmSize, MemoryConstants::pageSize);
MockGraphicsAllocation svmAlloc(svmPtr, svmSize);
@@ -424,7 +424,7 @@ TEST_F(KernelArgSvmTest, givenWritebleSvmAllocationWhenSettingAsArgThenExpectAll
auto retVal = pKernel->setArgSvmAlloc(0, svmPtr, &svmAlloc);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(&svmAlloc, pKernel->kernelArgRequiresCacheFlush[0]);
EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]);
alignedFree(svmPtr);
}
@@ -459,7 +459,7 @@ TEST_F(KernelArgSvmTest, givenNoCacheFlushSvmAllocationWhenSettingAsArgThenNotEx
alignedFree(svmPtr);
}
TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingKernelExecInfoThenExpectSvmFlushFlagTrue) {
TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingKernelExecInfoThenDoNotExpectSvmFlushFlagTrue) {
size_t svmSize = 4096;
void *svmPtr = alignedMalloc(svmSize, MemoryConstants::pageSize);
MockGraphicsAllocation svmAlloc(svmPtr, svmSize);
@@ -468,7 +468,7 @@ TEST_F(KernelArgSvmTest, givenWritableSvmAllocationWhenSettingKernelExecInfoThen
svmAlloc.setFlushL3Required(false);
pKernel->setKernelExecInfo(&svmAlloc);
EXPECT_TRUE(pKernel->svmAllocationsRequireCacheFlush);
EXPECT_FALSE(pKernel->svmAllocationsRequireCacheFlush);
alignedFree(svmPtr);
}

View File

@@ -261,7 +261,7 @@ TEST_F(KernelImageArgTest, givenKernelWithSharedImageWhenSetArgCalledThenUsingSh
EXPECT_TRUE(pKernel->isUsingSharedObjArgs());
}
TEST_F(KernelImageArgTest, givenWritebleImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) {
TEST_F(KernelImageArgTest, givenWritebleImageWhenSettingAsArgThenDoNotExpectAllocationInCacheFlushVector) {
MockImageBase image;
image.graphicsAllocation->setMemObjectsAllocationWithWritableFlags(true);
image.graphicsAllocation->setFlushL3Required(false);
@@ -270,7 +270,7 @@ TEST_F(KernelImageArgTest, givenWritebleImageWhenSettingAsArgThenExpectAllocatio
pKernel->setArg(0, sizeof(imageObj), &imageObj);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(image.graphicsAllocation, pKernel->kernelArgRequiresCacheFlush[0]);
EXPECT_EQ(nullptr, pKernel->kernelArgRequiresCacheFlush[0]);
}
TEST_F(KernelImageArgTest, givenCacheFlushImageWhenSettingAsArgThenExpectAllocationInCacheFlushVector) {

View File

@@ -2420,7 +2420,7 @@ TEST(KernelTest, whenCacheFlushEnabledForAllQueuesAndKernelRequireCacheFlushAfte
EXPECT_TRUE(kernel.mockKernel->requiresCacheFlushCommand(queue));
}
TEST(KernelTest, whenAllocationWriteableThenAssignAllocationPointerToCacheFlushVector) {
TEST(KernelTest, whenAllocationWriteableThenDoNotAssignAllocationPointerToCacheFlushVector) {
MockGraphicsAllocation mockAllocation;
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockKernelWithInternals kernel(*device);
@@ -2430,7 +2430,7 @@ TEST(KernelTest, whenAllocationWriteableThenAssignAllocationPointerToCacheFlushV
mockAllocation.setFlushL3Required(false);
kernel.mockKernel->addAllocationToCacheFlushVector(0, &mockAllocation);
EXPECT_EQ(&mockAllocation, kernel.mockKernel->kernelArgRequiresCacheFlush[0]);
EXPECT_EQ(nullptr, kernel.mockKernel->kernelArgRequiresCacheFlush[0]);
}
TEST(KernelTest, whenAllocationReadOnlyNonFlushRequiredThenAssignNullPointerToCacheFlushVector) {

View File

@@ -261,7 +261,7 @@ TEST_F(BufferSetArgTest, clSetKernelArgBuffer) {
}
TEST_F(BufferSetArgTest, clSetKernelArgSVMPointer) {
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, false, false);
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, 0);
EXPECT_NE(nullptr, ptrSVM);
GraphicsAllocation *pSvmAlloc = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSVM);

View File

@@ -562,7 +562,7 @@ TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThen
TEST_F(RenderCompressedBuffersTests, givenSvmAllocationWhenCreatingBufferThenForceDisableCompression) {
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
auto svmAlloc = context->getSVMAllocsManager()->createSVMAlloc(sizeof(uint32_t), false, false);
auto svmAlloc = context->getSVMAllocsManager()->createSVMAlloc(sizeof(uint32_t), 0);
buffer.reset(Buffer::create(context.get(), CL_MEM_USE_HOST_PTR, sizeof(uint32_t), svmAlloc, retVal));
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
@@ -956,7 +956,7 @@ TEST_P(ValidHostPtr, failedAllocationInjection) {
TEST_P(ValidHostPtr, SvmHostPtr) {
const DeviceInfo &devInfo = pDevice->getDeviceInfo();
if (devInfo.svmCapabilities != 0) {
auto ptr = context->getSVMAllocsManager()->createSVMAlloc(64, false, false);
auto ptr = context->getSVMAllocsManager()->createSVMAlloc(64, 0);
auto bufferSvm = Buffer::create(context.get(), CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 64, ptr, retVal);
EXPECT_NE(nullptr, bufferSvm);

View File

@@ -55,12 +55,26 @@ TEST(AllocationFlagsTest, givenAllocateMemoryFlagWhenGetAllocationFlagsIsCalledT
}
TEST(UncacheableFlagsTest, givenUncachedResourceFlagWhenGetAllocationFlagsIsCalledThenUncacheableFlagIsCorrectlySet) {
auto allocationFlags = MemObjHelper::getAllocationProperties(CL_MEM_LOCALLY_UNCACHED_RESOURCE, false, 0, GraphicsAllocation::AllocationType::BUFFER);
MemoryProperties memoryProperties;
memoryProperties.flags_intel = CL_MEM_LOCALLY_UNCACHED_RESOURCE;
auto allocationFlags = MemObjHelper::getAllocationProperties(memoryProperties, false, 0, GraphicsAllocation::AllocationType::BUFFER);
EXPECT_TRUE(allocationFlags.flags.uncacheable);
allocationFlags = MemObjHelper::getAllocationProperties(0, false, 0, GraphicsAllocation::AllocationType::BUFFER);
EXPECT_FALSE(allocationFlags.flags.uncacheable);
}
TEST(AllocationFlagsTest, givenReadOnlyResourceFlagWhenGetAllocationFlagsIsCalledThenFlushL3FlagsAreCorrectlySet) {
auto allocationFlags =
MemObjHelper::getAllocationProperties(CL_MEM_READ_ONLY, true, 0, GraphicsAllocation::AllocationType::BUFFER);
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForRead);
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForWrite);
allocationFlags = MemObjHelper::getAllocationProperties(0, true, 0, GraphicsAllocation::AllocationType::BUFFER);
EXPECT_TRUE(allocationFlags.flags.flushL3RequiredForRead);
EXPECT_TRUE(allocationFlags.flags.flushL3RequiredForWrite);
}
TEST(StorageInfoTest, whenStorageInfoIsCreatedWithDefaultConstructorThenReturnsOneHandle) {
StorageInfo storageInfo;
EXPECT_EQ(1u, storageInfo.getNumHandles());

View File

@@ -1644,6 +1644,36 @@ TEST(MemoryManagerTest, givenMemoryManagerWhenAllocationWasNotUnlockedThenItIsUn
EXPECT_EQ(1u, memoryManager.unlockResourceCalled);
}
TEST(MemoryManagerTest, givenAllocationTypesThatMayNeedL3FlushWhenCallingGetAllocationDataThenFlushL3FlagIsCorrectlySet) {
AllocationData allocData;
AllocationProperties properties(1, GraphicsAllocation::AllocationType::UNDECIDED);
properties.flags.flushL3RequiredForRead = 1;
properties.flags.flushL3RequiredForWrite = 1;
GraphicsAllocation::AllocationType allocationTypesThatMayNeedL3Flush[] = {
GraphicsAllocation::AllocationType::BUFFER, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED,
GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR,
GraphicsAllocation::AllocationType::GLOBAL_SURFACE, GraphicsAllocation::AllocationType::IMAGE,
GraphicsAllocation::AllocationType::PIPE, GraphicsAllocation::AllocationType::SHARED_IMAGE,
GraphicsAllocation::AllocationType::SHARED_BUFFER, GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY,
GraphicsAllocation::AllocationType::SVM, GraphicsAllocation::AllocationType::UNDECIDED};
for (auto allocationType : allocationTypesThatMayNeedL3Flush) {
properties.allocationType = allocationType;
MockMemoryManager::getAllocationData(allocData, properties, {}, nullptr);
EXPECT_TRUE(allocData.flags.flushL3);
}
properties.flags.flushL3RequiredForRead = 0;
properties.flags.flushL3RequiredForWrite = 0;
for (auto allocationType : allocationTypesThatMayNeedL3Flush) {
properties.allocationType = allocationType;
MockMemoryManager::getAllocationData(allocData, properties, {}, nullptr);
EXPECT_FALSE(allocData.flags.flushL3);
}
}
TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) {
GraphicsAllocation allocation{GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
allocation.set32BitAllocation(true);
@@ -1699,12 +1729,14 @@ TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForNullAllocatio
}
TEST(MemoryAllocationTest, givenAllocationTypeWhenPassedToMemoryAllocationConstructorThenAllocationTypeIsStored) {
MemoryAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0, MemoryPool::MemoryNull, false};
MemoryAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0,
MemoryPool::MemoryNull, false, false, false};
EXPECT_EQ(GraphicsAllocation::AllocationType::COMMAND_BUFFER, allocation.getAllocationType());
}
TEST(MemoryAllocationTest, givenMemoryPoolWhenPassedToMemoryAllocationConstructorThenMemoryPoolIsStored) {
MemoryAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0, MemoryPool::System64KBPages, false};
MemoryAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0,
MemoryPool::System64KBPages, false, false, false};
EXPECT_EQ(MemoryPool::System64KBPages, allocation.getMemoryPool());
}

View File

@@ -21,14 +21,14 @@ struct SVMMemoryAllocatorTest : ::testing::Test {
};
TEST_F(SVMMemoryAllocatorTest, whenCreateZeroSizedSVMAllocationThenReturnNullptr) {
auto ptr = svmManager.createSVMAlloc(0, false, false);
auto ptr = svmManager.createSVMAlloc(0, 0);
EXPECT_EQ(0u, svmManager.SVMAllocs.getNumAllocs());
EXPECT_EQ(ptr, nullptr);
}
TEST_F(SVMMemoryAllocatorTest, whenSVMAllocationIsFreedThenCannotBeGotAgain) {
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_NE(nullptr, ptr);
EXPECT_NE(nullptr, svmManager.getSVMAlloc(ptr));
EXPECT_NE(nullptr, svmManager.getSVMAlloc(ptr));
@@ -41,7 +41,7 @@ TEST_F(SVMMemoryAllocatorTest, whenSVMAllocationIsFreedThenCannotBeGotAgain) {
}
TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromReturnedPointerAreaThenReturnSameAllocation) {
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_NE(ptr, nullptr);
GraphicsAllocation *graphicsAllocation = svmManager.getSVMAlloc(ptr);
EXPECT_NE(nullptr, graphicsAllocation);
@@ -56,7 +56,7 @@ TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromReturnedPointerAreaThenRe
}
TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromOutsideOfReturnedPointerAreaThenDontReturnThisAllocation) {
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_NE(ptr, nullptr);
GraphicsAllocation *graphicsAllocation = svmManager.getSVMAlloc(ptr);
EXPECT_NE(nullptr, graphicsAllocation);
@@ -75,7 +75,7 @@ TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromOutsideOfReturnedPointerA
TEST_F(SVMMemoryAllocatorTest, whenCouldNotAllocateInMemoryManagerThenReturnsNullAndDoesNotChangeAllocsMap) {
FailMemoryManager failMemoryManager(executionEnvironment);
svmManager.memoryManager = &failMemoryManager;
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_EQ(nullptr, ptr);
EXPECT_EQ(0u, svmManager.SVMAllocs.getNumAllocs());
svmManager.freeSVMAlloc(ptr);
@@ -84,7 +84,7 @@ TEST_F(SVMMemoryAllocatorTest, whenCouldNotAllocateInMemoryManagerThenReturnsNul
TEST_F(SVMMemoryAllocatorTest, given64kbAllowedWhenAllocatingSvmMemoryThenDontPreferRenderCompression) {
MockMemoryManager memoryManager64Kb(true, false, executionEnvironment);
svmManager.memoryManager = &memoryManager64Kb;
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_FALSE(memoryManager64Kb.preferRenderCompressedFlagPassed);
svmManager.freeSVMAlloc(ptr);
}
@@ -92,19 +92,19 @@ TEST_F(SVMMemoryAllocatorTest, given64kbAllowedWhenAllocatingSvmMemoryThenDontPr
TEST_F(SVMMemoryAllocatorTest, given64kbAllowedwhenAllocatingSvmMemoryThenAllocationIsIn64kbPagePool) {
MockMemoryManager memoryManager64Kb(true, false, executionEnvironment);
svmManager.memoryManager = &memoryManager64Kb;
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_EQ(MemoryPool::System64KBPages, svmManager.getSVMAlloc(ptr)->getMemoryPool());
svmManager.freeSVMAlloc(ptr);
}
TEST_F(SVMMemoryAllocatorTest, given64kbDisallowedWhenAllocatingSvmMemoryThenAllocationIsIn4kbPagePool) {
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, false, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, 0);
EXPECT_EQ(MemoryPool::System4KBPages, svmManager.getSVMAlloc(ptr)->getMemoryPool());
svmManager.freeSVMAlloc(ptr);
}
TEST_F(SVMMemoryAllocatorTest, whenCoherentFlagIsPassedThenAllocationIsCoherent) {
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, true, false);
auto ptr = svmManager.createSVMAlloc(MemoryConstants::pageSize, CL_MEM_SVM_FINE_GRAIN_BUFFER);
EXPECT_TRUE(svmManager.getSVMAlloc(ptr)->isCoherent());
svmManager.freeSVMAlloc(ptr);
}
@@ -121,7 +121,7 @@ TEST_F(SVMMemoryAllocatorTest, whenNoReadOnlyFlagIsPresentThenReturnFalse) {
}
TEST_F(SVMMemoryAllocatorTest, whenReadOnlySvmAllocationCreatedThenGraphicsAllocationHasWriteableFlagFalse) {
void *svm = svmManager.createSVMAlloc(4096, false, true);
void *svm = svmManager.createSVMAlloc(4096, CL_MEM_READ_ONLY);
EXPECT_NE(nullptr, svm);
GraphicsAllocation *svmAllocation = svmManager.getSVMAlloc(svm);