feature: use heapless builtins for images

Related-To: NEO-12744
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2024-10-25 15:10:17 +00:00
committed by Compute-Runtime-Automation
parent bbdf1ac7b6
commit 3891e887c1
18 changed files with 659 additions and 106 deletions

View File

@@ -52,16 +52,27 @@ enum class Builtin : uint32_t {
enum class ImageBuiltin : uint32_t {
copyBufferToImage3d16Bytes = 0u,
copyBufferToImage3d16BytesHeapless,
copyBufferToImage3d2Bytes,
copyBufferToImage3d2BytesHeapless,
copyBufferToImage3d4Bytes,
copyBufferToImage3d4BytesHeapless,
copyBufferToImage3d8Bytes,
copyBufferToImage3d8BytesHeapless,
copyBufferToImage3dBytes,
copyBufferToImage3dBytesHeapless,
copyImage3dToBuffer16Bytes,
copyImage3dToBuffer16BytesHeapless,
copyImage3dToBuffer2Bytes,
copyImage3dToBuffer2BytesHeapless,
copyImage3dToBuffer4Bytes,
copyImage3dToBuffer4BytesHeapless,
copyImage3dToBuffer8Bytes,
copyImage3dToBuffer8BytesHeapless,
copyImage3dToBufferBytes,
copyImage3dToBufferBytesHeapless,
copyImageRegion,
copyImageRegionHeapless,
count
};
@@ -170,6 +181,30 @@ constexpr Builtin adjustBuiltinType<Builtin::fillBufferRightLeftover>(const bool
}
return Builtin::fillBufferRightLeftover;
}
template <ImageBuiltin type>
constexpr ImageBuiltin adjustImageBuiltinType(const bool isHeapless) {
return type;
}
#define DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(type) \
template <> \
constexpr ImageBuiltin adjustImageBuiltinType<type>(const bool isHeapless) { \
return isHeapless ? type##Heapless : type; \
}
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyBufferToImage3d16Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyBufferToImage3d2Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyBufferToImage3d4Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyBufferToImage3d8Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyBufferToImage3dBytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyImage3dToBuffer16Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyImage3dToBuffer2Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyImage3dToBuffer4Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyImage3dToBuffer8Bytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyImage3dToBufferBytes);
DEFINE_ADJUST_IMAGE_BUILTIN_TYPE(ImageBuiltin::copyImageRegion);
} // namespace BuiltinTypeHelper
} // namespace L0

View File

@@ -159,50 +159,93 @@ void BuiltinFunctionsLibImpl::initBuiltinImageKernel(ImageBuiltin func) {
builtinName = "CopyBufferToImage3d16Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3d;
break;
case ImageBuiltin::copyBufferToImage3d16BytesHeapless:
builtinName = "CopyBufferToImage3d16Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3dHeapless;
break;
case ImageBuiltin::copyBufferToImage3d2Bytes:
builtinName = "CopyBufferToImage3d2Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3d;
break;
case ImageBuiltin::copyBufferToImage3d2BytesHeapless:
builtinName = "CopyBufferToImage3d2Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3dHeapless;
break;
case ImageBuiltin::copyBufferToImage3d4Bytes:
builtinName = "CopyBufferToImage3d4Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3d;
break;
case ImageBuiltin::copyBufferToImage3d4BytesHeapless:
builtinName = "CopyBufferToImage3d4Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3dHeapless;
break;
case ImageBuiltin::copyBufferToImage3d8Bytes:
builtinName = "CopyBufferToImage3d8Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3d;
break;
case ImageBuiltin::copyBufferToImage3d8BytesHeapless:
builtinName = "CopyBufferToImage3d8Bytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3dHeapless;
break;
case ImageBuiltin::copyBufferToImage3dBytes:
builtinName = "CopyBufferToImage3dBytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3d;
break;
case ImageBuiltin::copyBufferToImage3dBytesHeapless:
builtinName = "CopyBufferToImage3dBytes";
builtin = NEO::EBuiltInOps::copyBufferToImage3dHeapless;
break;
case ImageBuiltin::copyImage3dToBuffer16Bytes:
builtinName = "CopyImage3dToBuffer16Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBuffer;
break;
case ImageBuiltin::copyImage3dToBuffer16BytesHeapless:
builtinName = "CopyImage3dToBuffer16Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBufferHeapless;
break;
case ImageBuiltin::copyImage3dToBuffer2Bytes:
builtinName = "CopyImage3dToBuffer2Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBuffer;
break;
case ImageBuiltin::copyImage3dToBuffer2BytesHeapless:
builtinName = "CopyImage3dToBuffer2Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBufferHeapless;
break;
case ImageBuiltin::copyImage3dToBuffer4Bytes:
builtinName = "CopyImage3dToBuffer4Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBuffer;
break;
case ImageBuiltin::copyImage3dToBuffer4BytesHeapless:
builtinName = "CopyImage3dToBuffer4Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBufferHeapless;
break;
case ImageBuiltin::copyImage3dToBuffer8Bytes:
builtinName = "CopyImage3dToBuffer8Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBuffer;
break;
case ImageBuiltin::copyImage3dToBuffer8BytesHeapless:
builtinName = "CopyImage3dToBuffer8Bytes";
builtin = NEO::EBuiltInOps::copyImage3dToBufferHeapless;
break;
case ImageBuiltin::copyImage3dToBufferBytes:
builtinName = "CopyImage3dToBufferBytes";
builtin = NEO::EBuiltInOps::copyImage3dToBuffer;
break;
case ImageBuiltin::copyImage3dToBufferBytesHeapless:
builtinName = "CopyImage3dToBufferBytes";
builtin = NEO::EBuiltInOps::copyImage3dToBufferHeapless;
break;
case ImageBuiltin::copyImageRegion:
builtinName = "CopyImageToImage3d";
builtin = NEO::EBuiltInOps::copyImageToImage3d;
break;
case ImageBuiltin::copyImageRegionHeapless:
builtinName = "CopyImageToImage3d";
builtin = NEO::EBuiltInOps::copyImageToImage3dHeapless;
break;
default:
UNRECOVERABLE_IF(true);
};
auto builtId = static_cast<uint32_t>(func);
imageBuiltins[builtId] = loadBuiltIn(builtin, builtinName);
}

View File

@@ -743,31 +743,33 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemoryExt(z
return status;
}
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
Kernel *builtinKernel = nullptr;
bool isHeaplessEnabled = this->heaplessModeEnabled;
ImageBuiltin builtInType = ImageBuiltin::copyBufferToImage3dBytes;
switch (bytesPerPixel) {
case 1u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyBufferToImage3dBytes>(isHeaplessEnabled);
break;
case 2u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyBufferToImage3d2Bytes>(isHeaplessEnabled);
break;
case 4u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyBufferToImage3d4Bytes>(isHeaplessEnabled);
break;
case 8u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyBufferToImage3d8Bytes>(isHeaplessEnabled);
break;
case 16u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyBufferToImage3d16Bytes>(isHeaplessEnabled);
break;
default:
UNRECOVERABLE_IF(true);
break;
case 1u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyBufferToImage3dBytes);
break;
case 2u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyBufferToImage3d2Bytes);
break;
case 4u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyBufferToImage3d4Bytes);
break;
case 8u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyBufferToImage3d8Bytes);
break;
case 16u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyBufferToImage3d16Bytes);
break;
}
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType);
builtinKernel->setArgBufferWithAlloc(0u, allocationStruct.alignedAllocationPtr,
allocationStruct.alloc,
nullptr);
@@ -913,11 +915,25 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
return status;
}
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
Kernel *builtinKernel = nullptr;
bool isHeaplessEnabled = this->heaplessModeEnabled;
ImageBuiltin builtInType = ImageBuiltin::copyBufferToImage3dBytes;
switch (bytesPerPixel) {
case 1u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImage3dToBufferBytes>(isHeaplessEnabled);
break;
case 2u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImage3dToBuffer2Bytes>(isHeaplessEnabled);
break;
case 4u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImage3dToBuffer4Bytes>(isHeaplessEnabled);
break;
case 8u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImage3dToBuffer8Bytes>(isHeaplessEnabled);
break;
case 16u:
builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImage3dToBuffer16Bytes>(isHeaplessEnabled);
break;
default: {
CREATE_DEBUG_STRING(str, "Invalid bytesPerPixel of size: %u\n", bytesPerPixel);
driverHandle->setErrorDescription(std::string(str.get()));
@@ -925,23 +941,11 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemoryExt(voi
UNRECOVERABLE_IF(true);
break;
}
case 1u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImage3dToBufferBytes);
break;
case 2u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImage3dToBuffer2Bytes);
break;
case 4u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImage3dToBuffer4Bytes);
break;
case 8u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImage3dToBuffer8Bytes);
break;
case 16u:
builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImage3dToBuffer16Bytes);
break;
}
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
Kernel *builtinKernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType);
builtinKernel->setArgRedescribedImage(0u, image->toHandle());
builtinKernel->setArgBufferWithAlloc(1u, allocationStruct.alignedAllocationPtr,
allocationStruct.alloc,
@@ -1109,9 +1113,10 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyRegion(ze_image
return status;
}
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
ImageBuiltin builtInType = BuiltinTypeHelper::adjustImageBuiltinType<ImageBuiltin::copyImageRegion>(this->heaplessModeEnabled);
auto kernel = device->getBuiltinFunctionsLib()->getImageFunction(ImageBuiltin::copyImageRegion);
auto lock = device->getBuiltinFunctionsLib()->obtainUniqueOwnership();
auto kernel = device->getBuiltinFunctionsLib()->getImageFunction(builtInType);
ze_result_t ret = kernel->suggestGroupSize(groupSizeX, groupSizeY, groupSizeZ, &groupSizeX,
&groupSizeY, &groupSizeZ);

View File

@@ -192,6 +192,47 @@ HWTEST_F(TestBuiltinFunctionsLibImpl, givenHeaplessBuiltinsWhenInitBuiltinKernel
EXPECT_STREQ("FillBufferRightLeftoverStateless", lib.kernelNamePassed.c_str());
}
HWTEST_F(TestBuiltinFunctionsLibImpl, givenHeaplessImageBuiltinsWhenInitBuiltinKernelThenCorrectArgumentsArePassed) {
MockCheckPassedArgumentsBuiltinFunctionsLibImpl lib(device, device->getNEODevice()->getBuiltIns());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyBufferToImage3d16BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyBufferToImage3dHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyBufferToImage3d16Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyBufferToImage3d2BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyBufferToImage3dHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyBufferToImage3d2Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyBufferToImage3d4BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyBufferToImage3dHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyBufferToImage3d4Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyBufferToImage3d8BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyBufferToImage3dHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyBufferToImage3d8Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyImage3dToBuffer16BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyImage3dToBufferHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyImage3dToBuffer16Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyImage3dToBuffer2BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyImage3dToBufferHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyImage3dToBuffer2Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyImage3dToBuffer4BytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyImage3dToBufferHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyImage3dToBuffer4Bytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyImage3dToBufferBytesHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyImage3dToBufferHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyImage3dToBufferBytes", lib.kernelNamePassed.c_str());
lib.initBuiltinImageKernel(L0::ImageBuiltin::copyImageRegionHeapless);
EXPECT_EQ(NEO::EBuiltInOps::copyImageToImage3dHeapless, lib.builtinPassed);
EXPECT_STREQ("CopyImageToImage3d", lib.kernelNamePassed.c_str());
}
HWTEST_F(TestBuiltinFunctionsLibImpl, givenCompilerInterfaceWhenCreateDeviceAndImageSupportedThenBuiltinsImageFunctionsAreLoaded) {
ze_result_t returnValue = ZE_RESULT_SUCCESS;
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->compilerInterface.reset(new NEO::MockCompilerInterfaceSpirv());

View File

@@ -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;

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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());
}

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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>;

View File

@@ -26,18 +26,28 @@ inline constexpr Type fillBufferStateless{8};
inline constexpr Type fillBufferStatelessHeapless{9};
inline constexpr Type copyBufferToImage3d{10};
inline constexpr Type copyBufferToImage3dStateless{11};
inline constexpr Type copyImage3dToBuffer{12};
inline constexpr Type copyImage3dToBufferStateless{13};
inline constexpr Type copyImageToImage1d{14};
inline constexpr Type copyImageToImage2d{15};
inline constexpr Type copyImageToImage3d{16};
inline constexpr Type fillImage1d{17};
inline constexpr Type fillImage2d{18};
inline constexpr Type fillImage3d{19};
inline constexpr Type queryKernelTimestamps{20};
inline constexpr Type copyBufferToImage3dHeapless{12};
inline constexpr Type copyImage3dToBuffer{13};
inline constexpr Type copyImage3dToBufferStateless{14};
inline constexpr Type copyImage3dToBufferHeapless{15};
inline constexpr Type copyImageToImage1d{16};
inline constexpr Type copyImageToImage1dHeapless{17};
inline constexpr Type copyImageToImage2d{18};
inline constexpr Type copyImageToImage2dHeapless{19};
inline constexpr Type copyImageToImage3d{20};
inline constexpr Type copyImageToImage3dHeapless{21};
inline constexpr Type fillImage1d{22};
inline constexpr Type fillImage1dHeapless{23};
inline constexpr Type fillImage2d{24};
inline constexpr Type fillImage2dHeapless{25};
inline constexpr Type fillImage3d{26};
inline constexpr Type fillImage3dHeapless{27};
inline constexpr Type queryKernelTimestamps{28};
constexpr bool isStateless(Type type) {
constexpr std::array<Type, 8> statelessBuiltins{{copyBufferToBufferStateless, copyBufferRectStateless, fillBufferStateless, copyBufferToImage3dStateless, copyImage3dToBufferStateless, copyBufferToBufferStatelessHeapless, copyBufferRectStatelessHeapless, fillBufferStatelessHeapless}};
constexpr std::array<Type, 10> statelessBuiltins{{copyBufferToBufferStateless, copyBufferRectStateless, fillBufferStateless, copyBufferToImage3dStateless,
copyImage3dToBufferStateless, copyBufferToBufferStatelessHeapless, copyBufferRectStatelessHeapless, fillBufferStatelessHeapless,
copyBufferToImage3dHeapless, copyImage3dToBufferHeapless}};
for (auto builtinType : statelessBuiltins) {
if (type == builtinType) {
return true;
@@ -47,7 +57,10 @@ constexpr bool isStateless(Type type) {
}
constexpr bool isHeapless(Type type) {
constexpr Type statelessBuiltins[] = {copyBufferToBufferStatelessHeapless, copyBufferRectStatelessHeapless, fillBufferStatelessHeapless};
constexpr Type statelessBuiltins[] = {copyBufferToBufferStatelessHeapless, copyBufferRectStatelessHeapless, fillBufferStatelessHeapless,
copyBufferToImage3dHeapless, copyImage3dToBufferHeapless, copyImageToImage1dHeapless, copyImageToImage2dHeapless, copyImageToImage3dHeapless,
fillImage1dHeapless, fillImage2dHeapless, fillImage3dHeapless};
for (auto builtinType : statelessBuiltins) {
if (type == builtinType) {
return true;
@@ -93,7 +106,9 @@ constexpr uint32_t adjustBuiltinType<fillBuffer>(const bool useStateless, const
template <>
constexpr uint32_t adjustBuiltinType<copyBufferToImage3d>(const bool useStateless, const bool useHeapless) {
if (useStateless) {
if (useHeapless) {
return copyBufferToImage3dHeapless;
} else if (useStateless) {
return copyBufferToImage3dStateless;
}
return copyBufferToImage3d;
@@ -101,13 +116,33 @@ constexpr uint32_t adjustBuiltinType<copyBufferToImage3d>(const bool useStateles
template <>
constexpr uint32_t adjustBuiltinType<copyImage3dToBuffer>(const bool useStateless, const bool useHeapless) {
if (useStateless) {
if (useHeapless) {
return copyImage3dToBufferHeapless;
} else if (useStateless) {
return copyImage3dToBufferStateless;
}
return copyImage3dToBuffer;
}
inline constexpr Type maxBaseValue{20};
template <Type builtinType>
constexpr Type adjustImageBuiltinType(const bool useHeapless) {
return builtinType;
}
#define DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(type) \
template <> \
constexpr Type adjustImageBuiltinType<type>(const bool useHeapless) { \
return useHeapless ? type##Heapless : type; \
}
DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(copyImageToImage1d);
DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(copyImageToImage2d);
DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(copyImageToImage3d);
DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(fillImage1d);
DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(fillImage2d);
DEFINE_ADJUST_BUILTIN_TYPE_IMAGE(fillImage3d);
inline constexpr Type maxBaseValue{28};
inline constexpr Type count{64};
} // namespace EBuiltInOps
} // namespace NEO

View File

@@ -46,22 +46,30 @@ const char *getBuiltinAsString(EBuiltInOps::Type builtin) {
case EBuiltInOps::copyBufferToImage3d:
return "copy_buffer_to_image3d.builtin_kernel";
case EBuiltInOps::copyBufferToImage3dStateless:
case EBuiltInOps::copyBufferToImage3dHeapless:
return "copy_buffer_to_image3d_stateless.builtin_kernel";
case EBuiltInOps::copyImage3dToBuffer:
return "copy_image3d_to_buffer.builtin_kernel";
case EBuiltInOps::copyImage3dToBufferStateless:
case EBuiltInOps::copyImage3dToBufferHeapless:
return "copy_image3d_to_buffer_stateless.builtin_kernel";
case EBuiltInOps::copyImageToImage1d:
case EBuiltInOps::copyImageToImage1dHeapless:
return "copy_image_to_image1d.builtin_kernel";
case EBuiltInOps::copyImageToImage2d:
case EBuiltInOps::copyImageToImage2dHeapless:
return "copy_image_to_image2d.builtin_kernel";
case EBuiltInOps::copyImageToImage3d:
case EBuiltInOps::copyImageToImage3dHeapless:
return "copy_image_to_image3d.builtin_kernel";
case EBuiltInOps::fillImage1d:
case EBuiltInOps::fillImage1dHeapless:
return "fill_image1d.builtin_kernel";
case EBuiltInOps::fillImage2d:
case EBuiltInOps::fillImage2dHeapless:
return "fill_image2d.builtin_kernel";
case EBuiltInOps::fillImage3d:
case EBuiltInOps::fillImage3dHeapless:
return "fill_image3d.builtin_kernel";
case EBuiltInOps::queryKernelTimestamps:
return "copy_kernel_timestamps.builtin_kernel";

View File

@@ -120,6 +120,8 @@ struct UnitTestHelper {
static void getSpaceAndInitWalkerCmd(LinearStream &stream, bool heapless);
static void *getInitWalkerCmd(bool heapless);
static size_t getWalkerSize(bool isHeaplessEnabled);
static bool isHeaplessAllowed();
};
} // namespace NEO

View File

@@ -137,4 +137,9 @@ size_t UnitTestHelper<GfxFamily>::getWalkerSize(bool isHeaplessEnabled) {
return sizeof(DefaultWalkerType);
}
template <typename GfxFamily>
bool UnitTestHelper<GfxFamily>::isHeaplessAllowed() {
return false;
}
} // namespace NEO

View File

@@ -124,9 +124,43 @@ HWTEST_F(BuiltInSharedTest, GivenRequestedTypeIntermediateWhenGettingResourceNam
}
HWTEST_F(BuiltInSharedTest, GivenValidBuiltinTypeAndExtensionWhenCreatingBuiltinResourceNameThenCorrectNameIsReturned) {
std::string builtinResourceName = createBuiltinResourceName(EBuiltInOps::copyBufferToBuffer, ".bin");
std::string expectedBuiltinResourceName = std::string(getBuiltinAsString(EBuiltInOps::copyBufferToBuffer)) + ".bin";
EXPECT_EQ(expectedBuiltinResourceName, builtinResourceName);
const std::pair<EBuiltInOps::Type, const char *> testCases[] = {
{EBuiltInOps::auxTranslation, "aux_translation.builtin_kernel"},
{EBuiltInOps::copyBufferToBuffer, "copy_buffer_to_buffer.builtin_kernel"},
{EBuiltInOps::copyBufferToBufferStateless, "copy_buffer_to_buffer_stateless.builtin_kernel"},
{EBuiltInOps::copyBufferToBufferStatelessHeapless, "copy_buffer_to_buffer_stateless.builtin_kernel"},
{EBuiltInOps::copyBufferRect, "copy_buffer_rect.builtin_kernel"},
{EBuiltInOps::copyBufferRectStateless, "copy_buffer_rect_stateless.builtin_kernel"},
{EBuiltInOps::copyBufferRectStatelessHeapless, "copy_buffer_rect_stateless.builtin_kernel"},
{EBuiltInOps::fillBuffer, "fill_buffer.builtin_kernel"},
{EBuiltInOps::fillBufferStateless, "fill_buffer_stateless.builtin_kernel"},
{EBuiltInOps::fillBufferStatelessHeapless, "fill_buffer_stateless.builtin_kernel"},
{EBuiltInOps::copyBufferToImage3d, "copy_buffer_to_image3d.builtin_kernel"},
{EBuiltInOps::copyBufferToImage3dStateless, "copy_buffer_to_image3d_stateless.builtin_kernel"},
{EBuiltInOps::copyBufferToImage3dHeapless, "copy_buffer_to_image3d_stateless.builtin_kernel"},
{EBuiltInOps::copyImage3dToBuffer, "copy_image3d_to_buffer.builtin_kernel"},
{EBuiltInOps::copyImage3dToBufferStateless, "copy_image3d_to_buffer_stateless.builtin_kernel"},
{EBuiltInOps::copyImage3dToBufferHeapless, "copy_image3d_to_buffer_stateless.builtin_kernel"},
{EBuiltInOps::copyImageToImage1d, "copy_image_to_image1d.builtin_kernel"},
{EBuiltInOps::copyImageToImage1dHeapless, "copy_image_to_image1d.builtin_kernel"},
{EBuiltInOps::copyImageToImage2d, "copy_image_to_image2d.builtin_kernel"},
{EBuiltInOps::copyImageToImage2dHeapless, "copy_image_to_image2d.builtin_kernel"},
{EBuiltInOps::copyImageToImage3d, "copy_image_to_image3d.builtin_kernel"},
{EBuiltInOps::copyImageToImage3dHeapless, "copy_image_to_image3d.builtin_kernel"},
{EBuiltInOps::fillImage1d, "fill_image1d.builtin_kernel"},
{EBuiltInOps::fillImage1dHeapless, "fill_image1d.builtin_kernel"},
{EBuiltInOps::fillImage2d, "fill_image2d.builtin_kernel"},
{EBuiltInOps::fillImage2dHeapless, "fill_image2d.builtin_kernel"},
{EBuiltInOps::fillImage3d, "fill_image3d.builtin_kernel"},
{EBuiltInOps::fillImage3dHeapless, "fill_image3d.builtin_kernel"},
{EBuiltInOps::queryKernelTimestamps, "copy_kernel_timestamps.builtin_kernel"}};
for (const auto &[type, name] : testCases) {
std::string builtinResourceName = createBuiltinResourceName(type, ".bin");
std::string expectedBuiltinResourceName = std::string(name) + ".bin";
EXPECT_EQ(expectedBuiltinResourceName, builtinResourceName);
}
}
HWTEST_F(BuiltInSharedTest, GivenValidBuiltinTypeAndAnyTypeWhenGettingBuiltinCodeThenNonEmptyBuiltinIsReturned) {