2021-07-21 08:47:43 +00:00
|
|
|
/*
|
2024-12-20 17:29:21 +00:00
|
|
|
* Copyright (C) 2021-2025 Intel Corporation
|
2021-07-21 08:47:43 +00:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2023-07-06 10:05:58 +00:00
|
|
|
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
2021-07-21 08:47:43 +00:00
|
|
|
#include "shared/test/common/helpers/unit_test_helper.h"
|
2021-11-10 12:09:53 +01:00
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
2023-10-14 11:32:40 +00:00
|
|
|
#include "shared/test/common/mocks/mock_ail_configuration.h"
|
2023-07-06 10:05:58 +00:00
|
|
|
#include "shared/test/common/mocks/mock_execution_environment.h"
|
2022-06-29 19:17:47 +00:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2021-07-21 08:47:43 +00:00
|
|
|
|
|
|
|
|
namespace NEO {
|
2022-06-10 15:11:17 +00:00
|
|
|
using IsDG2 = IsProduct<IGFX_DG2>;
|
2021-07-21 08:47:43 +00:00
|
|
|
|
|
|
|
|
using AILTests = ::testing::Test;
|
|
|
|
|
|
2023-10-31 02:33:24 +00:00
|
|
|
TEST(AILTests, whenAILConfigurationCreateFunctionIsCalledWithUnknownGfxCoreThenNullptrIsReturned) {
|
|
|
|
|
EXPECT_EQ(nullptr, AILConfiguration::create(IGFX_UNKNOWN));
|
2021-07-21 08:47:43 +00:00
|
|
|
}
|
2021-11-10 12:09:53 +01:00
|
|
|
|
2024-09-17 11:32:35 +00:00
|
|
|
HWTEST2_F(AILTests, givenInitilizedTemplateWhenApplyWithBlenderIsCalledThenFP64SupportIsEnabled, MatchAny) {
|
2023-10-31 02:33:24 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
|
|
|
|
ail.processName = "blender";
|
2021-11-10 12:09:53 +01:00
|
|
|
|
2024-12-20 17:29:21 +00:00
|
|
|
HardwareInfo hwInfo = {};
|
|
|
|
|
NEO::RuntimeCapabilityTable &rtTable = hwInfo.capabilityTable;
|
2021-11-10 12:09:53 +01:00
|
|
|
rtTable.ftrSupportsFP64 = false;
|
|
|
|
|
|
2024-12-20 17:29:21 +00:00
|
|
|
ail.apply(hwInfo);
|
2021-11-10 12:09:53 +01:00
|
|
|
|
|
|
|
|
EXPECT_EQ(rtTable.ftrSupportsFP64, true);
|
|
|
|
|
}
|
2022-06-10 15:11:17 +00:00
|
|
|
|
2024-09-17 11:32:35 +00:00
|
|
|
HWTEST2_F(AILTests, givenInitilizedTemplateWhenApplyWithAdobePremiereProIsCalledThenPreferredPlatformNameIsSet, MatchAny) {
|
2023-10-31 02:33:24 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
|
|
|
|
ail.processName = "Adobe Premiere Pro";
|
2023-09-11 21:29:01 +00:00
|
|
|
|
2024-12-20 17:29:21 +00:00
|
|
|
HardwareInfo hwInfo = {};
|
|
|
|
|
NEO::RuntimeCapabilityTable &rtTable = hwInfo.capabilityTable;
|
2023-09-11 21:29:01 +00:00
|
|
|
rtTable.preferredPlatformName = nullptr;
|
|
|
|
|
|
2024-12-20 17:29:21 +00:00
|
|
|
ail.apply(hwInfo);
|
2023-09-11 21:29:01 +00:00
|
|
|
|
|
|
|
|
EXPECT_NE(nullptr, rtTable.preferredPlatformName);
|
|
|
|
|
EXPECT_STREQ("Intel(R) OpenCL", rtTable.preferredPlatformName);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-17 11:32:35 +00:00
|
|
|
HWTEST2_F(AILTests, whenCheckingIfSourcesContainKernelThenCorrectResultIsReturned, MatchAny) {
|
2023-10-31 02:33:24 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
2022-06-15 11:49:38 +00:00
|
|
|
|
|
|
|
|
std::string kernelSources = R"(
|
|
|
|
|
__kernel void CopyBufferToBufferLeftLeftover(
|
|
|
|
|
const __global uchar* pSrc,
|
|
|
|
|
__global uchar* pDst,
|
|
|
|
|
uint srcOffsetInBytes,
|
|
|
|
|
uint dstOffsetInBytes)
|
|
|
|
|
{
|
|
|
|
|
unsigned int gid = get_global_id(0);
|
|
|
|
|
pDst[ gid + dstOffsetInBytes ] = pSrc[ gid + srcOffsetInBytes ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__kernel void CopyBufferToBufferMiddle(
|
|
|
|
|
const __global uint* pSrc,
|
|
|
|
|
__global uint* pDst,
|
|
|
|
|
uint srcOffsetInBytes,
|
|
|
|
|
uint dstOffsetInBytes)
|
|
|
|
|
{
|
|
|
|
|
unsigned int gid = get_global_id(0);
|
|
|
|
|
pDst += dstOffsetInBytes >> 2;
|
|
|
|
|
pSrc += srcOffsetInBytes >> 2;
|
|
|
|
|
uint4 loaded = vload4(gid, pSrc);
|
|
|
|
|
vstore4(loaded, gid, pDst);)";
|
|
|
|
|
|
2023-01-11 16:46:43 +00:00
|
|
|
EXPECT_TRUE(ail.sourcesContain(kernelSources, "CopyBufferToBufferMiddle"));
|
|
|
|
|
EXPECT_FALSE(ail.sourcesContain(kernelSources, "CopyBufferToBufferMiddleStateless"));
|
2022-06-15 11:49:38 +00:00
|
|
|
}
|
|
|
|
|
|
2024-09-17 11:32:35 +00:00
|
|
|
HWTEST2_F(AILTests, whenCheckingIsKernelHashCorrectThenCorrectResultIsReturned, MatchAny) {
|
2023-10-31 02:33:24 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
2022-06-15 11:49:38 +00:00
|
|
|
|
|
|
|
|
std::string kernelSources = R"(
|
|
|
|
|
__kernel void CopyBufferToBufferLeftLeftover(
|
|
|
|
|
const __global uchar* pSrc,
|
|
|
|
|
__global uchar* pDst,
|
|
|
|
|
uint srcOffsetInBytes,
|
|
|
|
|
uint dstOffsetInBytes)
|
|
|
|
|
{
|
|
|
|
|
unsigned int gid = get_global_id(0);
|
|
|
|
|
pDst[ gid + dstOffsetInBytes ] = pSrc[ gid + srcOffsetInBytes ];
|
|
|
|
|
}
|
|
|
|
|
)";
|
|
|
|
|
|
|
|
|
|
auto expectedHash = 0xafeba928e880fd89;
|
|
|
|
|
|
|
|
|
|
// If this check fails, probably hash algorithm has been changed.
|
|
|
|
|
// In this case we must regenerate hashes in AIL applications kernels
|
|
|
|
|
EXPECT_TRUE(ail.isKernelHashCorrect(kernelSources, expectedHash));
|
|
|
|
|
|
|
|
|
|
kernelSources.insert(0, "text");
|
|
|
|
|
EXPECT_FALSE(ail.isKernelHashCorrect(kernelSources, expectedHash));
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-17 11:32:35 +00:00
|
|
|
HWTEST2_F(AILTests, whenModifyKernelIfRequiredIsCalledThenDontChangeKernelSources, MatchAny) {
|
2023-10-31 02:33:24 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
2022-06-15 11:49:38 +00:00
|
|
|
|
|
|
|
|
std::string kernelSources = "example_kernel(){}";
|
|
|
|
|
auto copyKernel = kernelSources;
|
|
|
|
|
|
|
|
|
|
ail.modifyKernelIfRequired(kernelSources);
|
|
|
|
|
|
|
|
|
|
EXPECT_STREQ(copyKernel.c_str(), kernelSources.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-20 09:25:25 +00:00
|
|
|
HWTEST2_F(AILTests, givenAilWhenCheckingContextSyncFlagRequiredThenExpectFalse, MatchAny) {
|
2023-10-31 02:33:24 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
|
|
|
|
ail.processName = "other";
|
|
|
|
|
EXPECT_FALSE(ail.isContextSyncFlagRequired());
|
2023-10-14 11:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
2024-11-20 09:25:25 +00:00
|
|
|
HWTEST2_F(AILTests, givenAilWhenCheckingOverfetchDisableRequiredThenExpectFalse, MatchAny) {
|
2024-09-30 09:34:50 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
|
|
|
|
ail.processName = "other";
|
|
|
|
|
EXPECT_FALSE(ail.is256BPrefetchDisableRequired());
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-20 09:25:25 +00:00
|
|
|
HWTEST2_F(AILTests, givenAilWhenCheckingDrainHostptrsRequiredThenExpectTrue, MatchAny) {
|
2024-11-19 10:52:40 +00:00
|
|
|
AILWhitebox<productFamily> ail;
|
|
|
|
|
ail.processName = "other";
|
|
|
|
|
EXPECT_TRUE(ail.drainHostptrs());
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-11 10:18:07 +00:00
|
|
|
HWTEST2_F(AILTests, givenAilWhenGetMicrosecondResolutionCalledThenCorrectValueReturned, MatchAny) {
|
|
|
|
|
AILWhitebox<productFamily> ail;
|
|
|
|
|
EXPECT_EQ(ail.getMicrosecondResolution(), microsecondAdjustment);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-10 15:11:17 +00:00
|
|
|
} // namespace NEO
|