2021-10-29 03:07:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/test/common/fixtures/device_fixture.h"
|
2021-11-05 00:38:47 +08:00
|
|
|
#include "shared/test/common/helpers/default_hw_info.h"
|
|
|
|
#include "shared/test/common/helpers/variable_backup.h"
|
2021-12-29 00:44:23 +08:00
|
|
|
#include "shared/test/common/mocks/mock_compiler_interface.h"
|
|
|
|
#include "shared/test/common/mocks/mock_compilers.h"
|
2021-11-05 00:38:47 +08:00
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
|
|
|
#include "shared/test/common/mocks/ult_device_factory.h"
|
2021-12-15 01:40:08 +08:00
|
|
|
#include "shared/test/common/test_macros/test.h"
|
2021-10-29 03:07:28 +08:00
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
TEST(DeviceBlitterTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineIsReturned) {
|
2021-11-05 00:38:47 +08:00
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = false;
|
2021-10-29 03:07:28 +08:00
|
|
|
|
2021-11-05 00:38:47 +08:00
|
|
|
UltDeviceFactory factory{1, 0};
|
|
|
|
EXPECT_EQ(nullptr, factory.rootDevices[0]->getInternalCopyEngine());
|
2021-10-29 03:07:28 +08:00
|
|
|
}
|
2021-11-09 01:03:15 +08:00
|
|
|
|
2021-07-28 12:31:52 +08:00
|
|
|
TEST(DeviceBlitterTest, givenBlitterOperationsDisabledWhenCreatingBlitterEngineThenAbort) {
|
2021-11-09 01:03:15 +08:00
|
|
|
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
|
|
|
|
defaultHwInfo->capabilityTable.blitterOperationsSupported = false;
|
|
|
|
|
|
|
|
UltDeviceFactory factory{1, 0};
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Regular}), std::runtime_error);
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Cooperative}), std::runtime_error);
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Internal}), std::runtime_error);
|
|
|
|
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::LowPriority}), std::runtime_error);
|
|
|
|
}
|
2021-07-28 12:31:52 +08:00
|
|
|
|
|
|
|
using DeviceTest = Test<DeviceFixture>;
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledAndRtBackedBufferIsNullptrThenMemoryBackedBufferIsCreated) {
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTMemoryBackedBuffer());
|
|
|
|
EXPECT_EQ(false, pDevice->rayTracingIsInitialized());
|
|
|
|
pDevice->initializeRayTracing(0);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTMemoryBackedBuffer());
|
|
|
|
EXPECT_EQ(true, pDevice->rayTracingIsInitialized());
|
|
|
|
pDevice->initializeRayTracing(0);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTMemoryBackedBuffer());
|
|
|
|
EXPECT_EQ(true, pDevice->rayTracingIsInitialized());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithUnsupportedBVHLevelsThenNullptrIsReturned) {
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(100));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledWithMockAllocatorThenRTDispatchGlobalsIsAllocated) {
|
|
|
|
pDevice->setRTDispatchGlobalsForceAllocation();
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledMultipleTimesWithMockAllocatorThenInitializeRayTracingIsIdempotent) {
|
|
|
|
pDevice->setRTDispatchGlobalsForceAllocation();
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledBeforeInitializationThenNullPtrIsReturned) {
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithZeroSizeAndMockAllocatorThenDispatchGlobalsIsReturned) {
|
|
|
|
pDevice->setRTDispatchGlobalsForceAllocation();
|
|
|
|
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(0));
|
|
|
|
pDevice->initializeRayTracing(5);
|
|
|
|
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(0));
|
|
|
|
}
|
2021-12-27 20:44:57 +08:00
|
|
|
|
|
|
|
using DeviceGetCapsTest = Test<DeviceFixture>;
|
|
|
|
|
2021-12-29 00:44:23 +08:00
|
|
|
TEST_F(DeviceGetCapsTest, givenMockCompilerInterfaceWhenInitializeCapsIsCalledThenMaxParameterSizeIsSetCorrectly) {
|
|
|
|
auto pCompilerInterface = new MockCompilerInterface;
|
|
|
|
pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->compilerInterface.reset(pCompilerInterface);
|
|
|
|
pDevice->maxParameterSizeFromIGC = 2u;
|
|
|
|
pDevice->callBaseGetMaxParameterSizeFromIGC = true;
|
|
|
|
MockIgcFeaturesAndWorkarounds mockIgcFtrWa;
|
|
|
|
pCompilerInterface->igcFeaturesAndWorkaroundsTagOCL = &mockIgcFtrWa;
|
|
|
|
|
|
|
|
mockIgcFtrWa.maxOCLParamSize = 0u;
|
2021-12-27 20:44:57 +08:00
|
|
|
pDevice->initializeCaps();
|
2021-12-29 00:44:23 +08:00
|
|
|
EXPECT_EQ(2048u, pDevice->getDeviceInfo().maxParameterSize);
|
|
|
|
|
|
|
|
mockIgcFtrWa.maxOCLParamSize = 1u;
|
|
|
|
pDevice->initializeCaps();
|
|
|
|
EXPECT_EQ(1u, pDevice->getDeviceInfo().maxParameterSize);
|
|
|
|
}
|