mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add constructor parameter to select low priority context.
Change-Id: Ieb3fa008a2f1b54052e393516038c88f00944fa0 Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
This commit is contained in:
@@ -95,7 +95,7 @@ void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::setupContext(OsContext &
|
||||
uint32_t flags = 0;
|
||||
getCsTraits(engineType).setContextSaveRestoreFlags(flags);
|
||||
|
||||
if (aubManager && !(engineType.type == lowPriorityGpgpuEngine.type && engineType.id == lowPriorityGpgpuEngine.id)) {
|
||||
if (aubManager && !osContext.isLowPriority()) {
|
||||
hardwareContextController = std::make_unique<HardwareContextController>(*aubManager, osContext, engineIndex, flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,9 @@ bool Device::createEngines(const HardwareInfo *pHwInfo) {
|
||||
|
||||
DeviceBitfield deviceBitfield;
|
||||
deviceBitfield.set(getDeviceIndex());
|
||||
bool lowPriority = deviceCsrIndex == EngineInstanceConstants::lowPriorityGpgpuEngineIndex;
|
||||
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(commandStreamReceiver, gpgpuEngines[deviceCsrIndex],
|
||||
deviceBitfield, preemptionMode);
|
||||
deviceBitfield, preemptionMode, lowPriority);
|
||||
commandStreamReceiver->setupContext(*osContext);
|
||||
|
||||
if (!commandStreamReceiver->initializeTagAllocation()) {
|
||||
|
||||
@@ -188,9 +188,9 @@ bool MemoryManager::isMemoryBudgetExhausted() const {
|
||||
}
|
||||
|
||||
OsContext *MemoryManager::createAndRegisterOsContext(CommandStreamReceiver *commandStreamReceiver, EngineInstanceT engineType,
|
||||
DeviceBitfield deviceBitfield, PreemptionMode preemptionMode) {
|
||||
DeviceBitfield deviceBitfield, PreemptionMode preemptionMode, bool lowPriority) {
|
||||
auto contextId = ++latestContextId;
|
||||
auto osContext = OsContext::create(executionEnvironment.osInterface.get(), contextId, deviceBitfield, engineType, preemptionMode);
|
||||
auto osContext = OsContext::create(executionEnvironment.osInterface.get(), contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
||||
osContext->incRefInternal();
|
||||
|
||||
registeredEngines.emplace_back(commandStreamReceiver, osContext);
|
||||
|
||||
@@ -175,7 +175,7 @@ class MemoryManager {
|
||||
}
|
||||
|
||||
OsContext *createAndRegisterOsContext(CommandStreamReceiver *commandStreamReceiver, EngineInstanceT engineType,
|
||||
DeviceBitfield deviceBitfield, PreemptionMode preemptionMode);
|
||||
DeviceBitfield deviceBitfield, PreemptionMode preemptionMode, bool lowPriority);
|
||||
uint32_t getRegisteredEnginesCount() const { return static_cast<uint32_t>(registeredEngines.size()); }
|
||||
CommandStreamReceiver *getDefaultCommandStreamReceiver(uint32_t deviceId) const;
|
||||
EngineControlContainer &getRegisteredEngines();
|
||||
|
||||
@@ -15,22 +15,20 @@
|
||||
namespace OCLRT {
|
||||
|
||||
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode) {
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority) {
|
||||
if (osInterface) {
|
||||
return new OsContextLinux(*osInterface->get()->getDrm(), contextId, deviceBitfield, engineType, preemptionMode);
|
||||
return new OsContextLinux(*osInterface->get()->getDrm(), contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
||||
}
|
||||
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode);
|
||||
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
||||
}
|
||||
|
||||
OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
: OsContext(contextId, deviceBitfield, engineType, preemptionMode), drm(drm) {
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority)
|
||||
: OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority), drm(drm) {
|
||||
|
||||
engineFlag = DrmEngineMapper::engineNodeMap(engineType.type);
|
||||
this->drmContextId = drm.createDrmContext();
|
||||
if (drm.isPreemptionSupported() &&
|
||||
engineType.type == lowPriorityGpgpuEngine.type &&
|
||||
engineType.id == lowPriorityGpgpuEngine.id) {
|
||||
if (drm.isPreemptionSupported() && lowPriority) {
|
||||
drm.setLowPriorityContextParam(this->drmContextId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class OsContextLinux : public OsContext {
|
||||
OsContextLinux() = delete;
|
||||
~OsContextLinux() override;
|
||||
OsContextLinux(Drm &drm, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority);
|
||||
|
||||
unsigned int getEngineFlag() const { return engineFlag; }
|
||||
uint32_t getDrmContextId() const { return drmContextId; }
|
||||
|
||||
@@ -21,25 +21,29 @@ class OsContext : public ReferenceTrackedObject<OsContext> {
|
||||
public:
|
||||
OsContext() = delete;
|
||||
|
||||
static OsContext *create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield, EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
static OsContext *create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority);
|
||||
uint32_t getContextId() const { return contextId; }
|
||||
uint32_t getNumSupportedDevices() const { return numSupportedDevices; }
|
||||
DeviceBitfield getDeviceBitfield() const { return deviceBitfield; }
|
||||
PreemptionMode getPreemptionMode() const { return preemptionMode; }
|
||||
EngineInstanceT &getEngineType() { return engineType; }
|
||||
bool isLowPriority() const { return lowPriority; }
|
||||
|
||||
protected:
|
||||
OsContext(uint32_t contextId, DeviceBitfield deviceBitfield, EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
OsContext(uint32_t contextId, DeviceBitfield deviceBitfield, EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority)
|
||||
: contextId(contextId),
|
||||
deviceBitfield(deviceBitfield),
|
||||
preemptionMode(preemptionMode),
|
||||
numSupportedDevices(static_cast<uint32_t>(deviceBitfield.count())),
|
||||
engineType(engineType) {}
|
||||
engineType(engineType),
|
||||
lowPriority(lowPriority) {}
|
||||
|
||||
const uint32_t contextId;
|
||||
const DeviceBitfield deviceBitfield;
|
||||
const PreemptionMode preemptionMode;
|
||||
const uint32_t numSupportedDevices;
|
||||
EngineInstanceT engineType = {EngineType::ENGINE_RCS, 0};
|
||||
const bool lowPriority;
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
namespace OCLRT {
|
||||
|
||||
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode) {
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority) {
|
||||
if (osInterface) {
|
||||
return new OsContextWin(*osInterface->get()->getWddm(), contextId, deviceBitfield, engineType, preemptionMode);
|
||||
return new OsContextWin(*osInterface->get()->getWddm(), contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
||||
}
|
||||
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode);
|
||||
return new OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority);
|
||||
}
|
||||
|
||||
OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
: OsContext(contextId, deviceBitfield, engineType, preemptionMode), wddm(wddm), residencyController(wddm, contextId) {
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority)
|
||||
: OsContext(contextId, deviceBitfield, engineType, preemptionMode, lowPriority), wddm(wddm), residencyController(wddm, contextId) {
|
||||
|
||||
UNRECOVERABLE_IF(!wddm.isInitialized());
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class OsContextWin : public OsContext {
|
||||
~OsContextWin() override;
|
||||
|
||||
OsContextWin(Wddm &wddm, uint32_t contextId, DeviceBitfield deviceBitfield,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode, bool lowPriority);
|
||||
|
||||
D3DKMT_HANDLE getWddmContextHandle() const { return wddmContextHandle; }
|
||||
void setWddmContextHandle(D3DKMT_HANDLE wddmContextHandle) { this->wddmContextHandle = wddmContextHandle; }
|
||||
|
||||
Reference in New Issue
Block a user