mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Ensure that every device has execution environment.
Change-Id: I77a203fb5ffd2c6a9309091f5e048f71c58c4c04
This commit is contained in:

committed by
sys_ocldev

parent
92266e4ad1
commit
4fb02f2e99
@ -78,10 +78,10 @@ bool familyEnabled[IGFX_MAX_CORE] = {
|
||||
false,
|
||||
};
|
||||
|
||||
Device::Device(const HardwareInfo &hwInfo)
|
||||
Device::Device(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment)
|
||||
: memoryManager(nullptr), enabledClVersion(false), hwInfo(hwInfo), commandStreamReceiver(nullptr),
|
||||
tagAddress(nullptr), tagAllocation(nullptr), preemptionAllocation(nullptr),
|
||||
osTime(nullptr), slmWindowStartAddress(nullptr) {
|
||||
osTime(nullptr), slmWindowStartAddress(nullptr), executionEnvironment(executionEnvironment) {
|
||||
memset(&deviceInfo, 0, sizeof(deviceInfo));
|
||||
deviceExtensions.reserve(1000);
|
||||
name.reserve(100);
|
||||
@ -96,6 +96,7 @@ Device::Device(const HardwareInfo &hwInfo)
|
||||
bool localMemorySipAvailable = (SipKernelType::DbgCsrLocal == SipKernel::getSipKernelType(hwInfo.pPlatform->eRenderCoreFamily, true));
|
||||
sourceLevelDebugger->initialize(localMemorySipAvailable);
|
||||
}
|
||||
this->executionEnvironment->incRefInternal();
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
@ -128,9 +129,7 @@ Device::~Device() {
|
||||
tagAllocation = nullptr;
|
||||
delete memoryManager;
|
||||
memoryManager = nullptr;
|
||||
if (executionEnvironment) {
|
||||
executionEnvironment->decRefInternal();
|
||||
}
|
||||
}
|
||||
|
||||
bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
|
||||
@ -285,8 +284,4 @@ GFXCORE_FAMILY Device::getRenderCoreFamily() const {
|
||||
bool Device::isSourceLevelDebuggerActive() const {
|
||||
return deviceInfo.sourceLevelDebuggerActive;
|
||||
}
|
||||
void Device::connectToExecutionEnvironment(ExecutionEnvironment *executionEnvironment) {
|
||||
executionEnvironment->incRefInternal();
|
||||
this->executionEnvironment = executionEnvironment;
|
||||
}
|
||||
} // namespace OCLRT
|
||||
|
@ -55,8 +55,7 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
template <typename T>
|
||||
static T *create(const HardwareInfo *pHwInfo, ExecutionEnvironment *execEnv) {
|
||||
pHwInfo = getDeviceInitHwInfo(pHwInfo);
|
||||
T *device = new T(*pHwInfo);
|
||||
device->connectToExecutionEnvironment(execEnv);
|
||||
T *device = new T(*pHwInfo, execEnv);
|
||||
if (false == createDeviceImpl(pHwInfo, *device)) {
|
||||
delete device;
|
||||
return nullptr;
|
||||
@ -138,11 +137,10 @@ class Device : public BaseObject<_cl_device_id> {
|
||||
bool getEnabled64kbPages();
|
||||
bool isSourceLevelDebuggerActive() const;
|
||||
SourceLevelDebugger *getSourceLevelDebugger() { return sourceLevelDebugger.get(); }
|
||||
void connectToExecutionEnvironment(ExecutionEnvironment *executionEnvironment);
|
||||
|
||||
protected:
|
||||
Device() = delete;
|
||||
Device(const HardwareInfo &hwInfo);
|
||||
Device(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment);
|
||||
|
||||
static bool createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice);
|
||||
static const HardwareInfo *getDeviceInitHwInfo(const HardwareInfo *pHwInfoIn);
|
||||
|
@ -127,8 +127,8 @@ TEST_F(DeviceTest, givenDebugVariableOverrideEngineTypeWhenDeviceIsCreatedThenUs
|
||||
}
|
||||
|
||||
struct SmallMockDevice : public Device {
|
||||
SmallMockDevice(const HardwareInfo &hwInfo)
|
||||
: Device(hwInfo) {}
|
||||
SmallMockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment)
|
||||
: Device(hwInfo, executionEnvironment) {}
|
||||
GraphicsAllocation *peekTagAllocation() { return this->tagAllocation; }
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,11 @@
|
||||
using namespace OCLRT;
|
||||
|
||||
MockDevice::MockDevice(const HardwareInfo &hwInfo)
|
||||
: Device(hwInfo) {
|
||||
: MockDevice(hwInfo, new ExecutionEnvironment) {
|
||||
}
|
||||
|
||||
OCLRT::MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment)
|
||||
: Device(hwInfo, executionEnvironment) {
|
||||
memoryManager = new OsAgnosticMemoryManager;
|
||||
this->osTime = MockOSTime::create();
|
||||
mockWaTable = *hwInfo.pWaTable;
|
||||
@ -83,7 +87,7 @@ OCLRT::FailMemoryManager::FailMemoryManager(int32_t fail) : MockMemoryManager()
|
||||
this->fail = fail;
|
||||
}
|
||||
|
||||
MockAlignedMallocManagerDevice::MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo) : MockDevice(hwInfo) {
|
||||
MockAlignedMallocManagerDevice::MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment) : MockDevice(hwInfo, executionEnvironment) {
|
||||
//delete regular OsAgnosticMemoryManager
|
||||
delete memoryManager;
|
||||
//and create specific
|
||||
|
@ -50,6 +50,7 @@ class MockDevice : public Device {
|
||||
return this->slmWindowStartAddress;
|
||||
}
|
||||
MockDevice(const HardwareInfo &hwInfo);
|
||||
MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment);
|
||||
|
||||
DeviceInfo *getDeviceInfoToModify() {
|
||||
return &this->deviceInfo;
|
||||
@ -102,8 +103,7 @@ class MockDevice : public Device {
|
||||
static T *createWithMemoryManager(const HardwareInfo *pHwInfo,
|
||||
MemoryManager *memManager) {
|
||||
pHwInfo = getDeviceInitHwInfo(pHwInfo);
|
||||
T *device = new T(*pHwInfo);
|
||||
device->connectToExecutionEnvironment(new ExecutionEnvironment);
|
||||
T *device = new T(*pHwInfo, new ExecutionEnvironment);
|
||||
if (memManager) {
|
||||
device->setMemoryManager(memManager);
|
||||
}
|
||||
@ -203,29 +203,29 @@ class FailMemoryManager : public MockMemoryManager {
|
||||
|
||||
class FailDevice : public Device {
|
||||
public:
|
||||
FailDevice(const HardwareInfo &hwInfo)
|
||||
: Device(hwInfo) {
|
||||
FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment)
|
||||
: Device(hwInfo, executionEnvironment) {
|
||||
memoryManager = new FailMemoryManager;
|
||||
}
|
||||
};
|
||||
|
||||
class FailDeviceAfterOne : public Device {
|
||||
public:
|
||||
FailDeviceAfterOne(const HardwareInfo &hwInfo)
|
||||
: Device(hwInfo) {
|
||||
FailDeviceAfterOne(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment)
|
||||
: Device(hwInfo, executionEnvironment) {
|
||||
memoryManager = new FailMemoryManager(1);
|
||||
}
|
||||
};
|
||||
|
||||
class MockAlignedMallocManagerDevice : public MockDevice {
|
||||
public:
|
||||
MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo);
|
||||
MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment);
|
||||
};
|
||||
|
||||
template <typename T = SourceLevelDebugger>
|
||||
class MockDeviceWithSourceLevelDebugger : public MockDevice {
|
||||
public:
|
||||
MockDeviceWithSourceLevelDebugger(const HardwareInfo &hwInfo) : MockDevice(hwInfo) {
|
||||
MockDeviceWithSourceLevelDebugger(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment) : MockDevice(hwInfo, executionEnvironment) {
|
||||
T *sourceLevelDebuggerCreated = new T(nullptr);
|
||||
sourceLevelDebugger.reset(sourceLevelDebuggerCreated);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class MockDeviceWithActiveDebugger : public MockDevice {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
MockDeviceWithActiveDebugger(const HardwareInfo &hwInfo) : MockDevice(hwInfo) {
|
||||
MockDeviceWithActiveDebugger(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment) : MockDevice(hwInfo, executionEnvironment) {
|
||||
sourceLevelDebuggerCreated = new T(new MockOsLibrary);
|
||||
sourceLevelDebugger.reset(sourceLevelDebuggerCreated);
|
||||
}
|
||||
|
Reference in New Issue
Block a user