mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Revert "Fail build program on PVC with stateful accesses"
This reverts commit 9466113cef.
Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
cec0ea2809
commit
c5c3e865f0
@@ -16,7 +16,6 @@
|
||||
#include "shared/source/device_binary_format/elf/elf.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/device_binary_format/elf/ocl_elf.h"
|
||||
#include "shared/source/helpers/addressing_mode_helper.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/kernel_helpers.h"
|
||||
@@ -44,7 +43,6 @@ namespace BuildOptions {
|
||||
NEO::ConstStringRef optDisable = "-ze-opt-disable";
|
||||
NEO::ConstStringRef optLevel = "-ze-opt-level";
|
||||
NEO::ConstStringRef greaterThan4GbRequired = "-ze-opt-greater-than-4GB-buffer-required";
|
||||
NEO::ConstStringRef smallerThan4GbBuffersOnly = "-ze-opt-smaller-than-4GB-buffers-only";
|
||||
NEO::ConstStringRef hasBufferOffsetArg = "-ze-intel-has-buffer-offset-arg";
|
||||
NEO::ConstStringRef debugKernelEnable = "-ze-kernel-debug-enable";
|
||||
} // namespace BuildOptions
|
||||
@@ -126,10 +124,8 @@ std::string ModuleTranslationUnit::generateCompilerOptions(const char *buildOpti
|
||||
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, BuildOptions::debugKernelEnable);
|
||||
}
|
||||
|
||||
auto disableStatelessToStatefulOptimization = NEO::DebugManager.flags.DisableStatelessToStatefulOptimization.get();
|
||||
auto isForceToStatelessNeeded = NEO::AddressingModeHelper::forceToStatelessNeeded(options, BuildOptions::smallerThan4GbBuffersOnly.str(), device->getHwInfo());
|
||||
|
||||
if (disableStatelessToStatefulOptimization || isForceToStatelessNeeded) {
|
||||
if (NEO::DebugManager.flags.DisableStatelessToStatefulOptimization.get() ||
|
||||
device->getNEODevice()->areSharedSystemAllocationsAllowed()) {
|
||||
internalOptions = NEO::CompilerOptions::concatenate(internalOptions, NEO::CompilerOptions::greaterThan4gbBuffersRequired);
|
||||
}
|
||||
|
||||
@@ -527,14 +523,6 @@ bool ModuleImp::initialize(const ze_module_desc_t *desc, NEO::Device *neoDevice)
|
||||
this->updateBuildLog(neoDevice);
|
||||
verifyDebugCapabilities();
|
||||
|
||||
auto containsStatefulAccess = NEO::AddressingModeHelper::containsStatefulAccess(translationUnit->programInfo.kernelInfos);
|
||||
auto isForceToStatelessNeeded = NEO::AddressingModeHelper::forceToStatelessNeeded(translationUnit->options, BuildOptions::smallerThan4GbBuffersOnly.str(), device->getHwInfo());
|
||||
auto isUserKernel = (type == ModuleType::User);
|
||||
|
||||
if (containsStatefulAccess && isForceToStatelessNeeded && isUserKernel) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (false == success) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "shared/source/device_binary_format/debug_zebin.h"
|
||||
#include "shared/source/gmm_helper/gmm.h"
|
||||
#include "shared/source/gmm_helper/gmm_helper.h"
|
||||
#include "shared/source/helpers/addressing_mode_helper.h"
|
||||
#include "shared/source/helpers/compiler_hw_info_config.h"
|
||||
#include "shared/source/kernel/implicit_args.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
@@ -1785,19 +1783,28 @@ HWTEST_F(ModuleTranslationUnitTest, WhenBuildOptionsAreNullThenReuseExistingOpti
|
||||
EXPECT_NE(pMockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos);
|
||||
}
|
||||
|
||||
HWTEST_F(ModuleTranslationUnitTest, givenForceToStatelessRequiredWhenBuildingModuleThen4GbBuffersAreRequired) {
|
||||
HWTEST_F(ModuleTranslationUnitTest, givenSystemSharedAllocationAllowedWhenBuildingModuleThen4GbBuffersAreRequired) {
|
||||
auto mockCompilerInterface = new MockCompilerInterface;
|
||||
auto &rootDeviceEnvironment = neoDevice->executionEnvironment->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()];
|
||||
rootDeviceEnvironment->compilerInterface.reset(mockCompilerInterface);
|
||||
|
||||
MockModuleTranslationUnit moduleTu(device);
|
||||
auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr);
|
||||
EXPECT_TRUE(ret);
|
||||
{
|
||||
neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = 1;
|
||||
|
||||
MockModuleTranslationUnit moduleTu(device);
|
||||
auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
|
||||
if (compilerHwInfoConfig.isForceToStatelessRequired()) {
|
||||
EXPECT_NE(mockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos);
|
||||
} else {
|
||||
}
|
||||
|
||||
{
|
||||
neoDevice->getRootDeviceEnvironment().getMutableHardwareInfo()->capabilityTable.sharedSystemMemCapabilities = 0;
|
||||
|
||||
MockModuleTranslationUnit moduleTu(device);
|
||||
auto ret = moduleTu.buildFromSpirV("", 0U, nullptr, "", nullptr);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
EXPECT_EQ(mockCompilerInterface->inputInternalOptions.find("cl-intel-greater-than-4GB-buffer-required"), std::string::npos);
|
||||
}
|
||||
}
|
||||
@@ -2005,155 +2012,6 @@ TEST_F(ModuleTest, GivenInjectInternalBuildOptionsWhenBuildingBuiltinModuleThenI
|
||||
EXPECT_FALSE(CompilerOptions::contains(cip->buildInternalOptions, "-abc"));
|
||||
};
|
||||
|
||||
TEST_F(ModuleTest, givenForceToStatelessRequiredWhenGenerateCompilerOptionsThenOptionsAreCorrect) {
|
||||
|
||||
const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
|
||||
if (!compilerHwInfoConfig.isForceToStatelessRequired()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
auto module = std::make_unique<ModuleImp>(device, nullptr, ModuleType::User);
|
||||
ASSERT_NE(nullptr, module);
|
||||
auto moduleTranslationUnit = module->getTranslationUnit();
|
||||
ASSERT_NE(nullptr, moduleTranslationUnit);
|
||||
std::string buildOptions;
|
||||
std::string internalBuildOptions;
|
||||
|
||||
{
|
||||
NEO::DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(-1);
|
||||
buildOptions = "";
|
||||
auto internalOptions = moduleTranslationUnit->generateCompilerOptions(buildOptions.c_str(), internalBuildOptions.c_str());
|
||||
EXPECT_THAT(internalOptions, testing::HasSubstr("-cl-intel-greater-than-4GB-buffer-required"));
|
||||
}
|
||||
{
|
||||
NEO::DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(-1);
|
||||
buildOptions = "-ze-opt-smaller-than-4GB-buffers-only";
|
||||
auto internalOptions = moduleTranslationUnit->generateCompilerOptions(buildOptions.c_str(), internalBuildOptions.c_str());
|
||||
EXPECT_THAT(internalOptions, testing::Not(testing::HasSubstr("-cl-intel-greater-than-4GB-buffer-required")));
|
||||
}
|
||||
{
|
||||
NEO::DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(0);
|
||||
buildOptions = "";
|
||||
auto internalOptions = moduleTranslationUnit->generateCompilerOptions(buildOptions.c_str(), internalBuildOptions.c_str());
|
||||
EXPECT_THAT(internalOptions, testing::HasSubstr("-cl-intel-greater-than-4GB-buffer-required"));
|
||||
}
|
||||
{
|
||||
NEO::DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(0);
|
||||
buildOptions = "-ze-opt-smaller-than-4GB-buffers-only";
|
||||
auto internalOptions = moduleTranslationUnit->generateCompilerOptions(buildOptions.c_str(), internalBuildOptions.c_str());
|
||||
EXPECT_THAT(internalOptions, testing::HasSubstr("-cl-intel-greater-than-4GB-buffer-required"));
|
||||
}
|
||||
{
|
||||
NEO::DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(1);
|
||||
buildOptions = "";
|
||||
auto internalOptions = moduleTranslationUnit->generateCompilerOptions(buildOptions.c_str(), internalBuildOptions.c_str());
|
||||
EXPECT_THAT(internalOptions, testing::Not(testing::HasSubstr("-cl-intel-greater-than-4GB-buffer-required")));
|
||||
}
|
||||
{
|
||||
NEO::DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(1);
|
||||
buildOptions = "-ze-opt-smaller-than-4GB-buffers-only";
|
||||
auto internalOptions = moduleTranslationUnit->generateCompilerOptions(buildOptions.c_str(), internalBuildOptions.c_str());
|
||||
EXPECT_THAT(internalOptions, testing::Not(testing::HasSubstr("-cl-intel-greater-than-4GB-buffer-required")));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ModuleTest, whenContainsStatefulAccessIsCalledThenResultIsCorrect) {
|
||||
class MyModuleImpl : public ModuleImp {
|
||||
public:
|
||||
using ModuleImp::ModuleImp;
|
||||
};
|
||||
|
||||
std::vector<std::tuple<bool, SurfaceStateHeapOffset, CrossThreadDataOffset>> testParams = {
|
||||
{false, undefined<SurfaceStateHeapOffset>, undefined<CrossThreadDataOffset>},
|
||||
{true, 0x40, undefined<CrossThreadDataOffset>},
|
||||
{true, undefined<SurfaceStateHeapOffset>, 0x40},
|
||||
{true, 0x40, 0x40},
|
||||
};
|
||||
|
||||
for (auto &[expectedResult, surfaceStateHeapOffset, crossThreadDataOffset] : testParams) {
|
||||
auto module = std::make_unique<MyModuleImpl>(device, nullptr, ModuleType::User);
|
||||
ASSERT_NE(nullptr, module);
|
||||
auto moduleTranslationUnit = module->getTranslationUnit();
|
||||
ASSERT_NE(nullptr, moduleTranslationUnit);
|
||||
auto kernelInfo = std::make_unique<KernelInfo>();
|
||||
kernelInfo->kernelDescriptor.payloadMappings.explicitArgs.clear();
|
||||
auto argDescriptor = ArgDescriptor(ArgDescriptor::ArgTPointer);
|
||||
argDescriptor.as<ArgDescPointer>().bindful = surfaceStateHeapOffset;
|
||||
argDescriptor.as<ArgDescPointer>().bindless = crossThreadDataOffset;
|
||||
kernelInfo->kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptor);
|
||||
moduleTranslationUnit->programInfo.kernelInfos.clear();
|
||||
moduleTranslationUnit->programInfo.kernelInfos.push_back(kernelInfo.release());
|
||||
|
||||
EXPECT_EQ(expectedResult, NEO::AddressingModeHelper::containsStatefulAccess(moduleTranslationUnit->programInfo.kernelInfos));
|
||||
}
|
||||
}
|
||||
|
||||
using ModuleInitializeTest = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(ModuleInitializeTest, whenModuleInitializeIsCalledThenCorrectResultIsReturned) {
|
||||
class MockModuleImp : public ModuleImp {
|
||||
public:
|
||||
using ModuleImp::ModuleImp;
|
||||
using ModuleImp::translationUnit;
|
||||
|
||||
void setAddressingMode(bool isStateful) {
|
||||
auto kernelInfo = std::make_unique<KernelInfo>();
|
||||
kernelInfo->kernelDescriptor.payloadMappings.explicitArgs.clear();
|
||||
auto argDescriptor = ArgDescriptor(ArgDescriptor::ArgTPointer);
|
||||
if (isStateful) {
|
||||
argDescriptor.as<ArgDescPointer>().bindful = 0x40;
|
||||
argDescriptor.as<ArgDescPointer>().bindless = 0x40;
|
||||
} else {
|
||||
argDescriptor.as<ArgDescPointer>().bindful = undefined<SurfaceStateHeapOffset>;
|
||||
argDescriptor.as<ArgDescPointer>().bindless = undefined<CrossThreadDataOffset>;
|
||||
}
|
||||
kernelInfo->kernelDescriptor.payloadMappings.explicitArgs.push_back(argDescriptor);
|
||||
kernelInfo->heapInfo.KernelHeapSize = 0x1;
|
||||
kernelInfo->heapInfo.pKernelHeap = reinterpret_cast<void *>(0xffff);
|
||||
|
||||
this->translationUnit->programInfo.kernelInfos.clear();
|
||||
this->translationUnit->programInfo.kernelInfos.push_back(kernelInfo.release());
|
||||
}
|
||||
};
|
||||
|
||||
class MyMockModuleTU : public MockModuleTU {
|
||||
public:
|
||||
using MockModuleTU::MockModuleTU;
|
||||
bool createFromNativeBinary(const char *input, size_t inputSize) override { return true; }
|
||||
};
|
||||
|
||||
const auto &compilerHwInfoConfig = *CompilerHwInfoConfig::get(defaultHwInfo->platform.eProductFamily);
|
||||
if (!compilerHwInfoConfig.isForceToStatelessRequired()) {
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
std::string testFile;
|
||||
retrieveBinaryKernelFilenameNoRevision(testFile, "test_kernel_", ".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;
|
||||
|
||||
std::array<std::tuple<bool, bool, ModuleType, int32_t>, 4> testParams = {{{true, false, ModuleType::Builtin, -1},
|
||||
{true, true, ModuleType::Builtin, 1},
|
||||
{true, true, ModuleType::Builtin, 0},
|
||||
{false, true, ModuleType::User, 0}}};
|
||||
|
||||
for (auto &[expectedResult, isStateful, moduleType, debugKey] : testParams) {
|
||||
MockModuleImp module(device, nullptr, moduleType);
|
||||
module.translationUnit = std::make_unique<MyMockModuleTU>(device);
|
||||
DebugManager.flags.UseSmallerThan4gbBuffersOnly.set(debugKey);
|
||||
module.setAddressingMode(isStateful);
|
||||
EXPECT_EQ(expectedResult, module.initialize(&moduleDesc, device->getNEODevice()));
|
||||
}
|
||||
}
|
||||
|
||||
using ModuleDebugDataTest = Test<DeviceFixture>;
|
||||
TEST_F(ModuleDebugDataTest, GivenDebugDataWithRelocationsWhenCreatingRelocatedDebugDataThenRelocationsAreApplied) {
|
||||
auto cip = new NEO::MockCompilerInterfaceCaptureBuildOptions();
|
||||
|
||||
Reference in New Issue
Block a user