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
741fb9b7
Commit
741fb9b7
authored
May 07, 2013
by
Vadim Pisarevsky
Committed by
OpenCV Buildbot
May 07, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #865 from pengx17:2.4_ocl_ver
parents
2faa2ada
d34e7eca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
43 deletions
+54
-43
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+1
-1
initialization.cpp
modules/ocl/src/initialization.cpp
+6
-0
matrix_operations.cpp
modules/ocl/src/matrix_operations.cpp
+8
-12
mcwutil.cpp
modules/ocl/src/mcwutil.cpp
+39
-30
No files found.
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
741fb9b7
...
@@ -155,7 +155,7 @@ namespace cv
...
@@ -155,7 +155,7 @@ namespace cv
static
Context
*
getContext
();
static
Context
*
getContext
();
static
void
setContext
(
Info
&
oclinfo
);
static
void
setContext
(
Info
&
oclinfo
);
enum
{
CL_DOUBLE
,
CL_UNIFIED_MEM
};
enum
{
CL_DOUBLE
,
CL_UNIFIED_MEM
,
CL_VER_1_2
};
bool
supportsFeature
(
int
ftype
);
bool
supportsFeature
(
int
ftype
);
size_t
computeUnits
();
size_t
computeUnits
();
void
*
oclContext
();
void
*
oclContext
();
...
...
modules/ocl/src/initialization.cpp
View file @
741fb9b7
...
@@ -130,6 +130,7 @@ namespace cv
...
@@ -130,6 +130,7 @@ namespace cv
cl_platform_id
oclplatform
;
cl_platform_id
oclplatform
;
std
::
vector
<
cl_device_id
>
devices
;
std
::
vector
<
cl_device_id
>
devices
;
std
::
vector
<
std
::
string
>
devName
;
std
::
vector
<
std
::
string
>
devName
;
std
::
string
clVersion
;
cl_context
oclcontext
;
cl_context
oclcontext
;
cl_command_queue
clCmdQueue
;
cl_command_queue
clCmdQueue
;
...
@@ -304,6 +305,7 @@ namespace cv
...
@@ -304,6 +305,7 @@ namespace cv
char
deviceName
[
256
];
char
deviceName
[
256
];
int
devcienums
=
0
;
int
devcienums
=
0
;
char
clVersion
[
256
];
for
(
unsigned
i
=
0
;
i
<
numPlatforms
;
++
i
)
for
(
unsigned
i
=
0
;
i
<
numPlatforms
;
++
i
)
{
{
cl_uint
numsdev
;
cl_uint
numsdev
;
...
@@ -319,6 +321,8 @@ namespace cv
...
@@ -319,6 +321,8 @@ namespace cv
Info
ocltmpinfo
;
Info
ocltmpinfo
;
ocltmpinfo
.
impl
->
oclplatform
=
platforms
[
i
];
ocltmpinfo
.
impl
->
oclplatform
=
platforms
[
i
];
openCLSafeCall
(
clGetPlatformInfo
(
platforms
[
i
],
CL_PLATFORM_VERSION
,
sizeof
(
clVersion
),
clVersion
,
NULL
));
ocltmpinfo
.
impl
->
clVersion
=
clVersion
;
for
(
unsigned
j
=
0
;
j
<
numsdev
;
++
j
)
for
(
unsigned
j
=
0
;
j
<
numsdev
;
++
j
)
{
{
ocltmpinfo
.
impl
->
devices
.
push_back
(
devices
[
j
]);
ocltmpinfo
.
impl
->
devices
.
push_back
(
devices
[
j
]);
...
@@ -997,6 +1001,8 @@ namespace cv
...
@@ -997,6 +1001,8 @@ namespace cv
return
impl
->
double_support
==
1
;
return
impl
->
double_support
==
1
;
case
CL_UNIFIED_MEM
:
case
CL_UNIFIED_MEM
:
return
impl
->
unified_memory
==
1
;
return
impl
->
unified_memory
==
1
;
case
CL_VER_1_2
:
return
impl
->
clVersion
.
find
(
"OpenCL 1.2"
)
!=
string
::
npos
;
default
:
default
:
return
false
;
return
false
;
}
}
...
...
modules/ocl/src/matrix_operations.cpp
View file @
741fb9b7
...
@@ -593,11 +593,16 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri
...
@@ -593,11 +593,16 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri
CV_Error
(
CV_StsUnsupportedFormat
,
"unknown depth"
);
CV_Error
(
CV_StsUnsupportedFormat
,
"unknown depth"
);
}
}
#ifdef CL_VERSION_1_2
#ifdef CL_VERSION_1_2
if
(
dst
.
offset
==
0
&&
dst
.
cols
==
dst
.
wholecols
)
//this enables backwards portability to
//run on OpenCL 1.1 platform if library binaries are compiled with OpenCL 1.2 support
if
(
Context
::
getContext
()
->
supportsFeature
(
Context
::
CL_VER_1_2
)
&&
dst
.
offset
==
0
&&
dst
.
cols
==
dst
.
wholecols
)
{
{
clEnqueueFillBuffer
((
cl_command_queue
)
dst
.
clCxt
->
oclCommandQueue
(),
(
cl_mem
)
dst
.
data
,
args
[
0
].
second
,
args
[
0
].
first
,
0
,
dst
.
step
*
dst
.
rows
,
0
,
NULL
,
NULL
);
clEnqueueFillBuffer
((
cl_command_queue
)
dst
.
clCxt
->
oclCommandQueue
(),
(
cl_mem
)
dst
.
data
,
args
[
0
].
second
,
args
[
0
].
first
,
0
,
dst
.
step
*
dst
.
rows
,
0
,
NULL
,
NULL
);
}
}
else
else
#endif
{
{
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
cols
));
...
@@ -605,17 +610,8 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri
...
@@ -605,17 +610,8 @@ static void set_to_withoutmask_run(const oclMat &dst, const Scalar &scalar, stri
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
step_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
step_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
offset_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
offset_in_pixel
));
openCLExecuteKernel
(
dst
.
clCxt
,
&
operator_setTo
,
kernelName
,
globalThreads
,
openCLExecuteKernel
(
dst
.
clCxt
,
&
operator_setTo
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
compile_option
);
localThreads
,
args
,
-
1
,
-
1
,
compile_option
);
}
}
#else
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
step_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
offset_in_pixel
));
openCLExecuteKernel
(
dst
.
clCxt
,
&
operator_setTo
,
kernelName
,
globalThreads
,
localThreads
,
args
,
-
1
,
-
1
,
compile_option
);
#endif
}
}
static
void
set_to_withmask_run
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
const
oclMat
&
mask
,
string
kernelName
)
static
void
set_to_withmask_run
(
const
oclMat
&
dst
,
const
Scalar
&
scalar
,
const
oclMat
&
mask
,
string
kernelName
)
...
...
modules/ocl/src/mcwutil.cpp
View file @
741fb9b7
...
@@ -45,10 +45,6 @@
...
@@ -45,10 +45,6 @@
#include "precomp.hpp"
#include "precomp.hpp"
#ifndef CL_VERSION_1_2
#define CL_VERSION_1_2 0
#endif
using
namespace
std
;
using
namespace
std
;
namespace
cv
namespace
cv
...
@@ -124,7 +120,7 @@ namespace cv
...
@@ -124,7 +120,7 @@ namespace cv
build_options
,
finish_mode
);
build_options
,
finish_mode
);
}
}
cl_mem
bindTexture
(
const
oclMat
&
mat
)
cl_mem
bindTexture
(
const
oclMat
&
mat
)
{
{
cl_mem
texture
;
cl_mem
texture
;
cl_image_format
format
;
cl_image_format
format
;
...
@@ -162,30 +158,44 @@ namespace cv
...
@@ -162,30 +158,44 @@ namespace cv
CV_Error
(
-
1
,
"Image forma is not supported"
);
CV_Error
(
-
1
,
"Image forma is not supported"
);
break
;
break
;
}
}
#if CL_VERSION_1_2
#ifdef CL_VERSION_1_2
cl_image_desc
desc
;
//this enables backwards portability to
desc
.
image_type
=
CL_MEM_OBJECT_IMAGE2D
;
//run on OpenCL 1.1 platform if library binaries are compiled with OpenCL 1.2 support
desc
.
image_width
=
mat
.
cols
;
if
(
Context
::
getContext
()
->
supportsFeature
(
Context
::
CL_VER_1_2
))
desc
.
image_height
=
mat
.
rows
;
{
desc
.
image_depth
=
0
;
cl_image_desc
desc
;
desc
.
image_array_size
=
1
;
desc
.
image_type
=
CL_MEM_OBJECT_IMAGE2D
;
desc
.
image_row_pitch
=
0
;
desc
.
image_width
=
mat
.
cols
;
desc
.
image_slice_pitch
=
0
;
desc
.
image_height
=
mat
.
rows
;
desc
.
buffer
=
NULL
;
desc
.
image_depth
=
0
;
desc
.
num_mip_levels
=
0
;
desc
.
image_array_size
=
1
;
desc
.
num_samples
=
0
;
desc
.
image_row_pitch
=
0
;
texture
=
clCreateImage
((
cl_context
)
mat
.
clCxt
->
oclContext
(),
CL_MEM_READ_WRITE
,
&
format
,
&
desc
,
NULL
,
&
err
);
desc
.
image_slice_pitch
=
0
;
#else
desc
.
buffer
=
NULL
;
texture
=
clCreateImage2D
(
desc
.
num_mip_levels
=
0
;
(
cl_context
)
mat
.
clCxt
->
oclContext
(),
desc
.
num_samples
=
0
;
CL_MEM_READ_WRITE
,
texture
=
clCreateImage
((
cl_context
)
mat
.
clCxt
->
oclContext
(),
CL_MEM_READ_WRITE
,
&
format
,
&
desc
,
NULL
,
&
err
);
&
format
,
}
mat
.
cols
,
else
mat
.
rows
,
0
,
NULL
,
&
err
);
#endif
#endif
{
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
texture
=
clCreateImage2D
(
(
cl_context
)
mat
.
clCxt
->
oclContext
(),
CL_MEM_READ_WRITE
,
&
format
,
mat
.
cols
,
mat
.
rows
,
0
,
NULL
,
&
err
);
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
}
size_t
origin
[]
=
{
0
,
0
,
0
};
size_t
origin
[]
=
{
0
,
0
,
0
};
size_t
region
[]
=
{
mat
.
cols
,
mat
.
rows
,
1
};
size_t
region
[]
=
{
mat
.
cols
,
mat
.
rows
,
1
};
...
@@ -198,7 +208,7 @@ namespace cv
...
@@ -198,7 +208,7 @@ namespace cv
clEnqueueCopyBufferRect
((
cl_command_queue
)
mat
.
clCxt
->
oclCommandQueue
(),
(
cl_mem
)
mat
.
data
,
devData
,
origin
,
origin
,
clEnqueueCopyBufferRect
((
cl_command_queue
)
mat
.
clCxt
->
oclCommandQueue
(),
(
cl_mem
)
mat
.
data
,
devData
,
origin
,
origin
,
regin
,
mat
.
step
,
0
,
mat
.
cols
*
mat
.
elemSize
(),
0
,
0
,
NULL
,
NULL
);
regin
,
mat
.
step
,
0
,
mat
.
cols
*
mat
.
elemSize
(),
0
,
0
,
NULL
,
NULL
);
clFlush
((
cl_command_queue
)
mat
.
clCxt
->
oclCommandQueue
());
clFlush
((
cl_command_queue
)
mat
.
clCxt
->
oclCommandQueue
());
}
}
else
else
{
{
devData
=
(
cl_mem
)
mat
.
data
;
devData
=
(
cl_mem
)
mat
.
data
;
...
@@ -214,7 +224,6 @@ namespace cv
...
@@ -214,7 +224,6 @@ namespace cv
openCLSafeCall
(
err
);
openCLSafeCall
(
err
);
return
texture
;
return
texture
;
}
}
void
releaseTexture
(
cl_mem
&
texture
)
void
releaseTexture
(
cl_mem
&
texture
)
{
{
openCLFree
(
texture
);
openCLFree
(
texture
);
...
...
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