From e77ee5ace4c3278f4e9de1091a08b23f306f3f03 Mon Sep 17 00:00:00 2001 From: Liangliang He Date: Wed, 10 Apr 2019 10:30:30 +0800 Subject: [PATCH] Fix MT6771 OpenCL 2.0 breakage --- mace/core/runtime/opencl/opencl_runtime.cc | 6 ++++-- mace/core/runtime/opencl/opencl_wrapper.cc | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mace/core/runtime/opencl/opencl_runtime.cc b/mace/core/runtime/opencl/opencl_runtime.cc index cd4fc9b7..bcf26498 100644 --- a/mace/core/runtime/opencl/opencl_runtime.cc +++ b/mace/core/runtime/opencl/opencl_runtime.cc @@ -364,7 +364,8 @@ OpenCLRuntime::OpenCLRuntime( #endif } if (err != CL_SUCCESS) { - LOG(ERROR) << "error: " << OpenCLErrorToString(err); + LOG(ERROR) << "Failed to create OpenCL Context: " + << OpenCLErrorToString(err); return; } @@ -373,7 +374,8 @@ OpenCLRuntime::OpenCLRuntime( properties, &err); if (err != CL_SUCCESS) { - LOG(ERROR) << "error: " << OpenCLErrorToString(err); + LOG(ERROR) << "Failed to create OpenCL CommandQueue: " + << OpenCLErrorToString(err); return; } diff --git a/mace/core/runtime/opencl/opencl_wrapper.cc b/mace/core/runtime/opencl/opencl_wrapper.cc index eab1907b..a6f4135c 100644 --- a/mace/core/runtime/opencl/opencl_wrapper.cc +++ b/mace/core/runtime/opencl/opencl_wrapper.cc @@ -802,8 +802,19 @@ CL_API_ENTRY cl_command_queue clCreateCommandQueueWithProperties( MACE_LATENCY_LOGGER(3, "clCreateCommandQueueWithProperties"); return func(context, device, properties, errcode_ret); } else { - if (errcode_ret != nullptr) *errcode_ret = CL_INVALID_PLATFORM; - return nullptr; + // Fix MediaTek MT6771 OpenCL driver breakage + VLOG(2) << "Fallback to clCreateCommandQueue"; + if (properties[0] == CL_QUEUE_PROPERTIES) { + // When calling with OpenCL-CLHPP, the 2nd param is provided by caller. +#pragma GCC diagnostic push // disable warning both for clang and gcc +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + return clCreateCommandQueue(context, device, properties[1], errcode_ret); +#pragma GCC diagnostic pop + } else { + LOG(FATAL) << "Unknown calling parameters, check the code here"; + if (errcode_ret != nullptr) *errcode_ret = CL_INVALID_PLATFORM; + return nullptr; + } } } -- GitLab