feature: Add logic to disable bindless addressing via AIL

Add mockable Device functions to get ReleaseHelper and AILConfiguration.

Resolves: NEO-12699

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2024-09-18 12:38:06 +00:00
committed by Compute-Runtime-Automation
parent 9a44ac6779
commit ebc19b4a70
21 changed files with 103 additions and 28 deletions

View File

@@ -5,7 +5,9 @@
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/device.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/release_helper/release_helper.h"
@@ -30,9 +32,15 @@ bool ApiSpecificConfig::getGlobalBindlessHeapConfiguration(const ReleaseHelper *
return releaseHelper ? releaseHelper->isGlobalBindlessAllocatorEnabled() : false;
}
bool ApiSpecificConfig::getBindlessMode(const ReleaseHelper *releaseHelper) {
bool ApiSpecificConfig::getBindlessMode(const Device &device) {
if (debugManager.flags.UseBindlessMode.get() != -1) {
return debugManager.flags.UseBindlessMode.get();
}
auto ailHelper = device.getAilConfigurationHelper();
auto releaseHelper = device.getReleaseHelper();
if (ailHelper && ailHelper->disableBindlessAddressing()) {
return false;
} else {
return releaseHelper ? !releaseHelper->isBindlessAddressingDisabled() : false;
}

View File

@@ -909,7 +909,7 @@ void ModuleImp::createBuildOptions(const char *pBuildFlags, std::string &apiOpti
createBuildExtraOptions(apiOptions, internalBuildOptions);
}
if (NEO::ApiSpecificConfig::getBindlessMode(device->getNEODevice()->getReleaseHelper())) {
if (NEO::ApiSpecificConfig::getBindlessMode(*device->getNEODevice())) {
NEO::CompilerOptions::concatenateAppend(internalBuildOptions, NEO::CompilerOptions::bindlessMode.str());
}
}

View File

@@ -224,7 +224,7 @@ void CommandListPrivateHeapsFixture::setUp() {
}
void CommandListPrivateHeapsFixture::checkAndPrepareBindlessKernel() {
if (NEO::ApiSpecificConfig::getBindlessMode(device->getNEODevice()->getReleaseHelper())) {
if (NEO::ApiSpecificConfig::getBindlessMode(*device->getNEODevice())) {
const_cast<KernelDescriptor &>(kernel->getKernelDescriptor()).kernelAttributes.bufferAddressingMode = KernelDescriptor::Bindless;
isBindlessKernel = true;
}

View File

@@ -164,7 +164,7 @@ void ModuleFixture::createKernel() {
kernel = std::make_unique<WhiteBox<::L0::KernelImp>>();
kernel->module = module.get();
kernel->initialize(&desc);
if (NEO::ApiSpecificConfig::getBindlessMode(device->getNEODevice()->getReleaseHelper())) {
if (NEO::ApiSpecificConfig::getBindlessMode(*device->getNEODevice())) {
const_cast<KernelDescriptor &>(kernel->getKernelDescriptor()).kernelAttributes.bufferAddressingMode = KernelDescriptor::Bindless;
}
}

View File

@@ -8,6 +8,9 @@
#include "shared/source/command_container/implicit_scaling.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_ail_configuration.h"
#include "shared/test/common/mocks/mock_device.h"
#include "shared/test/common/mocks/mock_release_helper.h"
#include "level_zero/core/source/compiler_interface/l0_reg_path.h"
@@ -93,4 +96,20 @@ TEST(ApiSpecificConfigL0Tests, WhenCheckingIfCompilerCacheIsEnabledByDefaultThen
EXPECT_EQ(1l, ApiSpecificConfig::compilerCacheDefaultEnabled());
}
TEST(ApiSpecificConfigL0Tests, WhenCheckingIfBindlessAddressingIsEnabledThenReturnProperValue) {
MockAILConfiguration mockAilConfigurationHelper;
MockReleaseHelper mockReleaseHelper;
MockDevice mockDevice;
mockReleaseHelper.isBindlessAddressingDisabledResult = false;
mockDevice.mockReleaseHelper = &mockReleaseHelper;
EXPECT_TRUE(ApiSpecificConfig::getBindlessMode(mockDevice));
mockDevice.mockAilConfigurationHelper = &mockAilConfigurationHelper;
EXPECT_TRUE(ApiSpecificConfig::getBindlessMode(mockDevice));
mockAilConfigurationHelper.setDisableBindlessAddressing(true);
EXPECT_FALSE(ApiSpecificConfig::getBindlessMode(mockDevice));
}
} // namespace NEO

View File

@@ -24,7 +24,7 @@ bool ApiSpecificConfig::getGlobalBindlessHeapConfiguration(const ReleaseHelper *
return false;
}
bool ApiSpecificConfig::getBindlessMode(const ReleaseHelper *releaseHelper) {
bool ApiSpecificConfig::getBindlessMode(const Device &device) {
if (debugManager.flags.UseBindlessMode.get() != -1) {
return debugManager.flags.UseBindlessMode.get();
} else {

View File

@@ -80,7 +80,7 @@ std::string Program::getInternalOptions() const {
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::greaterThan4gbBuffersRequired);
}
if (ApiSpecificConfig::getBindlessMode(nullptr)) {
if (debugManager.flags.UseBindlessMode.get() == 1) {
CompilerOptions::concatenateAppend(internalOptions, CompilerOptions::bindlessMode);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -49,8 +49,8 @@ void KernelImageArgTest::SetUp() {
pKernelInfo->addArgImage(4, 0x20);
pKernelInfo->kernelDescriptor.kernelAttributes.bufferAddressingMode = ApiSpecificConfig::getBindlessMode(nullptr) ? KernelDescriptor::AddressingMode::BindlessAndStateless : KernelDescriptor::AddressingMode::BindfulAndStateless;
pKernelInfo->kernelDescriptor.kernelAttributes.imageAddressingMode = ApiSpecificConfig::getBindlessMode(nullptr) ? KernelDescriptor::AddressingMode::Bindless : KernelDescriptor::AddressingMode::Bindful;
pKernelInfo->kernelDescriptor.kernelAttributes.bufferAddressingMode = debugManager.flags.UseBindlessMode.get() == 1 ? KernelDescriptor::AddressingMode::BindlessAndStateless : KernelDescriptor::AddressingMode::BindfulAndStateless;
pKernelInfo->kernelDescriptor.kernelAttributes.imageAddressingMode = debugManager.flags.UseBindlessMode.get() == 1 ? KernelDescriptor::AddressingMode::Bindless : KernelDescriptor::AddressingMode::Bindful;
ClDeviceFixture::setUp();
context.reset(new MockContext(pClDevice));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2023 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -41,7 +41,7 @@ void KernelArgBufferFixture::setUp() {
pKernelInfo->addArgBuffer(0, 0x30, sizeof(void *), 0x0);
pKernelInfo->kernelDescriptor.kernelAttributes.bufferAddressingMode = ApiSpecificConfig::getBindlessMode(nullptr) ? KernelDescriptor::AddressingMode::BindlessAndStateless : KernelDescriptor::AddressingMode::BindfulAndStateless;
pKernelInfo->kernelDescriptor.kernelAttributes.bufferAddressingMode = debugManager.flags.UseBindlessMode.get() == 1 ? KernelDescriptor::AddressingMode::BindlessAndStateless : KernelDescriptor::AddressingMode::BindfulAndStateless;
pProgram = new MockProgram(pContext, false, toClDeviceVector(*pClDevice));

View File

@@ -41,6 +41,7 @@ enum class AILEnumeration : uint32_t {
enableLegacyPlatformName,
disableDirectSubmission,
handleDivergentBarriers,
disableBindlessAddressing,
};
class AILConfiguration;
@@ -77,6 +78,8 @@ class AILConfiguration {
virtual bool handleDivergentBarriers() = 0;
virtual bool disableBindlessAddressing() = 0;
protected:
virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0;
std::string processName;
@@ -84,6 +87,7 @@ class AILConfiguration {
bool sourcesContain(const std::string &sources, std::string_view contentToFind) const;
MOCKABLE_VIRTUAL bool isKernelHashCorrect(const std::string &kernelSources, uint64_t expectedHash) const;
virtual void setHandleDivergentBarriers(bool val) = 0;
virtual void setDisableBindlessAddressing(bool val) = 0;
};
extern const std::set<std::string_view> applicationsContextSyncFlag;
@@ -106,12 +110,15 @@ class AILConfigurationHw : public AILConfiguration {
bool useLegacyValidationLogic() override;
bool forceRcs() override;
bool handleDivergentBarriers() override;
bool disableBindlessAddressing() override;
bool shouldForceRcs = false;
bool shouldHandleDivergentBarriers = false;
bool shouldDisableBindlessAddressing = false;
protected:
void setHandleDivergentBarriers(bool val) override;
void setDisableBindlessAddressing(bool val) override;
};
template <PRODUCT_FAMILY product>

View File

@@ -44,8 +44,16 @@ inline bool AILConfigurationHw<product>::handleDivergentBarriers() {
return shouldHandleDivergentBarriers;
}
template <PRODUCT_FAMILY product>
inline bool AILConfigurationHw<product>::disableBindlessAddressing() {
return shouldDisableBindlessAddressing;
}
template <PRODUCT_FAMILY product>
inline void AILConfigurationHw<product>::setHandleDivergentBarriers(bool val) {
shouldHandleDivergentBarriers = val;
}
template <PRODUCT_FAMILY product>
inline void AILConfigurationHw<product>::setDisableBindlessAddressing(bool val) {
shouldDisableBindlessAddressing = val;
}
} // namespace NEO

View File

@@ -83,7 +83,6 @@ std::string createBuiltinResourceName(EBuiltInOps::Type builtin, const std::stri
StackVec<std::string, 3> getBuiltinResourceNames(EBuiltInOps::Type builtin, BuiltinCode::ECodeType type, const Device &device) {
auto &hwInfo = device.getHardwareInfo();
auto &productHelper = device.getRootDeviceEnvironment().getHelper<ProductHelper>();
auto releaseHelper = device.getReleaseHelper();
auto createDeviceIdFilenameComponent = [](const NEO::HardwareIpVersion &hwIpVersion) {
std::ostringstream deviceId;
@@ -93,14 +92,14 @@ StackVec<std::string, 3> getBuiltinResourceNames(EBuiltInOps::Type builtin, Buil
const auto deviceIp = createDeviceIdFilenameComponent(hwInfo.ipVersion);
const auto builtinFilename = getBuiltinAsString(builtin);
const auto extension = BuiltinCode::getExtension(type);
auto getAddressingModePrefix = [type, &productHelper, releaseHelper, builtin]() {
auto getAddressingModePrefix = [type, &productHelper, &device, builtin]() {
if (type == BuiltinCode::ECodeType::binary) {
const bool requiresStatelessAddressing = (false == productHelper.isStatefulAddressingModeSupported());
const bool builtInUsesStatelessAddressing = EBuiltInOps::isStateless(builtin);
const bool heaplessEnabled = EBuiltInOps::isHeapless(builtin);
if (builtInUsesStatelessAddressing || requiresStatelessAddressing) {
return heaplessEnabled ? "stateless_heapless_" : "stateless_";
} else if (ApiSpecificConfig::getBindlessMode(releaseHelper)) {
} else if (ApiSpecificConfig::getBindlessMode(device)) {
return "bindless_";
} else {
return "bindful_";

View File

@@ -1139,6 +1139,10 @@ ReleaseHelper *Device::getReleaseHelper() const {
return getRootDeviceEnvironment().getReleaseHelper();
}
AILConfiguration *Device::getAilConfigurationHelper() const {
return getRootDeviceEnvironment().getAILConfigurationHelper();
}
void Device::stopDirectSubmissionAndWaitForCompletion() {
for (auto &engine : allEngines) {
auto csr = engine.commandStreamReceiver;

View File

@@ -21,24 +21,25 @@
#include <mutex>
namespace NEO {
class AILConfiguration;
class BindlessHeapsHelper;
class BuiltIns;
class CompilerInterface;
class ExecutionEnvironment;
class CompilerProductHelper;
class Debugger;
class DebuggerL0;
class ExecutionEnvironment;
class GfxCoreHelper;
class GmmClientContext;
class GmmHelper;
class SyncBufferHandler;
enum class EngineGroupType : uint32_t;
class DebuggerL0;
class OSTime;
class SubDevice;
struct PhysicalDevicePciBusInfo;
class GfxCoreHelper;
class ProductHelper;
class CompilerProductHelper;
class ReleaseHelper;
class SubDevice;
class SyncBufferHandler;
class UsmMemAllocPoolsManager;
enum class EngineGroupType : uint32_t;
struct PhysicalDevicePciBusInfo;
struct SelectorCopyEngine : NonCopyableOrMovableClass {
std::atomic<bool> isMainUsed = false;
@@ -191,7 +192,8 @@ class Device : public ReferenceTrackedObject<Device> {
const GfxCoreHelper &getGfxCoreHelper() const;
const ProductHelper &getProductHelper() const;
const CompilerProductHelper &getCompilerProductHelper() const;
ReleaseHelper *getReleaseHelper() const;
MOCKABLE_VIRTUAL ReleaseHelper *getReleaseHelper() const;
MOCKABLE_VIRTUAL AILConfiguration *getAilConfigurationHelper() const;
ISAPoolAllocator &getIsaPoolAllocator() {
return isaPoolAllocator;
}

View File

@@ -50,7 +50,7 @@ Device *RootDevice::getRootDevice() const {
void RootDevice::createBindlessHeapsHelper() {
if (ApiSpecificConfig::getGlobalBindlessHeapConfiguration(this->getReleaseHelper()) && ApiSpecificConfig::getBindlessMode(this->getReleaseHelper())) {
if (ApiSpecificConfig::getGlobalBindlessHeapConfiguration(this->getReleaseHelper()) && ApiSpecificConfig::getBindlessMode(*this)) {
this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(this, getNumGenericSubDevices() > 1);
}
}

View File

@@ -14,6 +14,7 @@
#include <vector>
namespace NEO {
class Device;
class ReleaseHelper;
struct RootDeviceEnvironment;
@@ -22,7 +23,7 @@ struct ApiSpecificConfig {
L0 };
static bool isStatelessCompressionSupported();
static bool getGlobalBindlessHeapConfiguration(const ReleaseHelper *releaseHelper);
static bool getBindlessMode(const ReleaseHelper *);
static bool getBindlessMode(const Device &device);
static bool isDeviceAllocationCacheEnabled();
static bool isHostAllocationCacheEnabled();
static bool isDeviceUsmPoolingEnabled();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2023 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -236,7 +236,7 @@ struct ValidEmptyKernel {
auto execEnvTokInl = initToken<iOpenCL::SPatchExecutionEnvironment>(iOpenCL::PATCH_TOKEN_EXECUTION_ENVIRONMENT);
execEnvTokInl.LargestCompiledSIMDSize = 32U;
execEnvTokInl.CompiledSIMD32 = 1U;
execEnvTokInl.UseBindlessMode = NEO::ApiSpecificConfig::getBindlessMode(nullptr);
execEnvTokInl.UseBindlessMode = NEO::debugManager.flags.UseBindlessMode.get() == 1;
headerTokInl.PatchListSize = sizeof(execEnvTokInl);
ret.decodeStatus = NEO::DecodeError::success;
ret.name = "test_kernel";

View File

@@ -45,6 +45,14 @@ class MockAILConfiguration : public AILConfiguration {
}
bool handleDivergentBarriersValue = false;
bool disableBindlessAddressing() override {
return disableBindlessAddressingValue;
}
void setDisableBindlessAddressing(bool val) override {
disableBindlessAddressingValue = val;
}
bool disableBindlessAddressingValue = false;
protected:
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override {}
};

View File

@@ -167,6 +167,20 @@ ExecutionEnvironment *MockDevice::prepareExecutionEnvironment(const HardwareInfo
return executionEnvironment;
}
ReleaseHelper *MockDevice::getReleaseHelper() const {
if (mockReleaseHelper) {
return mockReleaseHelper;
}
return Device::getReleaseHelper();
}
AILConfiguration *MockDevice::getAilConfigurationHelper() const {
if (mockAilConfigurationHelper) {
return mockAilConfigurationHelper;
}
return Device::getAilConfigurationHelper();
}
bool MockSubDevice::createEngine(EngineTypeUsage engineTypeUsage) {
if (failOnCreateEngine) {
return false;

View File

@@ -164,6 +164,9 @@ class MockDevice : public RootDevice {
void finalizeRayTracing();
ReleaseHelper *getReleaseHelper() const override;
AILConfiguration *getAilConfigurationHelper() const override;
void setRTDispatchGlobalsForceAllocation() {
rtDispatchGlobalsForceAllocation = true;
}
@@ -181,6 +184,8 @@ class MockDevice : public RootDevice {
size_t maxParameterSizeFromIGC = 0u;
bool rtDispatchGlobalsForceAllocation = true;
bool stopDirectSubmissionCalled = false;
ReleaseHelper *mockReleaseHelper = nullptr;
AILConfiguration *mockAilConfigurationHelper = nullptr;
};
template <>

View File

@@ -35,7 +35,7 @@ bool ApiSpecificConfig::getGlobalBindlessHeapConfiguration(const ReleaseHelper *
}
return false;
}
bool ApiSpecificConfig::getBindlessMode(const ReleaseHelper *) {
bool ApiSpecificConfig::getBindlessMode(const Device &device) {
if (debugManager.flags.UseBindlessMode.get() != -1) {
return debugManager.flags.UseBindlessMode.get();
} else {