refactor: remove unused isSharedContext variable

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2023-07-25 14:44:02 +02:00
committed by Compute-Runtime-Automation
parent ea7d9fe106
commit f84f22d23c
29 changed files with 38 additions and 308 deletions

View File

@@ -21,7 +21,6 @@ struct _cl_command_queue : public ClDispatch {
};
struct _cl_context : public ClDispatch {
bool isSharedContext = false;
};
struct _cl_device_id : public ClDispatch {

View File

@@ -340,7 +340,7 @@ Buffer *Buffer::create(Context *context,
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*hwInfo), memoryProperties, *context,
gfxCoreHelper.isBufferSizeSuitableForCompression(size));
allocationInfo.allocationType = getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, *context, compressionEnabled,
allocationInfo.allocationType = getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled,
memoryManager->isLocalMemorySupported(rootDeviceIndex));
if (allocationCpuPtr) {
@@ -391,12 +391,6 @@ Buffer *Buffer::create(Context *context,
}
}
if (context->isSharedContext) {
allocationInfo.zeroCopyAllowed = true;
allocationInfo.copyMemoryFromHostPtr = false;
allocationInfo.allocateMemory = false;
}
if (!bufferCreateArgs.doNotProvidePerformanceHints && hostPtr && context->isProvidingPerformanceHints()) {
if (allocationInfo.zeroCopyAllowed) {
context->providePerformanceHint(CL_CONTEXT_DIAGNOSTICS_LEVEL_GOOD_INTEL, CL_BUFFER_MEETS_ALIGNMENT_RESTRICTIONS, hostPtr, size);
@@ -630,9 +624,9 @@ void Buffer::checkMemory(const MemoryProperties &memoryProperties,
}
}
AllocationType Buffer::getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties, Context &context,
AllocationType Buffer::getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties,
bool &compressionEnabled, bool isLocalMemoryEnabled) {
if (context.isSharedContext || properties.flags.forceHostMemory) {
if (properties.flags.forceHostMemory) {
compressionEnabled = false;
return AllocationType::BUFFER_HOST_MEMORY;
}

View File

@@ -208,7 +208,7 @@ class Buffer : public MemObj {
MemoryManager *memMngr,
uint32_t rootDeviceIndex,
bool forceCopyHostPtr);
static AllocationType getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties, Context &context,
static AllocationType getGraphicsAllocationTypeAndCompressionPreference(const MemoryProperties &properties,
bool &compressionEnabled, bool localMemoryEnabled);
static bool isReadOnlyMemoryPermittedByFlags(const MemoryProperties &properties);

View File

@@ -173,7 +173,7 @@ Image *Image::create(Context *context,
const auto hostPtrSlicePitch = getHostPtrSlicePitch(*imageDesc, hostPtrRowPitch, imageHeight);
auto &defaultProductHelper = defaultDevice->getProductHelper();
imgInfo.linearStorage = defaultProductHelper.isLinearStoragePreferred(context->isSharedContext, Image::isImage1d(*imageDesc),
imgInfo.linearStorage = defaultProductHelper.isLinearStoragePreferred(Image::isImage1d(*imageDesc),
memoryProperties.flags.forceLinearStorage);
// if device doesn't support images, it can create only linear images
@@ -223,10 +223,6 @@ Image *Image::create(Context *context,
// Image from parent image - reuse allocation from parent image
allocationInfo.memory = parentImage->getGraphicsAllocation(rootDeviceIndex);
allocationInfo.memory->getDefaultGmm()->queryImageParams(imgInfo);
} else if (memoryProperties.flags.useHostPtr && context->isSharedContext) {
// create graphics allocation from shared context
setAllocationInfoFromHostPtrWithSharedContext(allocationInfo, rootDeviceIndex, imgInfo, context,
preferCompression, memoryManager, hostPtr);
} else if (memoryProperties.flags.useHostPtr) {
// create graphics allocation from shared context
setAllocationInfoFromHostPtr(allocationInfo, rootDeviceIndex, hwInfo, memoryProperties, imgInfo, context,
@@ -1176,24 +1172,6 @@ void Image::setAllocationInfoFromParentBuffer(CreateMemObj::AllocationInfo &allo
imageInfo.offset = parentBuffer->getOffset();
}
void Image::setAllocationInfoFromHostPtrWithSharedContext(CreateMemObj::AllocationInfo &allocationInfo, uint32_t rootDeviceIndex, ImageInfo &imageInfo,
Context *context, bool preferCompression, MemoryManager *memoryManager, const void *hostPtr) {
auto &rootDeviceEnvironment = *memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex];
auto gmmHelper = rootDeviceEnvironment.getGmmHelper();
auto gmm = new Gmm(gmmHelper, imageInfo, StorageInfo{}, preferCompression);
AllocationProperties properties{rootDeviceIndex,
false, // allocateMemory
imageInfo.size, AllocationType::SHARED_CONTEXT_IMAGE,
false, // isMultiStorageAllocation
context->getDeviceBitfieldForAllocation(rootDeviceIndex)};
allocationInfo.memory = memoryManager->allocateGraphicsMemoryWithProperties(properties, hostPtr);
allocationInfo.memory->setDefaultGmm(gmm);
allocationInfo.zeroCopyAllowed = true;
}
void Image::setAllocationInfoFromHostPtr(CreateMemObj::AllocationInfo &allocationInfo, uint32_t rootDeviceIndex, const HardwareInfo &hwInfo,
const MemoryProperties &memoryProperties, ImageInfo &imageInfo, Context *context, bool preferCompression,
MemoryManager *memoryManager, const void *hostPtr, size_t hostPtrMinSize) {

View File

@@ -272,9 +272,6 @@ class Image : public MemObj {
static void setAllocationInfoFromParentBuffer(CreateMemObj::AllocationInfo &allocationInfo, const void *&hostPtr, void *&hostPtrToSet,
Buffer *parentBuffer, ImageInfo &imageInfo, uint32_t rootDeviceIndex);
static void setAllocationInfoFromHostPtrWithSharedContext(CreateMemObj::AllocationInfo &allocationInfo, uint32_t rootDeviceIndex, ImageInfo &imageInfo,
Context *context, bool preferCompression, MemoryManager *memoryManager, const void *hostPtr);
static void setAllocationInfoFromHostPtr(CreateMemObj::AllocationInfo &allocationInfo, uint32_t rootDeviceIndex, const HardwareInfo &hwInfo,
const MemoryProperties &memoryProperties, ImageInfo &imageInfo, Context *context, bool preferCompression,
MemoryManager *memoryManager, const void *hostPtr, size_t hostPtrMinSize);

View File

@@ -87,7 +87,7 @@ HWTEST_F(AUBCreateImageArray, Given1DImageArrayThenExpectationsMet) {
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto imageDescriptor = Image::convertDescriptor(imageDesc);
auto imgInfo = MockGmm::initImgInfo(imageDescriptor, 0, &surfaceFormat->surfaceFormat);
imgInfo.linearStorage = productHelper.isLinearStoragePreferred(false, Image::isImage1d(imageDesc), false);
imgInfo.linearStorage = productHelper.isLinearStoragePreferred(Image::isImage1d(imageDesc), false);
auto queryGmm = MockGmm::queryImgParams(pDevice->getGmmHelper(), imgInfo, false);
// allocate host_ptr
@@ -166,7 +166,7 @@ HWTEST_F(AUBCreateImageArray, Given2DImageArrayThenExpectationsMet) {
auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto imageDescriptor = Image::convertDescriptor(imageDesc);
auto imgInfo = MockGmm::initImgInfo(imageDescriptor, 0, &surfaceFormat->surfaceFormat);
imgInfo.linearStorage = productHelper.isLinearStoragePreferred(false, Image::isImage1d(imageDesc), false);
imgInfo.linearStorage = productHelper.isLinearStoragePreferred(Image::isImage1d(imageDesc), false);
auto queryGmm = MockGmm::queryImgParams(pDevice->getGmmHelper(), imgInfo, false);
// allocate host_ptr

View File

@@ -1916,9 +1916,9 @@ TEST_F(VmeBuiltInTests, WhenValidatingImagesThenCorrectResponses) {
{ // validate image tiling
std::unique_ptr<Image> imageValid(ImageHelper<ImageVmeValidFormat>::create(pContext));
pContext->isSharedContext = true;
DebugManagerStateRestore restorer;
DebugManager.flags.ForceLinearImages.set(true);
std::unique_ptr<Image> imageLinear(ImageHelper<ImageVmeValidFormat>::create(pContext));
pContext->isSharedContext = false;
Image *images[] = {imageValid.get(), imageLinear.get()};
for (Image *srcImg : images) {
for (Image *dstImg : images) {

View File

@@ -833,35 +833,6 @@ HWTEST_F(EnqueueReadImageTest, GivenImage1DArrayAndImageShareTheSameStorageWithH
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadImageTest, GivenSharedContextZeroCopy2DImageWhenEnqueueReadImageWithMappedPointerIsCalledThenImageIsNotRead) {
cl_int retVal = CL_SUCCESS;
context->isSharedContext = true;
std::unique_ptr<Image> dstImage(ImageHelper<ImageUseHostPtr<Image2dDefaults>>::create(context));
EXPECT_TRUE(dstImage->isMemObjZeroCopy());
auto &imageDesc = dstImage->getImageDesc();
size_t origin[] = {0, 0, 0};
size_t region[] = {imageDesc.image_width, imageDesc.image_height, 1};
void *ptr = dstImage->getCpuAddressForMemoryTransfer();
size_t rowPitch = dstImage->getHostPtrRowPitch();
size_t slicePitch = dstImage->getHostPtrSlicePitch();
retVal = pCmdQ->enqueueReadImage(dstImage.get(),
CL_FALSE,
origin,
region,
rowPitch,
slicePitch,
ptr,
nullptr,
0,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueReadImageTest, GivenImage1DThatIsZeroCopyWhenReadImageWithTheSamePointerAndOutputEventIsPassedThenEventHasCorrectCommandTypeSet) {
cl_int retVal = CL_SUCCESS;
std::unique_ptr<Image> dstImage(Image1dHelper<>::create(context));

View File

@@ -363,36 +363,6 @@ HWTEST_F(EnqueueWriteImageTest, GivenImage1DArrayAndImageShareTheSameStorageWith
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteImageTest, GivenSharedContextZeroCopy2DImageWhenEnqueueWriteImageWithMappedPointerIsCalledThenImageIsNotWritten) {
cl_int retVal = CL_SUCCESS;
context->isSharedContext = true;
std::unique_ptr<Image> dstImage(ImageHelper<ImageUseHostPtr<Image2dDefaults>>::create(context));
EXPECT_TRUE(dstImage->isMemObjZeroCopy());
auto &imageDesc = dstImage->getImageDesc();
size_t origin[] = {0, 0, 0};
size_t region[] = {imageDesc.image_width, imageDesc.image_height, 1};
void *ptr = dstImage->getCpuAddressForMemoryTransfer();
size_t rowPitch = dstImage->getHostPtrRowPitch();
size_t slicePitch = dstImage->getHostPtrSlicePitch();
retVal = pCmdQ->enqueueReadImage(dstImage.get(),
CL_FALSE,
origin,
region,
rowPitch,
slicePitch,
ptr,
nullptr,
0,
nullptr,
nullptr);
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_EQ(pCmdQ->taskLevel, 0u);
}
HWTEST_F(EnqueueWriteImageTest, GivenImage1DThatIsZeroCopyWhenWriteImageWithTheSamePointerAndOutputEventIsPassedThenEventHasCorrectCommandTypeSet) {
cl_int retVal = CL_SUCCESS;
std::unique_ptr<Image> srcImage(Image1dHelper<>::create(context));

View File

@@ -692,7 +692,6 @@ HWTEST2_F(PerformanceHintTest, given64bitCompressedBufferWhenItsCreatedThenPrope
cl_context_properties validProperties[3] = {CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL, CL_CONTEXT_DIAGNOSTICS_LEVEL_ALL_INTEL, 0};
auto context = std::unique_ptr<MockContext>(Context::create<NEO::MockContext>(validProperties, ClDeviceVector(&deviceId, 1), callbackFunction, static_cast<void *>(userData), retVal));
context->isSharedContext = false;
auto buffer = std::unique_ptr<Buffer>(
Buffer::create(context.get(), ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context->getDevice(0)->getDevice()),
0, 0, size, static_cast<void *>(NULL), retVal));
@@ -734,7 +733,7 @@ TEST_F(PerformanceHintTest, givenUncompressedBufferWhenItsCreatedThenProperPerfo
GfxCoreHelper::compressedBuffersSupported(hwInfo),
memoryProperties, *context,
gfxCoreHelper.isBufferSizeSuitableForCompression(size)) &&
!is32bit && !context->isSharedContext &&
!is32bit &&
(!memoryProperties.flags.useHostPtr || context->getMemoryManager()->isLocalMemorySupported(device->getRootDeviceIndex())) &&
!memoryProperties.flags.forceHostMemory;

View File

@@ -226,18 +226,6 @@ TYPED_TEST(BaseObjectTests, WhenCastingToDispatchTableThenEntriesAreCorrect) {
EXPECT_EQ(nullptr, genericObject->dispatch.crtDispatch->placeholder21);
}
TEST(BaseObjectTests, WhenSettingSharedContextFlagThenItIsSetCorrectly) {
MockContext newContext;
// cast to cl_context
cl_context clContext = &newContext;
EXPECT_FALSE(newContext.isSharedContext);
clContext->isSharedContext = true;
EXPECT_TRUE(newContext.isSharedContext);
}
TYPED_TEST(BaseObjectTests, WhenTakingAndReleasingOwnershipThenOwnershipCountIsUpdated) {
TypeParam obj;
EXPECT_FALSE(obj.hasOwnership());

View File

@@ -90,22 +90,20 @@ HWTEST_F(GfxCoreHelperTest, givenGfxCoreHelperWhenIsLinearStoragePreferredThenRe
bool allowedType = imgTypes[i] == (CL_MEM_OBJECT_IMAGE2D) || (imgTypes[i] == CL_MEM_OBJECT_IMAGE3D) ||
(imgTypes[i] == CL_MEM_OBJECT_IMAGE2D_ARRAY);
// non shared context, dont force linear storage
EXPECT_EQ((tilingSupported & allowedType), !productHelper.isLinearStoragePreferred(false, Image::isImage1d(imgDesc), false));
// dont force linear storage
EXPECT_EQ((tilingSupported & allowedType), !productHelper.isLinearStoragePreferred(Image::isImage1d(imgDesc), false));
{
DebugManagerStateRestore restore;
DebugManager.flags.ForceLinearImages.set(true);
// non shared context, dont force linear storage + debug flag
EXPECT_TRUE(productHelper.isLinearStoragePreferred(false, Image::isImage1d(imgDesc), false));
// dont force linear storage + debug flag
EXPECT_TRUE(productHelper.isLinearStoragePreferred(Image::isImage1d(imgDesc), false));
}
// shared context, dont force linear storage
EXPECT_TRUE(productHelper.isLinearStoragePreferred(true, Image::isImage1d(imgDesc), false));
// non shared context, force linear storage
EXPECT_TRUE(productHelper.isLinearStoragePreferred(false, Image::isImage1d(imgDesc), true));
// force linear storage
EXPECT_TRUE(productHelper.isLinearStoragePreferred(Image::isImage1d(imgDesc), true));
// non shared context, dont force linear storage + create from buffer
// dont force linear storage + create from buffer
imgDesc.buffer = buffer.get();
EXPECT_TRUE(productHelper.isLinearStoragePreferred(false, Image::isImage1d(imgDesc), false));
EXPECT_TRUE(productHelper.isLinearStoragePreferred(Image::isImage1d(imgDesc), false));
}
}
@@ -158,4 +156,4 @@ HWCMDTEST_F(IGFX_GEN8_CORE, ClGfxCoreHelperTest, givenCLImageFormatsWhenCallingI
}
EXPECT_EQ(expectedResult, clGfxCoreHelper.isFormatRedescribable(oclFormat));
}
}
}

View File

@@ -423,12 +423,11 @@ TEST(Buffer, givenCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferC
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
@@ -437,55 +436,25 @@ TEST(Buffer, givenCompressedBuffersDisabledLocalMemoryEnabledWhenAllocationTypeI
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
TEST(Buffer, givenSharedContextWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = true;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenSharedContextAndCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = true;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, type);
}
TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, type);
}
@@ -495,12 +464,11 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledWhenAllocationTypeIsQueried
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
@@ -510,12 +478,11 @@ TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferTypeIsRet
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
@@ -525,12 +492,11 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryDisabledAndCompressedBuffersEnable
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, type);
}
@@ -540,12 +506,11 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndCompressedBuffersEnabled
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
@@ -555,12 +520,11 @@ TEST(Buffer, givenUseHostPointerFlagAndForceSharedPhysicalStorageWhenLocalMemory
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, true);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, true);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER_HOST_MEMORY, type);
}
@@ -570,12 +534,11 @@ TEST(Buffer, givenAllocHostPtrFlagAndCompressedBuffersEnabledWhenAllocationTypeI
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(true, memoryProperties, context, true);
EXPECT_TRUE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_TRUE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
@@ -584,12 +547,11 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndCompressedBuffersDisabledWhenAlloca
MockContext context;
MemoryProperties memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice());
context.contextType = ContextType::CONTEXT_TYPE_UNRESTRICTIVE;
context.isSharedContext = false;
bool compressionEnabled = MemObjHelper::isSuitableForCompression(false, memoryProperties, context, true);
EXPECT_FALSE(compressionEnabled);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, context, compressionEnabled, false);
auto type = MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(memoryProperties, compressionEnabled, false);
EXPECT_FALSE(compressionEnabled);
EXPECT_EQ(AllocationType::BUFFER, type);
}
@@ -756,27 +718,6 @@ TEST_F(CompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhe
}
}
TEST_F(CompressedBuffersTests, givenBufferCompressedAllocationWhenSharedContextIsUsedThenForceDisableCompression) {
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
context->isSharedContext = false;
auto memoryManager = static_cast<MockMemoryManager *>(device->getExecutionEnvironment()->memoryManager.get());
buffer.reset(Buffer::create(context.get(), CL_MEM_READ_WRITE, bufferSize, nullptr, retVal));
auto graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
auto &gfxCoreHelper = context->getDevice(0)->getGfxCoreHelper();
if (gfxCoreHelper.isBufferSizeSuitableForCompression(bufferSize)) {
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::BUFFER);
EXPECT_EQ(!memoryManager->allocate32BitGraphicsMemoryImplCalled, graphicsAllocation->isCompressionEnabled());
} else {
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::BUFFER_HOST_MEMORY);
}
context->isSharedContext = true;
buffer.reset(Buffer::create(context.get(), CL_MEM_USE_HOST_PTR, bufferSize, hostPtr, retVal));
graphicsAllocation = buffer->getGraphicsAllocation(context->getDevice(0)->getRootDeviceIndex());
EXPECT_EQ(graphicsAllocation->getAllocationType(), AllocationType::BUFFER_HOST_MEMORY);
}
TEST_F(CompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThenSelectOptionFromDebugFlag) {
DebugManagerStateRestore restore;

View File

@@ -505,59 +505,6 @@ TEST(TestSliceAndRowPitch, Given2dArrayWithNonZeroRowPitchAndNonZeroSlicePitchGr
alignedFree(hostPtr);
}
TEST(TestCreateImage, GivenSharedContextWhenImageIsCreatedThenRowAndSliceAreCorrect) {
cl_image_format imageFormat;
cl_image_desc imageDesc;
cl_int retVal;
MockContext context;
context.isSharedContext = true;
const size_t width = 5;
const size_t height = 3;
const size_t depth = 2;
char *hostPtr = (char *)alignedMalloc(width * height * depth * elementSize * 2, 64);
imageFormat.image_channel_data_type = channelType;
imageFormat.image_channel_order = channelOrder;
imageDesc.num_mip_levels = 0;
imageDesc.num_samples = 0;
imageDesc.mem_object = NULL;
// 2D image with non-zero row_pitch and 0 slice_pitch
imageDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imageDesc.image_width = width;
imageDesc.image_height = height;
imageDesc.image_depth = 0;
imageDesc.image_array_size = 0;
imageDesc.image_row_pitch = (width + 1) * elementSize;
imageDesc.image_slice_pitch = 0;
cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR;
auto surfaceFormat = Image::getSurfaceFormatFromTable(
flags, &imageFormat, context.getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto image = Image::create(
&context,
ClMemoryPropertiesHelper::createMemoryProperties(flags, 0, 0, &context.getDevice(0)->getDevice()),
flags,
0,
surfaceFormat,
&imageDesc,
hostPtr,
retVal);
ASSERT_NE(nullptr, image);
EXPECT_EQ((width + 1) * elementSize, image->getHostPtrRowPitch());
EXPECT_EQ(0u, image->getHostPtrSlicePitch());
EXPECT_TRUE(image->isMemObjZeroCopy());
delete image;
alignedFree(hostPtr);
}
TEST(TestCreateImageUseHostPtr, GivenDifferenHostPtrAlignmentsWhenCheckingMemoryALignmentThenCorrectValueIsReturned) {
KernelBinaryHelper kbHelper(KernelBinaryHelper::BUILT_INS_WITH_IMAGES);

View File

@@ -394,7 +394,7 @@ TEST(MemObjHelper, givenDifferentCapabilityAndDebugFlagValuesWhenCheckingBufferC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true);
MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(
memoryProperties, context, compressionEnabled, false);
memoryProperties, compressionEnabled, false);
bool expectBufferCompressed = ftrRenderCompressedBuffers && (enableMultiTileCompressionValue == 1);
if (expectBufferCompressed && clGfxCoreHelper.allowCompressionForContext(*context.getDevice(0), context)) {
@@ -448,7 +448,7 @@ TEST(MemObjHelper, givenDifferentValuesWhenCheckingBufferCompressionSupportThenC
bool compressionEnabled = MemObjHelper::isSuitableForCompression(GfxCoreHelper::compressedBuffersSupported(*defaultHwInfo), memoryProperties, context, true);
MockPublicAccessBuffer::getGraphicsAllocationTypeAndCompressionPreference(
memoryProperties, context, compressionEnabled, false);
memoryProperties, compressionEnabled, false);
bool isCompressionDisabled = isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) ||
isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL);

View File

@@ -103,38 +103,6 @@ INSTANTIATE_TEST_CASE_P(
ZeroCopyBufferTest,
testing::ValuesIn(Inputs));
TEST(ZeroCopyBufferTestWithSharedContext, GivenContextThatIsSharedWhenAskedForBufferCreationThenAlwaysResultsInZeroCopy) {
MockContext context;
auto hostPtr = reinterpret_cast<void *>(0x1001);
auto size = 64;
auto retVal = CL_SUCCESS;
context.isSharedContext = true;
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_USE_HOST_PTR, size, hostPtr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(buffer->isMemObjZeroCopy()) << "Zero Copy not handled properly";
if (buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->is32BitAllocation() == false) {
EXPECT_EQ(hostPtr, buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getUnderlyingBuffer());
}
}
TEST(ZeroCopyBufferTestWithSharedContext, GivenContextThatIsSharedAndDisableZeroCopyFlagWhenAskedForBufferCreationThenAlwaysResultsInZeroCopy) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.DisableZeroCopyForUseHostPtr.set(true);
MockContext context;
auto hostPtr = reinterpret_cast<void *>(0x1001);
auto size = 64;
auto retVal = CL_SUCCESS;
context.isSharedContext = true;
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_USE_HOST_PTR, size, hostPtr, retVal));
EXPECT_EQ(CL_SUCCESS, retVal);
EXPECT_TRUE(buffer->isMemObjZeroCopy());
}
TEST(ZeroCopyWithDebugFlag, GivenInputsThatWouldResultInZeroCopyAndUseHostptrDisableZeroCopyFlagWhenBufferIsCreatedThenNonZeroCopyBufferIsReturned) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.DisableZeroCopyForUseHostPtr.set(true);

View File

@@ -344,7 +344,7 @@ TEST(ClMemoryManagerTest, givenForcedLinearImages3DImageAndProperDescriptorValue
imgInfo.rowPitch = imageDesc.image_width * surfaceFormat->surfaceFormat.imageElementSizeInBytes;
imgInfo.slicePitch = imgInfo.rowPitch * imageDesc.image_height;
imgInfo.size = imgInfo.slicePitch;
imgInfo.linearStorage = productHelper.isLinearStoragePreferred(false, Image::isImage1d(Image::convertDescriptor(imgInfo.imgDesc)), false);
imgInfo.linearStorage = productHelper.isLinearStoragePreferred(Image::isImage1d(Image::convertDescriptor(imgInfo.imgDesc)), false);
auto hostPtr = alignedMalloc(imgInfo.size, MemoryConstants::cacheLineSize);