//////////////////////////////////////////////////////////////////////////
// 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;
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;
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;
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;
if (stream == 0)
cudaSafeCall( cudaDeviceSynchronize() );
}
+#endif
//////////////////////////////////////////////////////////////////////////
// buildWarpMaps
#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__ */
//////////////////////////////////////////////////////////////////////////
// CUFFT errors
+#ifdef HAVE_CUFFT
const ErrorEntry cufft_errors[] =
{
error_entry( CUFFT_INVALID_PLAN ),
};
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 ),
};
const int cublas_error_num = sizeof(cublas_errors) / sizeof(cublas_errors[0]);
+#endif
}
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
}
}
//////////////////////////////////////////////////////////////////////////////
// mulSpectrums
+#ifdef HAVE_CUFFT
+
namespace cv { namespace gpu { namespace device
{
namespace imgproc
}
}}}
+#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);
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
}
}}}
+#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;
Caller caller = callers[(int)conjB];
caller(a, b, scale, c, StreamAccessor::getStream(stream));
+#endif
}
//////////////////////////////////////////////////////////////////////////////