mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Allow Device creating multiple CSRs [7/n]
Create and initialize all supported Engines Change-Id: If0adf1a06b5005ef2698cebc6f1aaa6eacf562ec Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
54269d9791
commit
1f7448425d
@@ -106,70 +106,90 @@ Device::~Device() {
|
||||
}
|
||||
|
||||
bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
|
||||
uint32_t deviceCsrIndex = 0;
|
||||
auto executionEnvironment = outDevice.executionEnvironment;
|
||||
executionEnvironment->initGmm(pHwInfo);
|
||||
if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex(), deviceCsrIndex)) {
|
||||
return false;
|
||||
}
|
||||
executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(),
|
||||
outDevice.getDeviceIndex(), deviceCsrIndex);
|
||||
|
||||
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext({getChosenEngineType(*pHwInfo), 0});
|
||||
auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get();
|
||||
commandStreamReceiver->setOsContext(*osContext);
|
||||
if (!commandStreamReceiver->initializeTagAllocation()) {
|
||||
if (!createEngines(pHwInfo, outDevice)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
outDevice.engines[0] = {commandStreamReceiver, osContext};
|
||||
executionEnvironment->memoryManager->setDefaultEngineIndex(outDevice.defaultEngineIndex);
|
||||
|
||||
auto pDevice = &outDevice;
|
||||
if (!pDevice->osTime) {
|
||||
pDevice->osTime = OSTime::create(commandStreamReceiver->getOSInterface());
|
||||
auto osInterface = executionEnvironment->osInterface.get();
|
||||
|
||||
if (!outDevice.osTime) {
|
||||
outDevice.osTime = OSTime::create(osInterface);
|
||||
}
|
||||
pDevice->driverInfo.reset(DriverInfo::create(commandStreamReceiver->getOSInterface()));
|
||||
outDevice.driverInfo.reset(DriverInfo::create(osInterface));
|
||||
|
||||
pDevice->initializeCaps();
|
||||
outDevice.initializeCaps();
|
||||
|
||||
if (pDevice->osTime->getOSInterface()) {
|
||||
if (outDevice.osTime->getOSInterface()) {
|
||||
if (pHwInfo->capabilityTable.instrumentationEnabled) {
|
||||
pDevice->performanceCounters = createPerformanceCountersFunc(pDevice->osTime.get());
|
||||
pDevice->performanceCounters->initialize(pHwInfo);
|
||||
outDevice.performanceCounters = createPerformanceCountersFunc(outDevice.osTime.get());
|
||||
outDevice.performanceCounters->initialize(pHwInfo);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t deviceHandle = 0;
|
||||
if (commandStreamReceiver->getOSInterface()) {
|
||||
deviceHandle = commandStreamReceiver->getOSInterface()->getDeviceHandle();
|
||||
if (osInterface) {
|
||||
deviceHandle = osInterface->getDeviceHandle();
|
||||
}
|
||||
|
||||
if (pDevice->deviceInfo.sourceLevelDebuggerActive) {
|
||||
pDevice->executionEnvironment->sourceLevelDebugger->notifyNewDevice(deviceHandle);
|
||||
if (outDevice.deviceInfo.sourceLevelDebuggerActive) {
|
||||
outDevice.executionEnvironment->sourceLevelDebugger->notifyNewDevice(deviceHandle);
|
||||
}
|
||||
|
||||
outDevice.executionEnvironment->memoryManager->setForce32BitAllocations(pDevice->getDeviceInfo().force32BitAddressess);
|
||||
outDevice.executionEnvironment->memoryManager->setDefaultEngineIndex(deviceCsrIndex);
|
||||
outDevice.executionEnvironment->memoryManager->setForce32BitAllocations(outDevice.getDeviceInfo().force32BitAddressess);
|
||||
|
||||
if (pDevice->preemptionMode == PreemptionMode::MidThread || pDevice->isSourceLevelDebuggerActive()) {
|
||||
if (outDevice.preemptionMode == PreemptionMode::MidThread || outDevice.isSourceLevelDebuggerActive()) {
|
||||
size_t requiredSize = pHwInfo->capabilityTable.requiredPreemptionSurfaceSize;
|
||||
size_t alignment = 256 * MemoryConstants::kiloByte;
|
||||
bool uncacheable = pDevice->getWaTable()->waCSRUncachable;
|
||||
pDevice->preemptionAllocation = outDevice.executionEnvironment->memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable);
|
||||
if (!pDevice->preemptionAllocation) {
|
||||
bool uncacheable = outDevice.getWaTable()->waCSRUncachable;
|
||||
outDevice.preemptionAllocation = outDevice.executionEnvironment->memoryManager->allocateGraphicsMemory(requiredSize, alignment, false, uncacheable);
|
||||
if (!outDevice.preemptionAllocation) {
|
||||
return false;
|
||||
}
|
||||
commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation);
|
||||
}
|
||||
|
||||
if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) {
|
||||
commandStreamReceiver->setExperimentalCmdBuffer(std::unique_ptr<ExperimentalCommandBuffer>(
|
||||
new ExperimentalCommandBuffer(commandStreamReceiver, pDevice->getDeviceInfo().profilingTimerResolution)));
|
||||
for (auto engine : outDevice.engines) {
|
||||
auto csr = engine.commandStreamReceiver;
|
||||
csr->setPreemptionCsrAllocation(outDevice.preemptionAllocation);
|
||||
if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) {
|
||||
csr->setExperimentalCmdBuffer(std::make_unique<ExperimentalCommandBuffer>(csr, outDevice.getDeviceInfo().profilingTimerResolution));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Device::createEngines(const HardwareInfo *pHwInfo, Device &outDevice) {
|
||||
auto executionEnvironment = outDevice.executionEnvironment;
|
||||
EngineType defaultEngineType = getChosenEngineType(*pHwInfo);
|
||||
|
||||
for (uint32_t deviceCsrIndex = 0; deviceCsrIndex < gpgpuEngineInstances.size(); deviceCsrIndex++) {
|
||||
if (!executionEnvironment->initializeCommandStreamReceiver(pHwInfo, outDevice.getDeviceIndex(), deviceCsrIndex)) {
|
||||
return false;
|
||||
}
|
||||
executionEnvironment->initializeMemoryManager(outDevice.getEnabled64kbPages(), outDevice.getEnableLocalMemory(),
|
||||
outDevice.getDeviceIndex(), deviceCsrIndex);
|
||||
|
||||
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(gpgpuEngineInstances[deviceCsrIndex]);
|
||||
auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get();
|
||||
commandStreamReceiver->setOsContext(*osContext);
|
||||
if (!commandStreamReceiver->initializeTagAllocation()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gpgpuEngineInstances[deviceCsrIndex].type == defaultEngineType && gpgpuEngineInstances[deviceCsrIndex].id == 0) {
|
||||
outDevice.defaultEngineIndex = deviceCsrIndex;
|
||||
}
|
||||
|
||||
outDevice.engines[deviceCsrIndex] = {commandStreamReceiver, osContext};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const HardwareInfo *Device::getDeviceInitHwInfo(const HardwareInfo *pHwInfoIn) {
|
||||
return pHwInfoIn ? pHwInfoIn : platformDevices[0];
|
||||
}
|
||||
|
||||
@@ -73,8 +73,6 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
EngineControl &getEngine(uint32_t engineId);
|
||||
EngineControl &getDefaultEngine();
|
||||
|
||||
volatile uint32_t *getTagAddress() const;
|
||||
|
||||
const char *getProductAbbrev() const;
|
||||
const std::string getFamilyNameWithType() const;
|
||||
|
||||
@@ -136,6 +134,7 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
}
|
||||
|
||||
static bool createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice);
|
||||
static bool createEngines(const HardwareInfo *pHwInfo, Device &outDevice);
|
||||
static const HardwareInfo *getDeviceInitHwInfo(const HardwareInfo *pHwInfoIn);
|
||||
MOCKABLE_VIRTUAL void initializeCaps();
|
||||
void setupFp64Flags();
|
||||
@@ -177,7 +176,7 @@ inline EngineControl &Device::getEngine(uint32_t engineId) {
|
||||
}
|
||||
|
||||
inline EngineControl &Device::getDefaultEngine() {
|
||||
return engines[defaultEngineIndex];
|
||||
return getEngine(defaultEngineIndex);
|
||||
}
|
||||
|
||||
inline MemoryManager *Device::getMemoryManager() const {
|
||||
|
||||
Reference in New Issue
Block a user