mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Respect platform in context properties when creating context
Resolves: NEO-5223 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
9606cde51a
commit
1e97e4117e
@@ -135,12 +135,8 @@ bool Context::createImpl(const cl_context_properties *properties,
|
||||
propertiesCurrent += 2;
|
||||
|
||||
switch (propertyType) {
|
||||
case CL_CONTEXT_PLATFORM: {
|
||||
if (castToObject<Platform>(reinterpret_cast<cl_platform_id>(propertyValue)) == nullptr) {
|
||||
errcodeRet = CL_INVALID_PLATFORM;
|
||||
return false;
|
||||
}
|
||||
} break;
|
||||
case CL_CONTEXT_PLATFORM:
|
||||
break;
|
||||
case CL_CONTEXT_SHOW_DIAGNOSTICS_INTEL:
|
||||
driverDiagnosticsUsed = static_cast<int32_t>(propertyValue);
|
||||
break;
|
||||
@@ -457,4 +453,19 @@ void Context::setupContextType() {
|
||||
}
|
||||
}
|
||||
|
||||
Platform *Context::getPlatformFromProperties(const cl_context_properties *properties, cl_int &errcode) {
|
||||
errcode = CL_SUCCESS;
|
||||
auto propertiesCurrent = properties;
|
||||
while (propertiesCurrent && *propertiesCurrent) {
|
||||
auto propertyType = propertiesCurrent[0];
|
||||
auto propertyValue = propertiesCurrent[1];
|
||||
propertiesCurrent += 2;
|
||||
if (CL_CONTEXT_PLATFORM == propertyType) {
|
||||
Platform *pPlatform = nullptr;
|
||||
errcode = validateObject(WithCastToInternal(reinterpret_cast<cl_platform_id>(propertyValue), &pPlatform));
|
||||
return pPlatform;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace NEO
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "opencl/source/cl_device/cl_device_vector.h"
|
||||
#include "opencl/source/context/context_type.h"
|
||||
#include "opencl/source/context/driver_diagnostics.h"
|
||||
#include "opencl/source/gtpin/gtpin_notify.h"
|
||||
#include "opencl/source/helpers/base_object.h"
|
||||
#include "opencl/source/helpers/destructor_callbacks.h"
|
||||
|
||||
@@ -33,6 +34,7 @@ class SharingFunctions;
|
||||
class SVMAllocsManager;
|
||||
class SchedulerKernel;
|
||||
class Program;
|
||||
class Platform;
|
||||
|
||||
template <>
|
||||
struct OpenCLObjectMapper<_cl_context> {
|
||||
@@ -60,7 +62,7 @@ class Context : public BaseObject<_cl_context> {
|
||||
delete pContext;
|
||||
pContext = nullptr;
|
||||
}
|
||||
|
||||
gtpinNotifyContextCreate(pContext);
|
||||
return pContext;
|
||||
}
|
||||
|
||||
@@ -162,6 +164,8 @@ class Context : public BaseObject<_cl_context> {
|
||||
}
|
||||
const std::map<uint32_t, DeviceBitfield> &getDeviceBitfields() const { return deviceBitfields; };
|
||||
|
||||
static Platform *getPlatformFromProperties(const cl_context_properties *properties, cl_int &errcode);
|
||||
|
||||
protected:
|
||||
struct BuiltInKernel {
|
||||
const char *pSource = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user