Add SvmAllocationProperties
Change-Id: Ie96aeab5597a1b3f2db8611a8a04597516730ce8 Related-To: NEO-2535 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
parent
b7bd3aa793
commit
fae1d882f8
|
@ -3359,7 +3359,7 @@ void *CL_API_CALL clSVMAlloc(cl_context context,
|
|||
return pAlloc;
|
||||
}
|
||||
|
||||
pAlloc = pContext->getSVMAllocsManager()->createSVMAlloc(size, flags);
|
||||
pAlloc = pContext->getSVMAllocsManager()->createSVMAlloc(size, MemObjHelper::getSvmAllocationProperties(flags));
|
||||
|
||||
if (pContext->isProvidingPerformanceHints()) {
|
||||
pContext->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_SVM_ALLOC_MEETS_ALIGNMENT_RESTRICTIONS, pAlloc, size);
|
||||
|
|
|
@ -136,7 +136,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueSVMMap(cl_bool blockingMap,
|
|||
if (event) {
|
||||
castToObjectOrAbort<Event>(*event)->setCmdType(CL_COMMAND_SVM_MAP);
|
||||
}
|
||||
bool readOnlyMap = SVMAllocsManager::mapFlagIsReadOnly(mapFlags);
|
||||
bool readOnlyMap = !isValueSet(mapFlags, CL_MAP_WRITE) && !isValueSet(mapFlags, CL_MAP_WRITE_INVALIDATE_REGION);
|
||||
context->getSVMAllocsManager()->insertSvmMapOperation(svmPtr, size, svmBasePtr, svmOffset, readOnlyMap);
|
||||
|
||||
return CL_SUCCESS;
|
||||
|
|
|
@ -34,7 +34,9 @@ bool MemObjHelper::parseMemoryProperties(const cl_mem_properties_intel *properti
|
|||
AllocationProperties MemObjHelper::getAllocationProperties(MemoryProperties memoryProperties, bool allocateMemory,
|
||||
size_t size, GraphicsAllocation::AllocationType type) {
|
||||
AllocationProperties allocationProperties(allocateMemory, size, type);
|
||||
fillCachePolicyInProperties(allocationProperties, memoryProperties);
|
||||
fillCachePolicyInProperties(allocationProperties,
|
||||
isValueSet(memoryProperties.flags_intel, CL_MEM_LOCALLY_UNCACHED_RESOURCE),
|
||||
isValueSet(memoryProperties.flags, CL_MEM_READ_ONLY));
|
||||
return allocationProperties;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "runtime/context/context_type.h"
|
||||
#include "runtime/mem_obj/mem_obj.h"
|
||||
#include "runtime/memory_manager/memory_manager.h"
|
||||
#include "runtime/memory_manager/svm_memory_manager.h"
|
||||
|
||||
#include "CL/cl.h"
|
||||
#include "mem_obj_types.h"
|
||||
|
@ -91,13 +92,15 @@ class MemObjHelper {
|
|||
size_t size, GraphicsAllocation::AllocationType type);
|
||||
static AllocationProperties getAllocationProperties(ImageInfo &imgInfo, bool allocateMemory, MemoryProperties memoryProperties) {
|
||||
AllocationProperties allocationProperties{allocateMemory, imgInfo, GraphicsAllocation::AllocationType::IMAGE};
|
||||
fillCachePolicyInProperties(allocationProperties, memoryProperties);
|
||||
fillCachePolicyInProperties(allocationProperties,
|
||||
isValueSet(memoryProperties.flags_intel, CL_MEM_LOCALLY_UNCACHED_RESOURCE),
|
||||
isValueSet(memoryProperties.flags, CL_MEM_READ_ONLY));
|
||||
return allocationProperties;
|
||||
}
|
||||
|
||||
static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, const MemoryProperties &memoryProperties) {
|
||||
allocationProperties.flags.uncacheable = isValueSet(memoryProperties.flags_intel, CL_MEM_LOCALLY_UNCACHED_RESOURCE);
|
||||
auto cacheFlushRequired = !allocationProperties.flags.uncacheable && !isValueSet(memoryProperties.flags, CL_MEM_READ_ONLY);
|
||||
static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly) {
|
||||
allocationProperties.flags.uncacheable = uncached;
|
||||
auto cacheFlushRequired = !uncached && !readOnly;
|
||||
allocationProperties.flags.flushL3RequiredForRead = cacheFlushRequired;
|
||||
allocationProperties.flags.flushL3RequiredForWrite = cacheFlushRequired;
|
||||
}
|
||||
|
@ -110,6 +113,14 @@ class MemObjHelper {
|
|||
return isFieldValid(flags, allValidFlags);
|
||||
}
|
||||
|
||||
static SVMAllocsManager::SvmAllocationProperties getSvmAllocationProperties(cl_mem_flags flags) {
|
||||
SVMAllocsManager::SvmAllocationProperties svmProperties;
|
||||
svmProperties.coherent = isValueSet(flags, CL_MEM_SVM_FINE_GRAIN_BUFFER);
|
||||
svmProperties.hostPtrReadOnly = isValueSet(flags, CL_MEM_HOST_READ_ONLY) || isValueSet(flags, CL_MEM_HOST_NO_ACCESS);
|
||||
svmProperties.readOnly = isValueSet(flags, CL_MEM_READ_ONLY);
|
||||
return svmProperties;
|
||||
}
|
||||
|
||||
static bool isSuitableForRenderCompression(bool renderCompressed, const MemoryProperties &properties, ContextType contextType, bool preferCompression);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -71,15 +71,15 @@ SvmMapOperation *SVMAllocsManager::MapOperationsTracker::get(const void *regionP
|
|||
SVMAllocsManager::SVMAllocsManager(MemoryManager *memoryManager) : memoryManager(memoryManager) {
|
||||
}
|
||||
|
||||
void *SVMAllocsManager::createSVMAlloc(size_t size, cl_mem_flags flags) {
|
||||
void *SVMAllocsManager::createSVMAlloc(size_t size, const SvmAllocationProperties svmProperties) {
|
||||
if (size == 0)
|
||||
return nullptr;
|
||||
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
if (!memoryManager->isLocalMemorySupported()) {
|
||||
return createZeroCopySvmAllocation(size, flags);
|
||||
return createZeroCopySvmAllocation(size, svmProperties);
|
||||
} else {
|
||||
return createSvmAllocationWithDeviceStorage(size, flags);
|
||||
return createSvmAllocationWithDeviceStorage(size, svmProperties);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,15 +100,15 @@ void SVMAllocsManager::freeSVMAlloc(void *ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, cl_mem_flags flags) {
|
||||
void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, const SvmAllocationProperties &svmProperties) {
|
||||
AllocationProperties properties{true, size, GraphicsAllocation::AllocationType::SVM_ZERO_COPY};
|
||||
MemObjHelper::fillCachePolicyInProperties(properties, flags);
|
||||
MemObjHelper::fillCachePolicyInProperties(properties, false, svmProperties.readOnly);
|
||||
GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
|
||||
if (!allocation) {
|
||||
return nullptr;
|
||||
}
|
||||
allocation->setMemObjectsAllocationWithWritableFlags(!SVMAllocsManager::memFlagIsReadOnly(flags));
|
||||
allocation->setCoherent(isValueSet(flags, CL_MEM_SVM_FINE_GRAIN_BUFFER));
|
||||
allocation->setMemObjectsAllocationWithWritableFlags(!svmProperties.readOnly && !svmProperties.hostPtrReadOnly);
|
||||
allocation->setCoherent(svmProperties.coherent);
|
||||
|
||||
SvmAllocationData allocData;
|
||||
allocData.gpuAllocation = allocation;
|
||||
|
@ -118,29 +118,29 @@ void *SVMAllocsManager::createZeroCopySvmAllocation(size_t size, cl_mem_flags fl
|
|||
return allocation->getUnderlyingBuffer();
|
||||
}
|
||||
|
||||
void *SVMAllocsManager::createSvmAllocationWithDeviceStorage(size_t size, cl_mem_flags flags) {
|
||||
void *SVMAllocsManager::createSvmAllocationWithDeviceStorage(size_t size, const SvmAllocationProperties &svmProperties) {
|
||||
size_t alignedSize = alignUp<size_t>(size, 2 * MemoryConstants::megaByte);
|
||||
AllocationProperties cpuProperties{true, alignedSize, GraphicsAllocation::AllocationType::SVM_CPU};
|
||||
cpuProperties.alignment = 2 * MemoryConstants::megaByte;
|
||||
MemObjHelper::fillCachePolicyInProperties(cpuProperties, flags);
|
||||
MemObjHelper::fillCachePolicyInProperties(cpuProperties, false, svmProperties.readOnly);
|
||||
GraphicsAllocation *allocationCpu = memoryManager->allocateGraphicsMemoryWithProperties(cpuProperties);
|
||||
if (!allocationCpu) {
|
||||
return nullptr;
|
||||
}
|
||||
allocationCpu->setMemObjectsAllocationWithWritableFlags(!SVMAllocsManager::memFlagIsReadOnly(flags));
|
||||
allocationCpu->setCoherent(isValueSet(flags, CL_MEM_SVM_FINE_GRAIN_BUFFER));
|
||||
allocationCpu->setMemObjectsAllocationWithWritableFlags(!svmProperties.readOnly && !svmProperties.hostPtrReadOnly);
|
||||
allocationCpu->setCoherent(svmProperties.coherent);
|
||||
void *svmPtr = allocationCpu->getUnderlyingBuffer();
|
||||
|
||||
AllocationProperties gpuProperties{false, alignedSize, GraphicsAllocation::AllocationType::SVM_GPU};
|
||||
gpuProperties.alignment = 2 * MemoryConstants::megaByte;
|
||||
MemObjHelper::fillCachePolicyInProperties(gpuProperties, flags);
|
||||
MemObjHelper::fillCachePolicyInProperties(gpuProperties, false, svmProperties.readOnly);
|
||||
GraphicsAllocation *allocationGpu = memoryManager->allocateGraphicsMemoryWithProperties(gpuProperties, svmPtr);
|
||||
if (!allocationGpu) {
|
||||
memoryManager->freeGraphicsMemory(allocationCpu);
|
||||
return nullptr;
|
||||
}
|
||||
allocationGpu->setMemObjectsAllocationWithWritableFlags(!SVMAllocsManager::memFlagIsReadOnly(flags));
|
||||
allocationGpu->setCoherent(isValueSet(flags, CL_MEM_SVM_FINE_GRAIN_BUFFER));
|
||||
allocationGpu->setMemObjectsAllocationWithWritableFlags(!svmProperties.readOnly && !svmProperties.hostPtrReadOnly);
|
||||
allocationGpu->setCoherent(svmProperties.coherent);
|
||||
|
||||
SvmAllocationData allocData;
|
||||
allocData.gpuAllocation = allocationGpu;
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include "CL/cl.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
@ -57,27 +55,25 @@ class SVMAllocsManager {
|
|||
SvmMapOperationsContainer operations;
|
||||
};
|
||||
|
||||
struct SvmAllocationProperties {
|
||||
bool coherent = false;
|
||||
bool hostPtrReadOnly = false;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
SVMAllocsManager(MemoryManager *memoryManager);
|
||||
void *createSVMAlloc(size_t size, cl_mem_flags flags);
|
||||
void *createSVMAlloc(size_t size, const SvmAllocationProperties svmProperties);
|
||||
SvmAllocationData *getSVMAlloc(const void *ptr);
|
||||
void freeSVMAlloc(void *ptr);
|
||||
size_t getNumAllocs() const { return SVMAllocs.getNumAllocs(); }
|
||||
|
||||
static bool memFlagIsReadOnly(cl_svm_mem_flags flags) {
|
||||
return (flags & (CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_HOST_NO_ACCESS)) != 0;
|
||||
}
|
||||
|
||||
static bool mapFlagIsReadOnly(cl_map_flags mapFlags) {
|
||||
return !((mapFlags & (CL_MAP_WRITE | CL_MAP_WRITE_INVALIDATE_REGION)) != 0);
|
||||
}
|
||||
|
||||
void insertSvmMapOperation(void *regionSvmPtr, size_t regionSize, void *baseSvmPtr, size_t offset, bool readOnlyMap);
|
||||
void removeSvmMapOperation(const void *regionSvmPtr);
|
||||
SvmMapOperation *getSvmMapOperation(const void *regionPtr);
|
||||
|
||||
protected:
|
||||
void *createZeroCopySvmAllocation(size_t size, cl_mem_flags flags);
|
||||
void *createSvmAllocationWithDeviceStorage(size_t size, cl_mem_flags flags);
|
||||
void *createZeroCopySvmAllocation(size_t size, const SvmAllocationProperties &svmProperties);
|
||||
void *createSvmAllocationWithDeviceStorage(size_t size, const SvmAllocationProperties &svmProperties);
|
||||
void freeZeroCopySvmAllocation(SvmAllocationData *svmData);
|
||||
void freeSvmAllocationWithDeviceStorage(SvmAllocationData *svmData);
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ struct EnqueueSvmMemCopyTest : public DeviceFixture,
|
|||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
CommandQueueFixture::SetUp(pDevice, 0);
|
||||
srcSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
srcSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
ASSERT_NE(nullptr, srcSvmPtr);
|
||||
dstSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
dstSvmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
ASSERT_NE(nullptr, dstSvmPtr);
|
||||
auto srcSvmData = context->getSVMAllocsManager()->getSVMAlloc(srcSvmPtr);
|
||||
ASSERT_NE(nullptr, srcSvmData);
|
||||
|
|
|
@ -27,7 +27,9 @@ struct EnqueueSvmMemFillTest : public DeviceFixture,
|
|||
CommandQueueFixture::SetUp(pDevice, 0);
|
||||
patternSize = (size_t)GetParam();
|
||||
ASSERT_TRUE((0 < patternSize) && (patternSize <= 128));
|
||||
svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, CL_MEM_SVM_FINE_GRAIN_BUFFER);
|
||||
SVMAllocsManager::SvmAllocationProperties svmProperties;
|
||||
svmProperties.coherent = true;
|
||||
svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, svmProperties);
|
||||
ASSERT_NE(nullptr, svmPtr);
|
||||
auto svmData = context->getSVMAllocsManager()->getSVMAlloc(svmPtr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
|
|
@ -38,7 +38,7 @@ struct EnqueueSvmTest : public DeviceFixture,
|
|||
void SetUp() override {
|
||||
DeviceFixture::SetUp();
|
||||
CommandQueueFixture::SetUp(pDevice, 0);
|
||||
ptrSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
ptrSVM = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
|
@ -243,7 +243,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_InvalidValueDstPtrIsNull) {
|
|||
DebugManagerStateRestore dbgRestore;
|
||||
DebugManager.flags.EnableAsyncEventsHandler.set(false);
|
||||
void *pDstSVM = nullptr;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
retVal = this->pCmdQ->enqueueSVMMemcpy(
|
||||
false, // cl_bool blocking_copy
|
||||
pDstSVM, // void *dst_ptr
|
||||
|
@ -274,7 +274,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_InvalidValueSrcPtrIsNull) {
|
|||
|
||||
TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_Success) {
|
||||
void *pDstSVM = ptrSVM;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
retVal = this->pCmdQ->enqueueSVMMemcpy(
|
||||
false, // cl_bool blocking_copy
|
||||
pDstSVM, // void *dst_ptr
|
||||
|
@ -290,7 +290,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpy_Success) {
|
|||
|
||||
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlocking_Success) {
|
||||
void *pDstSVM = ptrSVM;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
retVal = this->pCmdQ->enqueueSVMMemcpy(
|
||||
true, // cl_bool blocking_copy
|
||||
pDstSVM, // void *dst_ptr
|
||||
|
@ -306,7 +306,7 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlocking_Success) {
|
|||
|
||||
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlockedOnEvent_Success) {
|
||||
void *pDstSVM = ptrSVM;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
auto uEvent = make_releaseable<UserEvent>();
|
||||
cl_event eventWaitList[] = {uEvent.get()};
|
||||
retVal = this->pCmdQ->enqueueSVMMemcpy(
|
||||
|
@ -325,7 +325,9 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyBlockedOnEvent_Success) {
|
|||
|
||||
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherent_Success) {
|
||||
void *pDstSVM = ptrSVM;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, CL_MEM_SVM_FINE_GRAIN_BUFFER);
|
||||
SVMAllocsManager::SvmAllocationProperties svmProperties;
|
||||
svmProperties.coherent = true;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, svmProperties);
|
||||
retVal = this->pCmdQ->enqueueSVMMemcpy(
|
||||
false, // cl_bool blocking_copy
|
||||
pDstSVM, // void *dst_ptr
|
||||
|
@ -341,7 +343,9 @@ TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherent_Success) {
|
|||
|
||||
TEST_F(EnqueueSvmTest, enqueueSVMMemcpyCoherentBlockedOnEvent_Success) {
|
||||
void *pDstSVM = ptrSVM;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, CL_MEM_SVM_FINE_GRAIN_BUFFER);
|
||||
SVMAllocsManager::SvmAllocationProperties svmProperties;
|
||||
svmProperties.coherent = true;
|
||||
void *pSrcSVM = context->getSVMAllocsManager()->createSVMAlloc(256, svmProperties);
|
||||
auto uEvent = make_releaseable<UserEvent>();
|
||||
cl_event eventWaitList[] = {uEvent.get()};
|
||||
retVal = this->pCmdQ->enqueueSVMMemcpy(
|
||||
|
@ -535,7 +539,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, 0);
|
||||
svmPtrs[i] = context->getSVMAllocsManager()->createSVMAlloc(1, {});
|
||||
auto svmData = context->getSVMAllocsManager()->getSVMAlloc(svmPtrs[i]);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
auto ga = svmData->gpuAllocation;
|
||||
|
@ -593,6 +597,28 @@ TEST_F(EnqueueSvmTest, enqueueSVMMigrateMem_Success) {
|
|||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST(CreateSvmAllocTests, givenVariousSvmAllocationPropertiesWhenAllocatingSvmThenSvmIsCorrectlyAllocated) {
|
||||
DebugManagerStateRestore dbgRestore;
|
||||
SVMAllocsManager::SvmAllocationProperties svmAllocationProperties;
|
||||
|
||||
for (auto isLocalMemorySupported : ::testing::Bool()) {
|
||||
DebugManager.flags.EnableLocalMemory.set(isLocalMemorySupported);
|
||||
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
|
||||
auto mockContext = std::make_unique<MockContext>(mockDevice.get());
|
||||
|
||||
for (auto isReadOnly : ::testing::Bool()) {
|
||||
for (auto isHostPtrReadOnly : ::testing::Bool()) {
|
||||
svmAllocationProperties.readOnly = isReadOnly;
|
||||
svmAllocationProperties.hostPtrReadOnly = isHostPtrReadOnly;
|
||||
|
||||
auto ptrSVM = mockContext->getSVMAllocsManager()->createSVMAlloc(256, svmAllocationProperties);
|
||||
EXPECT_NE(nullptr, ptrSVM);
|
||||
mockContext->getSVMAllocsManager()->freeSVMAlloc(ptrSVM);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EnqueueSvmTestLocalMemory : public DeviceFixture,
|
||||
public ::testing::Test {
|
||||
void SetUp() override {
|
||||
|
@ -602,7 +628,7 @@ struct EnqueueSvmTestLocalMemory : public DeviceFixture,
|
|||
DeviceFixture::SetUp();
|
||||
context = std::make_unique<MockContext>(pDevice, true);
|
||||
size = 256;
|
||||
svmPtr = context->getSVMAllocsManager()->createSVMAlloc(size, 0);
|
||||
svmPtr = context->getSVMAllocsManager()->createSVMAlloc(size, {});
|
||||
ASSERT_NE(nullptr, svmPtr);
|
||||
mockSvmManager = reinterpret_cast<MockSVMAllocsManager *>(context->getSVMAllocsManager());
|
||||
}
|
||||
|
@ -622,6 +648,24 @@ struct EnqueueSvmTestLocalMemory : public DeviceFixture,
|
|||
HardwareParse hwParse;
|
||||
};
|
||||
|
||||
HWTEST_F(EnqueueSvmTestLocalMemory, givenWriteInvalidateRegionFlagWhenMappingSvmThenMapIsSuccessfulAndReadOnlyFlagIsFalse) {
|
||||
MockCommandQueueHw<FamilyType> queue(context.get(), pDevice, nullptr);
|
||||
uintptr_t offset = 64;
|
||||
void *regionSvmPtr = ptrOffset(svmPtr, offset);
|
||||
size_t regionSize = 64;
|
||||
retVal = queue.enqueueSVMMap(
|
||||
CL_TRUE,
|
||||
CL_MAP_WRITE_INVALIDATE_REGION,
|
||||
regionSvmPtr,
|
||||
regionSize,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
auto svmMap = mockSvmManager->svmMapOperations.get(regionSvmPtr);
|
||||
EXPECT_FALSE(svmMap->readOnlyMap);
|
||||
}
|
||||
|
||||
HWTEST_F(EnqueueSvmTestLocalMemory, givenEnabledLocalMemoryWhenEnqeueMapValidSvmPtrThenExpectSingleWalker) {
|
||||
using WALKER_TYPE = typename FamilyType::WALKER_TYPE;
|
||||
MockCommandQueueHw<FamilyType> queue(context.get(), pDevice, nullptr);
|
||||
|
@ -630,7 +674,7 @@ HWTEST_F(EnqueueSvmTestLocalMemory, givenEnabledLocalMemoryWhenEnqeueMapValidSvm
|
|||
cl_event event = nullptr;
|
||||
|
||||
uintptr_t offset = 64;
|
||||
void *regionSvmPtr = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(svmPtr) + offset);
|
||||
void *regionSvmPtr = ptrOffset(svmPtr, offset);
|
||||
size_t regionSize = 64;
|
||||
retVal = queue.enqueueSVMMap(
|
||||
CL_FALSE,
|
||||
|
@ -667,7 +711,7 @@ HWTEST_F(EnqueueSvmTestLocalMemory, givenEnabledLocalMemoryWhenEnqeueMapSvmPtrTw
|
|||
LinearStream &stream = queue.getCS(0x1000);
|
||||
|
||||
uintptr_t offset = 64;
|
||||
void *regionSvmPtr = reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(svmPtr) + offset);
|
||||
void *regionSvmPtr = ptrOffset(svmPtr, offset);
|
||||
size_t regionSize = 64;
|
||||
retVal = queue.enqueueSVMMap(
|
||||
CL_FALSE,
|
||||
|
@ -858,4 +902,4 @@ HWTEST_F(EnqueueSvmTestLocalMemory, givenEnabledLocalMemoryWhenMappedSvmRegionAn
|
|||
hwParse.parseCommands<FamilyType>(stream);
|
||||
auto walkerCount = hwParse.getCommandCount<WALKER_TYPE>();
|
||||
EXPECT_EQ(2u, walkerCount);
|
||||
}
|
||||
}
|
|
@ -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, 0);
|
||||
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *pSrcSVM = context.getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
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, 0);
|
||||
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *pSrcSVM = context.getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
void *pDstSVM = context.getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
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, 0);
|
||||
void *pSVM = context.getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
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, 0);
|
||||
void *pSVM = context.getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
const float pattern[1] = {1.2345f};
|
||||
size_t zeroSize = 0;
|
||||
mockCmdQ->enqueueSVMMemFill(pSVM, &pattern, sizeof(pattern), zeroSize, 0, nullptr, &event);
|
||||
|
|
|
@ -662,7 +662,7 @@ TEST_P(PerformanceHintEnqueueMapTest, GivenZeroCopyFlagWhenEnqueueUnmapIsCalling
|
|||
|
||||
TEST_F(PerformanceHintEnqueueTest, GivenSVMPointerWhenEnqueueSVMMapIsCallingThenContextProvidesProperHint) {
|
||||
|
||||
void *svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *svmPtr = context->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
|
||||
pCmdQ->enqueueSVMMap(CL_FALSE, 0, svmPtr, 256, 0, nullptr, nullptr);
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ TEST_F(CloneKernelTest, cloneKernelWithArgImmediate) {
|
|||
}
|
||||
|
||||
TEST_F(CloneKernelTest, cloneKernelWithExecInfo) {
|
||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
ASSERT_NE(nullptr, ptrSVM);
|
||||
|
||||
auto svmData = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
|
||||
|
|
|
@ -261,7 +261,7 @@ TEST_F(BufferSetArgTest, clSetKernelArgBuffer) {
|
|||
}
|
||||
|
||||
TEST_F(BufferSetArgTest, clSetKernelArgSVMPointer) {
|
||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, 0);
|
||||
void *ptrSVM = pContext->getSVMAllocsManager()->createSVMAlloc(256, {});
|
||||
EXPECT_NE(nullptr, ptrSVM);
|
||||
|
||||
auto svmData = pContext->getSVMAllocsManager()->getSVMAlloc(ptrSVM);
|
||||
|
|
|
@ -563,7 +563,7 @@ TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThen
|
|||
TEST_F(RenderCompressedBuffersTests, givenSvmAllocationWhenCreatingBufferThenForceDisableCompression) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
|
||||
auto svmPtr = context->getSVMAllocsManager()->createSVMAlloc(sizeof(uint32_t), 0);
|
||||
auto svmPtr = context->getSVMAllocsManager()->createSVMAlloc(sizeof(uint32_t), {});
|
||||
auto expectedAllocationType = context->getSVMAllocsManager()->getSVMAlloc(svmPtr)->gpuAllocation->getAllocationType();
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_USE_HOST_PTR, sizeof(uint32_t), svmPtr, retVal));
|
||||
EXPECT_EQ(expectedAllocationType, buffer->getGraphicsAllocation()->getAllocationType());
|
||||
|
@ -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, 0);
|
||||
auto ptr = context->getSVMAllocsManager()->createSVMAlloc(64, {});
|
||||
|
||||
auto bufferSvm = Buffer::create(context.get(), CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR, 64, ptr, retVal);
|
||||
EXPECT_NE(nullptr, bufferSvm);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/mocks/mock_execution_environment.h"
|
||||
#include "unit_tests/mocks/mock_memory_manager.h"
|
||||
|
@ -35,14 +36,14 @@ using SVMMemoryAllocatorTest = Test<SVMMemoryAllocatorFixture<false>>;
|
|||
using SVMLocalMemoryAllocatorTest = Test<SVMMemoryAllocatorFixture<true>>;
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenCreateZeroSizedSVMAllocationThenReturnNullptr) {
|
||||
auto ptr = svmManager->createSVMAlloc(0, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(0, {});
|
||||
|
||||
EXPECT_EQ(0u, svmManager->SVMAllocs.getNumAllocs());
|
||||
EXPECT_EQ(ptr, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenSVMAllocationIsFreedThenCannotBeGotAgain) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
auto svmData = svmManager->getSVMAlloc(ptr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
@ -60,7 +61,7 @@ TEST_F(SVMMemoryAllocatorTest, whenSVMAllocationIsFreedThenCannotBeGotAgain) {
|
|||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromReturnedPointerAreaThenReturnSameAllocation) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
auto svmData = svmManager->getSVMAlloc(ptr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
@ -79,7 +80,7 @@ TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromReturnedPointerAreaThenRe
|
|||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromOutsideOfReturnedPointerAreaThenDontReturnThisAllocation) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
auto svmData = svmManager->getSVMAlloc(ptr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
@ -100,7 +101,7 @@ TEST_F(SVMMemoryAllocatorTest, whenGetSVMAllocationFromOutsideOfReturnedPointerA
|
|||
TEST_F(SVMMemoryAllocatorTest, whenCouldNotAllocateInMemoryManagerThenReturnsNullAndDoesNotChangeAllocsMap) {
|
||||
FailMemoryManager failMemoryManager(executionEnvironment);
|
||||
svmManager->memoryManager = &failMemoryManager;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
EXPECT_EQ(0u, svmManager->SVMAllocs.getNumAllocs());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
|
@ -109,7 +110,7 @@ TEST_F(SVMMemoryAllocatorTest, whenCouldNotAllocateInMemoryManagerThenReturnsNul
|
|||
TEST_F(SVMMemoryAllocatorTest, given64kbAllowedWhenAllocatingSvmMemoryThenDontPreferRenderCompression) {
|
||||
MockMemoryManager memoryManager64Kb(true, false, executionEnvironment);
|
||||
svmManager->memoryManager = &memoryManager64Kb;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_FALSE(memoryManager64Kb.preferRenderCompressedFlagPassed);
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
@ -117,36 +118,66 @@ TEST_F(SVMMemoryAllocatorTest, given64kbAllowedWhenAllocatingSvmMemoryThenDontPr
|
|||
TEST_F(SVMMemoryAllocatorTest, given64kbAllowedwhenAllocatingSvmMemoryThenAllocationIsIn64kbPagePool) {
|
||||
MockMemoryManager memoryManager64Kb(true, false, executionEnvironment);
|
||||
svmManager->memoryManager = &memoryManager64Kb;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_EQ(MemoryPool::System64KBPages, svmManager->getSVMAlloc(ptr)->gpuAllocation->getMemoryPool());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, given64kbDisallowedWhenAllocatingSvmMemoryThenAllocationIsIn4kbPagePool) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_EQ(MemoryPool::System4KBPages, svmManager->getSVMAlloc(ptr)->gpuAllocation->getMemoryPool());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenCoherentFlagIsPassedThenAllocationIsCoherent) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, CL_MEM_SVM_FINE_GRAIN_BUFFER);
|
||||
SVMAllocsManager::SvmAllocationProperties svmProperties;
|
||||
svmProperties.coherent = true;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, svmProperties);
|
||||
EXPECT_TRUE(svmManager->getSVMAlloc(ptr)->gpuAllocation->isCoherent());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenReadOnlyFlagIsPresentThenReturnTrue) {
|
||||
EXPECT_TRUE(SVMAllocsManager::memFlagIsReadOnly(CL_MEM_READ_ONLY));
|
||||
EXPECT_TRUE(SVMAllocsManager::memFlagIsReadOnly(CL_MEM_HOST_READ_ONLY));
|
||||
EXPECT_TRUE(SVMAllocsManager::memFlagIsReadOnly(CL_MEM_READ_ONLY));
|
||||
}
|
||||
TEST(SvmAllocationPropertiesTests, givenDifferentMemFlagsWhenGettingSvmAllocationPropertiesThenPropertiesAreCorrectlySet) {
|
||||
SVMAllocsManager::SvmAllocationProperties allocationProperties = MemObjHelper::getSvmAllocationProperties(0);
|
||||
EXPECT_FALSE(allocationProperties.coherent);
|
||||
EXPECT_FALSE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_FALSE(allocationProperties.readOnly);
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenNoReadOnlyFlagIsPresentThenReturnFalse) {
|
||||
EXPECT_FALSE(SVMAllocsManager::memFlagIsReadOnly(CL_MEM_READ_WRITE));
|
||||
EXPECT_FALSE(SVMAllocsManager::memFlagIsReadOnly(CL_MEM_WRITE_ONLY));
|
||||
allocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_SVM_FINE_GRAIN_BUFFER);
|
||||
EXPECT_TRUE(allocationProperties.coherent);
|
||||
EXPECT_FALSE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_FALSE(allocationProperties.readOnly);
|
||||
|
||||
allocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_HOST_READ_ONLY);
|
||||
EXPECT_FALSE(allocationProperties.coherent);
|
||||
EXPECT_TRUE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_FALSE(allocationProperties.readOnly);
|
||||
|
||||
allocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_HOST_NO_ACCESS);
|
||||
EXPECT_FALSE(allocationProperties.coherent);
|
||||
EXPECT_TRUE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_FALSE(allocationProperties.readOnly);
|
||||
|
||||
allocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_READ_ONLY);
|
||||
EXPECT_FALSE(allocationProperties.coherent);
|
||||
EXPECT_FALSE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_TRUE(allocationProperties.readOnly);
|
||||
|
||||
allocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_HOST_READ_ONLY);
|
||||
EXPECT_TRUE(allocationProperties.coherent);
|
||||
EXPECT_TRUE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_FALSE(allocationProperties.readOnly);
|
||||
|
||||
allocationProperties = MemObjHelper::getSvmAllocationProperties(CL_MEM_SVM_FINE_GRAIN_BUFFER | CL_MEM_READ_ONLY);
|
||||
EXPECT_TRUE(allocationProperties.coherent);
|
||||
EXPECT_FALSE(allocationProperties.hostPtrReadOnly);
|
||||
EXPECT_TRUE(allocationProperties.readOnly);
|
||||
}
|
||||
|
||||
TEST_F(SVMMemoryAllocatorTest, whenReadOnlySvmAllocationCreatedThenGraphicsAllocationHasWriteableFlagFalse) {
|
||||
void *svm = svmManager->createSVMAlloc(4096, CL_MEM_READ_ONLY);
|
||||
SVMAllocsManager::SvmAllocationProperties svmProperties;
|
||||
svmProperties.readOnly = true;
|
||||
void *svm = svmManager->createSVMAlloc(4096, svmProperties);
|
||||
EXPECT_NE(nullptr, svm);
|
||||
|
||||
auto svmData = svmManager->getSVMAlloc(svm);
|
||||
|
@ -159,7 +190,7 @@ TEST_F(SVMMemoryAllocatorTest, whenReadOnlySvmAllocationCreatedThenGraphicsAlloc
|
|||
}
|
||||
|
||||
TEST_F(SVMLocalMemoryAllocatorTest, whenAllocatingSvmThenExpectCpuAllocationWithPointerAndGpuAllocationWithSameGpuAddress) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
auto svmData = svmManager->getSVMAlloc(ptr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
@ -175,7 +206,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenAllocatingSvmThenExpectCpuAllocationWith
|
|||
}
|
||||
|
||||
TEST_F(SVMLocalMemoryAllocatorTest, whenGetSVMAllocationFromOutsideOfReturnedPointerAreaThenDontReturnThisAllocation) {
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
auto svmData = svmManager->getSVMAlloc(ptr);
|
||||
ASSERT_NE(nullptr, svmData);
|
||||
|
@ -196,7 +227,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenGetSVMAllocationFromOutsideOfReturnedPoi
|
|||
TEST_F(SVMLocalMemoryAllocatorTest, whenCouldNotAllocateCpuAllocationInMemoryManagerThenReturnsNullAndDoesNotChangeAllocsMap) {
|
||||
FailMemoryManager failMemoryManager(false, true, executionEnvironment);
|
||||
svmManager->memoryManager = &failMemoryManager;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
EXPECT_EQ(0u, svmManager->SVMAllocs.getNumAllocs());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
|
@ -205,7 +236,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenCouldNotAllocateCpuAllocationInMemoryMan
|
|||
TEST_F(SVMLocalMemoryAllocatorTest, whenCouldNotAllocateGpuAllocationInMemoryManagerThenReturnsNullAndDoesNotChangeAllocsMap) {
|
||||
FailMemoryManager failMemoryManager(1, executionEnvironment, true);
|
||||
svmManager->memoryManager = &failMemoryManager;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
EXPECT_EQ(0u, svmManager->SVMAllocs.getNumAllocs());
|
||||
svmManager->freeSVMAlloc(ptr);
|
||||
|
@ -213,7 +244,7 @@ TEST_F(SVMLocalMemoryAllocatorTest, whenCouldNotAllocateGpuAllocationInMemoryMan
|
|||
|
||||
TEST_F(SVMLocalMemoryAllocatorTest, whenCouldNotReserveCpuAddressRangeInMemoryManagerThenReturnsNullAndDoesNotChangeAllocsMap) {
|
||||
memoryManager->failReserveAddress = true;
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, 0);
|
||||
auto ptr = svmManager->createSVMAlloc(MemoryConstants::pageSize, {});
|
||||
EXPECT_EQ(nullptr, ptr);
|
||||
EXPECT_EQ(0u, svmManager->SVMAllocs.getNumAllocs());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue