mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-28 16:48:45 +08:00
Add reference on device while creating a context
- Context uses device, it needs to make sure it exists. Change-Id: I1aeaabc53b6198965dc8f4e6fa37585490774a3f
This commit is contained in:
committed by
sys_ocldev
parent
d447c8c951
commit
887df5a90d
@@ -74,6 +74,9 @@ Context::~Context() {
|
||||
memoryManager->getDeferredDeleter()->removeClient();
|
||||
}
|
||||
gtpinNotifyContextDestroy((cl_context)this);
|
||||
for (auto &device : devices) {
|
||||
device->decRefInternal();
|
||||
}
|
||||
}
|
||||
|
||||
DeviceQueue *Context::getDefaultDeviceQueue() {
|
||||
@@ -99,7 +102,7 @@ void Context::overrideSpecialQueueAndDecrementRefCount(CommandQueue *commandQueu
|
||||
};
|
||||
|
||||
bool Context::createImpl(const cl_context_properties *properties,
|
||||
const DeviceVector &devices,
|
||||
const DeviceVector &inputDevices,
|
||||
void(CL_CALLBACK *funcNotify)(const char *, const void *, size_t, void *),
|
||||
void *data, cl_int &errcodeRet) {
|
||||
|
||||
@@ -160,7 +163,6 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
|
||||
this->numProperties = numProperties;
|
||||
this->properties = propertiesNew;
|
||||
this->devices = devices;
|
||||
this->setInteropUserSyncEnabled(interopUserSync);
|
||||
|
||||
if (!sharingBuilder->finalizeProperties(*this, errcodeRet)) {
|
||||
@@ -168,6 +170,7 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
}
|
||||
|
||||
this->driverDiagnostics = driverDiagnostics.release();
|
||||
this->devices = inputDevices;
|
||||
|
||||
// We currently assume each device uses the same MemoryManager
|
||||
if (devices.size() > 0) {
|
||||
@@ -178,6 +181,10 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &device : devices) {
|
||||
device->incRefInternal();
|
||||
}
|
||||
|
||||
auto commandQueue = CommandQueue::create(this, devices[0], nullptr, errcodeRet);
|
||||
DEBUG_BREAK_IF(commandQueue == nullptr);
|
||||
overrideSpecialQueueAndDecrementRefCount(commandQueue);
|
||||
|
||||
Reference in New Issue
Block a user