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
55a722fc
Commit
55a722fc
authored
Nov 10, 2010
by
Anatoly Baksheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some utility for GPU module internal purposes
parent
f76d3939
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
10 deletions
+49
-10
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+6
-1
cuda_shared.hpp
modules/gpu/src/cuda/cuda_shared.hpp
+36
-2
safe_call.hpp
modules/gpu/src/cuda/safe_call.hpp
+5
-5
error.cpp
modules/gpu/src/error.cpp
+2
-2
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
55a722fc
...
...
@@ -52,7 +52,7 @@ namespace cv
{
namespace
gpu
{
//////////////////////////////// Initialization ////////////////////////
//////////////////////////////// Initialization
& Info
////////////////////////
//! This is the only function that do not throw exceptions if the library is compiled without Cuda.
CV_EXPORTS
int
getCudaEnabledDeviceCount
();
...
...
@@ -67,6 +67,11 @@ namespace cv
CV_EXPORTS
void
getGpuMemInfo
(
size_t
&
free
,
size_t
&
total
);
//////////////////////////////// Error handling ////////////////////////
CV_EXPORTS
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
);
CV_EXPORTS
void
nppError
(
int
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
);
//////////////////////////////// GpuMat ////////////////////////////////
class
Stream
;
class
CudaMem
;
...
...
modules/gpu/src/cuda/cuda_shared.hpp
View file @
55a722fc
...
...
@@ -58,8 +58,42 @@ namespace cv
static
inline
int
divUp
(
int
total
,
int
grain
)
{
return
(
total
+
grain
-
1
)
/
grain
;
}
template
<
class
T
>
static
inline
void
uploadConstant
(
const
char
*
name
,
const
T
&
value
)
{
cudaSafeCall
(
cudaMemcpyToSymbol
(
name
,
&
value
,
sizeof
(
T
))
);
}
template
<
class
T
>
static
inline
void
uploadConstant
(
const
char
*
name
,
const
T
&
value
)
{
cudaSafeCall
(
cudaMemcpyToSymbol
(
name
,
&
value
,
sizeof
(
T
))
);
}
template
<
class
T
>
static
inline
void
uploadConstant
(
const
char
*
name
,
const
T
&
value
,
cudaStream_t
stream
)
{
cudaSafeCall
(
cudaMemcpyToSymbolAsyc
(
name
,
&
value
,
sizeof
(
T
),
0
,
cudaMemcpyHostToDevice
,
stream
)
);
}
template
<
class
T
>
static
inline
void
bindTexture
(
const
char
*
name
,
const
DevMem2D_
<
T
>&
img
/*, bool normalized = false,
enum cudaTextureFilterMode filterMode = cudaFilterModePoint, enum cudaTextureAddressMode addrMode = cudaAddressModeClamp*/
)
{
//!!!! const_cast is disabled!
//!!!! Please use constructor of 'class texture' instead.
//textureReference* tex;
//cudaSafeCall( cudaGetTextureReference((const textureReference**)&tex, name) );
//tex->normalized = normalized;
//tex->filterMode = filterMode;
//tex->addressMode[0] = addrMode;
//tex->addressMode[1] = addrMode;
const
textureReference
*
tex
;
cudaSafeCall
(
cudaGetTextureReference
(
&
tex
,
name
)
);
cudaChannelFormatDesc
desc
=
cudaCreateChannelDesc
<
T
>
();
cudaSafeCall
(
cudaBindTexture2D
(
0
,
tex
,
img
.
ptr
(),
&
desc
,
img
.
cols
,
img
.
rows
,
img
.
step
)
);
}
static
inline
void
unbindTexture
(
const
char
*
name
)
{
const
textureReference
*
tex
;
cudaSafeCall
(
cudaGetTextureReference
(
&
tex
,
name
)
);
cudaSafeCall
(
cudaUnbindTexture
(
tex
)
);
}
}
}
...
...
modules/gpu/src/cuda/safe_call.hpp
View file @
55a722fc
...
...
@@ -44,7 +44,7 @@
#define __OPENCV_CUDA_SAFE_CALL_HPP__
#include "cuda_runtime_api.h"
#include <nppdefs.h>
//
#include <nppdefs.h>
#if defined(__GNUC__)
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
...
...
@@ -58,8 +58,8 @@ namespace cv
{
namespace
gpu
{
extern
"C"
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
extern
"C"
void
npp_e
rror
(
int
error
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
void
nppE
rror
(
int
error
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
);
static
inline
void
___cudaSafeCall
(
cudaError_t
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
)
{
...
...
@@ -67,10 +67,10 @@ namespace cv
cv
::
gpu
::
error
(
cudaGetErrorString
(
err
),
file
,
line
,
func
);
}
static
inline
void
___nppSafeCall
(
NppStatus
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
)
static
inline
void
___nppSafeCall
(
int
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
=
""
)
{
if
(
err
<
0
)
cv
::
gpu
::
npp
_e
rror
(
err
,
file
,
line
,
func
);
cv
::
gpu
::
npp
E
rror
(
err
,
file
,
line
,
func
);
}
}
}
...
...
modules/gpu/src/error.cpp
View file @
55a722fc
...
...
@@ -129,12 +129,12 @@ namespace cv
return
interpreter
.
str
();
}
extern
"C"
void
npp_e
rror
(
int
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
)
void
nppE
rror
(
int
err
,
const
char
*
file
,
const
int
line
,
const
char
*
func
)
{
cv
::
error
(
cv
::
Exception
(
CV_GpuNppCallError
,
getNppErrorString
(
err
),
func
,
file
,
line
)
);
}
extern
"C"
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
)
void
error
(
const
char
*
error_string
,
const
char
*
file
,
const
int
line
,
const
char
*
func
)
{
cv
::
error
(
cv
::
Exception
(
CV_GpuApiCallError
,
error_string
,
func
,
file
,
line
)
);
}
...
...
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