mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 18:06:32 +08:00
feature: use heapless builtins for images
Related-To: NEO-12744 Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
bbdf1ac7b6
commit
3891e887c1
@@ -689,6 +689,25 @@ class BuiltInOp<EBuiltInOps::copyBufferToImage3dStateless> : public BuiltInOp<EB
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::copyBufferToImage3dHeapless> : public BuiltInOp<EBuiltInOps::copyBufferToImage3d> {
|
||||
public:
|
||||
BuiltInOp(BuiltIns &kernelsLib, ClDevice &device)
|
||||
: BuiltInOp<EBuiltInOps::copyBufferToImage3d>(kernelsLib, device, false) {
|
||||
populate(EBuiltInOps::copyBufferToImage3dHeapless,
|
||||
CompilerOptions::greaterThan4gbBuffersRequired,
|
||||
"CopyBufferToImage3dBytesStateless", kernelBytes[0],
|
||||
"CopyBufferToImage3d2BytesStateless", kernelBytes[1],
|
||||
"CopyBufferToImage3d4BytesStateless", kernelBytes[2],
|
||||
"CopyBufferToImage3d8BytesStateless", kernelBytes[3],
|
||||
"CopyBufferToImage3d16BytesStateless", kernelBytes[4]);
|
||||
}
|
||||
|
||||
bool buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo) const override {
|
||||
return buildDispatchInfosTyped<uint64_t>(multiDispatchInfo);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::copyImage3dToBuffer> : public BuiltinDispatchInfoBuilder {
|
||||
public:
|
||||
@@ -811,6 +830,25 @@ class BuiltInOp<EBuiltInOps::copyImage3dToBufferStateless> : public BuiltInOp<EB
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::copyImage3dToBufferHeapless> : public BuiltInOp<EBuiltInOps::copyImage3dToBuffer> {
|
||||
public:
|
||||
BuiltInOp(BuiltIns &kernelsLib, ClDevice &device)
|
||||
: BuiltInOp<EBuiltInOps::copyImage3dToBuffer>(kernelsLib, device, false) {
|
||||
populate(EBuiltInOps::copyImage3dToBufferHeapless,
|
||||
CompilerOptions::greaterThan4gbBuffersRequired,
|
||||
"CopyImage3dToBufferBytesStateless", kernelBytes[0],
|
||||
"CopyImage3dToBuffer2BytesStateless", kernelBytes[1],
|
||||
"CopyImage3dToBuffer4BytesStateless", kernelBytes[2],
|
||||
"CopyImage3dToBuffer8BytesStateless", kernelBytes[3],
|
||||
"CopyImage3dToBuffer16BytesStateless", kernelBytes[4]);
|
||||
}
|
||||
|
||||
bool buildDispatchInfos(MultiDispatchInfo &multiDispatchInfo) const override {
|
||||
return buildDispatchInfosTyped<uint64_t>(multiDispatchInfo);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::copyImageToImage3d> : public BuiltinDispatchInfoBuilder {
|
||||
public:
|
||||
@@ -873,9 +911,29 @@ class BuiltInOp<EBuiltInOps::copyImageToImage3d> : public BuiltinDispatchInfoBui
|
||||
}
|
||||
|
||||
protected:
|
||||
BuiltInOp(BuiltIns &kernelsLib, ClDevice &device, bool populateKernels)
|
||||
: BuiltinDispatchInfoBuilder(kernelsLib, device) {
|
||||
if (populateKernels) {
|
||||
populate(EBuiltInOps::copyImageToImage3d,
|
||||
"",
|
||||
"CopyImageToImage3d", kernel);
|
||||
}
|
||||
}
|
||||
|
||||
MultiDeviceKernel *kernel = nullptr;
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::copyImageToImage3dHeapless> : public BuiltInOp<EBuiltInOps::copyImageToImage3d> {
|
||||
public:
|
||||
BuiltInOp(BuiltIns &kernelsLib, ClDevice &device)
|
||||
: BuiltInOp<EBuiltInOps::copyImageToImage3d>(kernelsLib, device, false) {
|
||||
populate(EBuiltInOps::copyImageToImage3dHeapless,
|
||||
"",
|
||||
"CopyImageToImage3d", kernel);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::fillImage3d> : public BuiltinDispatchInfoBuilder {
|
||||
public:
|
||||
@@ -930,9 +988,30 @@ class BuiltInOp<EBuiltInOps::fillImage3d> : public BuiltinDispatchInfoBuilder {
|
||||
}
|
||||
|
||||
protected:
|
||||
BuiltInOp(BuiltIns &kernelsLib, ClDevice &device, bool populateKernels)
|
||||
: BuiltinDispatchInfoBuilder(kernelsLib, device) {
|
||||
if (populateKernels) {
|
||||
|
||||
populate(EBuiltInOps::fillImage3d,
|
||||
"",
|
||||
"FillImage3d", kernel);
|
||||
}
|
||||
}
|
||||
|
||||
MultiDeviceKernel *kernel = nullptr;
|
||||
};
|
||||
|
||||
template <>
|
||||
class BuiltInOp<EBuiltInOps::fillImage3dHeapless> : public BuiltInOp<EBuiltInOps::fillImage3d> {
|
||||
public:
|
||||
BuiltInOp(BuiltIns &kernelsLib, ClDevice &device)
|
||||
: BuiltInOp<EBuiltInOps::fillImage3d>(kernelsLib, device, false) {
|
||||
populate(EBuiltInOps::fillImage3dHeapless,
|
||||
"",
|
||||
"FillImage3d", kernel);
|
||||
}
|
||||
};
|
||||
|
||||
BuiltinDispatchInfoBuilder &BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::Type operation, ClDevice &device) {
|
||||
uint32_t operationId = static_cast<uint32_t>(operation);
|
||||
auto &builtins = *device.getDevice().getBuiltIns();
|
||||
@@ -972,18 +1051,30 @@ BuiltinDispatchInfoBuilder &BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuil
|
||||
case EBuiltInOps::copyBufferToImage3dStateless:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyBufferToImage3dStateless>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::copyBufferToImage3dHeapless:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyBufferToImage3dHeapless>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::copyImage3dToBuffer:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyImage3dToBuffer>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::copyImage3dToBufferStateless:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyImage3dToBufferStateless>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::copyImage3dToBufferHeapless:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyImage3dToBufferHeapless>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::copyImageToImage3d:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyImageToImage3d>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::copyImageToImage3dHeapless:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::copyImageToImage3dHeapless>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::fillImage3d:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::fillImage3d>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::fillImage3dHeapless:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::fillImage3dHeapless>>(builtins, device); });
|
||||
break;
|
||||
case EBuiltInOps::auxTranslation:
|
||||
std::call_once(operationBuilder.second, [&] { operationBuilder.first = std::make_unique<BuiltInOp<EBuiltInOps::auxTranslation>>(builtins, device); });
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -57,7 +57,9 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImage(
|
||||
|
||||
MultiDispatchInfo dispatchInfo(dc);
|
||||
|
||||
return dispatchBcsOrGpgpuEnqueue<CL_COMMAND_COPY_IMAGE>(dispatchInfo, surfaces, EBuiltInOps::copyImageToImage3d, numEventsInWaitList, eventWaitList, event, false, csr);
|
||||
auto builtIn = EBuiltInOps::adjustImageBuiltinType<EBuiltInOps::copyImageToImage3d>(this->heaplessModeEnabled);
|
||||
|
||||
return dispatchBcsOrGpgpuEnqueue<CL_COMMAND_COPY_IMAGE>(dispatchInfo, surfaces, builtIn, numEventsInWaitList, eventWaitList, event, false, csr);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -29,9 +29,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueCopyImageToBuffer(
|
||||
if (dstBuffer->getSize() >= 4ull * MemoryConstants::gigaByte) {
|
||||
isStateless = true;
|
||||
}
|
||||
const bool useHeapless = false;
|
||||
auto builtInType = EBuiltInOps::adjustBuiltinType<EBuiltInOps::copyImage3dToBuffer>(isStateless, useHeapless);
|
||||
|
||||
auto builtInType = EBuiltInOps::adjustBuiltinType<EBuiltInOps::copyImage3dToBuffer>(isStateless, this->heaplessModeEnabled);
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(builtInType,
|
||||
this->getClDevice());
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -29,8 +29,9 @@ cl_int CommandQueueHw<GfxFamily>::enqueueFillImage(
|
||||
cl_uint numEventsInWaitList,
|
||||
const cl_event *eventWaitList,
|
||||
cl_event *event) {
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::fillImage3d,
|
||||
this->getClDevice());
|
||||
|
||||
auto builtInType = EBuiltInOps::adjustImageBuiltinType<EBuiltInOps::fillImage3d>(this->heaplessModeEnabled);
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(builtInType, this->getClDevice());
|
||||
BuiltInOwnershipWrapper builtInLock(builder, this->context);
|
||||
|
||||
MemObjSurface dstImgSurf(image);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -100,7 +100,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
|
||||
dc.bcsSplit = bcsSplit;
|
||||
dc.direction = csrSelectionArgs.direction;
|
||||
|
||||
auto eBuiltInOps = EBuiltInOps::copyBufferToImage3d;
|
||||
auto eBuiltInOps = EBuiltInOps::adjustImageBuiltinType<EBuiltInOps::copyBufferToImage3d>(this->heaplessModeEnabled);
|
||||
MultiDispatchInfo dispatchInfo(dc);
|
||||
|
||||
const auto dispatchResult = dispatchBcsOrGpgpuEnqueue<CL_COMMAND_WRITE_IMAGE>(dispatchInfo, surfaces, eBuiltInOps, numEventsInWaitList, eventWaitList, event, blockingWrite == CL_TRUE, csr);
|
||||
|
||||
@@ -1115,6 +1115,161 @@ HWTEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyBufferToImageStateles
|
||||
EXPECT_FALSE(kernel->getKernelInfo().getArgDescriptorAt(0).as<ArgDescPointer>().isPureStateful());
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenHeaplessWhenBuilderCopyBufferToImageHeaplessIsUsedThenParamsAreCorrect) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
if (!heaplessAllowed) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
MockBuffer buffer;
|
||||
std ::unique_ptr<Image> image(Image2dHelper<>::create(pContext));
|
||||
ASSERT_NE(nullptr, image.get());
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::copyBufferToImage3dHeapless, *pClDevice);
|
||||
|
||||
BuiltinOpParams dc;
|
||||
dc.srcPtr = &buffer;
|
||||
dc.dstMemObj = image.get();
|
||||
dc.srcOffset = {0, 0, 0};
|
||||
dc.dstOffset = {0, 0, 0};
|
||||
dc.size = {1, 1, 1};
|
||||
dc.srcRowPitch = 0;
|
||||
dc.srcSlicePitch = 0;
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo(dc);
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo));
|
||||
EXPECT_EQ(1u, multiDispatchInfo.size());
|
||||
EXPECT_TRUE(compareBuiltinOpParams(multiDispatchInfo.peekBuiltinOpParams(), dc));
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenHeaplessWhenBuilderCopyImageToBufferHeaplessIsUsedThenParamsAreCorrect) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
if (!heaplessAllowed) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
MockBuffer buffer;
|
||||
std ::unique_ptr<Image> image(Image2dHelper<>::create(pContext));
|
||||
ASSERT_NE(nullptr, image.get());
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::copyImage3dToBufferHeapless, *pClDevice);
|
||||
|
||||
BuiltinOpParams dc;
|
||||
dc.srcMemObj = image.get();
|
||||
dc.dstPtr = &buffer;
|
||||
dc.srcOffset = {0, 0, 0};
|
||||
dc.dstOffset = {0, 0, 0};
|
||||
dc.size = {1, 1, 1};
|
||||
dc.dstRowPitch = 0;
|
||||
dc.dstSlicePitch = 0;
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo(dc);
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo));
|
||||
EXPECT_EQ(1u, multiDispatchInfo.size());
|
||||
EXPECT_TRUE(compareBuiltinOpParams(multiDispatchInfo.peekBuiltinOpParams(), dc));
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenHeaplessWhenBuilderCopyImageToImageHeaplessIsUsedThenParamsAreCorrect) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
if (!heaplessAllowed) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
std ::unique_ptr<Image> srcImage(Image2dHelper<>::create(pContext));
|
||||
std ::unique_ptr<Image> dstImage(Image2dHelper<>::create(pContext));
|
||||
|
||||
ASSERT_NE(nullptr, srcImage.get());
|
||||
ASSERT_NE(nullptr, dstImage.get());
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::copyImageToImage3dHeapless, *pClDevice);
|
||||
|
||||
BuiltinOpParams dc;
|
||||
dc.srcMemObj = srcImage.get();
|
||||
dc.dstMemObj = dstImage.get();
|
||||
|
||||
dc.srcOffset = {0, 0, 0};
|
||||
dc.dstOffset = {0, 0, 0};
|
||||
dc.size = {1, 1, 1};
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo(dc);
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo));
|
||||
EXPECT_EQ(1u, multiDispatchInfo.size());
|
||||
EXPECT_TRUE(compareBuiltinOpParams(multiDispatchInfo.peekBuiltinOpParams(), dc));
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, WhenBuilderCopyImageToImageIsUsedThenParamsAreCorrect) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
|
||||
std ::unique_ptr<Image> srcImage(Image2dHelper<>::create(pContext));
|
||||
std ::unique_ptr<Image> dstImage(Image2dHelper<>::create(pContext));
|
||||
|
||||
ASSERT_NE(nullptr, srcImage.get());
|
||||
ASSERT_NE(nullptr, dstImage.get());
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::copyImageToImage3d, *pClDevice);
|
||||
|
||||
BuiltinOpParams dc;
|
||||
dc.srcMemObj = srcImage.get();
|
||||
dc.dstMemObj = dstImage.get();
|
||||
|
||||
dc.srcOffset = {0, 0, 0};
|
||||
dc.dstOffset = {0, 0, 0};
|
||||
dc.size = {1, 1, 1};
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo(dc);
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo));
|
||||
EXPECT_EQ(1u, multiDispatchInfo.size());
|
||||
EXPECT_TRUE(compareBuiltinOpParams(multiDispatchInfo.peekBuiltinOpParams(), dc));
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenHeaplessWhenBuilderFillImageHeaplessIsUsedThenParamsAreCorrect) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
if (!heaplessAllowed) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
MockBuffer fillColor;
|
||||
std ::unique_ptr<Image> image(Image2dHelper<>::create(pContext));
|
||||
ASSERT_NE(nullptr, image.get());
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::fillImage3dHeapless, *pClDevice);
|
||||
|
||||
BuiltinOpParams dc;
|
||||
dc.srcPtr = &fillColor;
|
||||
dc.dstMemObj = image.get();
|
||||
dc.srcOffset = {0, 0, 0};
|
||||
dc.dstOffset = {0, 0, 0};
|
||||
dc.size = {1, 1, 1};
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo(dc);
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo));
|
||||
EXPECT_EQ(1u, multiDispatchInfo.size());
|
||||
EXPECT_TRUE(compareBuiltinOpParams(multiDispatchInfo.peekBuiltinOpParams(), dc));
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, WhenBuilderFillImageIsUsedThenParamsAreCorrect) {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
|
||||
MockBuffer fillColor;
|
||||
std ::unique_ptr<Image> image(Image2dHelper<>::create(pContext));
|
||||
ASSERT_NE(nullptr, image.get());
|
||||
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::fillImage3d, *pClDevice);
|
||||
|
||||
BuiltinOpParams dc;
|
||||
dc.srcPtr = &fillColor;
|
||||
dc.dstMemObj = image.get();
|
||||
dc.srcOffset = {0, 0, 0};
|
||||
dc.dstOffset = {0, 0, 0};
|
||||
dc.size = {1, 1, 1};
|
||||
|
||||
MultiDispatchInfo multiDispatchInfo(dc);
|
||||
EXPECT_TRUE(builder.buildDispatchInfos(multiDispatchInfo));
|
||||
EXPECT_EQ(1u, multiDispatchInfo.size());
|
||||
EXPECT_TRUE(compareBuiltinOpParams(multiDispatchInfo.peekBuiltinOpParams(), dc));
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, givenBigOffsetAndSizeWhenBuilderCopyImageToSystemBufferStatelessIsUsedThenParamsAreCorrect) {
|
||||
if (is32bit) {
|
||||
GTEST_SKIP();
|
||||
@@ -1300,6 +1455,58 @@ TEST_F(BuiltInTests, WhenGettingBuilderInfoTwiceThenPointerIsSame) {
|
||||
EXPECT_EQ(&builder1, &builder2);
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltInTests, GivenBuiltInOperationWhenGettingBuilderThenCorrectBuiltInBuilderIsReturned) {
|
||||
|
||||
auto clExecutionEnvironment = static_cast<ClExecutionEnvironment *>(pClDevice->getExecutionEnvironment());
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
|
||||
auto verifyBuilder = [&](auto operation) {
|
||||
auto &builder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(operation, *pClDevice);
|
||||
auto *expectedBuilder = clExecutionEnvironment->peekBuilders(pClDevice->getRootDeviceIndex())[static_cast<uint32_t>(operation)].first.get();
|
||||
|
||||
EXPECT_EQ(expectedBuilder, &builder);
|
||||
};
|
||||
|
||||
EBuiltInOps::Type operationsBuffers[] = {
|
||||
EBuiltInOps::copyBufferToBuffer,
|
||||
EBuiltInOps::copyBufferToBufferStateless,
|
||||
EBuiltInOps::copyBufferToBufferStatelessHeapless,
|
||||
EBuiltInOps::copyBufferRect,
|
||||
EBuiltInOps::copyBufferRectStateless,
|
||||
EBuiltInOps::copyBufferRectStatelessHeapless,
|
||||
EBuiltInOps::fillBuffer,
|
||||
EBuiltInOps::fillBufferStateless,
|
||||
EBuiltInOps::fillBufferStatelessHeapless};
|
||||
|
||||
EBuiltInOps::Type operationsImages[] = {
|
||||
EBuiltInOps::copyBufferToImage3d,
|
||||
EBuiltInOps::copyBufferToImage3dStateless,
|
||||
EBuiltInOps::copyBufferToImage3dHeapless,
|
||||
EBuiltInOps::copyImage3dToBuffer,
|
||||
EBuiltInOps::copyImage3dToBufferStateless,
|
||||
EBuiltInOps::copyImage3dToBufferHeapless,
|
||||
EBuiltInOps::copyImageToImage3d,
|
||||
EBuiltInOps::copyImageToImage3dHeapless,
|
||||
EBuiltInOps::fillImage3d,
|
||||
EBuiltInOps::fillImage3dHeapless};
|
||||
|
||||
for (auto operation : operationsBuffers) {
|
||||
if (EBuiltInOps::isHeapless(operation) && (heaplessAllowed == false)) {
|
||||
continue;
|
||||
}
|
||||
verifyBuilder(operation);
|
||||
}
|
||||
|
||||
if (pClDevice->getHardwareInfo().capabilityTable.supportsImages) {
|
||||
for (auto operation : operationsImages) {
|
||||
if (EBuiltInOps::isHeapless(operation) && (heaplessAllowed == false)) {
|
||||
continue;
|
||||
}
|
||||
verifyBuilder(operation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, GivenUnknownBuiltInOpWhenGettingBuilderInfoThenExceptionThrown) {
|
||||
EXPECT_THROW(
|
||||
BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::count, *pClDevice),
|
||||
@@ -1484,6 +1691,29 @@ TEST_F(BuiltInTests, GivenTypeInvalidWhenGettingBuiltinCodeThenKernelIsEmpty) {
|
||||
EXPECT_EQ(pDevice, code.targetDevice);
|
||||
}
|
||||
|
||||
HWTEST2_F(BuiltInTests, GivenImagesAndHeaplessBuiltinTypeSourceWhenGettingBuiltinResourceThenResourceSizeIsNonZero, HeaplessSupportedMatcher) {
|
||||
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
auto mockBuiltinsLib = std::unique_ptr<MockBuiltinsLib>(new MockBuiltinsLib());
|
||||
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyBufferToImage3dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyImage3dToBufferHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyImageToImage1dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyImageToImage2dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyImageToImage3dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillImage1dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillImage2dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillImage3dHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
}
|
||||
|
||||
HWTEST2_F(BuiltInTests, GivenHeaplessBuiltinTypeSourceWhenGettingBuiltinResourceThenResourceSizeIsNonZero, HeaplessSupportedMatcher) {
|
||||
auto mockBuiltinsLib = std::unique_ptr<MockBuiltinsLib>(new MockBuiltinsLib());
|
||||
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyBufferToBufferStatelessHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::copyBufferRectStatelessHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillBufferStatelessHeapless, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
}
|
||||
|
||||
TEST_F(BuiltInTests, GivenBuiltinTypeSourceWhenGettingBuiltinResourceThenResourceSizeIsNonZero) {
|
||||
auto mockBuiltinsLib = std::unique_ptr<MockBuiltinsLib>(new MockBuiltinsLib());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::auxTranslation, BuiltinCode::ECodeType::source, *pDevice).size());
|
||||
@@ -1515,6 +1745,7 @@ HWCMDTEST_F(IGFX_GEN12LP_CORE, BuiltInTests, GivenBuiltinTypeBinaryWhenGettingBu
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillImage1d, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillImage2d, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
EXPECT_NE(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::fillImage3d, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
|
||||
EXPECT_EQ(0u, mockBuiltinsLib->getBuiltinResource(EBuiltInOps::count, BuiltinCode::ECodeType::binary, *pDevice).size());
|
||||
}
|
||||
|
||||
|
||||
@@ -215,43 +215,54 @@ HWTEST_F(BuiltinParamsCommandQueueHwTests, givenEnqueueReadWriteBufferCallWhenBu
|
||||
|
||||
HWTEST_F(BuiltinParamsCommandQueueHwTests, givenEnqueueWriteImageCallWhenBuiltinParamsArePassedThenCheckValuesCorectness) {
|
||||
|
||||
setUpImpl(EBuiltInOps::copyBufferToImage3d);
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
|
||||
std::unique_ptr<Image> dstImage(ImageHelper<ImageUseHostPtr<Image2dDefaults>>::create(context));
|
||||
for (auto useHeapless : {false, true}) {
|
||||
|
||||
auto imageDesc = dstImage->getImageDesc();
|
||||
size_t origin[] = {0, 0, 0};
|
||||
size_t region[] = {imageDesc.image_width, imageDesc.image_height, 0};
|
||||
if (useHeapless && !heaplessAllowed) {
|
||||
continue;
|
||||
}
|
||||
reinterpret_cast<MockCommandQueueHw<FamilyType> *>(pCmdQ)->heaplessModeEnabled = useHeapless;
|
||||
auto builtInType = EBuiltInOps::adjustImageBuiltinType<EBuiltInOps::copyBufferToImage3d>(useHeapless);
|
||||
|
||||
size_t rowPitch = dstImage->getHostPtrRowPitch();
|
||||
size_t slicePitch = dstImage->getHostPtrSlicePitch();
|
||||
setUpImpl(builtInType);
|
||||
|
||||
char array[3 * MemoryConstants::cacheLineSize];
|
||||
char *ptr = &array[MemoryConstants::cacheLineSize];
|
||||
ptr = alignUp(ptr, MemoryConstants::cacheLineSize);
|
||||
ptr -= 1;
|
||||
std::unique_ptr<Image> dstImage(ImageHelper<ImageUseHostPtr<Image2dDefaults>>::create(context));
|
||||
|
||||
void *alignedPtr = alignDown(ptr, 4);
|
||||
size_t ptrOffset = ptrDiff(ptr, alignedPtr);
|
||||
Vec3<size_t> offset = {0, 0, 0};
|
||||
auto imageDesc = dstImage->getImageDesc();
|
||||
size_t origin[] = {0, 0, 0};
|
||||
size_t region[] = {imageDesc.image_width, imageDesc.image_height, 0};
|
||||
|
||||
cl_int status = pCmdQ->enqueueWriteImage(dstImage.get(),
|
||||
CL_FALSE,
|
||||
origin,
|
||||
region,
|
||||
rowPitch,
|
||||
slicePitch,
|
||||
ptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, status);
|
||||
size_t rowPitch = dstImage->getHostPtrRowPitch();
|
||||
size_t slicePitch = dstImage->getHostPtrSlicePitch();
|
||||
|
||||
auto builtinParams = mockBuilder->paramsReceived.multiDispatchInfo.peekBuiltinOpParams();
|
||||
EXPECT_EQ(alignedPtr, builtinParams.srcPtr);
|
||||
EXPECT_EQ(ptrOffset, builtinParams.srcOffset.x);
|
||||
EXPECT_EQ(offset, builtinParams.dstOffset);
|
||||
char array[3 * MemoryConstants::cacheLineSize];
|
||||
char *ptr = &array[MemoryConstants::cacheLineSize];
|
||||
ptr = alignUp(ptr, MemoryConstants::cacheLineSize);
|
||||
ptr -= 1;
|
||||
|
||||
void *alignedPtr = alignDown(ptr, 4);
|
||||
size_t ptrOffset = ptrDiff(ptr, alignedPtr);
|
||||
Vec3<size_t> offset = {0, 0, 0};
|
||||
|
||||
cl_int status = pCmdQ->enqueueWriteImage(dstImage.get(),
|
||||
CL_FALSE,
|
||||
origin,
|
||||
region,
|
||||
rowPitch,
|
||||
slicePitch,
|
||||
ptr,
|
||||
nullptr,
|
||||
0,
|
||||
0,
|
||||
nullptr);
|
||||
EXPECT_EQ(CL_SUCCESS, status);
|
||||
|
||||
auto builtinParams = mockBuilder->paramsReceived.multiDispatchInfo.peekBuiltinOpParams();
|
||||
EXPECT_EQ(alignedPtr, builtinParams.srcPtr);
|
||||
EXPECT_EQ(ptrOffset, builtinParams.srcOffset.x);
|
||||
EXPECT_EQ(offset, builtinParams.dstOffset);
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(BuiltinParamsCommandQueueHwTests, givenEnqueueReadImageCallWhenBuiltinParamsArePassedThenCheckValuesCorectness) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -55,7 +55,7 @@ struct EnqueueCopyImageTest : public CommandEnqueueFixture,
|
||||
|
||||
struct EnqueueCopyImageMipMapTest : public CommandEnqueueFixture,
|
||||
public ::testing::Test,
|
||||
public ::testing::WithParamInterface<std::tuple<uint32_t, uint32_t>> {
|
||||
public ::testing::WithParamInterface<std::tuple<uint32_t, uint32_t, bool>> {
|
||||
|
||||
void SetUp(void) override {
|
||||
REQUIRE_IMAGES_OR_SKIP(defaultHwInfo);
|
||||
|
||||
@@ -221,20 +221,31 @@ HWCMDTEST_F(IGFX_GEN12LP_CORE, EnqueueCopyImageTest, WhenCopyingImageThenMediaVf
|
||||
validateMediaVFEState<FamilyType>(&pDevice->getHardwareInfo(), cmdMediaVfeState, cmdList, itorMediaVfeState);
|
||||
}
|
||||
|
||||
typedef EnqueueCopyImageMipMapTest MipMapCopyImageTest;
|
||||
using MipMapCopyImageTest = EnqueueCopyImageMipMapTest;
|
||||
|
||||
HWTEST_P(MipMapCopyImageTest, GivenImagesWithNonZeroMipLevelsWhenCopyImageIsCalledThenProperMipLevelsAreSet) {
|
||||
bool heaplessAllowed = UnitTestHelper<FamilyType>::isHeaplessAllowed();
|
||||
|
||||
bool useHeapless = false;
|
||||
cl_mem_object_type srcImageType, dstImageType;
|
||||
std::tie(srcImageType, dstImageType) = GetParam();
|
||||
std::tie(srcImageType, dstImageType, useHeapless) = GetParam();
|
||||
|
||||
if (useHeapless && !heaplessAllowed) {
|
||||
return;
|
||||
}
|
||||
|
||||
reinterpret_cast<MockCommandQueueHw<FamilyType> *>(pCmdQ)->heaplessModeEnabled = useHeapless;
|
||||
auto builtInType = EBuiltInOps::adjustImageBuiltinType<EBuiltInOps::copyImageToImage3d>(useHeapless);
|
||||
|
||||
auto builtIns = new MockBuiltins();
|
||||
MockRootDeviceEnvironment::resetBuiltins(pCmdQ->getDevice().getExecutionEnvironment()->rootDeviceEnvironments[pCmdQ->getDevice().getRootDeviceIndex()].get(), builtIns);
|
||||
auto &origBuilder = BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(
|
||||
EBuiltInOps::copyImageToImage3d,
|
||||
builtInType,
|
||||
pCmdQ->getClDevice());
|
||||
// substitute original builder with mock builder
|
||||
auto oldBuilder = pClExecutionEnvironment->setBuiltinDispatchInfoBuilder(
|
||||
rootDeviceIndex,
|
||||
EBuiltInOps::copyImageToImage3d,
|
||||
builtInType,
|
||||
std::unique_ptr<NEO::BuiltinDispatchInfoBuilder>(new MockBuiltinDispatchInfoBuilder(*builtIns, pCmdQ->getClDevice(), &origBuilder)));
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
@@ -298,7 +309,6 @@ HWTEST_P(MipMapCopyImageTest, GivenImagesWithNonZeroMipLevelsWhenCopyImageIsCall
|
||||
dstImage = std::unique_ptr<Image>(ImageHelper<Image2dDefaults>::create(context, &dstImageDesc));
|
||||
break;
|
||||
case CL_MEM_OBJECT_IMAGE2D_ARRAY:
|
||||
dstImageDesc.image_array_size = 2;
|
||||
dstOrigin[3] = expectedDstMipLevel;
|
||||
dstImage = std::unique_ptr<Image>(ImageHelper<Image2dArrayDefaults>::create(context, &dstImageDesc));
|
||||
break;
|
||||
@@ -321,7 +331,7 @@ HWTEST_P(MipMapCopyImageTest, GivenImagesWithNonZeroMipLevelsWhenCopyImageIsCall
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
|
||||
auto &mockBuilder = static_cast<MockBuiltinDispatchInfoBuilder &>(BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(EBuiltInOps::copyImageToImage3d,
|
||||
auto &mockBuilder = static_cast<MockBuiltinDispatchInfoBuilder &>(BuiltInDispatchBuilderOp::getBuiltinDispatchInfoBuilder(builtInType,
|
||||
pCmdQ->getClDevice()));
|
||||
auto params = mockBuilder.getBuiltinOpParams();
|
||||
|
||||
@@ -331,7 +341,7 @@ HWTEST_P(MipMapCopyImageTest, GivenImagesWithNonZeroMipLevelsWhenCopyImageIsCall
|
||||
// restore original builder and retrieve mock builder
|
||||
auto newBuilder = pClExecutionEnvironment->setBuiltinDispatchInfoBuilder(
|
||||
rootDeviceIndex,
|
||||
EBuiltInOps::copyImageToImage3d,
|
||||
builtInType,
|
||||
std::move(oldBuilder));
|
||||
EXPECT_NE(nullptr, newBuilder);
|
||||
}
|
||||
@@ -342,7 +352,8 @@ INSTANTIATE_TEST_SUITE_P(MipMapCopyImageTest_GivenImagesWithNonZeroMipLevelsWhen
|
||||
MipMapCopyImageTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(types),
|
||||
::testing::ValuesIn(types)));
|
||||
::testing::ValuesIn(types),
|
||||
::testing::Values(false, true)));
|
||||
|
||||
using OneMipLevelCopyImageImageTests = Test<OneMipLevelImageFixture>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user