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
4f373a42
Commit
4f373a42
authored
Nov 30, 2015
by
Dan Moodie
Committed by
Dan
Dec 08, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarified default allocator interface.
Conflicts: modules/core/src/matrix.cpp
parent
5d5cf32e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
matrix.cpp
modules/core/src/matrix.cpp
+20
-3
ocl.cpp
modules/core/src/ocl.cpp
+3
-3
umatrix.cpp
modules/core/src/umatrix.cpp
+5
-5
No files found.
modules/core/src/matrix.cpp
View file @
4f373a42
...
@@ -218,10 +218,27 @@ public:
...
@@ -218,10 +218,27 @@ public:
delete
u
;
delete
u
;
}
}
};
};
namespace
{
MatAllocator
*
g_matAllocator
=
nullptr
;
}
MatAllocator
*
Mat
::
getDefaultAllocator
()
{
if
(
g_matAllocator
==
nullptr
)
{
g_matAllocator
=
getStdAllocator
();
}
return
g_matAllocator
;
}
void
Mat
::
setDefaultAllocator
(
MatAllocator
*
allocator
)
{
g_matAllocator
=
allocator
;
}
MatAllocator
*
Mat
::
getStdAllocator
()
MatAllocator
*
Mat
::
getStdAllocator
()
{
{
CV_SINGLETON_LAZY_INIT
(
MatAllocator
,
new
StdMatAllocator
())
CV_SINGLETON_LAZY_INIT
(
MatAllocator
,
new
StdMatAllocator
())
}
}
void
swap
(
Mat
&
a
,
Mat
&
b
)
void
swap
(
Mat
&
a
,
Mat
&
b
)
...
@@ -388,7 +405,7 @@ void Mat::create(int d, const int* _sizes, int _type)
...
@@ -388,7 +405,7 @@ void Mat::create(int d, const int* _sizes, int _type)
if
(
total
()
>
0
)
if
(
total
()
>
0
)
{
{
MatAllocator
*
a
=
allocator
,
*
a0
=
get
Std
Allocator
();
MatAllocator
*
a
=
allocator
,
*
a0
=
get
Default
Allocator
();
#ifdef HAVE_TGPU
#ifdef HAVE_TGPU
if
(
!
a
||
a
==
tegra
::
getAllocator
()
)
if
(
!
a
||
a
==
tegra
::
getAllocator
()
)
a
=
tegra
::
getAllocator
(
d
,
_sizes
,
_type
);
a
=
tegra
::
getAllocator
(
d
,
_sizes
,
_type
);
...
@@ -426,7 +443,7 @@ void Mat::copySize(const Mat& m)
...
@@ -426,7 +443,7 @@ void Mat::copySize(const Mat& m)
void
Mat
::
deallocate
()
void
Mat
::
deallocate
()
{
{
if
(
u
)
if
(
u
)
(
u
->
currAllocator
?
u
->
currAllocator
:
allocator
?
allocator
:
get
Std
Allocator
())
->
unmap
(
u
);
(
u
->
currAllocator
?
u
->
currAllocator
:
allocator
?
allocator
:
get
Default
Allocator
())
->
unmap
(
u
);
u
=
NULL
;
u
=
NULL
;
}
}
...
...
modules/core/src/ocl.cpp
View file @
4f373a42
...
@@ -4292,7 +4292,7 @@ public:
...
@@ -4292,7 +4292,7 @@ public:
bufferPoolSVM
.
setMaxReservedSize
(
poolSize
);
bufferPoolSVM
.
setMaxReservedSize
(
poolSize
);
#endif
#endif
matStdAllocator
=
Mat
::
get
Std
Allocator
();
matStdAllocator
=
Mat
::
get
Default
Allocator
();
}
}
UMatData
*
defaultAllocate
(
int
dims
,
const
int
*
sizes
,
int
type
,
void
*
data
,
size_t
*
step
,
UMatData
*
defaultAllocate
(
int
dims
,
const
int
*
sizes
,
int
type
,
void
*
data
,
size_t
*
step
,
...
@@ -4918,7 +4918,7 @@ public:
...
@@ -4918,7 +4918,7 @@ public:
if
(
u
->
data
&&
!
u
->
hostCopyObsolete
()
)
if
(
u
->
data
&&
!
u
->
hostCopyObsolete
()
)
{
{
Mat
::
get
Std
Allocator
()
->
download
(
u
,
dstptr
,
dims
,
sz
,
srcofs
,
srcstep
,
dststep
);
Mat
::
get
Default
Allocator
()
->
download
(
u
,
dstptr
,
dims
,
sz
,
srcofs
,
srcstep
,
dststep
);
return
;
return
;
}
}
CV_Assert
(
u
->
handle
!=
0
);
CV_Assert
(
u
->
handle
!=
0
);
...
@@ -5042,7 +5042,7 @@ public:
...
@@ -5042,7 +5042,7 @@ public:
// 2. we overwrite part of the matrix, but the GPU copy is out-of-date
// 2. we overwrite part of the matrix, but the GPU copy is out-of-date
if
(
u
->
data
&&
(
u
->
hostCopyObsolete
()
<
u
->
deviceCopyObsolete
()
||
total
==
u
->
size
))
if
(
u
->
data
&&
(
u
->
hostCopyObsolete
()
<
u
->
deviceCopyObsolete
()
||
total
==
u
->
size
))
{
{
Mat
::
get
Std
Allocator
()
->
upload
(
u
,
srcptr
,
dims
,
sz
,
dstofs
,
dststep
,
srcstep
);
Mat
::
get
Default
Allocator
()
->
upload
(
u
,
srcptr
,
dims
,
sz
,
dstofs
,
dststep
,
srcstep
);
u
->
markHostCopyObsolete
(
false
);
u
->
markHostCopyObsolete
(
false
);
u
->
markDeviceCopyObsolete
(
true
);
u
->
markDeviceCopyObsolete
(
true
);
return
;
return
;
...
...
modules/core/src/umatrix.cpp
View file @
4f373a42
...
@@ -94,7 +94,7 @@ UMatData::~UMatData()
...
@@ -94,7 +94,7 @@ UMatData::~UMatData()
// simulate Mat::deallocate
// simulate Mat::deallocate
if
(
u
->
mapcount
!=
0
)
if
(
u
->
mapcount
!=
0
)
{
{
(
u
->
currAllocator
?
u
->
currAllocator
:
/* TODO allocator ? allocator :*/
Mat
::
get
Std
Allocator
())
->
unmap
(
u
);
(
u
->
currAllocator
?
u
->
currAllocator
:
/* TODO allocator ? allocator :*/
Mat
::
get
Default
Allocator
())
->
unmap
(
u
);
}
}
else
else
{
{
...
@@ -144,7 +144,7 @@ MatAllocator* UMat::getStdAllocator()
...
@@ -144,7 +144,7 @@ MatAllocator* UMat::getStdAllocator()
if
(
ocl
::
haveOpenCL
()
&&
ocl
::
useOpenCL
()
)
if
(
ocl
::
haveOpenCL
()
&&
ocl
::
useOpenCL
()
)
return
ocl
::
getOpenCLAllocator
();
return
ocl
::
getOpenCLAllocator
();
#endif
#endif
return
Mat
::
get
Std
Allocator
();
return
Mat
::
get
Default
Allocator
();
}
}
void
swap
(
UMat
&
a
,
UMat
&
b
)
void
swap
(
UMat
&
a
,
UMat
&
b
)
...
@@ -286,7 +286,7 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
...
@@ -286,7 +286,7 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
accessFlags
|=
ACCESS_RW
;
accessFlags
|=
ACCESS_RW
;
UMatData
*
new_u
=
NULL
;
UMatData
*
new_u
=
NULL
;
{
{
MatAllocator
*
a
=
allocator
,
*
a0
=
get
Std
Allocator
();
MatAllocator
*
a
=
allocator
,
*
a0
=
get
Default
Allocator
();
if
(
!
a
)
if
(
!
a
)
a
=
a0
;
a
=
a0
;
new_u
=
a
->
allocate
(
dims
,
size
.
p
,
type
(),
data
,
step
.
p
,
accessFlags
,
usageFlags
);
new_u
=
a
->
allocate
(
dims
,
size
.
p
,
type
(),
data
,
step
.
p
,
accessFlags
,
usageFlags
);
...
@@ -302,7 +302,7 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
...
@@ -302,7 +302,7 @@ UMat Mat::getUMat(int accessFlags, UMatUsageFlags usageFlags) const
}
}
if
(
!
allocated
)
if
(
!
allocated
)
{
{
allocated
=
get
Std
Allocator
()
->
allocate
(
new_u
,
accessFlags
,
usageFlags
);
allocated
=
get
Default
Allocator
()
->
allocate
(
new_u
,
accessFlags
,
usageFlags
);
CV_Assert
(
allocated
);
CV_Assert
(
allocated
);
}
}
if
(
u
!=
NULL
)
if
(
u
!=
NULL
)
...
@@ -358,7 +358,7 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
...
@@ -358,7 +358,7 @@ void UMat::create(int d, const int* _sizes, int _type, UMatUsageFlags _usageFlag
if
(
!
a
)
if
(
!
a
)
{
{
a
=
a0
;
a
=
a0
;
a0
=
Mat
::
get
Std
Allocator
();
a0
=
Mat
::
get
Default
Allocator
();
}
}
try
try
{
{
...
...
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