Fix double ISA transfer for user kernels in L0
Related-To: NEO-6555 - ISA should only be copied once, after linking phase is complete Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
parent
8e6f92604e
commit
17f82bbe12
|
@ -63,6 +63,14 @@ struct KernelImmutableData {
|
|||
|
||||
const NEO::KernelInfo *getKernelInfo() const { return kernelInfo; }
|
||||
|
||||
void setIsaCopiedToAllocation() {
|
||||
isaCopiedToAllocation = true;
|
||||
}
|
||||
|
||||
bool isIsaCopiedToAllocation() const {
|
||||
return isaCopiedToAllocation;
|
||||
}
|
||||
|
||||
protected:
|
||||
MOCKABLE_VIRTUAL void createRelocatedDebugData(NEO::GraphicsAllocation *globalConstBuffer,
|
||||
NEO::GraphicsAllocation *globalVarBuffer);
|
||||
|
@ -82,6 +90,8 @@ struct KernelImmutableData {
|
|||
std::unique_ptr<uint8_t[]> dynamicStateHeapTemplate = nullptr;
|
||||
|
||||
std::vector<NEO::GraphicsAllocation *> residencyContainer;
|
||||
|
||||
bool isaCopiedToAllocation = false;
|
||||
};
|
||||
|
||||
struct Kernel : _ze_kernel_handle_t, virtual NEO::DispatchKernelEncoderI {
|
||||
|
|
|
@ -143,22 +143,6 @@ void KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device *device
|
|||
}
|
||||
}
|
||||
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
if (internalKernel == false) {
|
||||
NEO::MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *allocation),
|
||||
*neoDevice, allocation, 0, kernelInfo->heapInfo.pKernelHeap,
|
||||
static_cast<size_t>(kernelIsaSize));
|
||||
}
|
||||
|
||||
if (device->getL0Debugger()) {
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
if (memoryOperationsIface) {
|
||||
memoryOperationsIface->makeResident(neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&allocation, 1));
|
||||
}
|
||||
}
|
||||
|
||||
this->crossThreadDataSize = this->kernelDescriptor->kernelAttributes.crossThreadDataSize;
|
||||
|
||||
ArrayRef<uint8_t> crossThredDataArrayRef;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "shared/source/helpers/kernel_helpers.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/memory_manager/memory_operations_handler.h"
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/source/program/program_initialization.h"
|
||||
|
@ -552,6 +553,30 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
|
|||
passDebugData();
|
||||
}
|
||||
|
||||
auto &hwInfo = neoDevice->getHardwareInfo();
|
||||
auto &hwHelper = NEO::HwHelper::get(hwInfo.platform.eRenderCoreFamily);
|
||||
|
||||
if (this->isFullyLinked) {
|
||||
for (auto &ki : kernelImmDatas) {
|
||||
|
||||
if (this->type == ModuleType::User && !ki->isIsaCopiedToAllocation()) {
|
||||
|
||||
NEO::MemoryTransferHelper::transferMemoryToAllocation(hwHelper.isBlitCopyRequiredForLocalMemory(hwInfo, *ki->getIsaGraphicsAllocation()),
|
||||
*neoDevice, ki->getIsaGraphicsAllocation(), 0, ki->getKernelInfo()->heapInfo.pKernelHeap,
|
||||
static_cast<size_t>(ki->getKernelInfo()->heapInfo.KernelHeapSize));
|
||||
|
||||
ki->setIsaCopiedToAllocation();
|
||||
}
|
||||
|
||||
if (device->getL0Debugger()) {
|
||||
NEO::MemoryOperationsHandler *memoryOperationsIface = neoDevice->getRootDeviceEnvironment().memoryOperationsInterface.get();
|
||||
if (memoryOperationsIface) {
|
||||
auto allocation = ki->getIsaGraphicsAllocation();
|
||||
memoryOperationsIface->makeResident(neoDevice, ArrayRef<NEO::GraphicsAllocation *>(&allocation, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
@ -676,17 +701,21 @@ ze_result_t ModuleImp::getDebugInfo(size_t *pDebugDataSize, uint8_t *pDebugData)
|
|||
|
||||
void ModuleImp::copyPatchedSegments(const NEO::Linker::PatchableSegments &isaSegmentsForPatching) {
|
||||
if (this->translationUnit->programInfo.linkerInput && this->translationUnit->programInfo.linkerInput->getTraits().requiresPatchingOfInstructionSegments) {
|
||||
for (const auto &kernelImmData : this->kernelImmDatas) {
|
||||
for (auto &kernelImmData : this->kernelImmDatas) {
|
||||
if (nullptr == kernelImmData->getIsaGraphicsAllocation()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UNRECOVERABLE_IF(kernelImmData->isIsaCopiedToAllocation());
|
||||
|
||||
kernelImmData->getIsaGraphicsAllocation()->setTbxWritable(true, std::numeric_limits<uint32_t>::max());
|
||||
kernelImmData->getIsaGraphicsAllocation()->setAubWritable(true, std::numeric_limits<uint32_t>::max());
|
||||
auto segmentId = &kernelImmData - &this->kernelImmDatas[0];
|
||||
this->device->getDriverHandle()->getMemoryManager()->copyMemoryToAllocation(kernelImmData->getIsaGraphicsAllocation(), 0,
|
||||
isaSegmentsForPatching[segmentId].hostPointer,
|
||||
isaSegmentsForPatching[segmentId].segmentSize);
|
||||
|
||||
kernelImmData->setIsaCopiedToAllocation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -755,7 +784,7 @@ bool ModuleImp::linkBinary() {
|
|||
}
|
||||
isFullyLinked = false;
|
||||
return LinkingStatus::LinkedPartially == linkStatus;
|
||||
} else {
|
||||
} else if (type != ModuleType::Builtin) {
|
||||
copyPatchedSegments(isaSegmentsForPatching);
|
||||
}
|
||||
DBG_LOG(PrintRelocations, NEO::constructRelocationsDebugMessage(this->symbols));
|
||||
|
|
|
@ -87,9 +87,11 @@ struct ModuleImmutableDataFixture : public DeviceFixture {
|
|||
|
||||
struct MockModule : public L0::ModuleImp {
|
||||
using ModuleImp::getKernelImmutableDataVector;
|
||||
using ModuleImp::kernelImmDatas;
|
||||
using ModuleImp::maxGroupSize;
|
||||
using ModuleImp::translationUnit;
|
||||
using ModuleImp::type;
|
||||
|
||||
MockModule(L0::Device *device,
|
||||
L0::ModuleBuildLog *moduleBuildLog,
|
||||
L0::ModuleType type,
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
#include "shared/test/common/helpers/unit_test_helper.h"
|
||||
#include "shared/test/common/mocks/mock_compilers.h"
|
||||
#include "shared/test/common/mocks/mock_elf.h"
|
||||
#include "shared/test/common/test_macros/matchers.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
#include "shared/test/unit_test/compiler_interface/linker_mock.h"
|
||||
|
||||
#include "level_zero/core/source/module/module_imp.h"
|
||||
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
|
||||
|
@ -395,18 +397,117 @@ TEST_F(ModuleWithDebuggerL0Test, givenDebuggingEnabledWhenModuleIsCreatedThenDeb
|
|||
EXPECT_FALSE(CompilerOptions::contains(cip->buildOptions, L0::BuildOptions::optDisable));
|
||||
}
|
||||
|
||||
TEST_F(ModuleWithDebuggerL0Test, givenDebuggingEnabledWhenKernelsAreInitializedThenAllocationsAreBound) {
|
||||
uint32_t kernelHeap = 0;
|
||||
TEST_F(ModuleWithDebuggerL0Test, givenDebuggingEnabledWhenKernelsAreInitializedThenAllocationsAreNotResidentAndNotCopied) {
|
||||
uint32_t kernelHeap = 0xDEAD;
|
||||
KernelInfo kernelInfo;
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.KernelHeapSize = 4;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
memoryOperationsHandler->makeResidentCalledCount = 0;
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
EXPECT_EQ(1, memoryOperationsHandler->makeResidentCalledCount);
|
||||
EXPECT_EQ(0, memoryOperationsHandler->makeResidentCalledCount);
|
||||
|
||||
auto isa = kernelImmutableData.getIsaGraphicsAllocation()->getUnderlyingBuffer();
|
||||
EXPECT_THAT(isa, testing::Not(MemCompare(&kernelHeap, sizeof(kernelHeap))));
|
||||
};
|
||||
|
||||
using ModuleTest = Test<ModuleFixture>;
|
||||
|
||||
HWTEST_F(ModuleTest, givenDebuggingEnabledWhenModuleIsCreatedAndFullyLinkedThenIsaAllocationsAreCopiedAndResident) {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
auto memoryOperationsHandler = new NEO::MockMemoryOperations();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->memoryOperationsInterface.reset(memoryOperationsHandler);
|
||||
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameNoRevision(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto module = std::unique_ptr<L0::ModuleImp>(new L0::ModuleImp(device, moduleBuildLog, ModuleType::User));
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
|
||||
memoryOperationsHandler->makeResidentCalledCount = 0;
|
||||
|
||||
module->initialize(&moduleDesc, neoDevice);
|
||||
|
||||
EXPECT_EQ(4, memoryOperationsHandler->makeResidentCalledCount);
|
||||
|
||||
for (auto &ki : module->getKernelImmutableDataVector()) {
|
||||
EXPECT_TRUE(ki->isIsaCopiedToAllocation());
|
||||
}
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTest, givenDebuggingEnabledWhenModuleWithUnresolvedSymbolsIsCreatedThenIsaAllocationsAreNotCopiedAndNotResident) {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
auto memoryOperationsHandler = new NEO::MockMemoryOperations();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->memoryOperationsInterface.reset(memoryOperationsHandler);
|
||||
|
||||
auto debugger = MockDebuggerL0Hw<FamilyType>::allocate(neoDevice);
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameNoRevision(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto module = std::unique_ptr<Module>(new Module(device, moduleBuildLog, ModuleType::User));
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
|
||||
NEO::Linker::RelocationInfo unresolvedRelocation;
|
||||
unresolvedRelocation.symbolName = "unresolved";
|
||||
|
||||
auto linkerInput = std::make_unique<::WhiteBox<NEO::LinkerInput>>();
|
||||
linkerInput->dataRelocations.push_back(unresolvedRelocation);
|
||||
linkerInput->traits.requiresPatchingOfGlobalVariablesBuffer = true;
|
||||
|
||||
module->unresolvedExternalsInfo.push_back({unresolvedRelocation});
|
||||
module->translationUnit->programInfo.linkerInput = std::move(linkerInput);
|
||||
|
||||
memoryOperationsHandler->makeResidentCalledCount = 0;
|
||||
|
||||
module->initialize(&moduleDesc, neoDevice);
|
||||
|
||||
EXPECT_EQ(0, memoryOperationsHandler->makeResidentCalledCount);
|
||||
|
||||
for (auto &ki : module->getKernelImmutableDataVector()) {
|
||||
EXPECT_FALSE(ki->isIsaCopiedToAllocation());
|
||||
}
|
||||
|
||||
EXPECT_FALSE(module->isFullyLinked);
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
#include "shared/test/unit_test/compiler_interface/linker_mock.h"
|
||||
#include "shared/test/unit_test/device_binary_format/patchtokens_tests.h"
|
||||
|
||||
#include "level_zero/core/source/debugger/debugger_l0.h"
|
||||
|
@ -323,7 +324,7 @@ TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenPriv
|
|||
|
||||
using KernelImmutableDataIsaCopyTests = KernelImmutableDataTests;
|
||||
|
||||
TEST_F(KernelImmutableDataIsaCopyTests, whenUserKernelIsCreatedThenIsaIsaCopiedWhenModuleIsCreated) {
|
||||
TEST_F(KernelImmutableDataIsaCopyTests, whenUserKernelIsCreatedThenIsaIsCopiedWhenModuleIsCreated) {
|
||||
MockImmutableMemoryManager *mockMemoryManager =
|
||||
static_cast<MockImmutableMemoryManager *>(device->getNEODevice()->getMemoryManager());
|
||||
|
||||
|
@ -339,9 +340,6 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenUserKernelIsCreatedThenIsaIsaCopiedW
|
|||
|
||||
size_t copyForGlobalSurface = 1u;
|
||||
auto copyForIsa = module->getKernelImmutableDataVector().size();
|
||||
if (module->translationUnit->programInfo.linkerInput && module->translationUnit->programInfo.linkerInput->getTraits().requiresPatchingOfInstructionSegments) {
|
||||
copyForIsa += module->getKernelImmutableDataVector().size();
|
||||
}
|
||||
size_t expectedPreviouscopyMemoryToAllocationCalledTimes = previouscopyMemoryToAllocationCalledTimes +
|
||||
copyForGlobalSurface + copyForIsa;
|
||||
EXPECT_EQ(expectedPreviouscopyMemoryToAllocationCalledTimes,
|
||||
|
@ -356,7 +354,7 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenUserKernelIsCreatedThenIsaIsaCopiedW
|
|||
mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForUserKernelThenIsaIsCopied) {
|
||||
TEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForUserKernelThenIsaIsNotCopied) {
|
||||
MockImmutableMemoryManager *mockMemoryManager =
|
||||
static_cast<MockImmutableMemoryManager *>(device->getNEODevice()->getMemoryManager());
|
||||
|
||||
|
@ -375,7 +373,7 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForUserKer
|
|||
module.get()->translationUnit->globalVarBuffer,
|
||||
isInternal);
|
||||
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes + 1u,
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes,
|
||||
mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
}
|
||||
|
||||
|
@ -404,7 +402,7 @@ TEST_F(KernelImmutableDataIsaCopyTests, whenImmutableDataIsInitializedForInterna
|
|||
|
||||
using KernelImmutableDataWithNullHeapTests = KernelImmutableDataTests;
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenSingleIsaIsCopied) {
|
||||
TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenIsaIsCopiedOnce) {
|
||||
MockImmutableMemoryManager *mockMemoryManager =
|
||||
static_cast<MockImmutableMemoryManager *>(device->getNEODevice()->getMemoryManager());
|
||||
|
||||
|
@ -421,9 +419,6 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenSingl
|
|||
|
||||
size_t copyForGlobalSurface = 1u;
|
||||
size_t copyForPatchingIsa = 0u;
|
||||
if (module->translationUnit->programInfo.linkerInput && module->translationUnit->programInfo.linkerInput->getTraits().requiresPatchingOfInstructionSegments) {
|
||||
copyForPatchingIsa += module->getKernelImmutableDataVector().size();
|
||||
}
|
||||
size_t expectedPreviouscopyMemoryToAllocationCalledTimes = previouscopyMemoryToAllocationCalledTimes +
|
||||
copyForGlobalSurface + copyForPatchingIsa;
|
||||
EXPECT_EQ(expectedPreviouscopyMemoryToAllocationCalledTimes,
|
||||
|
@ -440,6 +435,66 @@ TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedThenSingl
|
|||
mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenInternalModuleWhenKernelIsCreatedIsaIsNotCopiedDuringLinking) {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
MockImmutableMemoryManager *mockMemoryManager = static_cast<MockImmutableMemoryManager *>(device->getNEODevice()->getMemoryManager());
|
||||
|
||||
uint8_t binary[16];
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV;
|
||||
moduleDesc.pInputModule = binary;
|
||||
moduleDesc.inputSize = 10;
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto linkerInput = std::make_unique<::WhiteBox<NEO::LinkerInput>>();
|
||||
linkerInput->traits.requiresPatchingOfGlobalVariablesBuffer = true;
|
||||
|
||||
std::unique_ptr<L0::ult::MockModule> moduleMock = std::make_unique<L0::ult::MockModule>(device, moduleBuildLog, ModuleType::Builtin);
|
||||
moduleMock->translationUnit = std::make_unique<MockModuleTranslationUnit>(device);
|
||||
moduleMock->translationUnit->programInfo.linkerInput = std::move(linkerInput);
|
||||
|
||||
uint32_t kernelHeap = 0;
|
||||
auto kernelInfo = new KernelInfo();
|
||||
kernelInfo->heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo->heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
Mock<::L0::Kernel> kernelMock;
|
||||
kernelMock.module = moduleMock.get();
|
||||
kernelMock.immutableData.kernelInfo = kernelInfo;
|
||||
kernelMock.immutableData.surfaceStateHeapSize = 64;
|
||||
kernelMock.immutableData.surfaceStateHeapTemplate.reset(new uint8_t[64]);
|
||||
kernelMock.immutableData.getIsaGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL);
|
||||
kernelInfo->kernelDescriptor.payloadMappings.implicitArgs.systemThreadSurfaceAddress.bindful = 0;
|
||||
|
||||
moduleMock->translationUnit->programInfo.kernelInfos.push_back(kernelInfo);
|
||||
moduleMock->kernelImmData = &kernelMock.immutableData;
|
||||
|
||||
size_t previouscopyMemoryToAllocationCalledTimes = mockMemoryManager->copyMemoryToAllocationCalledTimes;
|
||||
auto result = moduleMock->initialize(&moduleDesc, neoDevice);
|
||||
EXPECT_TRUE(result);
|
||||
size_t expectedPreviouscopyMemoryToAllocationCalledTimes = previouscopyMemoryToAllocationCalledTimes;
|
||||
|
||||
EXPECT_EQ(expectedPreviouscopyMemoryToAllocationCalledTimes, mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
|
||||
for (auto &ki : moduleMock->kernelImmDatas) {
|
||||
EXPECT_FALSE(ki->isIsaCopiedToAllocation());
|
||||
}
|
||||
|
||||
expectedPreviouscopyMemoryToAllocationCalledTimes++;
|
||||
|
||||
ze_kernel_desc_t desc = {};
|
||||
desc.pKernelName = "";
|
||||
|
||||
moduleMock->kernelImmData = moduleMock->kernelImmDatas[0].get();
|
||||
|
||||
kernelMock.initialize(&desc);
|
||||
|
||||
EXPECT_EQ(expectedPreviouscopyMemoryToAllocationCalledTimes, mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
}
|
||||
|
||||
TEST_F(KernelImmutableDataTests, givenKernelInitializedWithPrivateMemoryThenContainerHasOneExtraSpaceForAllocation) {
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameNoRevision(testFile, binaryFilename + "_", ".bin");
|
||||
|
|
|
@ -1300,6 +1300,48 @@ TEST_F(ModuleDynamicLinkTests, givenModuleWithUnresolvedSymbolsNotPresentInAnoth
|
|||
zeModuleBuildLogDestroy(dynLinkLog);
|
||||
}
|
||||
|
||||
TEST_F(ModuleDynamicLinkTests, givenUnresolvedSymbolsWhenModuleIsCreatedThenIsaAllocationsAreNotCopied) {
|
||||
NEO::MockCompilerEnableGuard mock(true);
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->compilerInterface.reset(cip);
|
||||
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameNoRevision(testFile, binaryFilename + "_", ".bin");
|
||||
|
||||
size_t size = 0;
|
||||
auto src = loadDataFromFile(testFile.c_str(), size);
|
||||
|
||||
ASSERT_NE(0u, size);
|
||||
ASSERT_NE(nullptr, src);
|
||||
|
||||
ze_module_desc_t moduleDesc = {};
|
||||
moduleDesc.format = ZE_MODULE_FORMAT_NATIVE;
|
||||
moduleDesc.pInputModule = reinterpret_cast<const uint8_t *>(src.get());
|
||||
moduleDesc.inputSize = size;
|
||||
|
||||
ModuleBuildLog *moduleBuildLog = nullptr;
|
||||
|
||||
auto module = std::unique_ptr<Module>(new Module(device, moduleBuildLog, ModuleType::User));
|
||||
ASSERT_NE(nullptr, module.get());
|
||||
|
||||
NEO::Linker::RelocationInfo unresolvedRelocation;
|
||||
unresolvedRelocation.symbolName = "unresolved";
|
||||
|
||||
auto linkerInput = std::make_unique<::WhiteBox<NEO::LinkerInput>>();
|
||||
linkerInput->dataRelocations.push_back(unresolvedRelocation);
|
||||
linkerInput->traits.requiresPatchingOfGlobalVariablesBuffer = true;
|
||||
module->unresolvedExternalsInfo.push_back({unresolvedRelocation});
|
||||
module->translationUnit->programInfo.linkerInput = std::move(linkerInput);
|
||||
|
||||
module->initialize(&moduleDesc, neoDevice);
|
||||
|
||||
for (auto &ki : module->getKernelImmutableDataVector()) {
|
||||
EXPECT_FALSE(ki->isIsaCopiedToAllocation());
|
||||
}
|
||||
|
||||
EXPECT_FALSE(module->isFullyLinked);
|
||||
}
|
||||
|
||||
class DeviceModuleSetArgBufferTest : public ModuleFixture, public ::testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
|
@ -2053,6 +2095,30 @@ TEST_F(ModuleTests, givenImplicitArgsRelocationAndNoDebuggerOrStackCallsWhenLink
|
|||
EXPECT_FALSE(kernelInfo->kernelDescriptor.kernelAttributes.flags.requiresImplicitArgs);
|
||||
}
|
||||
|
||||
using ModuleIsaCopyTest = Test<ModuleImmutableDataFixture>;
|
||||
|
||||
TEST_F(ModuleIsaCopyTest, whenModuleIsInitializedThenIsaIsCopied) {
|
||||
MockImmutableMemoryManager *mockMemoryManager = static_cast<MockImmutableMemoryManager *>(device->getNEODevice()->getMemoryManager());
|
||||
|
||||
uint32_t perHwThreadPrivateMemorySizeRequested = 32u;
|
||||
bool isInternal = false;
|
||||
|
||||
std::unique_ptr<MockImmutableData> mockKernelImmData = std::make_unique<MockImmutableData>(perHwThreadPrivateMemorySizeRequested);
|
||||
|
||||
uint32_t previouscopyMemoryToAllocationCalledTimes = mockMemoryManager->copyMemoryToAllocationCalledTimes;
|
||||
|
||||
createModuleFromBinary(perHwThreadPrivateMemorySizeRequested, isInternal, mockKernelImmData.get());
|
||||
|
||||
uint32_t numOfKernels = static_cast<uint32_t>(module->getKernelImmutableDataVector().size());
|
||||
const uint32_t numOfGlobalBuffers = 1;
|
||||
|
||||
EXPECT_EQ(previouscopyMemoryToAllocationCalledTimes + numOfGlobalBuffers + numOfKernels, mockMemoryManager->copyMemoryToAllocationCalledTimes);
|
||||
|
||||
for (auto &kid : module->getKernelImmutableDataVector()) {
|
||||
EXPECT_TRUE(kid->isIsaCopiedToAllocation());
|
||||
}
|
||||
}
|
||||
|
||||
using ModuleWithZebinTest = Test<ModuleWithZebinFixture>;
|
||||
TEST_F(ModuleWithZebinTest, givenNoZebinThenSegmentsAreEmpty) {
|
||||
auto segments = module->getZebinSegments();
|
||||
|
|
Loading…
Reference in New Issue