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
d45ce086
Commit
d45ce086
authored
Nov 26, 2013
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Nov 26, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1856 from alalek:ocl_fix_mt
parents
16a11cfb
d650efc0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
cl_context.cpp
modules/ocl/src/cl_context.cpp
+22
-7
cl_operations.cpp
modules/ocl/src/cl_operations.cpp
+8
-1
No files found.
modules/ocl/src/cl_context.cpp
View file @
d45ce086
...
...
@@ -189,11 +189,8 @@ static bool parseOpenCLDeviceConfiguration(const std::string& configurationStr,
return
true
;
}
static
bool
__deviceSelected
=
false
;
static
bool
selectOpenCLDevice
()
{
__deviceSelected
=
true
;
std
::
string
platform
;
std
::
vector
<
std
::
string
>
deviceTypes
;
std
::
string
deviceName
;
...
...
@@ -528,13 +525,18 @@ private:
static
ContextImpl
*
currentContext
=
NULL
;
static
bool
__deviceSelected
=
false
;
Context
*
Context
::
getContext
()
{
if
(
currentContext
==
NULL
)
{
if
(
!
__initialized
||
!
__deviceSelected
)
static
bool
defaultInitiaization
=
false
;
if
(
!
defaultInitiaization
)
{
cv
::
AutoLock
lock
(
getInitializationMutex
());
try
{
if
(
!
__initialized
)
{
if
(
initializeOpenCLDevices
()
==
0
)
...
...
@@ -549,6 +551,13 @@ Context* Context::getContext()
CV_Error
(
CV_OpenCLInitError
,
"Can't select OpenCL device"
);
}
}
defaultInitiaization
=
true
;
}
catch
(...)
{
defaultInitiaization
=
true
;
throw
;
}
}
CV_Assert
(
currentContext
!=
NULL
);
}
...
...
@@ -741,10 +750,16 @@ int getOpenCLDevices(std::vector<const DeviceInfo*> &devices, int deviceType, co
void
setDevice
(
const
DeviceInfo
*
info
)
{
if
(
!
__deviceSelected
)
__deviceSelected
=
true
;
try
{
ContextImpl
::
setContext
(
info
);
__deviceSelected
=
true
;
}
catch
(...)
{
__deviceSelected
=
true
;
throw
;
}
}
bool
supportsFeature
(
FEATURE_TYPE
featureType
)
...
...
modules/ocl/src/cl_operations.cpp
View file @
d45ce086
...
...
@@ -192,6 +192,7 @@ void openCLMallocPitchEx(Context *ctx, void **dev_ptr, size_t *pitch,
clFinish
(
getClCommandQueue
(
ctx
));
#endif
CheckBuffers
data
(
mainBuffer
,
size
,
widthInBytes
,
height
);
cv
::
AutoLock
lock
(
getInitializationMutex
());
__check_buffers
.
insert
(
std
::
pair
<
cl_mem
,
CheckBuffers
>
((
cl_mem
)
*
dev_ptr
,
data
));
}
#endif
...
...
@@ -253,10 +254,17 @@ void openCLFree(void *devPtr)
bool
failBefore
=
false
,
failAfter
=
false
;
#endif
CheckBuffers
data
;
{
cv
::
AutoLock
lock
(
getInitializationMutex
());
std
::
map
<
cl_mem
,
CheckBuffers
>::
iterator
i
=
__check_buffers
.
find
((
cl_mem
)
devPtr
);
if
(
i
!=
__check_buffers
.
end
())
{
data
=
i
->
second
;
__check_buffers
.
erase
(
i
);
}
}
if
(
data
.
mainBuffer
!=
NULL
)
{
#ifdef CHECK_MEMORY_CORRUPTION
Context
*
ctx
=
Context
::
getContext
();
std
::
vector
<
uchar
>
checkBefore
(
__memory_corruption_guard_bytes
);
...
...
@@ -286,7 +294,6 @@ void openCLFree(void *devPtr)
clFinish
(
getClCommandQueue
(
ctx
));
#endif
openCLSafeCall
(
clReleaseMemObject
(
data
.
mainBuffer
));
__check_buffers
.
erase
(
i
);
}
#if defined(CHECK_MEMORY_CORRUPTION)
if
(
failBefore
)
...
...
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