mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Improve HardwareContextController creation
Change-Id: Iba929a2b4fcd993b38dd674be578aad0a481e8de Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
e721f7c08c
commit
f24b428cf7
@@ -14,17 +14,17 @@
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, uint32_t numDevicesSupported,
|
||||
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, uint32_t deviceBitfiled,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode) {
|
||||
if (osInterface) {
|
||||
return new OsContextLinux(*osInterface->get()->getDrm(), contextId, numDevicesSupported, engineType, preemptionMode);
|
||||
return new OsContextLinux(*osInterface->get()->getDrm(), contextId, deviceBitfiled, engineType, preemptionMode);
|
||||
}
|
||||
return new OsContext(contextId, numDevicesSupported, engineType, preemptionMode);
|
||||
return new OsContext(contextId, deviceBitfiled, engineType, preemptionMode);
|
||||
}
|
||||
|
||||
OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, uint32_t numDevicesSupported,
|
||||
OsContextLinux::OsContextLinux(Drm &drm, uint32_t contextId, uint32_t deviceBitfiled,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
: OsContext(contextId, numDevicesSupported, engineType, preemptionMode), drm(drm) {
|
||||
: OsContext(contextId, deviceBitfiled, engineType, preemptionMode), drm(drm) {
|
||||
|
||||
engineFlag = DrmEngineMapper::engineNodeMap(engineType.type);
|
||||
this->drmContextId = drm.createDrmContext();
|
||||
|
||||
@@ -14,7 +14,7 @@ class OsContextLinux : public OsContext {
|
||||
public:
|
||||
OsContextLinux() = delete;
|
||||
~OsContextLinux() override;
|
||||
OsContextLinux(Drm &drm, uint32_t contextId, uint32_t numDevicesSupported,
|
||||
OsContextLinux(Drm &drm, uint32_t contextId, uint32_t deviceBitfiled,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
|
||||
unsigned int getEngineFlag() const { return engineFlag; }
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "common/helpers/bit_helpers.h"
|
||||
#include "runtime/command_stream/preemption_mode.h"
|
||||
#include "runtime/utilities/reference_tracked_object.h"
|
||||
|
||||
#include "engine_node.h"
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
namespace OCLRT {
|
||||
@@ -20,19 +22,28 @@ class OsContext : public ReferenceTrackedObject<OsContext> {
|
||||
public:
|
||||
OsContext() = delete;
|
||||
|
||||
static OsContext *create(OSInterface *osInterface, uint32_t contextId, uint32_t numDevicesSupported, EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
static OsContext *create(OSInterface *osInterface, uint32_t contextId, uint32_t deviceBitfiled, EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
uint32_t getContextId() const { return contextId; }
|
||||
uint32_t getNumDevicesSupported() const { return numDevicesSupported; }
|
||||
uint32_t getNumSupportedDevices() const { return numSupportedDevices; }
|
||||
uint8_t getDeviceBitfiled() const { return deviceBitfiled; }
|
||||
PreemptionMode getPreemptionMode() const { return preemptionMode; }
|
||||
EngineInstanceT &getEngineType() { return engineType; }
|
||||
|
||||
protected:
|
||||
OsContext(uint32_t contextId, uint32_t numDevicesSupported, EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
: contextId(contextId), numDevicesSupported(numDevicesSupported), preemptionMode(preemptionMode), engineType(engineType){};
|
||||
OsContext(uint32_t contextId, uint32_t deviceBitfiled, EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
: contextId(contextId), deviceBitfiled(deviceBitfiled), preemptionMode(preemptionMode), engineType(engineType) {
|
||||
constexpr uint32_t maxIndex = std::numeric_limits<decltype(deviceBitfiled)>::digits;
|
||||
for (uint32_t deviceIndex = 0; deviceIndex < maxIndex; deviceIndex++) {
|
||||
if (isBitSet(deviceBitfiled, deviceIndex)) {
|
||||
numSupportedDevices++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const uint32_t contextId;
|
||||
const uint32_t numDevicesSupported;
|
||||
const uint32_t deviceBitfiled;
|
||||
const PreemptionMode preemptionMode;
|
||||
uint32_t numSupportedDevices = 0;
|
||||
EngineInstanceT engineType = {EngineType::ENGINE_RCS, 0};
|
||||
};
|
||||
} // namespace OCLRT
|
||||
|
||||
@@ -13,17 +13,17 @@
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, uint32_t numDevicesSupported,
|
||||
OsContext *OsContext::create(OSInterface *osInterface, uint32_t contextId, uint32_t deviceBitfiled,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode) {
|
||||
if (osInterface) {
|
||||
return new OsContextWin(*osInterface->get()->getWddm(), contextId, numDevicesSupported, engineType, preemptionMode);
|
||||
return new OsContextWin(*osInterface->get()->getWddm(), contextId, deviceBitfiled, engineType, preemptionMode);
|
||||
}
|
||||
return new OsContext(contextId, numDevicesSupported, engineType, preemptionMode);
|
||||
return new OsContext(contextId, deviceBitfiled, engineType, preemptionMode);
|
||||
}
|
||||
|
||||
OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t numDevicesSupported,
|
||||
OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t deviceBitfiled,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode)
|
||||
: OsContext(contextId, numDevicesSupported, engineType, preemptionMode), wddm(wddm), residencyController(wddm, contextId) {
|
||||
: OsContext(contextId, deviceBitfiled, engineType, preemptionMode), wddm(wddm), residencyController(wddm, contextId) {
|
||||
|
||||
UNRECOVERABLE_IF(!wddm.isInitialized());
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class OsContextWin : public OsContext {
|
||||
OsContextWin() = delete;
|
||||
~OsContextWin() override;
|
||||
|
||||
OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t numDevicesSupported,
|
||||
OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t deviceBitfiled,
|
||||
EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||
|
||||
D3DKMT_HANDLE getWddmContextHandle() const { return wddmContextHandle; }
|
||||
|
||||
Reference in New Issue
Block a user