From 3f5347dd7a425a969232c54455a5b8049d2c822c Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Wed, 16 May 2018 19:23:19 +0900 Subject: [PATCH] work around of the test failure of opencv_test_dnn * let OpenCL kernel run only on Intel GPU * brush up the workaround based on 9a2b028 from alalek --- modules/dnn/src/dnn.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 3f753ecec6..cda478006a 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -62,6 +62,8 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN // this option is useful to run valgrind memory errors detection static bool DNN_DISABLE_MEMORY_OPTIMIZATIONS = utils::getConfigurationParameterBool("OPENCV_DNN_DISABLE_MEMORY_OPTIMIZATIONS", false); +static bool DNN_OPENCL_ALLOW_ALL_DEVICES = utils::getConfigurationParameterBool("OPENCV_DNN_OPENCL_ALLOW_ALL_DEVICES", false); + using std::vector; using std::map; using std::make_pair; @@ -847,12 +849,22 @@ struct Net::Impl if (!netWasAllocated || this->blobsToKeep != blobsToKeep_) { -#ifndef HAVE_OPENCL if (preferableBackend == DNN_BACKEND_DEFAULT && preferableTarget == DNN_TARGET_OPENCL) +#ifndef HAVE_OPENCL { - CV_LOG_WARNING(NULL, "DNN: OpenCL target is not available in this OpenCV build, switching to CPU.") + CV_LOG_WARNING(NULL, "DNN: OpenCL target is not available in this OpenCV build, switching to CPU."); preferableTarget = DNN_TARGET_CPU; } +#else + { + if (!DNN_OPENCL_ALLOW_ALL_DEVICES + && !(ocl::Device::getDefault().isIntel() && ocl::Device::getDefault().type() == ocl::Device::TYPE_GPU) // Current implementation is only valid for Intel GPU (#11494) + ) + { + CV_LOG_WARNING(NULL, "DNN: OpenCL target is not supported with current OpenCL device (tested with Intel GPUs only), switching to CPU."); + preferableTarget = DNN_TARGET_CPU; + } + } #endif clear();