mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Pass root device index to Buffer::setArgStateful
Related-To: NEO-4672 Change-Id: Ic846eac488809bd7d9534bb7378d9398acd36451 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
28aa29bcbd
commit
c96fd30e4c
@@ -139,7 +139,7 @@ void gtpinNotifyKernelSubmit(cl_kernel kernel, void *pCmdQueue) {
|
||||
void *pSurfaceState = gtpinHelper.getSurfaceState(pKernel, gtpinBTI);
|
||||
cl_mem buffer = (cl_mem)resource;
|
||||
auto pBuffer = castToObjectOrAbort<Buffer>(buffer);
|
||||
pBuffer->setArgStateful(pSurfaceState, false, false, false, false);
|
||||
pBuffer->setArgStateful(pSurfaceState, false, false, false, false, device.getRootDeviceIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1316,7 +1316,7 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex,
|
||||
|
||||
if (requiresSshForBuffers()) {
|
||||
auto surfaceState = ptrOffset(getSurfaceStateHeap(), kernelArgInfo.offsetHeap);
|
||||
buffer->setArgStateful(surfaceState, forceNonAuxMode, disableL3, isAuxTranslationKernel, kernelArgInfo.isReadOnly);
|
||||
buffer->setArgStateful(surfaceState, forceNonAuxMode, disableL3, isAuxTranslationKernel, kernelArgInfo.isReadOnly, getDevice().getRootDeviceIndex());
|
||||
}
|
||||
|
||||
kernelArguments[argIndex].isStatelessUncacheable = kernelArgInfo.pureStatefulBufferAccess ? false : buffer->isMemObjUncacheable();
|
||||
|
||||
@@ -626,16 +626,21 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device,
|
||||
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, device);
|
||||
auto pBuffer = funcCreate(nullptr, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation,
|
||||
zeroCopy, isHostPtrSVM, isImageRedescribed);
|
||||
|
||||
if (!gfxAllocation) {
|
||||
auto multiGraphicsAllocation = MultiGraphicsAllocation(device->getRootDeviceIndex());
|
||||
std::swap(pBuffer->multiGraphicsAllocation, multiGraphicsAllocation);
|
||||
}
|
||||
pBuffer->offset = offset;
|
||||
pBuffer->executionEnvironment = device->getExecutionEnvironment();
|
||||
pBuffer->rootDeviceEnvironment = pBuffer->executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get();
|
||||
return pBuffer;
|
||||
}
|
||||
|
||||
uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument) const {
|
||||
uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument, uint32_t rootDeviceIndex) const {
|
||||
uint64_t bufferAddress = 0;
|
||||
size_t bufferSize = 0;
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getDefaultGraphicsAllocation();
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
|
||||
if (graphicsAllocation) {
|
||||
bufferAddress = graphicsAllocation->getGpuAddress();
|
||||
bufferSize = graphicsAllocation->getUnderlyingBufferSize();
|
||||
@@ -657,8 +662,8 @@ uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument) cons
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Buffer::getSurfaceSize(bool alignSizeForAuxTranslation) const {
|
||||
auto bufferAddress = getBufferAddress();
|
||||
uint32_t Buffer::getSurfaceSize(bool alignSizeForAuxTranslation, uint32_t rootDeviceIndex) const {
|
||||
auto bufferAddress = getBufferAddress(rootDeviceIndex);
|
||||
auto bufferAddressAligned = alignDown(bufferAddress, 4);
|
||||
auto bufferOffset = ptrDiff(bufferAddress, bufferAddressAligned);
|
||||
|
||||
@@ -666,9 +671,9 @@ uint32_t Buffer::getSurfaceSize(bool alignSizeForAuxTranslation) const {
|
||||
return surfaceSize;
|
||||
}
|
||||
|
||||
uint64_t Buffer::getBufferAddress() const {
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getDefaultGraphicsAllocation();
|
||||
uint64_t Buffer::getBufferAddress(uint32_t rootDeviceIndex) const {
|
||||
// The graphics allocation for Host Ptr surface will be created in makeResident call and GPU address is expected to be the same as CPU address
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
|
||||
auto bufferAddress = (graphicsAllocation != nullptr) ? graphicsAllocation->getGpuAddress() : castToUint64(getHostPtr());
|
||||
bufferAddress += this->offset;
|
||||
return bufferAddress;
|
||||
@@ -695,7 +700,7 @@ void Buffer::setSurfaceState(const Device *device,
|
||||
cl_mem_flags flags,
|
||||
cl_mem_flags_intel flagsIntel) {
|
||||
auto buffer = Buffer::createBufferHwFromDevice(device, flags, flagsIntel, svmSize, svmPtr, svmPtr, gfxAlloc, offset, true, false, false);
|
||||
buffer->setArgStateful(surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(surfaceState, false, false, false, false, device->getRootDeviceIndex());
|
||||
buffer->graphicsAllocation = nullptr;
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class Buffer : public MemObj {
|
||||
bool isSubBuffer();
|
||||
bool isValidSubBufferOffset(size_t offset);
|
||||
uint64_t setArgStateless(void *memory, uint32_t patchSize, uint32_t rootDeviceIndex, bool set32BitAddressing);
|
||||
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) = 0;
|
||||
virtual void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) = 0;
|
||||
bool bufferRectPitchSet(const size_t *bufferOrigin,
|
||||
const size_t *region,
|
||||
size_t &bufferRowPitch,
|
||||
@@ -151,9 +151,9 @@ class Buffer : public MemObj {
|
||||
bool isReadWriteOnCpuAllowed(uint32_t rootDeviceIndex);
|
||||
bool isReadWriteOnCpuPreferred(void *ptr, size_t size, const Device &device);
|
||||
|
||||
uint32_t getMocsValue(bool disableL3Cache, bool isReadOnlyArgument) const;
|
||||
uint32_t getSurfaceSize(bool alignSizeForAuxTranslation) const;
|
||||
uint64_t getBufferAddress() const;
|
||||
uint32_t getMocsValue(bool disableL3Cache, bool isReadOnlyArgument, uint32_t rootDeviceIndex) const;
|
||||
uint32_t getSurfaceSize(bool alignSizeForAuxTranslation, uint32_t rootDeviceIndex) const;
|
||||
uint64_t getBufferAddress(uint32_t rootDeviceIndex) const;
|
||||
|
||||
bool isCompressed(uint32_t rootDeviceIndex) const;
|
||||
|
||||
@@ -204,7 +204,7 @@ class BufferHw : public Buffer {
|
||||
: Buffer(context, memoryProperties, flags, flagsIntel, size, memoryStorage, hostPtr, gfxAllocation,
|
||||
zeroCopy, isHostPtrSVM, isObjectRedescribed) {}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) override;
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, uint32_t rootDeviceIndex) override;
|
||||
void appendBufferState(void *memory, Context *context, GraphicsAllocation *gfxAllocation, bool isReadOnlyArgument);
|
||||
void appendSurfaceStateExt(void *memory);
|
||||
|
||||
|
||||
@@ -32,9 +32,11 @@ union SURFACE_STATE_BUFFER_LENGTH {
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument) {
|
||||
EncodeSurfaceState<GfxFamily>::encodeBuffer(memory, getBufferAddress(), getSurfaceSize(alignSizeForAuxTranslation), getMocsValue(disableL3, isReadOnlyArgument), true);
|
||||
EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(multiGraphicsAllocation.getDefaultGraphicsAllocation(), rootDeviceEnvironment->getGmmHelper(), memory, forceNonAuxMode, isReadOnlyArgument);
|
||||
void BufferHw<GfxFamily>::setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnlyArgument, uint32_t rootDeviceIndex) {
|
||||
auto graphicsAllocation = multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex);
|
||||
EncodeSurfaceState<GfxFamily>::encodeBuffer(memory, getBufferAddress(rootDeviceIndex), getSurfaceSize(alignSizeForAuxTranslation, rootDeviceIndex), getMocsValue(disableL3, isReadOnlyArgument, rootDeviceIndex), true);
|
||||
EncodeSurfaceState<GfxFamily>::encodeExtraBufferParams(multiGraphicsAllocation.getGraphicsAllocation(rootDeviceIndex),
|
||||
executionEnvironment->rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper(), memory, forceNonAuxMode, isReadOnlyArgument);
|
||||
|
||||
appendBufferState(memory, context, graphicsAllocation, isReadOnlyArgument);
|
||||
appendSurfaceStateExt(memory);
|
||||
|
||||
@@ -79,7 +79,7 @@ class MockObject : public MockObjectBase<BaseType> {};
|
||||
template <>
|
||||
class MockObject<Buffer> : public MockObjectBase<Buffer> {
|
||||
public:
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) override {}
|
||||
};
|
||||
|
||||
template <>
|
||||
@@ -293,7 +293,7 @@ class MockBuffer : public MockBufferStorage, public Buffer {
|
||||
CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, &mockGfxAllocation, true, false, false) {
|
||||
}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) override {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2656,6 +2656,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatAddressIsForcedTo32bitW
|
||||
{
|
||||
DebugManager.flags.Force32bitAddressing.set(true);
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
auto size = MemoryConstants::pageSize;
|
||||
auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
|
||||
auto retVal = CL_SUCCESS;
|
||||
@@ -2668,15 +2669,15 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatAddressIsForcedTo32bitW
|
||||
retVal);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
EXPECT_TRUE(is64bit ? buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->is32BitAllocation() : true);
|
||||
EXPECT_TRUE(is64bit ? buffer->getGraphicsAllocation(rootDeviceIndex)->is32BitAllocation() : true);
|
||||
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
|
||||
auto surfBaseAddress = surfaceState.getSurfaceBaseAddress();
|
||||
auto bufferAddress = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getGpuAddress();
|
||||
auto bufferAddress = buffer->getGraphicsAllocation(rootDeviceIndex)->getGpuAddress();
|
||||
EXPECT_EQ(bufferAddress, surfBaseAddress);
|
||||
|
||||
delete buffer;
|
||||
@@ -2687,6 +2688,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatAddressIsForcedTo32bitW
|
||||
|
||||
HWTEST_F(BufferSetSurfaceTests, givenBufferWithOffsetWhenSetArgStatefulIsCalledThenSurfaceBaseAddressIsProperlyOffseted) {
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
auto size = MemoryConstants::pageSize;
|
||||
auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
|
||||
auto retVal = CL_SUCCESS;
|
||||
@@ -2708,10 +2710,10 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferWithOffsetWhenSetArgStatefulIsCalledT
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
subBuffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
subBuffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
|
||||
auto surfBaseAddress = surfaceState.getSurfaceBaseAddress();
|
||||
auto bufferAddress = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getGpuAddress();
|
||||
auto bufferAddress = buffer->getGraphicsAllocation(rootDeviceIndex)->getGpuAddress();
|
||||
EXPECT_EQ(bufferAddress + region.origin, surfBaseAddress);
|
||||
|
||||
subBuffer->release();
|
||||
@@ -2723,6 +2725,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferWithOffsetWhenSetArgStatefulIsCalledT
|
||||
|
||||
HWTEST_F(BufferSetSurfaceTests, givenBufferWhenSetArgStatefulWithL3ChacheDisabledIsCalledThenL3CacheShouldBeOffAndSizeIsAlignedTo512) {
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
auto size = 128;
|
||||
auto retVal = CL_SUCCESS;
|
||||
|
||||
@@ -2737,7 +2740,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferWhenSetArgStatefulWithL3ChacheDisable
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, true, true, false);
|
||||
buffer->setArgStateful(&surfaceState, false, true, true, false, rootDeviceIndex);
|
||||
|
||||
auto mocs = surfaceState.getMemoryObjectControlState();
|
||||
auto gmmHelper = device->getGmmHelper();
|
||||
@@ -2748,6 +2751,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferWhenSetArgStatefulWithL3ChacheDisable
|
||||
|
||||
HWTEST_F(BufferSetSurfaceTests, givenBufferThatIsMisalignedButIsAReadOnlyArgumentWhenSurfaceStateIsSetThenL3IsOn) {
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
auto size = 128;
|
||||
auto retVal = CL_SUCCESS;
|
||||
|
||||
@@ -2762,9 +2766,9 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferThatIsMisalignedButIsAReadOnlyArgumen
|
||||
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
|
||||
buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->setSize(127);
|
||||
buffer->getGraphicsAllocation(rootDeviceIndex)->setSize(127);
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, true);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, true, rootDeviceIndex);
|
||||
|
||||
auto mocs = surfaceState.getMemoryObjectControlState();
|
||||
auto gmmHelper = device->getGmmHelper();
|
||||
@@ -2775,6 +2779,7 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferThatIsMisalignedButIsAReadOnlyArgumen
|
||||
|
||||
HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferPolicy) {
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
const auto size = MemoryConstants::pageSize;
|
||||
const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
|
||||
const auto flags = CL_MEM_USE_HOST_PTR | CL_MEM_READ_ONLY;
|
||||
@@ -2789,7 +2794,7 @@ HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableReadOnlyBufferThenChoseOclB
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
|
||||
const auto expectedMocs = device->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
|
||||
const auto actualMocs = surfaceState.getMemoryObjectControlState();
|
||||
@@ -2800,6 +2805,7 @@ HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableReadOnlyBufferThenChoseOclB
|
||||
|
||||
HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableNonReadOnlyBufferThenChooseOclBufferPolicy) {
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
const auto size = MemoryConstants::pageSize;
|
||||
const auto ptr = (void *)alignedMalloc(size * 2, MemoryConstants::pageSize);
|
||||
const auto flags = CL_MEM_USE_HOST_PTR;
|
||||
@@ -2814,7 +2820,7 @@ HWTEST_F(BufferSetSurfaceTests, givenAlignedCacheableNonReadOnlyBufferThenChoose
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
typename FamilyType::RENDER_SURFACE_STATE surfaceState = {};
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
|
||||
const auto expectedMocs = device->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
|
||||
const auto actualMocs = surfaceState.getMemoryObjectControlState();
|
||||
@@ -2829,23 +2835,24 @@ HWTEST_F(BufferSetSurfaceTests, givenRenderCompressedGmmResourceWhenSurfaceState
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
auto retVal = CL_SUCCESS;
|
||||
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
auto graphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex());
|
||||
auto graphicsAllocation = buffer->getGraphicsAllocation(rootDeviceIndex);
|
||||
graphicsAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false);
|
||||
graphicsAllocation->setDefaultGmm(gmm);
|
||||
gmm->isRenderCompressed = true;
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
|
||||
EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
|
||||
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E == surfaceState.getAuxiliarySurfaceMode());
|
||||
EXPECT_TRUE(RENDER_SURFACE_STATE::COHERENCY_TYPE_GPU_COHERENT == surfaceState.getCoherencyType());
|
||||
|
||||
graphicsAllocation->setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE == surfaceState.getAuxiliarySurfaceMode());
|
||||
}
|
||||
|
||||
@@ -2855,14 +2862,15 @@ HWTEST_F(BufferSetSurfaceTests, givenNonRenderCompressedGmmResourceWhenSurfaceSt
|
||||
|
||||
RENDER_SURFACE_STATE surfaceState = {};
|
||||
MockContext context;
|
||||
auto rootDeviceIndex = context.getDevice(0)->getRootDeviceIndex();
|
||||
auto retVal = CL_SUCCESS;
|
||||
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal));
|
||||
auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false);
|
||||
buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->setDefaultGmm(gmm);
|
||||
buffer->getGraphicsAllocation(rootDeviceIndex)->setDefaultGmm(gmm);
|
||||
gmm->isRenderCompressed = false;
|
||||
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false);
|
||||
buffer->setArgStateful(&surfaceState, false, false, false, false, rootDeviceIndex);
|
||||
|
||||
EXPECT_EQ(0u, surfaceState.getAuxiliarySurfaceBaseAddress());
|
||||
EXPECT_TRUE(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE == surfaceState.getAuxiliarySurfaceMode());
|
||||
@@ -3094,7 +3102,7 @@ TEST_F(MultiRootDeviceBufferTest, givenBufferWhenGetSurfaceSizeCalledWithoutAlig
|
||||
uint32_t size = 0x131;
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, size, nullptr, retVal));
|
||||
|
||||
auto surfaceSize = buffer->getSurfaceSize(false);
|
||||
auto surfaceSize = buffer->getSurfaceSize(false, expectedRootDeviceIndex);
|
||||
EXPECT_EQ(surfaceSize, alignUp(size, 4));
|
||||
}
|
||||
|
||||
@@ -3104,35 +3112,21 @@ TEST_F(MultiRootDeviceBufferTest, givenBufferWhenGetSurfaceSizeCalledWithAlignSi
|
||||
uint32_t size = 0x131;
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, size, nullptr, retVal));
|
||||
|
||||
auto surfaceSize = buffer->getSurfaceSize(true);
|
||||
auto surfaceSize = buffer->getSurfaceSize(true, expectedRootDeviceIndex);
|
||||
EXPECT_EQ(surfaceSize, alignUp(size, 512));
|
||||
}
|
||||
|
||||
TEST_F(MultiRootDeviceBufferTest, givenHostPtrBufferWhenGetBufferAddressCalledThenHostPtrReturned) {
|
||||
class MockBuffer : public Buffer {
|
||||
public:
|
||||
using Buffer::multiGraphicsAllocation;
|
||||
MockBuffer(void *hostPtr) {
|
||||
this->hostPtr = hostPtr;
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
}
|
||||
};
|
||||
void *hostPtr = reinterpret_cast<void *>(0x3000);
|
||||
|
||||
std::unique_ptr<MockBuffer> buffer(new MockBuffer(hostPtr));
|
||||
|
||||
auto address = buffer->getBufferAddress();
|
||||
ASSERT_EQ(hostPtr, reinterpret_cast<void *>(address));
|
||||
}
|
||||
|
||||
TEST_F(MultiRootDeviceBufferTest, givenBufferWithoutMultiGAWhenGetBufferAddressCalledThenCorrectAddressReturned) {
|
||||
TEST_F(MultiRootDeviceBufferTest, givenNullptrGraphicsAllocationForRootDeviceIndexWhenGettingBufferAddressThenHostPtrReturned) {
|
||||
cl_int retVal = 0;
|
||||
cl_mem_flags flags = CL_MEM_READ_WRITE;
|
||||
cl_mem_flags flags = CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR;
|
||||
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, MemoryConstants::pageSize, nullptr, retVal));
|
||||
char *hostPtr[MemoryConstants::pageSize]{};
|
||||
std::unique_ptr<Buffer> buffer(Buffer::create(context.get(), flags, MemoryConstants::pageSize, hostPtr, retVal));
|
||||
|
||||
auto address = buffer->getBufferAddress();
|
||||
auto address = buffer->getBufferAddress(expectedRootDeviceIndex);
|
||||
auto graphicsAllocation = buffer->getGraphicsAllocation(expectedRootDeviceIndex);
|
||||
ASSERT_EQ(graphicsAllocation->getGpuAddress(), address);
|
||||
EXPECT_EQ(graphicsAllocation->getGpuAddress(), address);
|
||||
|
||||
address = buffer->getBufferAddress(0);
|
||||
EXPECT_EQ(reinterpret_cast<uint64_t>(buffer->getHostPtr()), address);
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class MockBuffer : public MockBufferStorage, public Buffer {
|
||||
this->graphicsAllocation = &this->mockGfxAllocation;
|
||||
}
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) override {
|
||||
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), 0, (externalAlloc != nullptr) ? externalAlloc : &mockGfxAllocation, 0, 0);
|
||||
}
|
||||
GraphicsAllocation *externalAlloc = nullptr;
|
||||
@@ -61,7 +61,7 @@ class AlignedBuffer : public MockBufferStorage, public Buffer {
|
||||
}
|
||||
AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) {
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) override {
|
||||
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), 0, &mockGfxAllocation, 0, 0);
|
||||
}
|
||||
};
|
||||
@@ -73,7 +73,7 @@ class UnalignedBuffer : public MockBufferStorage, public Buffer {
|
||||
}
|
||||
UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) {
|
||||
}
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) override {
|
||||
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), 0, &mockGfxAllocation, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1447,7 +1447,7 @@ class DrmMockBuffer : public Buffer {
|
||||
gfxAllocation(alloc) {
|
||||
}
|
||||
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly) override {
|
||||
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, uint32_t rootDeviceIndex) override {
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class MultiGraphicsAllocation : NonCopyableOrMovableClass {
|
||||
class MultiGraphicsAllocation : NonCopyableClass {
|
||||
public:
|
||||
MultiGraphicsAllocation(uint32_t maxRootDeviceIndex);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user