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
034a43e7
Commit
034a43e7
authored
Mar 17, 2020
by
YashasSamaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
release and relock on wrapper resize
parent
c48473df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
memory.hpp
modules/dnn/src/cuda4dnn/csl/memory.hpp
+11
-3
op_cuda.hpp
modules/dnn/src/op_cuda.hpp
+11
-0
No files found.
modules/dnn/src/cuda4dnn/csl/memory.hpp
View file @
034a43e7
...
@@ -276,14 +276,22 @@ namespace cv { namespace dnn { namespace cuda4dnn { namespace csl {
...
@@ -276,14 +276,22 @@ namespace cv { namespace dnn { namespace cuda4dnn { namespace csl {
MemoryLockGuard
&
operator
=
(
const
MemoryLockGuard
&
)
=
delete
;
MemoryLockGuard
&
operator
=
(
const
MemoryLockGuard
&
)
=
delete
;
MemoryLockGuard
&
operator
=
(
MemoryLockGuard
&&
other
)
noexcept
{
MemoryLockGuard
&
operator
=
(
MemoryLockGuard
&&
other
)
noexcept
{
ptr
=
other
.
ptr
;
if
(
&
other
!=
this
)
{
other
.
ptr
=
nullptr
;
if
(
ptr
!=
nullptr
)
{
/* cudaHostUnregister does not throw for a valid ptr */
CUDA4DNN_CHECK_CUDA
(
cudaHostUnregister
(
ptr
));
}
ptr
=
other
.
ptr
;
other
.
ptr
=
nullptr
;
}
return
*
this
;
return
*
this
;
}
}
~
MemoryLockGuard
()
{
~
MemoryLockGuard
()
{
if
(
ptr
!=
nullptr
)
if
(
ptr
!=
nullptr
)
{
/* cudaHostUnregister does not throw for a valid ptr */
CUDA4DNN_CHECK_CUDA
(
cudaHostUnregister
(
ptr
));
CUDA4DNN_CHECK_CUDA
(
cudaHostUnregister
(
ptr
));
}
}
}
private
:
private
:
...
...
modules/dnn/src/op_cuda.hpp
View file @
034a43e7
...
@@ -308,7 +308,18 @@ namespace cv { namespace dnn {
...
@@ -308,7 +308,18 @@ namespace cv { namespace dnn {
auto
numel
=
total
(
shape_
);
auto
numel
=
total
(
shape_
);
if
(
numel
>
shared_block
->
device
.
size
())
if
(
numel
>
shared_block
->
device
.
size
())
{
/* if the host memory was already page-locked, release it and register again with the new size */
shared_block
->
memGuard
=
cuda4dnn
::
csl
::
MemoryLockGuard
();
try
{
CV_Assert
(
shared_block
->
host
.
type
()
==
CV_32F
);
shared_block
->
memGuard
=
cuda4dnn
::
csl
::
MemoryLockGuard
(
shared_block
->
host
.
data
,
numel
*
sizeof
(
float
));
}
catch
(...)
{
/* a common reason for failure is that the host system (for example, a Jetson device) does not support it */
/* we ignore the failure as this is just an optimization and not a requirement */
}
shared_block
->
device
.
reset
(
numel
);
shared_block
->
device
.
reset
(
numel
);
}
}
}
static
Ptr
<
BackendWrapper
>
create
(
Mat
&
m
)
{
static
Ptr
<
BackendWrapper
>
create
(
Mat
&
m
)
{
...
...
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