Correct image initialization for linear storage allocations 2/2

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2021-02-01 14:27:48 +00:00
committed by Compute-Runtime-Automation
parent 580fdd757c
commit 5618d4dfa4
6 changed files with 20 additions and 20 deletions

View File

@ -436,22 +436,18 @@ Image *Image::create(Context *context,
hostPtr, allocationInfo[rootDeviceIndex].mapAllocation, 0, nullptr, nullptr);
}
} else {
void *pDestinationAddress = allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer();
auto isNotInSystemMemory = !MemoryPool::isSystemMemoryPool(allocationInfo[rootDeviceIndex].memory->getMemoryPool());
auto &allocations = image->getMultiGraphicsAllocation().getGraphicsAllocations();
if (isNotInSystemMemory) {
for (auto &pAllocation : allocations) {
context->getMemoryManager()->lockResource(pAllocation);
}
pDestinationAddress = context->getMemoryManager()->lockResource(allocationInfo[rootDeviceIndex].memory);
}
image->transferData(allocationInfo[rootDeviceIndex].memory->getUnderlyingBuffer(), imgInfo.rowPitch, imgInfo.slicePitch,
image->transferData(pDestinationAddress, imgInfo.rowPitch, imgInfo.slicePitch,
const_cast<void *>(hostPtr), hostPtrRowPitch, hostPtrSlicePitch,
copyRegion, copyOrigin);
if (isNotInSystemMemory) {
for (auto &pAllocation : allocations) {
context->getMemoryManager()->unlockResource(pAllocation);
}
context->getMemoryManager()->unlockResource(allocationInfo[rootDeviceIndex].memory);
}
}
}

View File

@ -219,7 +219,7 @@ class Image : public MemObj {
void getOsSpecificImageInfo(const cl_mem_info &paramName, size_t *srcParamSize, void **srcParam);
void transferData(void *dst, size_t dstRowPitch, size_t dstSlicePitch,
MOCKABLE_VIRTUAL void transferData(void *dst, size_t dstRowPitch, size_t dstSlicePitch,
void *src, size_t srcRowPitch, size_t srcSlicePitch,
std::array<size_t, 3> copyRegion, std::array<size_t, 3> copyOrigin);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -41,8 +41,9 @@ struct MultipleMapImageTest : public ClDeviceFixture, public ::testing::Test {
const ClSurfaceFormatInfo *surfaceFormatInfo,
const SurfaceOffsets *surfaceOffsets) {
auto memoryStorage = multiGraphicsAllocation.getDefaultGraphicsAllocation()->getUnderlyingBuffer();
return new MockImage<T>(context, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, imageFormat, imageDesc, zeroCopy, multiGraphicsAllocation,
isObjectRedescribed, baseMipLevel, mipCount, *surfaceFormatInfo, surfaceOffsets);
return new MockImage<T>(context, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, imageFormat, imageDesc,
zeroCopy, std::move(multiGraphicsAllocation), isObjectRedescribed, baseMipLevel, mipCount,
*surfaceFormatInfo, surfaceOffsets);
};
void transferDataToHostPtr(MemObjSizeArray &copySize, MemObjOffsetArray &copyOffset) override {

View File

@ -83,7 +83,9 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
void *lockResourceImpl(GraphicsAllocation &gfxAllocation) override {
lockResourceCalled++;
return OsAgnosticMemoryManager::lockResourceImpl(gfxAllocation);
auto pLockedMemory = OsAgnosticMemoryManager::lockResourceImpl(gfxAllocation);
lockResourcePointers.push_back(pLockedMemory);
return pLockedMemory;
}
void unlockResourceImpl(GraphicsAllocation &gfxAllocation) override {
@ -121,6 +123,7 @@ class MockMemoryManager : public MemoryManagerCreate<OsAgnosticMemoryManager> {
uint32_t freeGraphicsMemoryCalled = 0u;
uint32_t unlockResourceCalled = 0u;
uint32_t lockResourceCalled = 0u;
std::vector<void *> lockResourcePointers;
uint32_t handleFenceCompletionCalled = 0u;
uint32_t waitForEnginesCompletionCalled = 0u;
bool allocationCreated = false;

View File

@ -495,6 +495,11 @@ bool HwHelperHw<GfxFamily>::useSystemMemoryPlacementForISA(const HardwareInfo &h
return !getEnableLocalMemory(hwInfo);
}
template <typename GfxFamily>
bool HwHelperHw<GfxFamily>::isCpuImageTransferPreferred(const HardwareInfo &hwInfo) const {
return false;
}
template <typename GfxFamily>
bool MemorySynchronizationCommands<GfxFamily>::isPipeControlPriorToPipelineSelectWArequired(const HardwareInfo &hwInfo) {
return false;

View File

@ -98,11 +98,6 @@ uint64_t HwHelperHw<GfxFamily>::getGpuTimeStampInNS(uint64_t timeStamp, double f
return static_cast<uint64_t>(timeStamp * frequency);
}
template <typename GfxFamily>
bool HwHelperHw<GfxFamily>::isCpuImageTransferPreferred(const HardwareInfo &hwInfo) const {
return false;
}
template <typename GfxFamily>
inline void MemorySynchronizationCommands<GfxFamily>::addPipeControlWA(LinearStream &commandStream, uint64_t gpuAddress, const HardwareInfo &hwInfo) {
}