feature: Introduce SipClassType::externalLib

Related-To: NEO-13737
Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:
Jitendra Sharma
2025-03-18 18:19:14 +00:00
committed by Compute-Runtime-Automation
parent 0e25970853
commit dda7876d3a
15 changed files with 144 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2024 Intel Corporation
# Copyright (C) 2019-2025 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -121,6 +121,7 @@ append_sources_from_properties(CORE_SOURCES
NEO_CORE_GEN_COMMON
NEO_CORE_GMM_HELPER
NEO_CORE_HELPERS
NEO_CORE_HELPERS_SIP_EXTERNAL_LIB
NEO_CORE_IMAGE
NEO_CORE_INDIRECT_HEAP
NEO_CORE_KERNEL

View File

@@ -23,6 +23,7 @@
#include "shared/source/memory_manager/allocation_properties.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/sip_external_lib/sip_external_lib.h"
#include "shared/source/utilities/io_functions.h"
#include "common/StateSaveAreaHeader.h"
@@ -249,13 +250,21 @@ bool SipKernel::initHexadecimalArraySipKernel(SipKernelType type, Device &device
return true;
}
bool SipKernel::initSipKernelFromExternalLib(SipKernelType type, Device &device) {
return false;
}
void SipKernel::selectSipClassType(std::string &fileName, Device &device) {
const GfxCoreHelper &gfxCoreHelper = device.getGfxCoreHelper();
const std::string unknown("unk");
if (fileName.compare(unknown) == 0) {
bool debuggingEnabled = device.getDebugger() != nullptr;
if (debuggingEnabled) {
SipKernel::classType = SipClassType::builtins;
if (device.getSipExternalLibInterface() != nullptr) {
SipKernel::classType = SipClassType::externalLib;
} else {
SipKernel::classType = SipClassType::builtins;
}
} else {
SipKernel::classType = gfxCoreHelper.isSipKernelAsHexadecimalArrayPreferred()
? SipClassType::hexadecimalHeaderFile
@@ -278,6 +287,8 @@ bool SipKernel::initSipKernelImpl(SipKernelType type, Device &device, OsContext
return SipKernel::initRawBinaryFromFileKernel(type, device, fileName);
case SipClassType::hexadecimalHeaderFile:
return SipKernel::initHexadecimalArraySipKernel(type, device);
case SipClassType::externalLib:
return SipKernel::initSipKernelFromExternalLib(type, device);
default:
return SipKernel::initBuiltinsSipKernel(type, device, context);
}

View File

@@ -75,6 +75,7 @@ class SipKernel : NEO::NonCopyableAndNonMovableClass {
static std::string createHeaderFilename(const std::string &filename);
static bool initHexadecimalArraySipKernel(SipKernelType type, Device &device);
static bool initSipKernelFromExternalLib(SipKernelType type, Device &device);
static void selectSipClassType(std::string &fileName, Device &device);
const std::vector<char> stateSaveAreaHeader;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -24,7 +24,8 @@ enum class SipClassType : std::uint32_t {
init = 0,
builtins,
rawBinaryFromFile,
hexadecimalHeaderFile
hexadecimalHeaderFile,
externalLib
};
} // namespace NEO

View File

@@ -296,7 +296,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableWaitOnUserFenceAfterBindAndUnbind, -1, "-1
DECLARE_DEBUG_VARIABLE(int32_t, ForceTlbFlushWithTaskCountAfterCopy, -1, "-1: default, 0: Do not force TLB flush (default), 1: Force TLB flush with task count update after copy")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideCmdListUpdateCapability, -1, "-1: default, >=0: Use value to report command list update capability")
DECLARE_DEBUG_VARIABLE(int32_t, ForceSynchronizedDispatchMode, -1, "-1: default, 0: disabled, 1: enable full synchronization mode")
DECLARE_DEBUG_VARIABLE(int32_t, ForceSipClass, -1, "-1: default, otherwise based on values from enum class SipClassType (init, builtins, rawBinaryFromFile, hexadecimalHeaderFile)")
DECLARE_DEBUG_VARIABLE(int32_t, ForceSipClass, -1, "-1: default, otherwise based on values from enum class SipClassType (init, builtins, rawBinaryFromFile, hexadecimalHeaderFile, externalLib)")
DECLARE_DEBUG_VARIABLE(int32_t, ForceScratchAndMTPBufferSizeMode, -1, "-1: default, 0: Full, 1: Min. BMG+: Reduce required memory for scratch and MTP buffers on CCS context")
DECLARE_DEBUG_VARIABLE(int32_t, CFEStackIDControl, -1, "Set Stack ID Control in CFE_STATE on Xe2+, -1 - do not set")
DECLARE_DEBUG_VARIABLE(int32_t, StandaloneInOrderTimestampAllocationEnabled, -1, "-1: default, 0: disabled, 1: enabled. If enabled, use internal allocations, instead of Event pool for timestamps")

View File

@@ -31,6 +31,7 @@
#include "shared/source/os_interface/os_time.h"
#include "shared/source/program/sync_buffer_handler.h"
#include "shared/source/release_helper/release_helper.h"
#include "shared/source/sip_external_lib/sip_external_lib.h"
#include "shared/source/unified_memory/usm_memory_support.h"
#include "shared/source/utilities/software_tags_manager.h"
@@ -1190,6 +1191,10 @@ CompilerInterface *Device::getCompilerInterface() const {
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getCompilerInterface();
}
SipExternalLib *Device::getSipExternalLibInterface() const {
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getSipExternalLibInterface();
}
BuiltIns *Device::getBuiltIns() const {
return executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->getBuiltIns();
}

View File

@@ -36,6 +36,7 @@ class GmmHelper;
class OSTime;
class ProductHelper;
class ReleaseHelper;
class SipExternalLib;
class SubDevice;
class SyncBufferHandler;
class UsmMemAllocPoolsManager;
@@ -157,6 +158,7 @@ class Device : public ReferenceTrackedObject<Device>, NEO::NonCopyableAndNonMova
return reinterpret_cast<SpecializedDeviceT *>(specializedDevice);
}
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface() const;
MOCKABLE_VIRTUAL SipExternalLib *getSipExternalLibInterface() const;
BuiltIns *getBuiltIns() const;
void allocateSyncBufferHandler();

View File

@@ -34,6 +34,7 @@
#include "shared/source/os_interface/os_time.h"
#include "shared/source/os_interface/product_helper.h"
#include "shared/source/release_helper/release_helper.h"
#include "shared/source/sip_external_lib/sip_external_lib.h"
#include "shared/source/utilities/software_tags_manager.h"
namespace NEO {
@@ -155,6 +156,16 @@ CompilerInterface *RootDeviceEnvironment::getCompilerInterface() {
return this->compilerInterface.get();
}
SipExternalLib *RootDeviceEnvironment::getSipExternalLibInterface() {
if (sipExternalLib.get() == nullptr) {
if (gfxCoreHelper->getSipBinaryFromExternalLib()) {
std::lock_guard<std::mutex> autolock(this->mtx);
sipExternalLib.reset(SipExternalLib::getSipExternalLibInstance());
}
}
return sipExternalLib.get();
}
void RootDeviceEnvironment::initHelpers() {
initProductHelper();
initGfxCoreHelper();

View File

@@ -21,6 +21,7 @@ class AubCenter;
class BindlessHeapsHelper;
class BuiltIns;
class CompilerInterface;
class SipExternalLib;
class Debugger;
class Device;
class ExecutionEnvironment;
@@ -74,6 +75,7 @@ struct RootDeviceEnvironment : NonCopyableClass {
GmmHelper *getGmmHelper() const;
GmmClientContext *getGmmClientContext() const;
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
MOCKABLE_VIRTUAL SipExternalLib *getSipExternalLibInterface();
BuiltIns *getBuiltIns();
BindlessHeapsHelper *getBindlessHeapsHelper() const;
AssertHandler *getAssertHandler(Device *neoDevice);
@@ -106,6 +108,7 @@ struct RootDeviceEnvironment : NonCopyableClass {
std::unique_ptr<OSTime> osTime;
std::unique_ptr<CompilerInterface> compilerInterface;
std::unique_ptr<SipExternalLib> sipExternalLib;
std::unique_ptr<BuiltIns> builtins;
std::unique_ptr<Debugger> debugger;
std::unique_ptr<SWTagsManager> tagsManager;

View File

@@ -0,0 +1,14 @@
#
# Copyright (C) 2025 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_HELPERS_SIP_EXTERNAL_LIB
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}sip_external_lib.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sip_external_lib.h
)
set_property(GLOBAL APPEND PROPERTY NEO_CORE_HELPERS_SIP_EXTERNAL_LIB ${NEO_CORE_HELPERS_SIP_EXTERNAL_LIB})
add_subdirectories()

View File

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/sip_external_lib/sip_external_lib.h"
namespace NEO {
SipExternalLib *SipExternalLib::getSipExternalLibInstance() {
return nullptr;
}
} // namespace NEO

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "shared/source/os_interface/os_library.h"
#include <memory>
#include <string>
namespace NEO {
class SipExternalLib : NonCopyableAndNonMovableClass {
public:
virtual ~SipExternalLib() {}
static SipExternalLib *getSipExternalLibInstance();
static std::string_view getLibName();
std::unique_ptr<OsLibrary> libraryHandle = nullptr;
};
} // namespace NEO

View File

@@ -26,6 +26,7 @@
#include "shared/test/common/mocks/mock_os_context.h"
#include "shared/test/common/mocks/mock_release_helper.h"
#include "shared/test/common/mocks/mock_sip.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "shared/test/common/test_macros/test.h"
#include "common/StateSaveAreaHeader.h"
@@ -931,3 +932,21 @@ TEST(SipTest, whenForcingBuiltinSipClassThenPreemptionSurfaceSizeIsSetBasedOnSta
EXPECT_NE(initialPreemptionSurfaceSize, preemptionSurfaceSize);
EXPECT_EQ(sipKernel.getStateSaveAreaSize(mockDevice.get()), preemptionSurfaceSize);
}
using DebugExternalLibSipTest = Test<DeviceFixture>;
HWTEST2_F(DebugExternalLibSipTest, givenDebuggerWhenInitSipKernelThenDbgSipIsLoadedFromBuiltIns, IsAtMostXe3Core) {
DebugManagerStateRestore restorer;
debugManager.flags.GetSipBinaryFromExternalLib.set(1);
VariableBackup<bool> mockSipBackup(&MockSipData::useMockSip, false);
pDevice->executionEnvironment->rootDeviceEnvironments[0]->initDebuggerL0(pDevice);
std::string fileName = "unk";
SipKernelMock::selectSipClassType(fileName, *pDevice);
EXPECT_EQ(SipKernelMock::classType, SipClassType::builtins);
}
TEST_F(DebugExternalLibSipTest, givenGetSipBinaryFromExternalLibRetunsTrueWhenGetSipExternalLibInterfaceIsCalledThenNullptrReturned) {
DebugManagerStateRestore restorer;
debugManager.flags.GetSipBinaryFromExternalLib.set(1);
EXPECT_EQ(nullptr, pDevice->getSipExternalLibInterface());
}

View File

@@ -0,0 +1,12 @@
#
# Copyright (C) 2025 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
target_sources(neo_shared_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}sip_external_lib_tests.cpp
)
add_subdirectories()

View File

@@ -0,0 +1,17 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/sip_external_lib/sip_external_lib.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(SipExternalLibTest, whenGetSipExternalLibInstanceCalledThenNullptrRetuned) {
auto sipExternalLib = SipExternalLib::getSipExternalLibInstance();
EXPECT_EQ(nullptr, sipExternalLib);
}