Fix BCS tests

Related-To: NEO-6139

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz 2021-08-06 14:36:48 +00:00 committed by Compute-Runtime-Automation
parent 628c21ca37
commit b63d952407
1 changed files with 116 additions and 30 deletions

View File

@ -208,7 +208,11 @@ HWTEST_F(BcsTests, givenCsrDependenciesWhenProgrammingCommandStreamThenAddSemaph
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
uint32_t numberOfDependencyContainers = 2;
size_t numberNodesPerContainer = 5;
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
@ -259,8 +263,14 @@ HWTEST_F(BcsTests, givenMultipleBlitPropertiesWhenDispatchingThenProgramCommands
cl_int retVal = CL_SUCCESS;
auto buffer1 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
auto buffer2 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr1 = reinterpret_cast<void *>(0x12340000);
void *hostPtr2 = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr1 = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr1 = reinterpret_cast<void *>(hostAllocationPtr1.get());
auto hostAllocationPtr2 = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr2 = reinterpret_cast<void *>(hostAllocationPtr2.get());
auto graphicsAllocation1 = buffer1->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto graphicsAllocation2 = buffer2->getGraphicsAllocation(pDevice->getRootDeviceIndex());
@ -316,7 +326,11 @@ HWTEST_F(BcsTests, whenBlitBufferThenCommandBufferHasProperTaskCount) {
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer,
@ -341,7 +355,11 @@ HWTEST_F(BcsTests, givenProfilingEnabledWhenBlitBufferThenCommandBufferIsConstru
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer,
@ -385,7 +403,11 @@ HWTEST_F(BcsTests, givenNotInitializedOsContextWhenBlitBufferIsCalledThenInitial
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer,
*bcsCsr, graphicsAllocation, nullptr, hostPtr,
@ -409,8 +431,13 @@ HWTEST_F(BcsTests, givenInputAllocationsWhenBlitDispatchedThenMakeAllAllocations
cl_int retVal = CL_SUCCESS;
auto buffer1 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
auto buffer2 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr1 = reinterpret_cast<void *>(0x12340000);
void *hostPtr2 = reinterpret_cast<void *>(0x43210000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr1 = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr1 = reinterpret_cast<void *>(hostAllocationPtr1.get());
auto hostAllocationPtr2 = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr2 = reinterpret_cast<void *>(hostAllocationPtr2.get());
EXPECT_EQ(0u, csr.makeSurfacePackNonResidentCalled);
auto graphicsAllocation1 = buffer1->getGraphicsAllocation(pDevice->getRootDeviceIndex());
@ -462,8 +489,13 @@ HWTEST_F(BcsTests, givenFenceAllocationIsRequiredWhenBlitDispatchedThenMakeAllAl
cl_int retVal = CL_SUCCESS;
auto buffer1 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
auto buffer2 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr1 = reinterpret_cast<void *>(0x12340000);
void *hostPtr2 = reinterpret_cast<void *>(0x43210000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr1 = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr1 = reinterpret_cast<void *>(hostAllocationPtr1.get());
auto hostAllocationPtr2 = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr2 = reinterpret_cast<void *>(hostAllocationPtr2.get());
EXPECT_EQ(0u, bcsCsr->makeSurfacePackNonResidentCalled);
auto graphicsAllocation1 = buffer1->getGraphicsAllocation(pDevice->getRootDeviceIndex());
@ -505,7 +537,11 @@ HWTEST_F(BcsTests, givenBufferWhenBlitCalledThenFlushCommandBuffer) {
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto &commandStream = csr.getCS(MemoryConstants::pageSize);
@ -563,7 +599,11 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCallWaitWithKmdFallback) {
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto blitProperties = BlitProperties::constructPropertiesForReadWrite(BlitterConstants::BlitDirection::HostPtrToBuffer,
@ -592,7 +632,11 @@ HWTEST_F(BcsTests, whenBlitFromHostPtrCalledThenCleanTemporaryAllocations) {
cl_int retVal = CL_SUCCESS;
auto buffer = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer->getGraphicsAllocation(pDevice->getRootDeviceIndex());
bcsCsr.taskCount = 17;
@ -624,7 +668,9 @@ HWTEST_F(BcsTests, givenBufferWhenBlitOperationCalledThenProgramCorrectGpuAddres
auto graphicsAllocation1 = buffer1->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto graphicsAllocation2 = buffer2->getGraphicsAllocation(pDevice->getRootDeviceIndex());
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize * 2;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
const size_t hostPtrOffset = 0x1234;
const size_t subBuffer1Offset = 0x23;
@ -742,8 +788,11 @@ HWTEST_F(BcsTests, givenMapAllocationWhenDispatchReadWriteOperationThenSetValidG
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto memoryManager = csr.getMemoryManager();
AllocationProperties properties{csr.getRootDeviceIndex(), false, 1234, GraphicsAllocation::AllocationType::MAP_ALLOCATION, false, pDevice->getDeviceBitfield()};
GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, reinterpret_cast<void *>(0x12340000));
constexpr size_t mapAllocationSize = MemoryConstants::pageSize * 2;
auto mapAllocationPtr = allocateAlignedMemory(mapAllocationSize, MemoryConstants::pageSize);
AllocationProperties properties{csr.getRootDeviceIndex(), false, mapAllocationSize, GraphicsAllocation::AllocationType::MAP_ALLOCATION, false, pDevice->getDeviceBitfield()};
GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, mapAllocationPtr.get());
auto mapAllocationOffset = 0x1234;
auto mapPtr = reinterpret_cast<void *>(mapAllocation->getGpuAddress() + mapAllocationOffset);
@ -861,8 +910,11 @@ HWTEST_F(BcsTests, givenMapAllocationInBuiltinOpParamsWhenConstructingThenUseItA
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
auto memoryManager = static_cast<MockMemoryManager *>(csr.getMemoryManager());
AllocationProperties properties{csr.getRootDeviceIndex(), false, 1234, GraphicsAllocation::AllocationType::MAP_ALLOCATION, false, pDevice->getDeviceBitfield()};
GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, reinterpret_cast<void *>(0x12340000));
constexpr size_t mapAllocationSize = MemoryConstants::pageSize * 2;
auto mapAllocationPtr = allocateAlignedMemory(mapAllocationSize, MemoryConstants::pageSize);
AllocationProperties properties{csr.getRootDeviceIndex(), false, mapAllocationSize, GraphicsAllocation::AllocationType::MAP_ALLOCATION, false, pDevice->getDeviceBitfield()};
GraphicsAllocation *mapAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, reinterpret_cast<void *>(mapAllocationPtr.get()));
auto mapAllocationOffset = 0x1234;
auto mapPtr = reinterpret_cast<void *>(mapAllocation->getGpuAddress() + mapAllocationOffset);
@ -1029,7 +1081,11 @@ HWTEST_F(BcsTests, givenBufferWithOffsetWhenBlitOperationCalledThenProgramCorrec
cl_int retVal = CL_SUCCESS;
auto buffer1 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
auto buffer2 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation1 = buffer1->getGraphicsAllocation(pDevice->getRootDeviceIndex());
auto graphicsAllocation2 = buffer2->getGraphicsAllocation(pDevice->getRootDeviceIndex());
@ -1121,7 +1177,11 @@ HWTEST_F(BcsTests, givenBufferWithBigSizesWhenBlitOperationCalledThenProgramCorr
cl_int retVal = CL_SUCCESS;
auto buffer1 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
auto buffer2 = clUniquePtr<Buffer>(Buffer::create(context.get(), CL_MEM_READ_WRITE, 1, nullptr, retVal));
void *hostPtr = reinterpret_cast<void *>(0x4000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
auto graphicsAllocation = buffer1->getGraphicsAllocation(pDevice->getRootDeviceIndex());
size_t srcOrigin[] = {1, 2, 0};
@ -1312,7 +1372,6 @@ HWTEST_F(BcsTests, givenBlitterDirectSubmissionEnabledWhenProgrammingBlitterThen
}
struct BcsTestsImages : public BcsTests {
size_t rowPitch = 0;
size_t slicePitch = 0;
};
@ -1383,7 +1442,10 @@ HWTEST_F(BcsTestsImages, givenImageWithSurfaceOffsetWhenAdjustBlitPropertiesForI
}
HWTEST_F(BcsTests, givenHostPtrToImageWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.image_width = 10u;
imgDesc.image_height = 12u;
@ -1418,7 +1480,10 @@ HWTEST_F(BcsTests, givenHostPtrToImageWhenConstructPropertiesIsCalledThenValuesA
}
HWTEST_F(BcsTests, givenImageToHostPtrWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.image_width = 10u;
imgDesc.image_height = 12u;
@ -1453,7 +1518,10 @@ HWTEST_F(BcsTests, givenImageToHostPtrWhenConstructPropertiesIsCalledThenValuesA
}
HWTEST_F(BcsTests, givenHostPtrToImageWithInputRowSlicePitchesWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
BuiltinOpParams builtinOpParams{};
@ -1480,7 +1548,10 @@ HWTEST_F(BcsTests, givenHostPtrToImageWithInputRowSlicePitchesWhenConstructPrope
}
HWTEST_F(BcsTests, givenImageToHostPtrWithInputRowSlicePitchesWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get(), &imgDesc));
BuiltinOpParams builtinOpParams{};
@ -1511,7 +1582,10 @@ HWTEST_F(BcsTests, givenHostPtrToImageWhenBlitBufferIsCalledThenBlitCmdIsFound)
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get()));
BuiltinOpParams builtinOpParams{};
builtinOpParams.srcPtr = hostPtr;
@ -1533,7 +1607,10 @@ HWTEST_F(BcsTests, given3dImageWhenBlitBufferIsCalledThenBlitCmdIsFoundZtimes) {
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
std::unique_ptr<Image> image(Image3dHelper<>::create(context.get()));
BuiltinOpParams builtinOpParams{};
builtinOpParams.srcPtr = hostPtr;
@ -1561,7 +1638,10 @@ HWTEST_F(BcsTests, givenImageToHostPtrWhenBlitBufferIsCalledThenBlitCmdIsFound)
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
std::unique_ptr<Image> image(Image2dHelper<>::create(context.get()));
BuiltinOpParams builtinOpParams{};
builtinOpParams.dstPtr = hostPtr;
@ -1583,7 +1663,10 @@ HWTEST_F(BcsTests, givenHostPtrToImageWhenBlitBufferIsCalledThenBlitCmdIsCorrect
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.image_width = 10;
imgDesc.image_height = 12;
@ -1615,7 +1698,10 @@ HWTEST_F(BcsTests, givenImageToHostPtrWhenBlitBufferIsCalledThenBlitCmdIsCorrect
if (!pDevice->getHardwareInfo().capabilityTable.supportsImages) {
GTEST_SKIP();
}
void *hostPtr = reinterpret_cast<void *>(0x12340000);
constexpr size_t hostAllocationSize = MemoryConstants::pageSize;
auto hostAllocationPtr = allocateAlignedMemory(hostAllocationSize, MemoryConstants::pageSize);
void *hostPtr = reinterpret_cast<void *>(hostAllocationPtr.get());
cl_image_desc imgDesc = Image2dDefaults::imageDesc;
imgDesc.image_width = 10u;
imgDesc.image_height = 12u;