fixed compilation without CUBLAS and CUFFT
authorVladislav Vinogradov <vlad.vinogradov@itseez.com>
Thu, 18 Jul 2013 07:24:34 +0000 (11:24 +0400)
committerVladislav Vinogradov <vlad.vinogradov@itseez.com>
Thu, 18 Jul 2013 08:04:33 +0000 (12:04 +0400)
modules/gpu/src/cuda/imgproc.cu
modules/gpu/src/cuda/safe_call.hpp
modules/gpu/src/error.cpp
modules/gpu/src/imgproc.cpp

index b23e0a6..067dfaf 100644 (file)
@@ -619,6 +619,7 @@ namespace cv { namespace gpu { namespace device
         //////////////////////////////////////////////////////////////////////////
         // mulSpectrums
 
+#ifdef HAVE_CUFFT
         __global__ void mulSpectrumsKernel(const PtrStep<cufftComplex> a, const PtrStep<cufftComplex> b, PtrStepSz<cufftComplex> c)
         {
             const int x = blockIdx.x * blockDim.x + threadIdx.x;
@@ -642,11 +643,13 @@ namespace cv { namespace gpu { namespace device
             if (stream == 0)
                 cudaSafeCall( cudaDeviceSynchronize() );
         }
+#endif
 
 
         //////////////////////////////////////////////////////////////////////////
         // mulSpectrums_CONJ
 
+#ifdef HAVE_CUFFT
         __global__ void mulSpectrumsKernel_CONJ(const PtrStep<cufftComplex> a, const PtrStep<cufftComplex> b, PtrStepSz<cufftComplex> c)
         {
             const int x = blockIdx.x * blockDim.x + threadIdx.x;
@@ -670,11 +673,13 @@ namespace cv { namespace gpu { namespace device
             if (stream == 0)
                 cudaSafeCall( cudaDeviceSynchronize() );
         }
+#endif
 
 
         //////////////////////////////////////////////////////////////////////////
         // mulAndScaleSpectrums
 
+#ifdef HAVE_CUFFT
         __global__ void mulAndScaleSpectrumsKernel(const PtrStep<cufftComplex> a, const PtrStep<cufftComplex> b, float scale, PtrStepSz<cufftComplex> c)
         {
             const int x = blockIdx.x * blockDim.x + threadIdx.x;
@@ -699,11 +704,13 @@ namespace cv { namespace gpu { namespace device
             if (stream)
                 cudaSafeCall( cudaDeviceSynchronize() );
         }
+#endif
 
 
         //////////////////////////////////////////////////////////////////////////
         // mulAndScaleSpectrums_CONJ
 
+#ifdef HAVE_CUFFT
         __global__ void mulAndScaleSpectrumsKernel_CONJ(const PtrStep<cufftComplex> a, const PtrStep<cufftComplex> b, float scale, PtrStepSz<cufftComplex> c)
         {
             const int x = blockIdx.x * blockDim.x + threadIdx.x;
@@ -728,6 +735,7 @@ namespace cv { namespace gpu { namespace device
             if (stream == 0)
                 cudaSafeCall( cudaDeviceSynchronize() );
         }
+#endif
 
         //////////////////////////////////////////////////////////////////////////
         // buildWarpMaps
index 7fae710..53d691f 100644 (file)
 #ifndef __OPENCV_CUDA_SAFE_CALL_HPP__
 #define __OPENCV_CUDA_SAFE_CALL_HPP__
 
+#include "cvconfig.h"
+
 #include <cuda_runtime_api.h>
-#include <cufft.h>
-#include <cublas.h>
-#include "NCV.hpp"
 
-#if defined(__GNUC__)
-    #define nppSafeCall(expr)  ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
-    #define ncvSafeCall(expr)  ___ncvSafeCall(expr, __FILE__, __LINE__, __func__)
-    #define cufftSafeCall(expr)  ___cufftSafeCall(expr, __FILE__, __LINE__, __func__)
-    #define cublasSafeCall(expr)  ___cublasSafeCall(expr, __FILE__, __LINE__, __func__)
-#else /* defined(__CUDACC__) || defined(__MSVC__) */
-    #define nppSafeCall(expr)  ___nppSafeCall(expr, __FILE__, __LINE__)
-    #define ncvSafeCall(expr)  ___ncvSafeCall(expr, __FILE__, __LINE__)
-    #define cufftSafeCall(expr)  ___cufftSafeCall(expr, __FILE__, __LINE__)
-    #define cublasSafeCall(expr)  ___cublasSafeCall(expr, __FILE__, __LINE__)
+#ifdef HAVE_CUFFT
+#   include <cufft.h>
 #endif
 
-namespace cv { namespace gpu
-{
-    void nppError(int err, const char *file, const int line, const char *func = "");
-    void ncvError(int err, const char *file, const int line, const char *func = "");
+#ifdef HAVE_CUBLAS
+#   include <cublas.h>
+#endif
+
+#include "NCV.hpp"
+
+namespace cv { namespace gpu {
+
+void nppError(int err, const char *file, const int line, const char *func = "");
+
+void ncvError(int err, const char *file, const int line, const char *func = "");
+
+#ifdef HAVE_CUFFT
     void cufftError(int err, const char *file, const int line, const char *func = "");
+#endif
+
+#ifdef HAVE_CUBLAS
     void cublasError(int err, const char *file, const int line, const char *func = "");
+#endif
+
 }}
 
+// nppSafeCall
+
 static inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
 {
     if (err < 0)
         cv::gpu::nppError(err, file, line, func);
 }
 
+#if defined(__GNUC__)
+    #define nppSafeCall(expr)  ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
+#else
+    #define nppSafeCall(expr)  ___nppSafeCall(expr, __FILE__, __LINE__)
+#endif
+
+// ncvSafeCall
+
 static inline void ___ncvSafeCall(int err, const char *file, const int line, const char *func = "")
 {
     if (NCV_SUCCESS != err)
         cv::gpu::ncvError(err, file, line, func);
 }
 
-static inline void ___cufftSafeCall(cufftResult_t err, const char *file, const int line, const char *func = "")
-{
-    if (CUFFT_SUCCESS != err)
-        cv::gpu::cufftError(err, file, line, func);
-}
+#if defined(__GNUC__)
+    #define ncvSafeCall(expr)  ___ncvSafeCall(expr, __FILE__, __LINE__, __func__)
+#else
+    #define ncvSafeCall(expr)  ___ncvSafeCall(expr, __FILE__, __LINE__)
+#endif
 
-static inline void ___cublasSafeCall(cublasStatus_t err, const char *file, const int line, const char *func = "")
-{
-    if (CUBLAS_STATUS_SUCCESS != err)
-        cv::gpu::cublasError(err, file, line, func);
-}
+// cufftSafeCall
+
+#ifdef HAVE_CUFFT
+    static inline void ___cufftSafeCall(cufftResult_t err, const char *file, const int line, const char *func = "")
+    {
+        if (CUFFT_SUCCESS != err)
+            cv::gpu::cufftError(err, file, line, func);
+    }
+
+    #if defined(__GNUC__)
+        #define cufftSafeCall(expr)  ___cufftSafeCall(expr, __FILE__, __LINE__, __func__)
+    #else
+        #define cufftSafeCall(expr)  ___cufftSafeCall(expr, __FILE__, __LINE__)
+    #endif
+#endif
+
+// cublasSafeCall
+
+#ifdef HAVE_CUBLAS
+    static inline void ___cublasSafeCall(cublasStatus_t err, const char *file, const int line, const char *func = "")
+    {
+        if (CUBLAS_STATUS_SUCCESS != err)
+            cv::gpu::cublasError(err, file, line, func);
+    }
+
+    #if defined(__GNUC__)
+        #define cublasSafeCall(expr)  ___cublasSafeCall(expr, __FILE__, __LINE__, __func__)
+    #else
+        #define cublasSafeCall(expr)  ___cublasSafeCall(expr, __FILE__, __LINE__)
+    #endif
+#endif
 
 #endif /* __OPENCV_CUDA_SAFE_CALL_HPP__ */
index 7f5d5f3..ff0cadb 100644 (file)
@@ -224,6 +224,7 @@ namespace
     //////////////////////////////////////////////////////////////////////////
     // CUFFT errors
 
+#ifdef HAVE_CUFFT
     const ErrorEntry cufft_errors[] =
     {
         error_entry( CUFFT_INVALID_PLAN ),
@@ -238,10 +239,12 @@ namespace
     };
 
     const int cufft_error_num = sizeof(cufft_errors) / sizeof(cufft_errors[0]);
+#endif
 
     //////////////////////////////////////////////////////////////////////////
     // CUBLAS errors
 
+#ifdef HAVE_CUBLAS
     const ErrorEntry cublas_errors[] =
     {
         error_entry( CUBLAS_STATUS_SUCCESS ),
@@ -255,6 +258,7 @@ namespace
     };
 
     const int cublas_error_num = sizeof(cublas_errors) / sizeof(cublas_errors[0]);
+#endif
 }
 
 namespace cv
@@ -273,17 +277,21 @@ namespace cv
             cv::gpu::error(msg.c_str(), file, line, func);
         }
 
+#ifdef HAVE_CUFFT
         void cufftError(int code, const char *file, const int line, const char *func)
         {
             string msg = getErrorString(code, cufft_errors, cufft_error_num);
             cv::gpu::error(msg.c_str(), file, line, func);
         }
+#endif
 
+#ifdef HAVE_CUBLAS
         void cublasError(int code, const char *file, const int line, const char *func)
         {
             string msg = getErrorString(code, cublas_errors, cublas_error_num);
             cv::gpu::error(msg.c_str(), file, line, func);
         }
+#endif
     }
 }
 
index 97c7c76..8e452b4 100644 (file)
@@ -1136,6 +1136,8 @@ void cv::gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, GpuMat& Dx, GpuM
 //////////////////////////////////////////////////////////////////////////////
 // mulSpectrums
 
+#ifdef HAVE_CUFFT
+
 namespace cv { namespace gpu { namespace device
 {
     namespace imgproc
@@ -1146,9 +1148,20 @@ namespace cv { namespace gpu { namespace device
     }
 }}}
 
+#endif
+
 void cv::gpu::mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, bool conjB, Stream& stream)
 {
-    (void)flags;
+#ifndef HAVE_CUFFT
+    (void) a;
+    (void) b;
+    (void) c;
+    (void) flags;
+    (void) conjB;
+    (void) stream;
+    throw_nogpu();
+#else
+    (void) flags;
     using namespace ::cv::gpu::device::imgproc;
 
     typedef void (*Caller)(const PtrStep<cufftComplex>, const PtrStep<cufftComplex>, PtrStepSz<cufftComplex>, cudaStream_t stream);
@@ -1162,11 +1175,14 @@ void cv::gpu::mulSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flag
 
     Caller caller = callers[(int)conjB];
     caller(a, b, c, StreamAccessor::getStream(stream));
+#endif
 }
 
 //////////////////////////////////////////////////////////////////////////////
 // mulAndScaleSpectrums
 
+#ifdef HAVE_CUFFT
+
 namespace cv { namespace gpu { namespace device
 {
     namespace imgproc
@@ -1177,8 +1193,20 @@ namespace cv { namespace gpu { namespace device
     }
 }}}
 
+#endif
+
 void cv::gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c, int flags, float scale, bool conjB, Stream& stream)
 {
+#ifndef HAVE_CUFFT
+    (void) a;
+    (void) b;
+    (void) c;
+    (void) flags;
+    (void) scale;
+    (void) conjB;
+    (void) stream;
+    throw_nogpu();
+#else
     (void)flags;
     using namespace ::cv::gpu::device::imgproc;
 
@@ -1192,6 +1220,7 @@ void cv::gpu::mulAndScaleSpectrums(const GpuMat& a, const GpuMat& b, GpuMat& c,
 
     Caller caller = callers[(int)conjB];
     caller(a, b, scale, c, StreamAccessor::getStream(stream));
+#endif
 }
 
 //////////////////////////////////////////////////////////////////////////////