mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
Zebin: Create mock zebin module for L0 common test module
Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
8da78d3ed4
commit
497e5a4765
@@ -12,12 +12,12 @@
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
|
||||
#include "level_zero/core/source/module/module.h"
|
||||
#include "level_zero/core/source/module/module_imp.h"
|
||||
@@ -156,22 +156,15 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
|
||||
DeviceFixture::setupWithExecutionEnvironment(*executionEnvironment);
|
||||
}
|
||||
|
||||
void createModuleFromBinary(uint32_t perHwThreadPrivateMemorySize, bool isInternal, MockImmutableData *mockKernelImmData) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
void createModuleFromMockBinary(uint32_t perHwThreadPrivateMemorySize, bool isInternal, MockImmutableData *mockKernelImmData,
|
||||
std::initializer_list<ZebinTestData::appendElfAdditionalSection> additionalSections = {}) {
|
||||
zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo(), additionalSections);
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
@@ -201,6 +194,7 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::unique_ptr<MockModule> module;
|
||||
std::unique_ptr<ZebinTestData::ZebinWithL0TestCommonModule> zebinData;
|
||||
MockImmutableMemoryManager *memoryManager;
|
||||
};
|
||||
|
||||
@@ -208,25 +202,17 @@ struct ModuleFixture : public DeviceFixture {
|
||||
void setUp() {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
DeviceFixture::setUp();
|
||||
createModuleFromBinary();
|
||||
createModuleFromMockBinary();
|
||||
}
|
||||
|
||||
void createModuleFromBinary(ModuleType type = ModuleType::User) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
void createModuleFromMockBinary(ModuleType type = ModuleType::User) {
|
||||
zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
@@ -248,11 +234,11 @@ struct ModuleFixture : public DeviceFixture {
|
||||
DeviceFixture::tearDown();
|
||||
}
|
||||
|
||||
const std::string binaryFilename = "test_kernel";
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::unique_ptr<L0::Module> module;
|
||||
std::unique_ptr<WhiteBox<::L0::Kernel>> kernel;
|
||||
std::unique_ptr<ZebinTestData::ZebinWithL0TestCommonModule> zebinData;
|
||||
};
|
||||
|
||||
struct MultiDeviceModuleFixture : public MultiDeviceFixture {
|
||||
@@ -261,24 +247,18 @@ struct MultiDeviceModuleFixture : public MultiDeviceFixture {
|
||||
modules.resize(numRootDevices);
|
||||
}
|
||||
|
||||
void createModuleFromBinary(uint32_t rootDeviceIndex) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
void createModuleFromMockBinary(uint32_t rootDeviceIndex) {
|
||||
auto device = driverHandle->devices[rootDeviceIndex];
|
||||
zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto device = driverHandle->devices[rootDeviceIndex];
|
||||
modules[rootDeviceIndex].reset(Module::create(device,
|
||||
&moduleDesc,
|
||||
moduleBuildLog, ModuleType::User));
|
||||
@@ -301,11 +281,11 @@ struct MultiDeviceModuleFixture : public MultiDeviceFixture {
|
||||
MultiDeviceFixture::tearDown();
|
||||
}
|
||||
|
||||
const std::string binaryFilename = "test_kernel";
|
||||
const std::string kernelName = "test";
|
||||
const uint32_t numKernelArguments = 6;
|
||||
std::vector<std::unique_ptr<L0::Module>> modules;
|
||||
std::unique_ptr<WhiteBox<::L0::Kernel>> kernel;
|
||||
std::unique_ptr<ZebinTestData::ZebinWithL0TestCommonModule> zebinData;
|
||||
};
|
||||
|
||||
struct ModuleWithZebinFixture : public DeviceFixture {
|
||||
@@ -428,7 +408,7 @@ struct MultiTileModuleFixture : public MultiDeviceModuleFixture {
|
||||
MultiDeviceFixture::numSubDevices = 2u;
|
||||
|
||||
MultiDeviceModuleFixture::setUp();
|
||||
createModuleFromBinary(0);
|
||||
createModuleFromMockBinary(0);
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ void MultiTileCommandListAppendLaunchFunctionFixture::setUp() {
|
||||
MultiDeviceFixture::numSubDevices = 4u;
|
||||
|
||||
MultiDeviceModuleFixture::setUp();
|
||||
createModuleFromBinary(0u);
|
||||
createModuleFromMockBinary(0u);
|
||||
createKernel(0u);
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
@@ -49,7 +49,7 @@ void MultiTileImmediateCommandListAppendLaunchFunctionFixture::setUp() {
|
||||
MultiDeviceFixture::numSubDevices = 2u;
|
||||
|
||||
MultiDeviceModuleFixture::setUp();
|
||||
createModuleFromBinary(0u);
|
||||
createModuleFromMockBinary(0u);
|
||||
createKernel(0u);
|
||||
|
||||
device = driverHandle->devices[0];
|
||||
|
||||
@@ -475,7 +475,7 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
||||
auto kernelDescriptor = mockKernelImmData->kernelDescriptor;
|
||||
kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = false;
|
||||
kernelDescriptor->kernelAttributes.perThreadScratchSize[0] = scratchPerThreadSize;
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -518,7 +518,7 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests,
|
||||
kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = false;
|
||||
kernelDescriptor->kernelAttributes.perThreadScratchSize[0] = scratchPerThreadSize;
|
||||
kernelDescriptor->kernelAttributes.perThreadScratchSize[1] = privateScratchPerThreadSize;
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
|
||||
@@ -958,7 +958,7 @@ struct CmdlistAppendLaunchKernelWithImplicitArgsTests : CmdlistAppendLaunchKerne
|
||||
kernelDescriptor->kernelAttributes.workgroupDimensionsOrder[0] = workgroupDimOrder[0];
|
||||
kernelDescriptor->kernelAttributes.workgroupDimensionsOrder[1] = workgroupDimOrder[1];
|
||||
kernelDescriptor->kernelAttributes.workgroupDimensionsOrder[2] = workgroupDimOrder[2];
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -1108,7 +1108,7 @@ HWTEST_F(CmdlistAppendLaunchKernelTests, givenKernelWithoutImplicitArgsWhenAppen
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(0u);
|
||||
auto kernelDescriptor = mockKernelImmData->kernelDescriptor;
|
||||
kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = false;
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -1146,7 +1146,7 @@ HWTEST2_F(CmdlistAppendLaunchKernelTests, givenKernelWitchScratchAndPrivateWhenA
|
||||
kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = false;
|
||||
kernelDescriptor->kernelAttributes.perThreadScratchSize[0] = 0x200;
|
||||
kernelDescriptor->kernelAttributes.perThreadScratchSize[1] = 0x100;
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
|
||||
@@ -793,36 +793,32 @@ HWTEST_F(NotifyModuleLoadTest, givenDebuggingEnabledWhenModuleIsCreatedAndFullyL
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto elfAdditionalSections = {ZebinTestData::appendElfAdditionalSection::CONSTANT}; //for const surface allocation copy
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo(), elfAdditionalSections);
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
neoDevice->executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(nullptr);
|
||||
|
||||
auto module = std::unique_ptr<L0::ModuleImp>(new L0::ModuleImp(device, moduleBuildLog, ModuleType::User));
|
||||
auto module = std::make_unique<WhiteBox<::L0::Module>>(device, moduleBuildLog, ModuleType::User);
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
|
||||
memoryOperationsHandler->makeResidentCalledCount = 0;
|
||||
|
||||
auto linkerInput = std::make_unique<::WhiteBox<NEO::LinkerInput>>();
|
||||
linkerInput->traits.requiresPatchingOfInstructionSegments = true;
|
||||
module->translationUnit->programInfo.linkerInput = std::move(linkerInput);
|
||||
module->initialize(&moduleDesc, neoDevice);
|
||||
|
||||
auto numIsaAllocations = static_cast<int>(module->getKernelImmutableDataVector().size());
|
||||
|
||||
auto expectedMakeResidentCallsCount = numIsaAllocations + 1; // const surface
|
||||
if (module->getTranslationUnit()->programInfo.linkerInput) {
|
||||
expectedMakeResidentCallsCount += numIsaAllocations;
|
||||
}
|
||||
auto expectedMakeResidentCallsCount = numIsaAllocations + 1; //const surface
|
||||
expectedMakeResidentCallsCount += numIsaAllocations;
|
||||
|
||||
EXPECT_EQ(expectedMakeResidentCallsCount, memoryOperationsHandler->makeResidentCalledCount);
|
||||
|
||||
@@ -855,19 +851,13 @@ HWTEST_F(NotifyModuleLoadTest, givenDebuggingEnabledWhenModuleWithUnresolvedSymb
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
@@ -909,19 +899,13 @@ HWTEST_F(NotifyModuleLoadTest, givenDebuggingEnabledWhenModuleWithUnresolvedSymb
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ TEST_F(KernelInitTest, givenKernelToInitWhenItHasUnknownArgThenUnknowKernelArgHa
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData =
|
||||
std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
ze_kernel_desc_t desc = {};
|
||||
@@ -69,7 +69,7 @@ TEST_F(KernelBaseAddressTests, whenQueryingKernelBaseAddressThenCorrectAddressIs
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData =
|
||||
std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
ze_kernel_desc_t desc = {};
|
||||
@@ -486,7 +486,7 @@ TEST_F(KernelImmutableDataTests, givenKernelInitializedWithNoPrivateMemoryThenPr
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
@@ -502,7 +502,7 @@ TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenPriv
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
@@ -530,7 +530,8 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenUserKernelIsCreatedThenIsaIsCopiedWh
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
auto additionalSections = {ZebinTestData::appendElfAdditionalSection::GLOBAL};
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get(), additionalSections);
|
||||
|
||||
size_t copyForGlobalSurface = 1u;
|
||||
auto copyForIsa = module->getKernelImmutableDataVector().size();
|
||||
@@ -556,7 +557,7 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForUserKer
|
||||
bool isInternal = false;
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
uint32_t previouscopyMemoryToAllocationCalledTimes =
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes;
|
||||
@@ -579,7 +580,7 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForInterna
|
||||
bool isInternal = true;
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
uint32_t previouscopyMemoryToAllocationCalledTimes =
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes;
|
||||
@@ -609,7 +610,8 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaIs
|
||||
size_t previouscopyMemoryToAllocationCalledTimes =
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes;
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
auto additionalSections = {ZebinTestData::appendElfAdditionalSection::GLOBAL};
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get(), additionalSections);
|
||||
|
||||
size_t copyForGlobalSurface = 1u;
|
||||
size_t copyForPatchingIsa = 0u;
|
||||
@@ -690,20 +692,13 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedIsaIsNotC
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenContainerHasOneExtraSpaceForAllocation) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
size);
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
uint32_t perHwThreadPrivateMemorySizeRequested = 32u;
|
||||
@@ -746,20 +741,12 @@ TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenCont
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenKernelWithPrivateMemoryBiggerThanGlobalMemoryThenPrivateMemoryIsNotAllocated) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
size);
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
uint32_t perHwThreadPrivateMemorySizeRequested = std::numeric_limits<uint32_t>::max();
|
||||
@@ -1087,7 +1074,7 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, whenInitializingKernelWithNoKernelL
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData =
|
||||
std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
kernel = std::make_unique<ModuleImmutableDataFixture::MockKernel>(module.get());
|
||||
@@ -1114,7 +1101,7 @@ TEST_F(KernelIndirectPropertiesFromIGCTests, whenInitializingKernelWithKernelLoa
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData =
|
||||
std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
{
|
||||
std::unique_ptr<ModuleImmutableDataFixture::MockKernel> kernel;
|
||||
@@ -2338,7 +2325,7 @@ TEST_F(KernelWorkDimTests, givenGroupCountsWhenPatchingWorkDimThenCrossThreadDat
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData =
|
||||
std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, false, mockKernelImmData.get());
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
createKernel(kernel.get());
|
||||
kernel->setCrossThreadData(sizeof(uint32_t));
|
||||
@@ -2473,7 +2460,7 @@ TEST_F(KernelPatchtokensPrintfStringMapTests, givenKernelWithPrintfStringsMapUsa
|
||||
std::string expectedString("test123");
|
||||
kernelDescriptor->kernelMetadata.printfStringsMap.insert(std::make_pair(0u, expectedString));
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -2501,7 +2488,7 @@ TEST_F(KernelPatchtokensPrintfStringMapTests, givenKernelWithPrintfStringsMapUsa
|
||||
std::string expectedString("test123");
|
||||
kernelDescriptor->kernelMetadata.printfStringsMap.insert(std::make_pair(0u, expectedString));
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -2529,7 +2516,7 @@ TEST_F(KernelPatchtokensPrintfStringMapTests, givenKernelWithPrintfStringsMapUsa
|
||||
std::string expectedString("test123");
|
||||
kernelDescriptor->kernelMetadata.printfStringsMap.insert(std::make_pair(0u, expectedString));
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -2553,7 +2540,7 @@ TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenInitializeThenPrin
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = true;
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.usesPrintf = false;
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -2576,7 +2563,7 @@ TEST_F(KernelImplicitArgTests, givenImplicitArgsRequiredWhenCreatingKernelThenIm
|
||||
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = true;
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
@@ -2596,7 +2583,7 @@ TEST_F(KernelImplicitArgTests, givenKernelWithImplicitArgsWhenSettingKernelParam
|
||||
mockKernelImmData->kernelDescriptor->kernelAttributes.flags.requiresImplicitArgs = true;
|
||||
auto simd = mockKernelImmData->kernelDescriptor->kernelAttributes.simdSize;
|
||||
|
||||
createModuleFromBinary(0u, false, mockKernelImmData.get());
|
||||
createModuleFromMockBinary(0u, false, mockKernelImmData.get());
|
||||
|
||||
auto kernel = std::make_unique<MockKernel>(module.get());
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_driver_model.h"
|
||||
#include "shared/test/common/mocks/mock_memory_manager.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
@@ -2131,22 +2132,13 @@ TEST_F(MultipleDevicePeerAllocationFailTest,
|
||||
}
|
||||
|
||||
struct MultipleDevicePeerAllocationTest : public ::testing::Test {
|
||||
void createModuleFromBinary(L0::Device *device, ModuleType type = ModuleType::User) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(
|
||||
testFile.c_str(),
|
||||
size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
|
||||
void createModuleFromMockBinary(L0::Device *device, ModuleType type = ModuleType::User) {
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
@@ -2669,7 +2661,7 @@ HWTEST_F(MultipleDevicePeerAllocationTest,
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_NE(nullptr, ptr1);
|
||||
|
||||
createModuleFromBinary(device1);
|
||||
MultipleDevicePeerAllocationTest::createModuleFromMockBinary(device1);
|
||||
createKernel();
|
||||
|
||||
// set argument in device 1's list with ptr from device 0: peer allocation is created
|
||||
@@ -2712,7 +2704,7 @@ HWTEST_F(MultipleDevicePeerAllocationTest,
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
|
||||
createModuleFromBinary(device1);
|
||||
MultipleDevicePeerAllocationTest::createModuleFromMockBinary(device1);
|
||||
createKernel();
|
||||
|
||||
result = kernel->setArgBuffer(0, sizeof(ptr), &ptr);
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/test/common/compiler_interface/linker_mock.h"
|
||||
#include "shared/test/common/device_binary_format/patchtokens_tests.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_elf.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "level_zero/core/source/context/context.h"
|
||||
@@ -100,7 +100,7 @@ HWTEST_F(ModuleTest, givenUserModuleWhenCreatedThenCorrectAllocationTypeIsUsedFo
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTest, givenBuiltinModuleWhenCreatedThenCorrectAllocationTypeIsUsedForIsa) {
|
||||
createModuleFromBinary(ModuleType::Builtin);
|
||||
createModuleFromMockBinary(ModuleType::Builtin);
|
||||
createKernel();
|
||||
EXPECT_EQ(NEO::AllocationType::KERNEL_ISA_INTERNAL, kernel->getIsaAllocation()->getAllocationType());
|
||||
}
|
||||
@@ -126,19 +126,13 @@ HWTEST_F(ModuleTest, givenBlitterAvailableWhenCopyingPatchedSegmentsThenIsaIsTra
|
||||
Mock<L0::DeviceImp> device(neoMockDevice, neoMockDevice->getExecutionEnvironment());
|
||||
device.driverHandle = driverHandle.get();
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device.getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
@@ -157,7 +151,7 @@ HWTEST_F(ModuleTest, givenBlitterAvailableWhenCopyingPatchedSegmentsThenIsaIsTra
|
||||
|
||||
const auto &hwInfoConfig = *HwInfoConfig::get(hwInfo.platform.eProductFamily);
|
||||
if (hwInfoConfig.isBlitCopyRequiredForLocalMemory(hwInfo, *module->getKernelImmutableDataVector()[0]->getIsaGraphicsAllocation())) {
|
||||
EXPECT_EQ(8u, blitterCalled);
|
||||
EXPECT_EQ(zebinData->numOfKernels, blitterCalled);
|
||||
} else {
|
||||
EXPECT_EQ(0u, blitterCalled);
|
||||
}
|
||||
@@ -1663,23 +1657,17 @@ TEST_F(ModuleDynamicLinkTest, givenUnresolvedSymbolsWhenModuleIsCreatedThenIsaAl
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto module = std::unique_ptr<Module>(new Module(device, moduleBuildLog, ModuleType::User));
|
||||
auto module = std::make_unique<Module>(device, moduleBuildLog, ModuleType::User);
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
|
||||
NEO::Linker::RelocationInfo unresolvedRelocation;
|
||||
@@ -1861,7 +1849,7 @@ class DeviceModuleSetArgBufferTest : public ModuleFixture, public ::testing::Tes
|
||||
HWTEST_F(DeviceModuleSetArgBufferTest,
|
||||
givenValidMemoryUsedinFirstCallToSetArgBufferThenNullptrSetOnTheSecondCallThenArgBufferisUpdatedInEachCallAndSuccessIsReturned) {
|
||||
uint32_t rootDeviceIndex = 0;
|
||||
createModuleFromBinary();
|
||||
createModuleFromMockBinary();
|
||||
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
void *validBufferPtr = nullptr;
|
||||
@@ -1924,7 +1912,7 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
givenCallsToSetArgBufferThenAllocationIsSetForCorrectDevice) {
|
||||
|
||||
for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < numRootDevices; rootDeviceIndex++) {
|
||||
createModuleFromBinary(rootDeviceIndex);
|
||||
createModuleFromMockBinary(rootDeviceIndex);
|
||||
|
||||
ze_kernel_handle_t kernelHandle;
|
||||
void *ptr = nullptr;
|
||||
@@ -1947,19 +1935,13 @@ HWTEST_F(MultiDeviceModuleSetArgBufferTest,
|
||||
using ContextModuleCreateTest = Test<DeviceFixture>;
|
||||
|
||||
HWTEST_F(ContextModuleCreateTest, givenCallToCreateModuleThenModuleIsReturned) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
ze_module_handle_t hModule;
|
||||
ze_device_handle_t hDevice = device->toHandle();
|
||||
@@ -1995,19 +1977,13 @@ HWTEST_F(ModuleTranslationUnitTest, GivenRebuildPrecompiledKernelsFlagAndFileWit
|
||||
DebugManagerStateRestore dgbRestorer;
|
||||
NEO::DebugManager.flags.RebuildPrecompiledKernels.set(true);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".gen");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
Module module(device, nullptr, ModuleType::User);
|
||||
MockModuleTU *tu = new MockModuleTU(device);
|
||||
@@ -2023,19 +1999,13 @@ HWTEST_F(ModuleTranslationUnitTest, GivenRebuildPrecompiledKernelsFlagAndFileWit
|
||||
DebugManagerStateRestore dgbRestorer;
|
||||
NEO::DebugManager.flags.RebuildPrecompiledKernels.set(true);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
Module module(device, nullptr, ModuleType::User);
|
||||
MockModuleTU *tu = new MockModuleTU(device);
|
||||
@@ -2051,19 +2021,15 @@ HWTEST_F(ModuleTranslationUnitTest, GivenRebuildFlagWhenCreatingModuleFromNative
|
||||
DebugManagerStateRestore dgbRestorer;
|
||||
NEO::DebugManager.flags.RebuildPrecompiledKernels.set(true);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto additionalSections = {ZebinTestData::appendElfAdditionalSection::SPIRV};
|
||||
bool forceRecompilation = true;
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo(), additionalSections, forceRecompilation);
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
std::unique_ptr<ModuleBuildLog> moduleBuildLog{ModuleBuildLog::create()};
|
||||
Module module(device, moduleBuildLog.get(), ModuleType::User);
|
||||
@@ -2089,19 +2055,15 @@ HWTEST_F(ModuleTranslationUnitTest, GivenRebuildFlagWhenCreatingModuleFromNative
|
||||
DebugManagerStateRestore dgbRestorer;
|
||||
NEO::DebugManager.flags.RebuildPrecompiledKernels.set(true);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto additionalSections = {ZebinTestData::appendElfAdditionalSection::SPIRV};
|
||||
bool forceRecompilation = true;
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo(), additionalSections, forceRecompilation);
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
moduleDesc.pBuildFlags = CompilerOptions::noRecompiledFromIr.data();
|
||||
|
||||
std::unique_ptr<ModuleBuildLog> moduleBuildLog{ModuleBuildLog::create()};
|
||||
@@ -2189,7 +2151,7 @@ HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromZebinThenAppendAllowZebinFla
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTranslationUnitTest, WhenCreatingFromZeBinaryThenLinkerInputIsCreated) {
|
||||
std::string validZeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : some_kernel
|
||||
execution_env :
|
||||
@@ -2217,7 +2179,7 @@ kernels:
|
||||
}
|
||||
|
||||
TEST_F(ModuleTranslationUnitTest, WhenCreatingFromZeBinaryAndGlobalsAreExportedThenTheirAllocationTypeIsSVM) {
|
||||
std::string zeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string zeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : kernel
|
||||
execution_env :
|
||||
@@ -2389,19 +2351,13 @@ TEST(ModuleBuildLog, WhenTooSmallBufferIsPassedToGetStringThenErrorIsReturned) {
|
||||
using PrintfModuleTest = Test<DeviceFixture>;
|
||||
|
||||
HWTEST_F(PrintfModuleTest, GivenModuleWithPrintfWhenKernelIsCreatedThenPrintfAllocationIsPlacedInResidencyContainer) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".gen");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
auto module = std::unique_ptr<L0::Module>(Module::create(device, &moduleDesc, nullptr, ModuleType::User));
|
||||
|
||||
@@ -2663,16 +2619,12 @@ TEST_F(ModuleInitializeTest, whenModuleInitializeIsCalledThenCorrectResultIsRetu
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".bin");
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
moduleDesc.inputSize = src.size();
|
||||
|
||||
std::array<std::tuple<bool, bool, ModuleType, int32_t>, 5> testParams = {{
|
||||
{true, false, ModuleType::Builtin, -1},
|
||||
@@ -3048,7 +3000,8 @@ TEST_F(ModuleIsaCopyTest, whenModuleIsInitializedThenIsaIsCopied) {
|
||||
|
||||
uint32_t previouscopyMemoryToAllocationCalledTimes = mockMemoryManager->copyMemoryToAllocationCalledTimes;
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
auto additionalSections = {ZebinTestData::appendElfAdditionalSection::GLOBAL};
|
||||
createModuleFromMockBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get(), additionalSections);
|
||||
|
||||
uint32_t numOfKernels = static_cast<uint32_t>(module->getKernelImmutableDataVector().size());
|
||||
const uint32_t numOfGlobalBuffers = 1;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/test/common/helpers/test_files.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "level_zero/core/source/image/image.h"
|
||||
@@ -23,18 +24,13 @@ class ModuleOnlineCompiled : public DeviceFixture, public testing::Test {
|
||||
void SetUp() override {
|
||||
DeviceFixture::setUp();
|
||||
|
||||
std::string kernelFilename;
|
||||
size_t spvModuleSize = 0;
|
||||
retrieveBinaryKernelFilenameApiSpecific(kernelFilename, "test_kernel_", ".bin");
|
||||
|
||||
auto spvModule = loadDataFromFile(kernelFilename.c_str(), spvModuleSize);
|
||||
|
||||
ASSERT_NE(0U, spvModuleSize);
|
||||
auto zebinData = std::make_unique<ZebinTestData::ZebinWithL0TestCommonModule>(device->getHwInfo());
|
||||
const auto &src = zebinData->storage;
|
||||
|
||||
ze_module_desc_t modDesc = {};
|
||||
modDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
modDesc.inputSize = static_cast<uint32_t>(spvModuleSize);
|
||||
modDesc.pInputModule = reinterpret_cast<const uint8_t *>(spvModule.get());
|
||||
modDesc.inputSize = static_cast<uint32_t>(src.size());
|
||||
modDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.data());
|
||||
|
||||
module.reset(whiteboxCast(Module::create(device, &modDesc, nullptr, ModuleType::User)));
|
||||
ASSERT_NE(nullptr, module);
|
||||
@@ -244,6 +240,21 @@ TEST_F(ModuleOnlineCompiled, GivenKernelThenCorrectPropertiesAreReturned) {
|
||||
}
|
||||
|
||||
TEST_F(ModuleOnlineCompiled, GivenKernelThenCorrectAttributesAreReturned) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameApiSpecific(testFile, "test_kernel_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
|
||||
auto module = std::unique_ptr<L0::ModuleImp>(new L0::ModuleImp(device, nullptr, ModuleType::User));
|
||||
module->initialize(&moduleDesc, device->getNEODevice());
|
||||
|
||||
ze_kernel_desc_t kernelDesc = {};
|
||||
kernelDesc.pKernelName = "memcpy_bytes_attr";
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ set(IGDRCL_SRCS_offline_compiler_tests
|
||||
${NEO_SHARED_DIRECTORY}/memory_manager/deferred_deleter.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compilers.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_compilers.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/device_binary_format/zebin_tests.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_modules_zebin.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_modules_zebin.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/test_files.cpp
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/libult/signal_utils.h
|
||||
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_excludes.cpp
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "shared/offline_compiler/source/ocloc_validator.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
|
||||
#include "opencl/test/unit_test/offline_compiler/mock/mock_argument_helper.h"
|
||||
|
||||
@@ -80,7 +80,7 @@ TEST(OclocValidate, WhenWarningsEmitedThenRedirectsThemToStdout) {
|
||||
TEST(OclocValidate, WhenErrorsEmitedThenRedirectsThemToStdout) {
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
std::string zeInfo = "version:" + toString(NEO::zeInfoDecoderVersion) + "\nkernels : \nkernels :\n";
|
||||
std::string zeInfo = "version:" + versionToString(NEO::zeInfoDecoderVersion) + "\nkernels : \nkernels :\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const char>(zeInfo).toArrayRef<const uint8_t>());
|
||||
MockOclocArgHelper::FilesMap files{{"src.gen", MockOclocArgHelper::FileData(reinterpret_cast<const char *>(zebin.storage.data()),
|
||||
reinterpret_cast<const char *>(zebin.storage.data()) + zebin.storage.size())}};
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
#include "shared/source/helpers/file_io.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/product_config_helper.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
|
||||
#include "compiler_options.h"
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "shared/source/memory_manager/surface.h"
|
||||
#include "shared/source/os_interface/os_context.h"
|
||||
#include "shared/test/common/device_binary_format/patchtokens_tests.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/helpers/kernel_binary_helper.h"
|
||||
@@ -36,6 +35,7 @@
|
||||
#include "shared/test/common/mocks/mock_allocation_properties.h"
|
||||
#include "shared/test/common/mocks/mock_compiler_interface.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/hw_test.h"
|
||||
#include "shared/test/common/utilities/base_object_utils.h"
|
||||
|
||||
@@ -2092,7 +2092,7 @@ TEST_F(ProgramTests, GivenNullContextWhenCreatingProgramFromGenBinaryThenSuccess
|
||||
|
||||
TEST_F(ProgramTests, givenValidZebinPrepareLinkerInput) {
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
const std::string validZeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
const std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : some_kernel
|
||||
execution_env :
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "opencl/test/unit_test/program/program_with_zebin.h"
|
||||
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
|
||||
#include "opencl/test/unit_test/mocks/mock_buffer.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/mocks/mock_source_level_debugger.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
target_sources(neo_libult_common PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/patchtokens_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/zebin_tests.h
|
||||
)
|
||||
@@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
#include "shared/source/device_binary_format/zebin_decoder.h"
|
||||
#include "shared/source/utilities/const_stringref.h"
|
||||
#include "shared/test/common/mocks/mock_elf.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern PRODUCT_FAMILY productFamily;
|
||||
|
||||
inline std::string toString(NEO::Elf::ZebinKernelMetadata::Types::Version version) {
|
||||
return std::to_string(version.major) + "." + std::to_string(version.minor);
|
||||
}
|
||||
|
||||
namespace ZebinTestData {
|
||||
|
||||
struct ValidEmptyProgram {
|
||||
static constexpr char kernelName[19] = "valid_empty_kernel";
|
||||
|
||||
ValidEmptyProgram() {
|
||||
NEO::Elf::ElfEncoder<> enc;
|
||||
enc.getElfFileHeader().type = NEO::Elf::ET_ZEBIN_EXE;
|
||||
enc.getElfFileHeader().machine = productFamily;
|
||||
auto zeInfo = std::string{"---\nversion : \'" + toString(NEO::zeInfoDecoderVersion) + "\'" + "\nkernels : \n - name : " + kernelName + "\n execution_env : \n simd_size : 32\n grf_count : 128\n...\n"};
|
||||
enc.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, zeInfo);
|
||||
enc.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "valid_empty_kernel", zeInfo);
|
||||
storage = enc.encode();
|
||||
recalcPtr(); // NOLINT(clang-analyzer-optin.cplusplus.VirtualCall)
|
||||
}
|
||||
|
||||
virtual void recalcPtr() {
|
||||
elfHeader = reinterpret_cast<NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *>(storage.data());
|
||||
}
|
||||
|
||||
template <typename SectionHeaderEnumT>
|
||||
NEO::Elf::ElfSectionHeader<NEO::Elf::EI_CLASS_64> &appendSection(SectionHeaderEnumT sectionType, NEO::ConstStringRef sectionLabel, const ArrayRef<const uint8_t> sectionData) {
|
||||
std::string err, warn;
|
||||
auto decoded = NEO::Elf::decodeElf(storage, err, warn);
|
||||
NEO::Elf::ElfEncoder<NEO::Elf::EI_CLASS_64> enc;
|
||||
enc.getElfFileHeader() = *decoded.elfFileHeader;
|
||||
int sectionIt = 0;
|
||||
auto sectionHeaderNamesData = decoded.sectionHeaders[decoded.elfFileHeader->shStrNdx].data;
|
||||
NEO::ConstStringRef sectionHeaderNamesString(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (const auto §ion : decoded.sectionHeaders) {
|
||||
switch (section.header->type) {
|
||||
case NEO::Elf::SHN_UNDEF:
|
||||
break;
|
||||
case NEO::Elf::SHT_STRTAB:
|
||||
if (decoded.elfFileHeader->shStrNdx != sectionIt) {
|
||||
enc.appendSection(section.header->type, sectionHeaderNamesString.data() + section.header->name, section.data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
enc.appendSection(section.header->type, sectionHeaderNamesString.data() + section.header->name, section.data);
|
||||
break;
|
||||
}
|
||||
++sectionIt;
|
||||
}
|
||||
enc.appendSection(static_cast<NEO::Elf::SECTION_HEADER_TYPE>(sectionType), sectionLabel, sectionData);
|
||||
storage = enc.encode();
|
||||
recalcPtr();
|
||||
decoded = NEO::Elf::decodeElf(storage, err, warn);
|
||||
sectionHeaderNamesData = decoded.sectionHeaders[decoded.elfFileHeader->shStrNdx].data;
|
||||
sectionHeaderNamesString = NEO::ConstStringRef(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (const auto §ion : decoded.sectionHeaders) {
|
||||
if ((sectionType == section.header->type) && (sectionLabel == sectionHeaderNamesString.data() + section.header->name)) {
|
||||
return const_cast<NEO::Elf::ElfSectionHeader<NEO::Elf::EI_CLASS_64> &>(*section.header);
|
||||
}
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
template <typename SectionHeaderEnumT>
|
||||
void removeSection(SectionHeaderEnumT sectionType, NEO::ConstStringRef sectionLabel) {
|
||||
std::string err, warn;
|
||||
auto decoded = NEO::Elf::decodeElf(storage, err, warn);
|
||||
NEO::Elf::ElfEncoder<NEO::Elf::EI_CLASS_64> enc;
|
||||
enc.getElfFileHeader() = *decoded.elfFileHeader;
|
||||
int sectionIt = 0;
|
||||
auto sectionHeaderNamesData = decoded.sectionHeaders[decoded.elfFileHeader->shStrNdx].data;
|
||||
NEO::ConstStringRef sectionHeaderNamesString(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (const auto §ion : decoded.sectionHeaders) {
|
||||
bool add = true;
|
||||
switch (section.header->type) {
|
||||
case NEO::Elf::SHN_UNDEF:
|
||||
add = false;
|
||||
break;
|
||||
case NEO::Elf::SHT_STRTAB:
|
||||
add = (decoded.elfFileHeader->shStrNdx != sectionIt);
|
||||
break;
|
||||
default:
|
||||
add = ((section.header->type != sectionType) || (sectionHeaderNamesString.data() + section.header->name != sectionLabel));
|
||||
break;
|
||||
}
|
||||
if (add) {
|
||||
enc.appendSection(section.header->type, sectionHeaderNamesString.data() + section.header->name, section.data);
|
||||
}
|
||||
++sectionIt;
|
||||
}
|
||||
if (decoded.elfFileHeader->shNum <= 3) {
|
||||
enc.appendSection(NEO::Elf::SHT_STRTAB, "", {});
|
||||
}
|
||||
storage = enc.encode();
|
||||
recalcPtr();
|
||||
}
|
||||
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *elfHeader;
|
||||
std::vector<uint8_t> storage;
|
||||
};
|
||||
|
||||
struct ZebinWithExternalFunctionsInfo {
|
||||
ZebinWithExternalFunctionsInfo() {
|
||||
std::string zeInfo = std::string("version :\'") + toString(NEO::zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name: kernel
|
||||
execution_env:
|
||||
simd_size: 8
|
||||
- name: Intel_Symbol_Table_Void_Program
|
||||
execution_env:
|
||||
simd_size: 8
|
||||
functions:
|
||||
- name: fun0
|
||||
execution_env:
|
||||
grf_count: 128
|
||||
simd_size: 8
|
||||
barrier_count: 0
|
||||
- name: fun1
|
||||
execution_env:
|
||||
grf_count: 128
|
||||
simd_size: 8
|
||||
barrier_count: 2
|
||||
)===";
|
||||
MockElfEncoder<> elfEncoder;
|
||||
auto &elfHeader = elfEncoder.getElfFileHeader();
|
||||
elfHeader.type = NEO::Elf::ET_ZEBIN_EXE;
|
||||
elfHeader.flags = 0U;
|
||||
|
||||
const uint8_t kData[32] = {0U};
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel", kData);
|
||||
auto kernelSectionIdx = elfEncoder.getLastSectionHeaderIndex();
|
||||
|
||||
const uint8_t funData[32] = {0U};
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + NEO::Elf::SectionsNamesZebin::externalFunctions.str(), funData);
|
||||
auto externalFunctionsIdx = elfEncoder.getLastSectionHeaderIndex();
|
||||
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, zeInfo);
|
||||
|
||||
NEO::Elf::ElfSymbolEntry<NEO::Elf::EI_CLASS_64> symbols[2];
|
||||
symbols[0].name = decltype(symbols[0].name)(elfEncoder.appendSectionName(fun0Name));
|
||||
symbols[0].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_FUNC | NEO::Elf::SYMBOL_TABLE_BIND::STB_GLOBAL << 4;
|
||||
symbols[0].shndx = decltype(symbols[0].shndx)(externalFunctionsIdx);
|
||||
symbols[0].size = 16;
|
||||
symbols[0].value = 0;
|
||||
|
||||
symbols[1].name = decltype(symbols[1].name)(elfEncoder.appendSectionName(fun1Name));
|
||||
symbols[1].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_FUNC | NEO::Elf::SYMBOL_TABLE_BIND::STB_GLOBAL << 4;
|
||||
symbols[1].shndx = decltype(symbols[1].shndx)(externalFunctionsIdx);
|
||||
symbols[1].size = 16;
|
||||
symbols[1].value = 16;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_SYMTAB, NEO::Elf::SectionsNamesZebin::symtab,
|
||||
ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(symbols), sizeof(symbols)));
|
||||
|
||||
NEO::Elf::ElfRel<NEO::Elf::EI_CLASS_64> extFuncSegReloc = {}; // fun0 calls fun1
|
||||
extFuncSegReloc.offset = 0x8;
|
||||
extFuncSegReloc.info = (uint64_t(1) << 32) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
|
||||
auto &extFuncRelSection = elfEncoder.appendSection(NEO::Elf::SHT_REL, NEO::Elf::SpecialSectionNames::relPrefix.str() + NEO::Elf::SectionsNamesZebin::textPrefix.str() + NEO::Elf::SectionsNamesZebin::externalFunctions.str(),
|
||||
{reinterpret_cast<uint8_t *>(&extFuncSegReloc), sizeof(extFuncSegReloc)});
|
||||
extFuncRelSection.info = externalFunctionsIdx;
|
||||
|
||||
NEO::Elf::ElfRel<NEO::Elf::EI_CLASS_64>
|
||||
kernelSegReloc = {}; // kernel calls fun0
|
||||
kernelSegReloc.offset = 0x8;
|
||||
kernelSegReloc.info = (uint64_t(0) << 32) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
|
||||
auto &kernelRelSection = elfEncoder.appendSection(NEO::Elf::SHT_REL, NEO::Elf::SpecialSectionNames::relPrefix.str() + NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel",
|
||||
{reinterpret_cast<uint8_t *>(&kernelSegReloc), sizeof(kernelSegReloc)});
|
||||
kernelRelSection.info = kernelSectionIdx;
|
||||
|
||||
storage = elfEncoder.encode();
|
||||
recalcPtr();
|
||||
|
||||
nameToSegId["kernel"] = 0;
|
||||
nameToSegId["Intel_Symbol_Table_Void_Program"] = 1;
|
||||
}
|
||||
|
||||
void recalcPtr() {
|
||||
elfHeader = reinterpret_cast<NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *>(storage.data());
|
||||
}
|
||||
|
||||
void setProductFamily(uint16_t productFamily) {
|
||||
elfHeader->machine = productFamily;
|
||||
}
|
||||
|
||||
NEO::Elf::Elf<NEO::Elf::EI_CLASS_64> getElf() {
|
||||
std::string errors, warnings;
|
||||
auto elf = NEO::Elf::decodeElf({storage.data(), storage.size()}, errors, warnings);
|
||||
return elf;
|
||||
}
|
||||
std::unordered_map<std::string, uint32_t> nameToSegId;
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *elfHeader;
|
||||
NEO::ConstStringRef fun0Name = "fun0";
|
||||
NEO::ConstStringRef fun1Name = "fun1";
|
||||
const uint8_t barrierCount = 2;
|
||||
std::vector<uint8_t> storage;
|
||||
};
|
||||
} // namespace ZebinTestData
|
||||
@@ -68,6 +68,8 @@ set(NEO_CORE_tests_mocks
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_memory_operations_handler.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_migration_sync_data.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_modules_zebin.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_modules_zebin.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_multi_graphics_allocation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_context.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/mock_os_library.h
|
||||
|
||||
214
shared/test/common/mocks/mock_modules_zebin.cpp
Normal file
214
shared/test/common/mocks/mock_modules_zebin.cpp
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/helpers/compiler_hw_info_config.h"
|
||||
|
||||
namespace ZebinTestData {
|
||||
|
||||
ValidEmptyProgram::ValidEmptyProgram() {
|
||||
NEO::Elf::ElfEncoder<> enc;
|
||||
enc.getElfFileHeader().type = NEO::Elf::ET_ZEBIN_EXE;
|
||||
enc.getElfFileHeader().machine = productFamily;
|
||||
auto zeInfo = std::string{"---\nversion : \'" + versionToString(NEO::zeInfoDecoderVersion) + "\'" + "\nkernels : \n - name : " + kernelName + "\n execution_env : \n simd_size : 32\n grf_count : 128\n...\n"};
|
||||
enc.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, zeInfo);
|
||||
enc.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "valid_empty_kernel", zeInfo);
|
||||
storage = enc.encode();
|
||||
recalcPtr();
|
||||
}
|
||||
|
||||
void ValidEmptyProgram::recalcPtr() {
|
||||
elfHeader = reinterpret_cast<NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *>(storage.data());
|
||||
}
|
||||
|
||||
NEO::Elf::ElfSectionHeader<NEO::Elf::EI_CLASS_64> &ValidEmptyProgram::appendSection(uint32_t sectionType, NEO::ConstStringRef sectionLabel, const ArrayRef<const uint8_t> sectionData) {
|
||||
std::string err, warn;
|
||||
auto decoded = NEO::Elf::decodeElf(storage, err, warn);
|
||||
NEO::Elf::ElfEncoder<NEO::Elf::EI_CLASS_64> enc;
|
||||
enc.getElfFileHeader() = *decoded.elfFileHeader;
|
||||
int sectionIt = 0;
|
||||
auto sectionHeaderNamesData = decoded.sectionHeaders[decoded.elfFileHeader->shStrNdx].data;
|
||||
NEO::ConstStringRef sectionHeaderNamesString(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (const auto §ion : decoded.sectionHeaders) {
|
||||
switch (section.header->type) {
|
||||
case NEO::Elf::SHN_UNDEF:
|
||||
break;
|
||||
case NEO::Elf::SHT_STRTAB:
|
||||
if (decoded.elfFileHeader->shStrNdx != sectionIt) {
|
||||
enc.appendSection(section.header->type, sectionHeaderNamesString.data() + section.header->name, section.data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
enc.appendSection(section.header->type, sectionHeaderNamesString.data() + section.header->name, section.data);
|
||||
break;
|
||||
}
|
||||
++sectionIt;
|
||||
}
|
||||
enc.appendSection(sectionType, sectionLabel, sectionData);
|
||||
storage = enc.encode();
|
||||
recalcPtr();
|
||||
decoded = NEO::Elf::decodeElf(storage, err, warn);
|
||||
sectionHeaderNamesData = decoded.sectionHeaders[decoded.elfFileHeader->shStrNdx].data;
|
||||
sectionHeaderNamesString = NEO::ConstStringRef(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (const auto §ion : decoded.sectionHeaders) {
|
||||
if ((sectionType == section.header->type) && (sectionLabel == sectionHeaderNamesString.data() + section.header->name)) {
|
||||
return const_cast<NEO::Elf::ElfSectionHeader<NEO::Elf::EI_CLASS_64> &>(*section.header);
|
||||
}
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
void ValidEmptyProgram::removeSection(uint32_t sectionType, NEO::ConstStringRef sectionLabel) {
|
||||
std::string err, warn;
|
||||
auto decoded = NEO::Elf::decodeElf(storage, err, warn);
|
||||
NEO::Elf::ElfEncoder<NEO::Elf::EI_CLASS_64> enc;
|
||||
enc.getElfFileHeader() = *decoded.elfFileHeader;
|
||||
int sectionIt = 0;
|
||||
auto sectionHeaderNamesData = decoded.sectionHeaders[decoded.elfFileHeader->shStrNdx].data;
|
||||
NEO::ConstStringRef sectionHeaderNamesString(reinterpret_cast<const char *>(sectionHeaderNamesData.begin()), sectionHeaderNamesData.size());
|
||||
for (const auto §ion : decoded.sectionHeaders) {
|
||||
bool add = true;
|
||||
switch (section.header->type) {
|
||||
case NEO::Elf::SHN_UNDEF:
|
||||
add = false;
|
||||
break;
|
||||
case NEO::Elf::SHT_STRTAB:
|
||||
add = (decoded.elfFileHeader->shStrNdx != sectionIt);
|
||||
break;
|
||||
default:
|
||||
add = ((section.header->type != sectionType) || (sectionHeaderNamesString.data() + section.header->name != sectionLabel));
|
||||
break;
|
||||
}
|
||||
if (add) {
|
||||
enc.appendSection(section.header->type, sectionHeaderNamesString.data() + section.header->name, section.data);
|
||||
}
|
||||
++sectionIt;
|
||||
}
|
||||
if (decoded.elfFileHeader->shNum <= 3) {
|
||||
enc.appendSection(NEO::Elf::SHT_STRTAB, "", {});
|
||||
}
|
||||
storage = enc.encode();
|
||||
recalcPtr();
|
||||
}
|
||||
|
||||
ZebinWithExternalFunctionsInfo::ZebinWithExternalFunctionsInfo() {
|
||||
MockElfEncoder<> elfEncoder;
|
||||
auto &elfHeader = elfEncoder.getElfFileHeader();
|
||||
elfHeader.type = NEO::Elf::ET_ZEBIN_EXE;
|
||||
elfHeader.flags = 0U;
|
||||
|
||||
const uint8_t kData[32] = {0U};
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel", kData);
|
||||
auto kernelSectionIdx = elfEncoder.getLastSectionHeaderIndex();
|
||||
|
||||
const uint8_t funData[32] = {0U};
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + NEO::Elf::SectionsNamesZebin::externalFunctions.str(), funData);
|
||||
auto externalFunctionsIdx = elfEncoder.getLastSectionHeaderIndex();
|
||||
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, zeInfo);
|
||||
|
||||
NEO::Elf::ElfSymbolEntry<NEO::Elf::EI_CLASS_64> symbols[2];
|
||||
symbols[0].name = decltype(symbols[0].name)(elfEncoder.appendSectionName(fun0Name));
|
||||
symbols[0].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_FUNC | NEO::Elf::SYMBOL_TABLE_BIND::STB_GLOBAL << 4;
|
||||
symbols[0].shndx = decltype(symbols[0].shndx)(externalFunctionsIdx);
|
||||
symbols[0].size = 16;
|
||||
symbols[0].value = 0;
|
||||
|
||||
symbols[1].name = decltype(symbols[1].name)(elfEncoder.appendSectionName(fun1Name));
|
||||
symbols[1].info = NEO::Elf::SYMBOL_TABLE_TYPE::STT_FUNC | NEO::Elf::SYMBOL_TABLE_BIND::STB_GLOBAL << 4;
|
||||
symbols[1].shndx = decltype(symbols[1].shndx)(externalFunctionsIdx);
|
||||
symbols[1].size = 16;
|
||||
symbols[1].value = 16;
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_SYMTAB, NEO::Elf::SectionsNamesZebin::symtab,
|
||||
ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(symbols), sizeof(symbols)));
|
||||
|
||||
NEO::Elf::ElfRel<NEO::Elf::EI_CLASS_64> extFuncSegReloc = {}; // fun0 calls fun1
|
||||
extFuncSegReloc.offset = 0x8;
|
||||
extFuncSegReloc.info = (uint64_t(1) << 32) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
|
||||
auto &extFuncRelSection = elfEncoder.appendSection(NEO::Elf::SHT_REL, NEO::Elf::SpecialSectionNames::relPrefix.str() + NEO::Elf::SectionsNamesZebin::textPrefix.str() + NEO::Elf::SectionsNamesZebin::externalFunctions.str(),
|
||||
{reinterpret_cast<uint8_t *>(&extFuncSegReloc), sizeof(extFuncSegReloc)});
|
||||
extFuncRelSection.info = externalFunctionsIdx;
|
||||
|
||||
NEO::Elf::ElfRel<NEO::Elf::EI_CLASS_64>
|
||||
kernelSegReloc = {}; // kernel calls fun0
|
||||
kernelSegReloc.offset = 0x8;
|
||||
kernelSegReloc.info = (uint64_t(0) << 32) | NEO::Elf::RELOC_TYPE_ZEBIN::R_ZE_SYM_ADDR;
|
||||
auto &kernelRelSection = elfEncoder.appendSection(NEO::Elf::SHT_REL, NEO::Elf::SpecialSectionNames::relPrefix.str() + NEO::Elf::SectionsNamesZebin::textPrefix.str() + "kernel",
|
||||
{reinterpret_cast<uint8_t *>(&kernelSegReloc), sizeof(kernelSegReloc)});
|
||||
kernelRelSection.info = kernelSectionIdx;
|
||||
|
||||
storage = elfEncoder.encode();
|
||||
recalcPtr();
|
||||
|
||||
nameToSegId["kernel"] = 0;
|
||||
nameToSegId["Intel_Symbol_Table_Void_Program"] = 1;
|
||||
}
|
||||
|
||||
void ZebinWithExternalFunctionsInfo::recalcPtr() {
|
||||
elfHeader = reinterpret_cast<NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *>(storage.data());
|
||||
}
|
||||
|
||||
void ZebinWithExternalFunctionsInfo::setProductFamily(uint16_t productFamily) {
|
||||
elfHeader->machine = productFamily;
|
||||
}
|
||||
|
||||
NEO::Elf::Elf<NEO::Elf::EI_CLASS_64> ZebinWithExternalFunctionsInfo::getElf() {
|
||||
std::string errors, warnings;
|
||||
auto elf = NEO::Elf::decodeElf({storage.data(), storage.size()}, errors, warnings);
|
||||
return elf;
|
||||
}
|
||||
|
||||
ZebinWithL0TestCommonModule::ZebinWithL0TestCommonModule(const NEO::HardwareInfo &hwInfo, std::initializer_list<appendElfAdditionalSection> additionalSections, bool forceRecompilation) {
|
||||
MockElfEncoder<> elfEncoder;
|
||||
auto &elfHeader = elfEncoder.getElfFileHeader();
|
||||
elfHeader.type = NEO::Elf::ET_ZEBIN_EXE;
|
||||
if (forceRecompilation) {
|
||||
elfHeader.machine = NEO::Elf::EM_NONE;
|
||||
} else {
|
||||
auto adjustedHwInfo = hwInfo;
|
||||
NEO::CompilerHwInfoConfig::get(productFamily)->adjustHwInfoForIgc(adjustedHwInfo);
|
||||
elfHeader.machine = adjustedHwInfo.platform.eProductFamily;
|
||||
}
|
||||
|
||||
const uint8_t testKernelData[0xac0] = {0u};
|
||||
const uint8_t testKernelMemcpyBytesData[0x2c0] = {0u};
|
||||
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "test", testKernelData);
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::textPrefix.str() + "memcpy_bytes", testKernelMemcpyBytesData);
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, zeInfo);
|
||||
|
||||
const uint8_t testAdditionalSectionsData[0x10] = {0u};
|
||||
for (const auto &s : additionalSections) {
|
||||
switch (s) {
|
||||
case appendElfAdditionalSection::SPIRV:
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_ZEBIN_SPIRV, NEO::Elf::SectionsNamesZebin::spv, testAdditionalSectionsData);
|
||||
break;
|
||||
case appendElfAdditionalSection::GLOBAL:
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::dataGlobal, testAdditionalSectionsData);
|
||||
break;
|
||||
case appendElfAdditionalSection::CONSTANT:
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::dataConst, testAdditionalSectionsData);
|
||||
break;
|
||||
case appendElfAdditionalSection::CONSTANT_STRING:
|
||||
elfEncoder.appendSection(NEO::Elf::SHT_PROGBITS, NEO::Elf::SectionsNamesZebin::dataConstString.str(), testAdditionalSectionsData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
storage = elfEncoder.encode();
|
||||
recalcPtr();
|
||||
}
|
||||
|
||||
void ZebinWithL0TestCommonModule::recalcPtr() {
|
||||
elfHeader = reinterpret_cast<NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *>(storage.data());
|
||||
}
|
||||
|
||||
}; // namespace ZebinTestData
|
||||
261
shared/test/common/mocks/mock_modules_zebin.h
Normal file
261
shared/test/common/mocks/mock_modules_zebin.h
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
#include "shared/source/device_binary_format/zebin_decoder.h"
|
||||
#include "shared/source/utilities/const_stringref.h"
|
||||
#include "shared/test/common/mocks/mock_elf.h"
|
||||
|
||||
#include "igfxfmid.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
extern PRODUCT_FAMILY productFamily;
|
||||
|
||||
inline std::string versionToString(NEO::Elf::ZebinKernelMetadata::Types::Version version) {
|
||||
return std::to_string(version.major) + "." + std::to_string(version.minor);
|
||||
}
|
||||
|
||||
namespace ZebinTestData {
|
||||
|
||||
enum class appendElfAdditionalSection {
|
||||
NONE,
|
||||
SPIRV,
|
||||
GLOBAL,
|
||||
CONSTANT,
|
||||
CONSTANT_STRING
|
||||
};
|
||||
|
||||
struct ValidEmptyProgram {
|
||||
static constexpr char kernelName[19] = "valid_empty_kernel";
|
||||
|
||||
ValidEmptyProgram();
|
||||
void recalcPtr();
|
||||
NEO::Elf::ElfSectionHeader<NEO::Elf::EI_CLASS_64> &appendSection(uint32_t sectionType, NEO::ConstStringRef sectionLabel, const ArrayRef<const uint8_t> sectionData);
|
||||
void removeSection(uint32_t sectionType, NEO::ConstStringRef sectionLabel);
|
||||
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *elfHeader;
|
||||
std::vector<uint8_t> storage;
|
||||
};
|
||||
|
||||
struct ZebinWithExternalFunctionsInfo {
|
||||
ZebinWithExternalFunctionsInfo();
|
||||
|
||||
void recalcPtr();
|
||||
void setProductFamily(uint16_t productFamily);
|
||||
NEO::Elf::Elf<NEO::Elf::EI_CLASS_64> getElf();
|
||||
|
||||
std::unordered_map<std::string, uint32_t> nameToSegId;
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *elfHeader;
|
||||
NEO::ConstStringRef fun0Name = "fun0";
|
||||
NEO::ConstStringRef fun1Name = "fun1";
|
||||
const uint8_t barrierCount = 2;
|
||||
std::vector<uint8_t> storage;
|
||||
std::string zeInfo = std::string("version :\'") + versionToString(NEO::zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name: kernel
|
||||
execution_env:
|
||||
simd_size: 8
|
||||
- name: Intel_Symbol_Table_Void_Program
|
||||
execution_env:
|
||||
simd_size: 8
|
||||
functions:
|
||||
- name: fun0
|
||||
execution_env:
|
||||
grf_count: 128
|
||||
simd_size: 8
|
||||
barrier_count: 0
|
||||
- name: fun1
|
||||
execution_env:
|
||||
grf_count: 128
|
||||
simd_size: 8
|
||||
barrier_count: 2
|
||||
)===";
|
||||
};
|
||||
|
||||
struct ZebinWithL0TestCommonModule {
|
||||
ZebinWithL0TestCommonModule(const NEO::HardwareInfo &hwInfo) : ZebinWithL0TestCommonModule(hwInfo, std::initializer_list<appendElfAdditionalSection>{}) {}
|
||||
ZebinWithL0TestCommonModule(const NEO::HardwareInfo &hwInfo, std::initializer_list<appendElfAdditionalSection> additionalSections, bool forceRecompilation = false);
|
||||
|
||||
void recalcPtr();
|
||||
|
||||
const uint8_t numOfKernels = 2;
|
||||
NEO::Elf::ElfFileHeader<NEO::Elf::EI_CLASS_64> *elfHeader;
|
||||
std::vector<uint8_t> storage;
|
||||
std::string zeInfo = std::string("version :\'") + versionToString(NEO::zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name: test
|
||||
execution_env:
|
||||
barrier_count: 1
|
||||
grf_count: 128
|
||||
has_global_atomics: true
|
||||
inline_data_payload_size: 32
|
||||
offset_to_skip_per_thread_data_load: 192
|
||||
simd_size: 32
|
||||
slm_size: 64
|
||||
subgroup_independent_forward_progress: true
|
||||
payload_arguments:
|
||||
- arg_type: global_id_offset
|
||||
offset: 0
|
||||
size: 12
|
||||
- arg_type: local_size
|
||||
offset: 12
|
||||
size: 12
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 0
|
||||
addrmode: stateful
|
||||
addrspace: global
|
||||
access_type: readonly
|
||||
- arg_type: arg_bypointer
|
||||
offset: 32
|
||||
size: 8
|
||||
arg_index: 0
|
||||
addrmode: stateless
|
||||
addrspace: global
|
||||
access_type: readonly
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 1
|
||||
addrmode: stateful
|
||||
addrspace: global
|
||||
access_type: readonly
|
||||
- arg_type: arg_bypointer
|
||||
offset: 40
|
||||
size: 8
|
||||
arg_index: 1
|
||||
addrmode: stateless
|
||||
addrspace: global
|
||||
access_type: readonly
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 2
|
||||
addrmode: stateful
|
||||
addrspace: global
|
||||
access_type: readwrite
|
||||
- arg_type: arg_bypointer
|
||||
offset: 48
|
||||
size: 8
|
||||
arg_index: 2
|
||||
addrmode: stateless
|
||||
addrspace: global
|
||||
access_type: readwrite
|
||||
- arg_type: printf_buffer
|
||||
offset: 56
|
||||
size: 8
|
||||
- arg_type: buffer_offset
|
||||
offset: 64
|
||||
size: 4
|
||||
arg_index: 2
|
||||
- arg_type: local_size
|
||||
offset: 68
|
||||
size: 12
|
||||
- arg_type: enqueued_local_size
|
||||
offset: 80
|
||||
size: 12
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 5
|
||||
addrmode: stateful
|
||||
addrspace: sampler
|
||||
access_type: readwrite
|
||||
sampler_index: 0
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 3
|
||||
addrmode: stateful
|
||||
addrspace: image
|
||||
access_type: readonly
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 4
|
||||
addrmode: stateful
|
||||
addrspace: image
|
||||
access_type: writeonly
|
||||
per_thread_payload_arguments:
|
||||
- arg_type: local_id
|
||||
offset: 0
|
||||
size: 192
|
||||
binding_table_indices:
|
||||
- bti_value: 1
|
||||
arg_index: 0
|
||||
- bti_value: 2
|
||||
arg_index: 1
|
||||
- bti_value: 3
|
||||
arg_index: 2
|
||||
- bti_value: 0
|
||||
arg_index: 3
|
||||
- bti_value: 5
|
||||
arg_index: 4
|
||||
- name: memcpy_bytes
|
||||
execution_env:
|
||||
grf_count: 128
|
||||
has_no_stateless_write: true
|
||||
inline_data_payload_size: 32
|
||||
offset_to_skip_per_thread_data_load: 192
|
||||
simd_size: 32
|
||||
subgroup_independent_forward_progress: true
|
||||
payload_arguments:
|
||||
- arg_type: global_id_offset
|
||||
offset: 0
|
||||
size: 12
|
||||
- arg_type: local_size
|
||||
offset: 12
|
||||
size: 12
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 0
|
||||
addrmode: stateful
|
||||
addrspace: global
|
||||
access_type: readwrite
|
||||
- arg_type: arg_bypointer
|
||||
offset: 32
|
||||
size: 8
|
||||
arg_index: 0
|
||||
addrmode: stateless
|
||||
addrspace: global
|
||||
access_type: readwrite
|
||||
- arg_type: arg_bypointer
|
||||
offset: 0
|
||||
size: 0
|
||||
arg_index: 1
|
||||
addrmode: stateful
|
||||
addrspace: global
|
||||
access_type: readonly
|
||||
- arg_type: arg_bypointer
|
||||
offset: 40
|
||||
size: 8
|
||||
arg_index: 1
|
||||
addrmode: stateless
|
||||
addrspace: global
|
||||
access_type: readonly
|
||||
- arg_type: enqueued_local_size
|
||||
offset: 48
|
||||
size: 12
|
||||
per_thread_payload_arguments:
|
||||
- arg_type: local_id
|
||||
offset: 0
|
||||
size: 192
|
||||
binding_table_indices:
|
||||
- bti_value: 0
|
||||
arg_index: 0
|
||||
- bti_value: 1
|
||||
arg_index: 1
|
||||
-)===";
|
||||
};
|
||||
|
||||
} // namespace ZebinTestData
|
||||
@@ -13,13 +13,13 @@
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
#include "shared/source/program/program_initialization.h"
|
||||
#include "shared/test/common/compiler_interface/linker_mock.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/gtest_helpers.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_elf.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/mocks/ult_device_factory.h"
|
||||
|
||||
#include "RelocationInfo.h"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "shared/source/helpers/ptr_math.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "shared/source/device_binary_format/elf/ocl_elf.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
#include "shared/test/common/device_binary_format/patchtokens_tests.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
TEST(DecodeError, WhenStringRepresentationIsNeededThenAsStringEncodesProperly) {
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "shared/source/device_binary_format/debug_zebin.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/mocks/mock_elf.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO::Elf;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include "shared/source/kernel/kernel_arg_descriptor_extended_vme.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
#include "shared/test/common/device_binary_format/zebin_tests.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_modules_zebin.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include <numeric>
|
||||
@@ -2251,7 +2251,7 @@ TEST(DecodeSingleDeviceBinaryZebin, GivenEmptyInZeInfoThenEmitsWarning) {
|
||||
TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmitsWarning) {
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
auto brokenZeInfo = std::string("some_entry : a\nkernels : \n - name : valid_empty_kernel\n execution_env : \n simd_size : 32\n grf_count : 128\nversion:\'") + toString(zeInfoDecoderVersion) + "\'\n";
|
||||
auto brokenZeInfo = std::string("some_entry : a\nkernels : \n - name : valid_empty_kernel\n execution_env : \n simd_size : 32\n grf_count : 128\nversion:\'") + versionToString(zeInfoDecoderVersion) + "\'\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(brokenZeInfo.data(), brokenZeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2268,7 +2268,7 @@ TEST(DecodeSingleDeviceBinaryZebin, GivenUnknownEntryInZeInfoGlobalScopeThenEmit
|
||||
TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoDoesNotContainKernelsSectionThenEmitsWarning) {
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
auto brokenZeInfo = std::string("version:\'") + toString(zeInfoDecoderVersion) + "\'\na:b\n";
|
||||
auto brokenZeInfo = std::string("version:\'") + versionToString(zeInfoDecoderVersion) + "\'\na:b\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(brokenZeInfo.data(), brokenZeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2285,7 +2285,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoDoesNotContainKernelsSectionThenEm
|
||||
TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoContainsMultipleKernelSectionsThenFails) {
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
auto brokenZeInfo = std::string("version:\'") + toString(zeInfoDecoderVersion) + "\'\nkernels : \n - name : valid_empty_kernel\n execution_env : \n simd_size : 32\n grf_count : 128\n" + "\nkernels : \n - name : valid_empty_kernel\n execution_env : \n simd_size : 32\n grf_count : 128\n...\n";
|
||||
auto brokenZeInfo = std::string("version:\'") + versionToString(zeInfoDecoderVersion) + "\'\nkernels : \n - name : valid_empty_kernel\n execution_env : \n simd_size : 32\n grf_count : 128\n" + "\nkernels : \n - name : valid_empty_kernel\n execution_env : \n simd_size : 32\n grf_count : 128\n...\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(brokenZeInfo.data(), brokenZeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2302,7 +2302,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoContainsMultipleKernelSectionsThen
|
||||
TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoContainsMultipleVersionSectionsThenFails) {
|
||||
ZebinTestData::ValidEmptyProgram zebin;
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
auto brokenZeInfo = std::string("version:\'") + toString(zeInfoDecoderVersion) + "\'\nversion:\'5.4\'\nkernels:\n";
|
||||
auto brokenZeInfo = std::string("version:\'") + versionToString(zeInfoDecoderVersion) + "\'\nversion:\'5.4\'\nkernels:\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(brokenZeInfo.data(), brokenZeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2360,7 +2360,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoMinorVersionIsNewerThenEmitsWarnin
|
||||
auto version = NEO::zeInfoDecoderVersion;
|
||||
std::string expectedWarning = "DeviceBinaryFormat::Zebin::.ze_info : Minor version : " + std::to_string(version.minor + 1) + " is newer than available in decoder : " + std::to_string(version.minor) + " - some features may be skipped\n";
|
||||
version.minor += 1;
|
||||
auto zeInfo = std::string("version:\'") + toString(version) + "\'\nkernels:\n";
|
||||
auto zeInfo = std::string("version:\'") + versionToString(version) + "\'\nkernels:\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(zeInfo.data(), zeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2380,7 +2380,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoMajorVersionIsMismatchedThenFails)
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
auto version = NEO::zeInfoDecoderVersion;
|
||||
version.major += 1;
|
||||
auto zeInfo = std::string("version:\'") + toString(version) + "\'\nkernels:\n";
|
||||
auto zeInfo = std::string("version:\'") + versionToString(version) + "\'\nkernels:\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(zeInfo.data(), zeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2399,7 +2399,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoMajorVersionIsMismatchedThenFails)
|
||||
zebin.removeSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo);
|
||||
auto version = NEO::zeInfoDecoderVersion;
|
||||
version.major -= 1;
|
||||
auto zeInfo = std::string("version:\'") + toString(version) + "\'\nkernels:\n";
|
||||
auto zeInfo = std::string("version:\'") + versionToString(version) + "\'\nkernels:\n";
|
||||
zebin.appendSection(NEO::Elf::SHT_ZEBIN::SHT_ZEBIN_ZEINFO, NEO::Elf::SectionsNamesZebin::zeInfo, ArrayRef<const uint8_t>::fromAny(zeInfo.data(), zeInfo.size()));
|
||||
|
||||
NEO::ProgramInfo programInfo;
|
||||
@@ -2415,7 +2415,7 @@ TEST(DecodeSingleDeviceBinaryZebin, WhenZeInfoMajorVersionIsMismatchedThenFails)
|
||||
}
|
||||
|
||||
TEST(DecodeSingleDeviceBinaryZebin, WhenDecodeZeInfoFailsThenDecodingFails) {
|
||||
std::string brokenZeInfo = "version : \'" + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string brokenZeInfo = "version : \'" + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
-
|
||||
)===";
|
||||
@@ -2436,7 +2436,7 @@ kernels:
|
||||
}
|
||||
|
||||
TEST(DecodeSingleDeviceBinaryZebin, GivenValidZeInfoThenPopulatesKernelDescriptorProperly) {
|
||||
std::string validZeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : some_kernel
|
||||
execution_env :
|
||||
@@ -2471,7 +2471,7 @@ kernels:
|
||||
}
|
||||
|
||||
TEST(DecodeSingleDeviceBinaryZebin, GivenValidZeInfoAndExternalFunctionsMetadataThenPopulatesExternalFunctionMetadataProperly) {
|
||||
std::string validZeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : some_kernel
|
||||
execution_env :
|
||||
@@ -2508,7 +2508,7 @@ functions:
|
||||
}
|
||||
|
||||
TEST(DecodeSingleDeviceBinaryZebin, GivenValidZeInfoAndInvalidExternalFunctionsMetadataThenFail) {
|
||||
std::string validZeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : some_kernel
|
||||
execution_env :
|
||||
@@ -2538,7 +2538,7 @@ functions:
|
||||
}
|
||||
|
||||
TEST(DecodeSingleDeviceBinaryZebin, GivenZeInfoWithTwoExternalFunctionsEntriesThenFail) {
|
||||
std::string validZeInfo = std::string("version :\'") + toString(zeInfoDecoderVersion) + R"===('
|
||||
std::string validZeInfo = std::string("version :\'") + versionToString(zeInfoDecoderVersion) + R"===('
|
||||
kernels:
|
||||
- name : some_kernel
|
||||
execution_env :
|
||||
|
||||
Reference in New Issue
Block a user