cuda+npp version check at configure time.

pull/13383/head
Anatoly Baksheev 14 years ago
parent 03aa0c9fec
commit 36ebf4ef0d
  1. 4
      CMakeLists.txt
  2. 3
      modules/gpu/CMakeLists.txt
  3. 15
      modules/gpu/FindNPP.cmake
  4. 6
      modules/gpu/src/precomp.hpp

@ -647,10 +647,10 @@ endif()
############################### CUDA ################################ ############################### CUDA ################################
if (WITH_CUDA) if (WITH_CUDA)
find_package(CUDA) find_package(CUDA 3.2)
if (CUDA_FOUND) if (CUDA_FOUND)
message(STATUS "CUDA detected.")
set(HAVE_CUDA 1) set(HAVE_CUDA 1)
message(STATUS "CUDA detected: " ${CUDA_VERSION})
set(CUDA_COMPUTE_CAPABILITIES " 1.0 1.1 1.2 1.3 2.0 " CACHE STRING "Add or remove compute capability") set(CUDA_COMPUTE_CAPABILITIES " 1.0 1.1 1.2 1.3 2.0 " CACHE STRING "Add or remove compute capability")
set(CUDA_NVCC_FLAGS_ARCH ${CUDA_COMPUTE_CAPABILITIES}) set(CUDA_NVCC_FLAGS_ARCH ${CUDA_COMPUTE_CAPABILITIES})

@ -35,7 +35,8 @@ source_group("Include" FILES ${lib_hdrs})
if (HAVE_CUDA) if (HAVE_CUDA)
get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp}) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp})
find_package(NPP REQUIRED) find_package(NPP 3.2.16 REQUIRED)
message(STATUS "NPP detected: " ${NPP_VERSION})
include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_NPP_INCLUDES}) include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_NPP_INCLUDES})

@ -96,20 +96,23 @@ if(EXISTS ${CUDA_NPP_INCLUDES}/nppversion.h)
string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} ) string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} )
string( REGEX MATCH "[0-9]+" npp_build ${npp_build} ) string( REGEX MATCH "[0-9]+" npp_build ${npp_build} )
set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}")
MESSAGE(STATUS "Npp version: " ${NPP_VERSION})
endif() endif()
if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h) if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h)
set(CUDA_NPP_FOUND FALSE) set(CUDA_NPP_FOUND FALSE)
unset(CUDA_NPP_INCLUDES CACHE)
unset(CUDA_NPP_LIBRARIES CACHE)
message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.") message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $NPP_ROOT_DIR.")
endif() endif()
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args( NPP
REQUIRED_VARS
CUDA_NPP_INCLUDES
CUDA_NPP_LIBRARIES
VERSION_VAR
NPP_VERSION)
if(APPLE) if(APPLE)
# We need to add the path to cudart to the linker using rpath, since the # We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath.
# library name for the cuda libraries is prepended with @rpath.
get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH) get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH)
if(_cuda_path_to_npp) if(_cuda_path_to_npp)
list(APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}") list(APPEND CUDA_NPP_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_npp}")

@ -67,12 +67,18 @@
#include "opencv2/gpu/stream_accessor.hpp" #include "opencv2/gpu/stream_accessor.hpp"
#include "npp.h" #include "npp.h"
#define CUDART_MINIMUM_REQUIRED_VERSION 3020
#define NPP_MINIMUM_REQUIRED_VERSION 3216 #define NPP_MINIMUM_REQUIRED_VERSION 3216
#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) #if (NPP_VERSION_MAJOR*1000+NPP_VERSION_MINOR*100+NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION)
#error "Insufficient NPP version, please update it." #error "Insufficient NPP version, please update it."
#endif #endif
#else /* defined(HAVE_CUDA) */ #else /* defined(HAVE_CUDA) */
static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compilled without GPU support"); } static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compilled without GPU support"); }

Loading…
Cancel
Save