mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 09:03:14 +08:00
Each host function gets its unique ID within a CSR, uses 1 mi store to write ID - to signal that host function is ready, and 1 mi semaphore wait will wait for the ID to be cleared, Use 0th bit from ID as pending/completed flag, host function ID is incremented by 2, and starts with 1. So each ID will always have 0bit set. This is a must have since semaphore wait can wait for 4 bytes only. Adjust command buffer programming and patching logic to IDs. Add hostFunction callable class - using invoke method, which stores required information about callback. Add host function streamer - stores all host function data for a given CSR. All user provided host functions are stored in unordered map, where key is host function ID. Add host function scheduler, and a thread pool - under debug flag Single threaded scheduler loops over all registered host function streamers, dispatch ready to execute host functions to thread pool. Allow for out of order host functions execution for OOQ - under debug flag, each host function has bool isInOrder flag which indicates if it can be executed Out Of Order - in this mode, ID tag will be cleared immediately, so semaphore wait will unblock before the host function execution. Remove Host Function worker CV and atomics based implementation. Rename classes Related-To: NEO-14577 Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
159 lines
5.3 KiB
C++
159 lines
5.3 KiB
C++
/*
|
|
* Copyright (C) 2019-2025 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include "shared/source/built_ins/sip_kernel_type.h"
|
|
#include "shared/source/helpers/affinity_mask.h"
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
|
#include "shared/source/helpers/options.h"
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <mutex>
|
|
|
|
namespace NEO {
|
|
class AssertHandler;
|
|
class AubCenter;
|
|
class BindlessHeapsHelper;
|
|
class BuiltIns;
|
|
class CompilerInterface;
|
|
class SipExternalLib;
|
|
class Debugger;
|
|
class Device;
|
|
class ExecutionEnvironment;
|
|
class GmmClientContext;
|
|
class GmmHelper;
|
|
class GmmPageTableMngr;
|
|
class HwDeviceId;
|
|
class MemoryManager;
|
|
class MemoryOperationsHandler;
|
|
class OSInterface;
|
|
class OSTime;
|
|
class SipKernel;
|
|
class SWTagsManager;
|
|
class ProductHelper;
|
|
class GfxCoreHelper;
|
|
class ApiGfxCoreHelper;
|
|
class CompilerProductHelper;
|
|
class GraphicsAllocation;
|
|
class ReleaseHelper;
|
|
class AILConfiguration;
|
|
class HostFunctionWorker;
|
|
|
|
struct AllocationProperties;
|
|
struct HardwareInfo;
|
|
|
|
struct RootDeviceEnvironment : NonCopyableClass {
|
|
|
|
protected:
|
|
std::unique_ptr<HardwareInfo> hwInfo;
|
|
|
|
public:
|
|
RootDeviceEnvironment(ExecutionEnvironment &executionEnvironment);
|
|
MOCKABLE_VIRTUAL ~RootDeviceEnvironment();
|
|
|
|
MOCKABLE_VIRTUAL const HardwareInfo *getHardwareInfo() const;
|
|
HardwareInfo *getMutableHardwareInfo() const;
|
|
void setHwInfoAndInitHelpers(const HardwareInfo *hwInfo);
|
|
void setHwInfo(const HardwareInfo *hwInfo);
|
|
bool isFullRangeSvm() const;
|
|
bool isWddmOnLinux() const;
|
|
|
|
MOCKABLE_VIRTUAL void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType);
|
|
MOCKABLE_VIRTUAL bool initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex);
|
|
void initOsTime();
|
|
void initGmm();
|
|
void initDebuggerL0(Device *neoDevice);
|
|
void initWaitUtils();
|
|
MOCKABLE_VIRTUAL void initDummyAllocation();
|
|
void setDummyBlitProperties(uint32_t rootDeviceIndex);
|
|
|
|
MOCKABLE_VIRTUAL void prepareForCleanup() const;
|
|
MOCKABLE_VIRTUAL bool initAilConfiguration();
|
|
GmmHelper *getGmmHelper() const;
|
|
GmmClientContext *getGmmClientContext() const;
|
|
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();
|
|
MOCKABLE_VIRTUAL SipExternalLib *getSipExternalLibInterface();
|
|
BuiltIns *getBuiltIns();
|
|
BindlessHeapsHelper *getBindlessHeapsHelper() const;
|
|
AssertHandler *getAssertHandler(Device *neoDevice);
|
|
void createBindlessHeapsHelper(Device *rootDevice, bool availableDevices);
|
|
void setNumberOfCcs(uint32_t numberOfCcs);
|
|
uint32_t getNumberOfCcs() const;
|
|
bool isNumberOfCcsLimited() const;
|
|
void setRcsExposure();
|
|
void initProductHelper();
|
|
void initHelpers();
|
|
void initGfxCoreHelper();
|
|
void initializeGfxCoreHelperFromHwInfo();
|
|
void initializeGfxCoreHelperFromProductHelper();
|
|
void initApiGfxCoreHelper();
|
|
void initCompilerProductHelper();
|
|
void initReleaseHelper();
|
|
void initAilConfigurationHelper();
|
|
ReleaseHelper *getReleaseHelper() const;
|
|
AILConfiguration *getAILConfigurationHelper() const;
|
|
template <typename HelperType>
|
|
HelperType &getHelper() const;
|
|
const ProductHelper &getProductHelper() const;
|
|
GraphicsAllocation *getDummyAllocation() const;
|
|
void releaseDummyAllocation();
|
|
|
|
void setExposeSingleDeviceMode(bool singleDeviceMode) {
|
|
exposeSingleDevice = singleDeviceMode;
|
|
}
|
|
bool isExposeSingleDeviceMode() const {
|
|
return exposeSingleDevice;
|
|
}
|
|
|
|
void setHostFunctionScheduler(std::unique_ptr<HostFunctionWorker> &&scheduler);
|
|
HostFunctionWorker *getHostFunctionScheduler() const;
|
|
|
|
std::unique_ptr<SipKernel> sipKernels[static_cast<uint32_t>(SipKernelType::count)];
|
|
std::unique_ptr<GmmHelper> gmmHelper;
|
|
std::unique_ptr<OSInterface> osInterface;
|
|
std::unique_ptr<MemoryOperationsHandler> memoryOperationsInterface;
|
|
std::unique_ptr<AubCenter> aubCenter;
|
|
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;
|
|
std::unique_ptr<ApiGfxCoreHelper> apiGfxCoreHelper;
|
|
std::unique_ptr<GfxCoreHelper> gfxCoreHelper;
|
|
std::unique_ptr<ProductHelper> productHelper;
|
|
std::unique_ptr<CompilerProductHelper> compilerProductHelper;
|
|
std::unique_ptr<ReleaseHelper> releaseHelper;
|
|
std::unique_ptr<AILConfiguration> ailConfiguration;
|
|
std::unique_ptr<BindlessHeapsHelper> bindlessHeapsHelper;
|
|
std::unique_ptr<HostFunctionWorker> hostFunctionScheduler;
|
|
std::unique_ptr<AssertHandler> assertHandler;
|
|
|
|
ExecutionEnvironment &executionEnvironment;
|
|
|
|
AffinityMaskHelper deviceAffinityMask{true};
|
|
|
|
protected:
|
|
using GraphicsAllocationUniquePtrType = std::unique_ptr<GraphicsAllocation, std::function<void(GraphicsAllocation *)>>;
|
|
GraphicsAllocationUniquePtrType dummyAllocation = nullptr;
|
|
|
|
bool limitedNumberOfCcs = false;
|
|
bool isWddmOnLinuxEnable = false;
|
|
bool exposeSingleDevice = false;
|
|
std::once_flag isDummyAllocationInitialized;
|
|
std::unique_ptr<AllocationProperties> dummyBlitProperties;
|
|
|
|
private:
|
|
std::mutex mtx;
|
|
};
|
|
|
|
static_assert(NEO::NonCopyable<RootDeviceEnvironment>);
|
|
|
|
} // namespace NEO
|