From 4aa9f83100e93b2350242acd06c517db0259b49b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 26 Dec 2013 10:16:29 +0400 Subject: [PATCH 1/2] Dynamic CUDA support library name fixed. Additional error messages added. --- modules/core/src/gpumat.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/modules/core/src/gpumat.cpp b/modules/core/src/gpumat.cpp index 94bb548235..cc9789817b 100644 --- a/modules/core/src/gpumat.cpp +++ b/modules/core/src/gpumat.cpp @@ -93,6 +93,9 @@ static GpuFactoryType gpuFactory = NULL; static DeviceInfoFactoryType deviceInfoFactory = NULL; # if defined(__linux__) || defined(__APPLE__) || defined (ANDROID) + +const std::string DYNAMIC_CUDA_LIB_NAME = "libopencv_dynamicuda.so"; + # ifdef ANDROID static const std::string getCudaSupportLibName() { @@ -144,7 +147,7 @@ static const std::string getCudaSupportLibName() LOGD("Libraries folder found: %s", pathBegin); fclose(file); - return std::string(pathBegin) + "/libopencv_core_cuda.so"; + return std::string(pathBegin) + DYNAMIC_CUDA_LIB_NAME; } fclose(file); LOGE("Could not find library path"); @@ -165,7 +168,7 @@ static const std::string getCudaSupportLibName() # else static const std::string getCudaSupportLibName() { - return "libopencv_core_cuda.so"; + return DYNAMIC_CUDA_LIB_NAME; } # endif @@ -173,13 +176,18 @@ static bool loadCudaSupportLib() { void* handle; const std::string name = getCudaSupportLibName(); + dlerror(); handle = dlopen(name.c_str(), RTLD_LAZY); if (!handle) + { + LOGE("Cannot dlopen %s: %s", name.c_str(), dlerror()); return false; + } deviceInfoFactory = (DeviceInfoFactoryType)dlsym(handle, "deviceInfoFactory"); if (!deviceInfoFactory) { + LOGE("Cannot dlsym deviceInfoFactory: %s", dlerror()); dlclose(handle); return false; } @@ -187,6 +195,7 @@ static bool loadCudaSupportLib() gpuFactory = (GpuFactoryType)dlsym(handle, "gpuFactory"); if (!gpuFactory) { + LOGE("Cannot dlsym gpuFactory: %s", dlerror()); dlclose(handle); return false; } From 1e038e2837afe4d28965900023bf396ef4252bc4 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 24 Dec 2013 12:23:50 +0400 Subject: [PATCH 2/2] CUDA warning fix/supporession for Android. --- modules/core/src/gpumat.cpp | 41 ++++++++++++++++++++----------- modules/dynamicuda/CMakeLists.txt | 2 +- modules/dynamicuda/src/main.cpp | 20 +++++++-------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/modules/core/src/gpumat.cpp b/modules/core/src/gpumat.cpp index cc9789817b..5dae4697d3 100644 --- a/modules/core/src/gpumat.cpp +++ b/modules/core/src/gpumat.cpp @@ -45,29 +45,42 @@ #include #if defined(HAVE_CUDA) - #include - #include +# include +# include - #define CUDART_MINIMUM_REQUIRED_VERSION 4020 - #define NPP_MINIMUM_REQUIRED_VERSION 4200 +# define CUDART_MINIMUM_REQUIRED_VERSION 4020 +# define NPP_MINIMUM_REQUIRED_VERSION 4200 - #if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION) - #error "Insufficient Cuda Runtime library version, please update it." - #endif +# if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION) +# error "Insufficient Cuda Runtime library version, please update it." +# endif - #if (NPP_VERSION_MAJOR * 1000 + NPP_VERSION_MINOR * 100 + NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION) - #error "Insufficient NPP version, please update it." - #endif +# if (NPP_VERSION_MAJOR * 1000 + NPP_VERSION_MINOR * 100 + NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION) +# error "Insufficient NPP version, please update it." +# endif #endif #ifdef DYNAMIC_CUDA_SUPPORT -#include -#include -#include -#include +# include +# include +# include +# include #endif #ifdef ANDROID +# ifdef LOG_TAG +# undef LOG_TAG +# endif +# ifdef LOGE +# undef LOGE +# endif +# ifdef LOGD +# undef LOGD +# endif +# ifdef LOGI +# undef LOGI +# endif + # include # define LOG_TAG "OpenCV::CUDA" diff --git a/modules/dynamicuda/CMakeLists.txt b/modules/dynamicuda/CMakeLists.txt index 2e0154406a..b523bf0fd1 100644 --- a/modules/dynamicuda/CMakeLists.txt +++ b/modules/dynamicuda/CMakeLists.txt @@ -5,7 +5,7 @@ endif() set(the_description "Dynamic CUDA linkage") add_definitions(-DUSE_CUDA) -ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) +ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wshadow) ocv_module_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") set(OPENCV_MODULE_TYPE SHARED) if (BUILD_FAT_JAVA_LIB) diff --git a/modules/dynamicuda/src/main.cpp b/modules/dynamicuda/src/main.cpp index 8eb66fd98d..0c74ecb34a 100644 --- a/modules/dynamicuda/src/main.cpp +++ b/modules/dynamicuda/src/main.cpp @@ -6,19 +6,19 @@ #include #ifdef HAVE_CUDA -#include -#include +# include +# include -#define CUDART_MINIMUM_REQUIRED_VERSION 4020 -#define NPP_MINIMUM_REQUIRED_VERSION 4200 +# define CUDART_MINIMUM_REQUIRED_VERSION 4020 +# define NPP_MINIMUM_REQUIRED_VERSION 4200 -#if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION) -#error "Insufficient Cuda Runtime library version, please update it." -#endif +# if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION) +# error "Insufficient Cuda Runtime library version, please update it." +# endif -#if (NPP_VERSION_MAJOR * 1000 + NPP_VERSION_MINOR * 100 + NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION) -#error "Insufficient NPP version, please update it." -#endif +# if (NPP_VERSION_MAJOR * 1000 + NPP_VERSION_MINOR * 100 + NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION) +# error "Insufficient NPP version, please update it." +# endif #endif using namespace std;