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
8bce7601
Commit
8bce7601
authored
Mar 21, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8424 from khnaba:expose-buffer-pool
parents
b3d128bb
cdcf44b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
18 deletions
+45
-18
cuda.hpp
modules/core/include/opencv2/core/cuda.hpp
+28
-0
private.cuda.hpp
modules/core/include/opencv2/core/private.cuda.hpp
+0
-14
cuda_stream.cpp
modules/core/src/cuda_stream.cpp
+17
-4
No files found.
modules/core/include/opencv2/core/cuda.hpp
View file @
8bce7601
...
...
@@ -327,6 +327,34 @@ The function does not reallocate memory if the matrix has proper attributes alre
*/
CV_EXPORTS
void
ensureSizeIsEnough
(
int
rows
,
int
cols
,
int
type
,
OutputArray
arr
);
/** @brief BufferPool for use with CUDA streams
* BufferPool utilizes cuda::Stream's allocator to create new buffers. It is
* particularly useful when BufferPoolUsage is set to true, or a custom
* allocator is specified for the cuda::Stream, and you want to implement your
* own stream based functions utilizing the same underlying GPU memory
* management.
*/
class
CV_EXPORTS
BufferPool
{
public
:
//! Gets the BufferPool for the given stream.
explicit
BufferPool
(
Stream
&
stream
);
//! Allocates a new GpuMat of given size and type.
GpuMat
getBuffer
(
int
rows
,
int
cols
,
int
type
);
//! Allocates a new GpuMat of given size and type.
GpuMat
getBuffer
(
Size
size
,
int
type
)
{
return
getBuffer
(
size
.
height
,
size
.
width
,
type
);
}
//! Returns the allocator associated with the stream.
Ptr
<
GpuMat
::
Allocator
>
getAllocator
()
const
{
return
allocator_
;
}
private
:
Ptr
<
GpuMat
::
Allocator
>
allocator_
;
};
//! BufferPool management (must be called before Stream creation)
CV_EXPORTS
void
setBufferPoolUsage
(
bool
on
);
CV_EXPORTS
void
setBufferPoolConfig
(
int
deviceId
,
size_t
stackSize
,
int
stackCount
);
...
...
modules/core/include/opencv2/core/private.cuda.hpp
View file @
8bce7601
...
...
@@ -102,20 +102,6 @@ static inline void throw_no_cuda() { CV_Error(cv::Error::StsNotImplemented, "The
namespace
cv
{
namespace
cuda
{
class
CV_EXPORTS
BufferPool
{
public
:
explicit
BufferPool
(
Stream
&
stream
);
GpuMat
getBuffer
(
int
rows
,
int
cols
,
int
type
);
GpuMat
getBuffer
(
Size
size
,
int
type
)
{
return
getBuffer
(
size
.
height
,
size
.
width
,
type
);
}
GpuMat
::
Allocator
*
getAllocator
()
const
{
return
allocator_
;
}
private
:
GpuMat
::
Allocator
*
allocator_
;
};
static
inline
void
checkNppError
(
int
code
,
const
char
*
file
,
const
int
line
,
const
char
*
func
)
{
if
(
code
<
0
)
...
...
modules/core/src/cuda_stream.cpp
View file @
8bce7601
...
...
@@ -668,20 +668,33 @@ void cv::cuda::setBufferPoolConfig(int deviceId, size_t stackSize, int stackCoun
#endif
}
#ifdef HAVE_CUDA
cv
::
cuda
::
BufferPool
::
BufferPool
(
Stream
&
stream
)
:
allocator_
(
stream
.
impl_
->
stackAllocator
.
get
())
#ifndef HAVE_CUDA
cv
::
cuda
::
BufferPool
::
BufferPool
(
Stream
&
stream
)
{
(
void
)
stream
;
throw_no_cuda
();
}
#else
cv
::
cuda
::
BufferPool
::
BufferPool
(
Stream
&
stream
)
:
allocator_
(
stream
.
impl_
->
stackAllocator
)
{
}
#endif
GpuMat
cv
::
cuda
::
BufferPool
::
getBuffer
(
int
rows
,
int
cols
,
int
type
)
{
#ifndef HAVE_CUDA
(
void
)
rows
;
(
void
)
cols
;
(
void
)
type
;
throw_no_cuda
();
return
GpuMat
();
#else
GpuMat
buf
(
allocator_
);
buf
.
create
(
rows
,
cols
,
type
);
return
buf
;
#endif
}
#endif
////////////////////////////////////////////////////////////////
// Event
...
...
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