Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
12f304ec
Commit
12f304ec
authored
Jul 18, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Jul 18, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1146 from jet47:fix-gpu-without-cufft-cublas
parents
c48d3ad7
ebe7ff99
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
28 deletions
+114
-28
imgproc.cu
modules/gpu/src/cuda/imgproc.cu
+8
-0
safe_call.hpp
modules/gpu/src/cuda/safe_call.hpp
+68
-27
error.cpp
modules/gpu/src/error.cpp
+8
-0
imgproc.cpp
modules/gpu/src/imgproc.cpp
+30
-1
No files found.
modules/gpu/src/cuda/imgproc.cu
View file @
12f304ec
...
...
@@ -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
...
...
modules/gpu/src/cuda/safe_call.hpp
View file @
12f304ec
...
...
@@ -43,53 +43,94 @@
#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__ */
modules/gpu/src/error.cpp
View file @
12f304ec
...
...
@@ -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
}
}
...
...
modules/gpu/src/imgproc.cpp
View file @
12f304ec
...
...
@@ -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
}
//////////////////////////////////////////////////////////////////////////////
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment