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
dbb30134
Commit
dbb30134
authored
Mar 19, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16835 from YashasSamaga:cuda4dnn-hotfix-memory-lock
parents
8fe96743
034a43e7
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 @
dbb30134
...
...
@@ -276,14 +276,22 @@ namespace cv { namespace dnn { namespace cuda4dnn { namespace csl {
MemoryLockGuard
&
operator
=
(
const
MemoryLockGuard
&
)
=
delete
;
MemoryLockGuard
&
operator
=
(
MemoryLockGuard
&&
other
)
noexcept
{
ptr
=
other
.
ptr
;
other
.
ptr
=
nullptr
;
if
(
&
other
!=
this
)
{
if
(
ptr
!=
nullptr
)
{
/* cudaHostUnregister does not throw for a valid ptr */
CUDA4DNN_CHECK_CUDA
(
cudaHostUnregister
(
ptr
));
}
ptr
=
other
.
ptr
;
other
.
ptr
=
nullptr
;
}
return
*
this
;
}
~
MemoryLockGuard
()
{
if
(
ptr
!=
nullptr
)
if
(
ptr
!=
nullptr
)
{
/* cudaHostUnregister does not throw for a valid ptr */
CUDA4DNN_CHECK_CUDA
(
cudaHostUnregister
(
ptr
));
}
}
private
:
...
...
modules/dnn/src/op_cuda.hpp
View file @
dbb30134
...
...
@@ -308,7 +308,18 @@ namespace cv { namespace dnn {
auto
numel
=
total
(
shape_
);
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
);
}
}
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