mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
Revert "Initialize kernel immutable data when kernel is created"
This reverts commit a6ac10088c.
Signed-off-by: Jaime Arteaga <jaime.a.arteaga.molina@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1ba588d4eb
commit
d7ea713c5f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -30,11 +30,10 @@ struct Device;
|
||||
struct Module;
|
||||
|
||||
struct KernelImmutableData {
|
||||
KernelImmutableData() = default;
|
||||
KernelImmutableData(L0::Device *l0device, NEO::KernelInfo *ki);
|
||||
KernelImmutableData(L0::Device *l0device = nullptr);
|
||||
virtual ~KernelImmutableData();
|
||||
|
||||
void initialize(Device *device,
|
||||
void initialize(NEO::KernelInfo *kernelInfo, Device *device,
|
||||
uint32_t computeUnitsUsedForSratch,
|
||||
NEO::GraphicsAllocation *globalConstBuffer, NEO::GraphicsAllocation *globalVarBuffer, bool internalKernel);
|
||||
|
||||
@@ -66,7 +65,6 @@ struct KernelImmutableData {
|
||||
|
||||
protected:
|
||||
Device *device = nullptr;
|
||||
NEO::KernelInfo *kernelInfo = nullptr;
|
||||
NEO::KernelDescriptor *kernelDescriptor = nullptr;
|
||||
std::unique_ptr<NEO::GraphicsAllocation> isaGraphicsAllocation = nullptr;
|
||||
std::unique_ptr<NEO::GraphicsAllocation> privateMemoryGraphicsAllocation = nullptr;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -64,10 +64,7 @@ inline SamplerPatchValues getAddrMode(ze_sampler_address_mode_t addressingMode)
|
||||
return SamplerPatchValues::AddressNone;
|
||||
}
|
||||
|
||||
KernelImmutableData::KernelImmutableData(L0::Device *l0device, NEO::KernelInfo *ki) : device(l0device), kernelInfo(ki) {
|
||||
UNRECOVERABLE_IF(kernelInfo == nullptr);
|
||||
this->kernelDescriptor = &kernelInfo->kernelDescriptor;
|
||||
}
|
||||
KernelImmutableData::KernelImmutableData(L0::Device *l0device) : device(l0device) {}
|
||||
|
||||
KernelImmutableData::~KernelImmutableData() {
|
||||
if (nullptr != isaGraphicsAllocation) {
|
||||
@@ -99,10 +96,14 @@ inline void patchWithImplicitSurface(ArrayRef<uint8_t> crossThreadData, ArrayRef
|
||||
}
|
||||
}
|
||||
|
||||
void KernelImmutableData::initialize(Device *device,
|
||||
void KernelImmutableData::initialize(NEO::KernelInfo *kernelInfo, Device *device,
|
||||
uint32_t computeUnitsUsedForSratch,
|
||||
NEO::GraphicsAllocation *globalConstBuffer,
|
||||
NEO::GraphicsAllocation *globalVarBuffer, bool internalKernel) {
|
||||
|
||||
UNRECOVERABLE_IF(kernelInfo == nullptr);
|
||||
this->kernelDescriptor = &kernelInfo->kernelDescriptor;
|
||||
|
||||
auto neoDevice = device->getNEODevice();
|
||||
auto memoryManager = device->getNEODevice()->getMemoryManager();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
* Copyright (C) 2019-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -350,7 +350,10 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
|
||||
|
||||
kernelImmDatas.reserve(this->translationUnit->programInfo.kernelInfos.size());
|
||||
for (auto &ki : this->translationUnit->programInfo.kernelInfos) {
|
||||
std::unique_ptr<KernelImmutableData> kernelImmData{new KernelImmutableData(this->device, ki)};
|
||||
std::unique_ptr<KernelImmutableData> kernelImmData{new KernelImmutableData(this->device)};
|
||||
kernelImmData->initialize(ki, device, device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
this->translationUnit->globalConstBuffer, this->translationUnit->globalVarBuffer,
|
||||
this->type == ModuleType::Builtin);
|
||||
kernelImmDatas.push_back(std::move(kernelImmData));
|
||||
}
|
||||
this->maxGroupSize = static_cast<uint32_t>(this->translationUnit->device->getNEODevice()->getDeviceInfo().maxWorkGroupSize);
|
||||
@@ -361,11 +364,6 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
|
||||
const KernelImmutableData *ModuleImp::getKernelImmutableData(const char *functionName) const {
|
||||
for (auto &kernelImmData : kernelImmDatas) {
|
||||
if (kernelImmData->getDescriptor().kernelMetadata.kernelName.compare(functionName) == 0) {
|
||||
if (kernelImmData->getIsaGraphicsAllocation() == nullptr) {
|
||||
kernelImmData->initialize(device, device->getNEODevice()->getDeviceInfo().computeUnitsUsedForScratch,
|
||||
this->translationUnit->globalConstBuffer, this->translationUnit->globalVarBuffer,
|
||||
this->type == ModuleType::Builtin);
|
||||
}
|
||||
return kernelImmData.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -262,8 +262,8 @@ HWTEST_F(KernelPropertiesTests, whenInitializingThenCalculatesProperPrivateSurfa
|
||||
kernelAttributes.perHwThreadPrivateMemorySize = 0x100;
|
||||
kernelAttributes.simdSize = 8;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
kernelImmutableData.initialize(device, computeUnitsUsedForSratch, nullptr, nullptr, false);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, computeUnitsUsedForSratch, nullptr, nullptr, false);
|
||||
|
||||
size_t expectedSize = static_cast<size_t>(kernelAttributes.perHwThreadPrivateMemorySize) * computeUnitsUsedForSratch;
|
||||
EXPECT_GE(expectedSize, kernelImmutableData.getPrivateMemoryGraphicsAllocation()->getUnderlyingBufferSize());
|
||||
@@ -488,12 +488,12 @@ TEST_F(KernelIsaTests, givenKernelAllocationInLocalMemoryWhenCreatingWithoutAllo
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
auto bcsCsr = device->getNEODevice()->getEngine(aub_stream::EngineType::ENGINE_BCS, false, false).commandStreamReceiver;
|
||||
auto initialTaskCount = bcsCsr->peekTaskCount();
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, false);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
|
||||
if (kernelImmutableData.getIsaGraphicsAllocation()->isAllocatedInLocalMemoryPool()) {
|
||||
EXPECT_EQ(initialTaskCount + 1, bcsCsr->peekTaskCount());
|
||||
@@ -514,12 +514,12 @@ TEST_F(KernelIsaTests, givenKernelAllocationInLocalMemoryWhenCreatingWithAllowed
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
auto bcsCsr = device->getNEODevice()->getEngine(aub_stream::EngineType::ENGINE_BCS, false, false).commandStreamReceiver;
|
||||
auto initialTaskCount = bcsCsr->peekTaskCount();
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, false);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
|
||||
EXPECT_EQ(initialTaskCount, bcsCsr->peekTaskCount());
|
||||
|
||||
@@ -538,12 +538,12 @@ TEST_F(KernelIsaTests, givenKernelAllocationInLocalMemoryWhenCreatingWithDisallo
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
auto bcsCsr = device->getNEODevice()->getEngine(aub_stream::EngineType::ENGINE_BCS, false, false).commandStreamReceiver;
|
||||
auto initialTaskCount = bcsCsr->peekTaskCount();
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, false);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
|
||||
EXPECT_EQ(initialTaskCount, bcsCsr->peekTaskCount());
|
||||
|
||||
@@ -556,9 +556,9 @@ TEST_F(KernelIsaTests, givenKernelInfoWhenInitializingImmutableDataWithInternalI
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, true);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, true);
|
||||
EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::KERNEL_ISA_INTERNAL, kernelImmutableData.getIsaGraphicsAllocation()->getAllocationType());
|
||||
}
|
||||
|
||||
@@ -568,9 +568,9 @@ TEST_F(KernelIsaTests, givenKernelInfoWhenInitializingImmutableDataWithNonIntern
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, false);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
EXPECT_EQ(NEO::GraphicsAllocation::AllocationType::KERNEL_ISA, kernelImmutableData.getIsaGraphicsAllocation()->getAllocationType());
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ TEST_F(KernelIsaTests, givenGlobalBuffersWhenCreatingKernelImmutableDataThenBuff
|
||||
kernelInfo.heapInfo.KernelHeapSize = 1;
|
||||
kernelInfo.heapInfo.pKernelHeap = &kernelHeap;
|
||||
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
uint64_t gpuAddress = 0x1200;
|
||||
void *buffer = reinterpret_cast<void *>(gpuAddress);
|
||||
@@ -588,7 +588,7 @@ TEST_F(KernelIsaTests, givenGlobalBuffersWhenCreatingKernelImmutableDataThenBuff
|
||||
NEO::MockGraphicsAllocation globalVarBuffer(buffer, gpuAddress, size);
|
||||
NEO::MockGraphicsAllocation globalConstBuffer(buffer, gpuAddress, size);
|
||||
|
||||
kernelImmutableData.initialize(device, 0,
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0,
|
||||
&globalConstBuffer, &globalVarBuffer, false);
|
||||
auto &resCont = kernelImmutableData.getResidencyContainer();
|
||||
EXPECT_EQ(1, std::count(resCont.begin(), resCont.end(), &globalVarBuffer));
|
||||
@@ -615,9 +615,9 @@ TEST_F(KernelIsaTests, givenDebugONAndKernelDegugInfoWhenInitializingImmutableDa
|
||||
MockDebugger *debugger = new MockDebugger(neoDevice);
|
||||
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(static_cast<NEO::Debugger *>(debugger));
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, false);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
EXPECT_EQ(kernelInfo.kernelDescriptor.external.debugData->vIsaSize, static_cast<uint32_t>(123));
|
||||
}
|
||||
|
||||
@@ -640,9 +640,9 @@ TEST_F(KernelIsaTests, givenDebugONAndNoKernelDegugInfoWhenInitializingImmutable
|
||||
MockDebugger *debugger = new MockDebugger(neoDevice);
|
||||
|
||||
neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(static_cast<NEO::Debugger *>(debugger));
|
||||
KernelImmutableData kernelImmutableData(device, &kernelInfo);
|
||||
KernelImmutableData kernelImmutableData(device);
|
||||
|
||||
kernelImmutableData.initialize(device, 0, nullptr, nullptr, false);
|
||||
kernelImmutableData.initialize(&kernelInfo, device, 0, nullptr, nullptr, false);
|
||||
EXPECT_EQ(kernelInfo.kernelDescriptor.external.debugData, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -76,56 +76,6 @@ HWTEST_F(ModuleTest, givenNonZeroCountWhenGettingKernelNamesThenNamesAreReturned
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTest, givenCallToGetKernelImmutableDataWithValidNameThenImutableDataIsReturned) {
|
||||
uint32_t count = 1;
|
||||
const char *kernelNames = nullptr;
|
||||
auto result = module->getKernelNames(&count, &kernelNames);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
EXPECT_EQ(1u, count);
|
||||
EXPECT_STREQ(this->kernelName.c_str(), kernelNames);
|
||||
|
||||
auto kernelImmutableData = module->getKernelImmutableData(kernelNames);
|
||||
EXPECT_NE(nullptr, kernelImmutableData);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTest, givenCallToGetKernelImmutableDataWithInvalidNameThenNullptrisReturned) {
|
||||
uint32_t count = 1;
|
||||
const char *kernelNames = nullptr;
|
||||
auto result = module->getKernelNames(&count, &kernelNames);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
EXPECT_EQ(1u, count);
|
||||
EXPECT_STREQ(this->kernelName.c_str(), kernelNames);
|
||||
|
||||
auto kernelImmutableData = module->getKernelImmutableData("nonexistent_kernel");
|
||||
EXPECT_EQ(nullptr, kernelImmutableData);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTest, givenTwoCallsToGetKernelImmutableDataThenKernelImmutableDataIsInitializedOnce) {
|
||||
uint32_t count = 1;
|
||||
const char *kernelNames = nullptr;
|
||||
auto result = module->getKernelNames(&count, &kernelNames);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
|
||||
EXPECT_EQ(1u, count);
|
||||
EXPECT_STREQ(this->kernelName.c_str(), kernelNames);
|
||||
|
||||
auto beforeKernelImmutableData = module->getKernelImmutableData(kernelNames);
|
||||
EXPECT_NE(nullptr, beforeKernelImmutableData);
|
||||
|
||||
auto beforeIsaAllocation = beforeKernelImmutableData->getIsaGraphicsAllocation();
|
||||
EXPECT_NE(nullptr, beforeIsaAllocation);
|
||||
|
||||
auto kernelImmutableData = module->getKernelImmutableData(kernelNames);
|
||||
EXPECT_NE(nullptr, kernelImmutableData);
|
||||
EXPECT_EQ(beforeKernelImmutableData, kernelImmutableData);
|
||||
|
||||
auto isaAllocation = kernelImmutableData->getIsaGraphicsAllocation();
|
||||
EXPECT_NE(nullptr, isaAllocation);
|
||||
EXPECT_EQ(beforeIsaAllocation, isaAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTest, givenUserModuleTypeWhenCreatingModuleThenCorrectTypeIsSet) {
|
||||
WhiteBox<Module> module(device, nullptr, ModuleType::User);
|
||||
EXPECT_EQ(ModuleType::User, module.type);
|
||||
@@ -522,11 +472,6 @@ TEST_F(ModuleDynamicLinkTests, givenModuleWithUnresolvedSymbolWhenTheOtherModule
|
||||
auto kernelInfo = std::make_unique<NEO::KernelInfo>();
|
||||
kernelInfo->heapInfo.pKernelHeap = kernelHeap;
|
||||
kernelInfo->heapInfo.KernelHeapSize = MemoryConstants::pageSize;
|
||||
|
||||
auto kernelImmData = std::make_unique<WhiteBox<::L0::KernelImmutableData>>(device, kernelInfo.get());
|
||||
kernelImmData->isaGraphicsAllocation.reset(neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(
|
||||
{device->getRootDeviceIndex(), MemoryConstants::pageSize, NEO::GraphicsAllocation::AllocationType::KERNEL_ISA, neoDevice->getDeviceBitfield()}));
|
||||
|
||||
module0->getTranslationUnit()->programInfo.kernelInfos.push_back(kernelInfo.release());
|
||||
|
||||
auto linkerInput = std::make_unique<::WhiteBox<NEO::LinkerInput>>();
|
||||
@@ -536,6 +481,10 @@ TEST_F(ModuleDynamicLinkTests, givenModuleWithUnresolvedSymbolWhenTheOtherModule
|
||||
module0->unresolvedExternalsInfo.push_back({unresolvedRelocation});
|
||||
module0->unresolvedExternalsInfo[0].instructionsSegmentId = 0u;
|
||||
|
||||
auto kernelImmData = std::make_unique<WhiteBox<::L0::KernelImmutableData>>(device);
|
||||
kernelImmData->isaGraphicsAllocation.reset(neoDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(
|
||||
{device->getRootDeviceIndex(), MemoryConstants::pageSize, NEO::GraphicsAllocation::AllocationType::KERNEL_ISA, neoDevice->getDeviceBitfield()}));
|
||||
|
||||
auto isaPtr = kernelImmData->getIsaGraphicsAllocation()->getUnderlyingBuffer();
|
||||
|
||||
module0->kernelImmDatas.push_back(std::move(kernelImmData));
|
||||
|
||||
Reference in New Issue
Block a user