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
19b30647
Commit
19b30647
authored
Nov 14, 2013
by
Roman Donchenko
Committed by
OpenCV Buildbot
Nov 14, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1790 from ilya-lavrenov:ocl_ref
parents
15f4292a
6770c040
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
127 deletions
+99
-127
arithm.cpp
modules/ocl/src/arithm.cpp
+0
-0
arithm_cartToPolar.cl
modules/ocl/src/opencl/arithm_cartToPolar.cl
+24
-20
arithm_magnitude.cl
modules/ocl/src/opencl/arithm_magnitude.cl
+11
-37
arithm_polarToCart.cl
modules/ocl/src/opencl/arithm_polarToCart.cl
+55
-37
arithm_pow.cl
modules/ocl/src/opencl/arithm_pow.cl
+9
-33
No files found.
modules/ocl/src/arithm.cpp
View file @
19b30647
This diff is collapsed.
Click to expand it.
modules/ocl/src/opencl/arithm_cartToPolar.cl
View file @
19b30647
...
@@ -58,21 +58,21 @@ __kernel void arithm_cartToPolar_D5 (__global float *src1, int src1_step, int sr
...
@@ -58,21 +58,21 @@ __kernel void arithm_cartToPolar_D5 (__global float *src1, int src1_step, int sr
__global
float
*src2,
int
src2_step,
int
src2_offset,
__global
float
*src2,
int
src2_step,
int
src2_offset,
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
//
magnitude
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
//
magnitude
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
//
cartToPolar
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
//
cartToPolar
int
rows,
int
cols
,
int
angInDegree
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
2
)
+
src1_offset
)
;
int
src1_index
=
mad24
(
y,
src1_step,
x
+
src1_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
(
x
<<
2
)
+
src2_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
x
+
src2_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
(
x
<<
2
)
+
dst1_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
x
+
dst1_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
(
x
<<
2
)
+
dst2_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
x
+
dst2_offset
)
;
float
x
=
*
((
__global
float
*
)((
__global
char
*
)
src1
+
src1_index
))
;
float
x
=
src1[src1_index]
;
float
y
=
*
((
__global
float
*
)((
__global
char
*
)
src2
+
src2_index
))
;
float
y
=
src2[src2_index]
;
float
x2
=
x
*
x
;
float
x2
=
x
*
x
;
float
y2
=
y
*
y
;
float
y2
=
y
*
y
;
...
@@ -86,10 +86,12 @@ __kernel void arithm_cartToPolar_D5 (__global float *src1, int src1_step, int sr
...
@@ -86,10 +86,12 @@ __kernel void arithm_cartToPolar_D5 (__global float *src1, int src1_step, int sr
float
cartToPolar
=
y2
<=
x2
?
x*y/
(
x2
+
0.28f*y2
+
FLT_EPSILON
)
+
tmp
:
float
cartToPolar
=
y2
<=
x2
?
x*y/
(
x2
+
0.28f*y2
+
FLT_EPSILON
)
+
tmp
:
tmp1
-
x*y/
(
y2
+
0.28f*x2
+
FLT_EPSILON
)
;
tmp1
-
x*y/
(
y2
+
0.28f*x2
+
FLT_EPSILON
)
;
cartToPolar
=
angInDegree
==
0
?
cartToPolar
:
cartToPolar
*
(
180/CV_PI
)
;
#
ifdef
DEGREE
cartToPolar
*=
(
180/CV_PI
)
;
#
endif
*
((
__global
float
*
)((
__global
char
*
)
dst1
+
dst1_index
))
=
magnitude
;
dst1[dst1_index]
=
magnitude
;
*
((
__global
float
*
)((
__global
char
*
)
dst2
+
dst2_index
))
=
cartToPolar
;
dst2[dst2_index]
=
cartToPolar
;
}
}
}
}
...
@@ -99,21 +101,21 @@ __kernel void arithm_cartToPolar_D6 (__global double *src1, int src1_step, int s
...
@@ -99,21 +101,21 @@ __kernel void arithm_cartToPolar_D6 (__global double *src1, int src1_step, int s
__global
double
*src2,
int
src2_step,
int
src2_offset,
__global
double
*src2,
int
src2_step,
int
src2_offset,
__global
double
*dst1,
int
dst1_step,
int
dst1_offset,
__global
double
*dst1,
int
dst1_step,
int
dst1_offset,
__global
double
*dst2,
int
dst2_step,
int
dst2_offset,
__global
double
*dst2,
int
dst2_step,
int
dst2_offset,
int
rows,
int
cols
,
int
angInDegree
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
3
)
+
src1_offset
)
;
int
src1_index
=
mad24
(
y,
src1_step,
x
+
src1_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
(
x
<<
3
)
+
src2_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
x
+
src2_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
(
x
<<
3
)
+
dst1_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
x
+
dst1_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
(
x
<<
3
)
+
dst2_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
x
+
dst2_offset
)
;
double
x
=
*
((
__global
double
*
)((
__global
char
*
)
src1
+
src1_index
))
;
double
x
=
src1[src1_index]
;
double
y
=
*
((
__global
double
*
)((
__global
char
*
)
src2
+
src2_index
))
;
double
y
=
src2[src2_index]
;
double
x2
=
x
*
x
;
double
x2
=
x
*
x
;
double
y2
=
y
*
y
;
double
y2
=
y
*
y
;
...
@@ -127,10 +129,12 @@ __kernel void arithm_cartToPolar_D6 (__global double *src1, int src1_step, int s
...
@@ -127,10 +129,12 @@ __kernel void arithm_cartToPolar_D6 (__global double *src1, int src1_step, int s
double
cartToPolar
=
y2
<=
x2
?
x*y/
(
x2
+
0.28f*y2
+
DBL_EPSILON
)
+
tmp
:
double
cartToPolar
=
y2
<=
x2
?
x*y/
(
x2
+
0.28f*y2
+
DBL_EPSILON
)
+
tmp
:
tmp1
-
x*y/
(
y2
+
0.28f*x2
+
DBL_EPSILON
)
;
tmp1
-
x*y/
(
y2
+
0.28f*x2
+
DBL_EPSILON
)
;
cartToPolar
=
angInDegree
==
0
?
cartToPolar
:
cartToPolar
*
(
180/CV_PI
)
;
#
ifdef
DEGREE
cartToPolar
*=
(
180/CV_PI
)
;
#
endif
*
((
__global
double
*
)((
__global
char
*
)
dst1
+
dst1_index
))
=
magnitude
;
dst1[dst1_index]
=
magnitude
;
*
((
__global
double
*
)((
__global
char
*
)
dst2
+
dst2_index
))
=
cartToPolar
;
dst2[dst2_index]
=
cartToPolar
;
}
}
}
}
...
...
modules/ocl/src/opencl/arithm_magnitude.cl
View file @
19b30647
...
@@ -51,50 +51,24 @@
...
@@ -51,50 +51,24 @@
#
endif
#
endif
#
endif
#
endif
__kernel
void
arithm_magnitude
_D5
(
__global
float
*src1,
int
src1_step,
int
src1_offset,
__kernel
void
arithm_magnitude
(
__global
T
*src1,
int
src1_step,
int
src1_offset,
__global
float
*src2,
int
src2_step,
int
src2_offset,
__global
T
*src2,
int
src2_step,
int
src2_offset,
__global
float
*dst,
int
dst_step,
int
dst_offset,
__global
T
*dst,
int
dst_step,
int
dst_offset,
int
rows,
int
cols
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
2
)
+
src1_offset
)
;
int
src1_index
=
mad24
(
y,
src1_step,
x
+
src1_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
(
x
<<
2
)
+
src2_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
x
+
src2_offset
)
;
int
dst_index
=
mad24
(
y,
dst_step,
(
x
<<
2
)
+
dst_offset
)
;
int
dst_index
=
mad24
(
y,
dst_step,
x
+
dst_offset
)
;
float
data1
=
*
((
__global
float
*
)((
__global
char
*
)
src1
+
src1_index
))
;
T
data1
=
src1[src1_index]
;
float
data2
=
*
((
__global
float
*
)((
__global
char
*
)
src2
+
src2_index
))
;
T
data2
=
src2[src2_index]
;
float
tmp
=
sqrt
(
data1
*
data1
+
data2
*
data2
)
;
T
tmp
=
hypot
(
data1,
data2
)
;
dst[dst_index]
=
tmp
;
*
((
__global
float
*
)((
__global
char
*
)
dst
+
dst_index
))
=
tmp
;
}
}
#
if
defined
(
DOUBLE_SUPPORT
)
__kernel
void
arithm_magnitude_D6
(
__global
double
*src1,
int
src1_step,
int
src1_offset,
__global
double
*src2,
int
src2_step,
int
src2_offset,
__global
double
*dst,
int
dst_step,
int
dst_offset,
int
rows,
int
cols
)
{
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
3
)
+
src1_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
(
x
<<
3
)
+
src2_offset
)
;
int
dst_index
=
mad24
(
y,
dst_step,
(
x
<<
3
)
+
dst_offset
)
;
double
data1
=
*
((
__global
double
*
)((
__global
char
*
)
src1
+
src1_index
))
;
double
data2
=
*
((
__global
double
*
)((
__global
char
*
)
src2
+
src2_index
))
;
double
tmp
=
sqrt
(
data1
*
data1
+
data2
*
data2
)
;
*
((
__global
double
*
)((
__global
char
*
)
dst
+
dst_index
))
=
tmp
;
}
}
}
}
#
endif
modules/ocl/src/opencl/arithm_polarToCart.cl
View file @
19b30647
...
@@ -57,33 +57,38 @@
...
@@ -57,33 +57,38 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////polarToCart
with
magnitude//////////////////////////////
/////////////////////////////////////////polarToCart
with
magnitude//////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
__kernel
void
arithm_polarToCart_mag_D5
(
__global
float
*src1,
int
src1_step,
int
src1_offset,//magnitue
__kernel
void
arithm_polarToCart_mag_D5
(
__global
float
*src1,
int
src1_step,
int
src1_offset,//magnitue
__global
float
*src2,
int
src2_step,
int
src2_offset,//angle
__global
float
*src2,
int
src2_step,
int
src2_offset,//angle
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
int
rows,
int
cols
,
int
angInDegree
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
2
)
+
src1_offset
)
;
int
src1_index
=
mad24
(
y,
src1_step,
x
+
src1_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
(
x
<<
2
)
+
src2_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
x
+
src2_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
(
x
<<
2
)
+
dst1_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
x
+
dst1_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
(
x
<<
2
)
+
dst2_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
x
+
dst2_offset
)
;
float
x
=
*
((
__global
float
*
)((
__global
char
*
)
src1
+
src1_index
))
;
float
x
=
src1[src1_index]
;
float
y
=
*
((
__global
float
*
)((
__global
char
*
)
src2
+
src2_index
))
;
float
y
=
src2[src2_index]
;
#
ifdef
DEGREE
float
ascale
=
CV_PI/180.0f
;
float
ascale
=
CV_PI/180.0f
;
float
alpha
=
angInDegree
==
1
?
y
*
ascale
:
y
;
float
alpha
=
y
*
ascale
;
#
else
float
alpha
=
y
;
#
endif
float
a
=
cos
(
alpha
)
*
x
;
float
a
=
cos
(
alpha
)
*
x
;
float
b
=
sin
(
alpha
)
*
x
;
float
b
=
sin
(
alpha
)
*
x
;
*
((
__global
float
*
)((
__global
char
*
)
dst1
+
dst1_index
))
=
a
;
dst1[dst1_index]
=
a
;
*
((
__global
float
*
)((
__global
char
*
)
dst2
+
dst2_index
))
=
b
;
dst2[dst2_index]
=
b
;
}
}
}
}
...
@@ -92,29 +97,33 @@ __kernel void arithm_polarToCart_mag_D6 (__global double *src1, int src1_step, i
...
@@ -92,29 +97,33 @@ __kernel void arithm_polarToCart_mag_D6 (__global double *src1, int src1_step, i
__global
double
*src2,
int
src2_step,
int
src2_offset,//angle
__global
double
*src2,
int
src2_step,
int
src2_offset,//angle
__global
double
*dst1,
int
dst1_step,
int
dst1_offset,
__global
double
*dst1,
int
dst1_step,
int
dst1_offset,
__global
double
*dst2,
int
dst2_step,
int
dst2_offset,
__global
double
*dst2,
int
dst2_step,
int
dst2_offset,
int
rows,
int
cols
,
int
angInDegree
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
3
)
+
src1_offset
)
;
int
src1_index
=
mad24
(
y,
src1_step,
x
+
src1_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
(
x
<<
3
)
+
src2_offset
)
;
int
src2_index
=
mad24
(
y,
src2_step,
x
+
src2_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
(
x
<<
3
)
+
dst1_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
x
+
dst1_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
(
x
<<
3
)
+
dst2_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
x
+
dst2_offset
)
;
double
x
=
*
((
__global
double
*
)((
__global
char
*
)
src1
+
src1_index
))
;
double
x
=
src1[src1_index]
;
double
y
=
*
((
__global
double
*
)((
__global
char
*
)
src2
+
src2_index
))
;
double
y
=
src2[src2_index]
;
#
ifdef
DEGREE
float
ascale
=
CV_PI/180.0
;
float
ascale
=
CV_PI/180.0
;
double
alpha
=
angInDegree
==
1
?
y
*
ascale
:
y
;
float
alpha
=
y
*
ascale
;
#
else
float
alpha
=
y
;
#
endif
double
a
=
cos
(
alpha
)
*
x
;
double
a
=
cos
(
alpha
)
*
x
;
double
b
=
sin
(
alpha
)
*
x
;
double
b
=
sin
(
alpha
)
*
x
;
*
((
__global
double
*
)((
__global
char
*
)
dst1
+
dst1_index
))
=
a
;
dst1[dst1_index]
=
a
;
*
((
__global
double
*
)((
__global
char
*
)
dst2
+
dst2_index
))
=
b
;
dst2[dst2_index]
=
b
;
}
}
}
}
#
endif
#
endif
...
@@ -122,30 +131,35 @@ __kernel void arithm_polarToCart_mag_D6 (__global double *src1, int src1_step, i
...
@@ -122,30 +131,35 @@ __kernel void arithm_polarToCart_mag_D6 (__global double *src1, int src1_step, i
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////polarToCart
without
magnitude//////////////////////////////
/////////////////////////////////////////polarToCart
without
magnitude//////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
__kernel
void
arithm_polarToCart_D5
(
__global
float
*src,
int
src_step,
int
src_offset,//angle
__kernel
void
arithm_polarToCart_D5
(
__global
float
*src,
int
src_step,
int
src_offset,//angle
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
int
rows,
int
cols
,
int
angInDegree
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src_index
=
mad24
(
y,
src_step,
(
x
<<
2
)
+
src_offset
)
;
int
src_index
=
mad24
(
y,
src_step,
x
+
src_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
(
x
<<
2
)
+
dst1_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
x
+
dst1_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
(
x
<<
2
)
+
dst2_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
x
+
dst2_offset
)
;
float
y
=
*
((
__global
float
*
)((
__global
char
*
)
src
+
src_index
))
;
float
y
=
src[src_index]
;
#
ifdef
DEGREE
float
ascale
=
CV_PI/180.0f
;
float
ascale
=
CV_PI/180.0f
;
float
alpha
=
angInDegree
==
1
?
y
*
ascale
:
y
;
float
alpha
=
y
*
ascale
;
#
else
float
alpha
=
y
;
#
endif
float
a
=
cos
(
alpha
)
;
float
a
=
cos
(
alpha
)
;
float
b
=
sin
(
alpha
)
;
float
b
=
sin
(
alpha
)
;
*
((
__global
float
*
)((
__global
char
*
)
dst1
+
dst1_index
))
=
a
;
dst1[dst1_index]
=
a
;
*
((
__global
float
*
)((
__global
char
*
)
dst2
+
dst2_index
))
=
b
;
dst2[dst2_index]
=
b
;
}
}
}
}
...
@@ -153,27 +167,31 @@ __kernel void arithm_polarToCart_D5 (__global float *src, int src_step, int sr
...
@@ -153,27 +167,31 @@ __kernel void arithm_polarToCart_D5 (__global float *src, int src_step, int sr
__kernel
void
arithm_polarToCart_D6
(
__global
float
*src,
int
src_step,
int
src_offset,//angle
__kernel
void
arithm_polarToCart_D6
(
__global
float
*src,
int
src_step,
int
src_offset,//angle
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
__global
float
*dst1,
int
dst1_step,
int
dst1_offset,
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
__global
float
*dst2,
int
dst2_step,
int
dst2_offset,
int
rows,
int
cols
,
int
angInDegree
)
int
rows,
int
cols
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src_index
=
mad24
(
y,
src_step,
(
x
<<
3
)
+
src_offset
)
;
int
src_index
=
mad24
(
y,
src_step,
x
+
src_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
(
x
<<
3
)
+
dst1_offset
)
;
int
dst1_index
=
mad24
(
y,
dst1_step,
x
+
dst1_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
(
x
<<
3
)
+
dst2_offset
)
;
int
dst2_index
=
mad24
(
y,
dst2_step,
x
+
dst2_offset
)
;
double
y
=
*
((
__global
double
*
)((
__global
char
*
)
src
+
src_index
))
;
double
y
=
src[src_index]
;
float
ascale
=
CV_PI/180.0
;
#
ifdef
DEGREE
double
alpha
=
angInDegree
==
1
?
y
*
ascale
:
y
;
float
ascale
=
CV_PI/180.0f
;
float
alpha
=
y
*
ascale
;
#
else
float
alpha
=
y
;
#
endif
double
a
=
cos
(
alpha
)
;
double
a
=
cos
(
alpha
)
;
double
b
=
sin
(
alpha
)
;
double
b
=
sin
(
alpha
)
;
*
((
__global
double
*
)((
__global
char
*
)
dst1
+
dst1_index
))
=
a
;
dst1[dst1_index]
=
a
;
*
((
__global
double
*
)((
__global
char
*
)
dst2
+
dst2_index
))
=
b
;
dst2[dst2_index]
=
b
;
}
}
}
}
#
endif
#
endif
modules/ocl/src/opencl/arithm_pow.cl
View file @
19b30647
...
@@ -56,45 +56,21 @@
...
@@ -56,45 +56,21 @@
/**************************************
pow
**************************************
/
/**************************************
pow
**************************************
/
__kernel
void
arithm_pow
_D5
(
__global
float
*src1,
int
src1_step,
int
src1
_offset,
__kernel
void
arithm_pow
(
__global
T
*
src,
int
src_step,
int
src
_offset,
__global
float
*dst,
int
dst_step,
int
dst_offset,
__global
T
*
dst,
int
dst_step,
int
dst_offset,
int
rows,
int
cols,
int
dst_step1
,
F
p
)
int
rows,
int
cols
,
F
p
)
{
{
int
x
=
get_global_id
(
0
)
;
int
x
=
get_global_id
(
0
)
;
int
y
=
get_global_id
(
1
)
;
int
y
=
get_global_id
(
1
)
;
if
(
x
<
cols
&&
y
<
rows
)
if
(
x
<
cols
&&
y
<
rows
)
{
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
2
)
+
src1_offset
)
;
int
src_index
=
mad24
(
y,
src_step,
x
+
src_offset
)
;
int
dst_index
=
mad24
(
y,
dst_step,
(
x
<<
2
)
+
dst_offset
)
;
int
dst_index
=
mad24
(
y,
dst_step,
x
+
dst_offset
)
;
float
src1_data
=
*
((
__global
float
*
)((
__global
char
*
)
src1
+
src1_index
))
;
float
tmp
=
src1_data
>
0
?
exp
(
p
*
log
(
src1_data
))
:
(
src1_data
==
0
?
0
:
exp
(
p
*
log
(
fabs
(
src1_data
))))
;
*
((
__global
float
*
)((
__global
char
*
)
dst
+
dst_index
))
=
tmp
;
}
}
#
if
defined
(
DOUBLE_SUPPORT
)
__kernel
void
arithm_pow_D6
(
__global
double
*src1,
int
src1_step,
int
src1_offset,
__global
double
*dst,
int
dst_step,
int
dst_offset,
int
rows,
int
cols,
int
dst_step1,
F
p
)
{
int
x
=
get_global_id
(
0
)
;
T
src_data
=
src[src_index]
;
int
y
=
get_global_id
(
1
)
;
T
tmp
=
src_data
>
0
?
exp
(
p
*
log
(
src_data
))
:
(
src_data
==
0
?
0
:
exp
(
p
*
log
(
fabs
(
src_data
)))
)
;
if
(
x
<
cols
&&
y
<
rows
)
dst[dst_index]
=
tmp
;
{
int
src1_index
=
mad24
(
y,
src1_step,
(
x
<<
3
)
+
src1_offset
)
;
int
dst_index
=
mad24
(
y,
dst_step,
(
x
<<
3
)
+
dst_offset
)
;
double
src1_data
=
*
((
__global
double
*
)((
__global
char
*
)
src1
+
src1_index
))
;
double
tmp
=
src1_data
>
0
?
exp
(
p
*
log
(
src1_data
))
:
(
src1_data
==
0
?
0
:
exp
(
p
*
log
(
fabs
(
src1_data
))))
;
*
((
__global
double
*
)((
__global
char
*
)
dst
+
dst_index
))
=
tmp
;
}
}
}
}
#
endif
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