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
5e92a777
Commit
5e92a777
authored
Jan 19, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3569 from ilya-lavrenov:sse_mul
parents
17b1152f
68962adc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
159 additions
and
0 deletions
+159
-0
arithm.cpp
modules/core/src/arithm.cpp
+159
-0
No files found.
modules/core/src/arithm.cpp
View file @
5e92a777
...
...
@@ -2355,6 +2355,165 @@ struct Mul_SIMD<float, float>
}
};
#elif CV_SSE2
#if CV_SSE4_1
template
<>
struct
Mul_SIMD
<
ushort
,
float
>
{
Mul_SIMD
()
{
haveSSE
=
checkHardwareSupport
(
CV_CPU_SSE4_1
);
}
int
operator
()
(
const
ushort
*
src1
,
const
ushort
*
src2
,
ushort
*
dst
,
int
width
,
float
scale
)
const
{
int
x
=
0
;
if
(
!
haveSSE
)
return
x
;
__m128i
v_zero
=
_mm_setzero_si128
();
if
(
scale
!=
1.0
f
)
{
__m128
v_scale
=
_mm_set1_ps
(
scale
);
for
(
;
x
<=
width
-
8
;
x
+=
8
)
{
__m128i
v_src1
=
_mm_loadu_si128
((
__m128i
const
*
)(
src1
+
x
));
__m128i
v_src2
=
_mm_loadu_si128
((
__m128i
const
*
)(
src2
+
x
));
__m128
v_dst1
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_unpacklo_epi16
(
v_src1
,
v_zero
)),
_mm_cvtepi32_ps
(
_mm_unpacklo_epi16
(
v_src2
,
v_zero
)));
v_dst1
=
_mm_mul_ps
(
v_dst1
,
v_scale
);
__m128
v_dst2
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_unpackhi_epi16
(
v_src1
,
v_zero
)),
_mm_cvtepi32_ps
(
_mm_unpackhi_epi16
(
v_src2
,
v_zero
)));
v_dst2
=
_mm_mul_ps
(
v_dst2
,
v_scale
);
__m128i
v_dsti
=
_mm_packus_epi32
(
_mm_cvtps_epi32
(
v_dst1
),
_mm_cvtps_epi32
(
v_dst2
));
_mm_storeu_si128
((
__m128i
*
)(
dst
+
x
),
v_dsti
);
}
}
return
x
;
}
bool
haveSSE
;
};
#endif
template
<>
struct
Mul_SIMD
<
schar
,
float
>
{
Mul_SIMD
()
{
haveSSE
=
checkHardwareSupport
(
CV_CPU_SSE2
);
}
int
operator
()
(
const
schar
*
src1
,
const
schar
*
src2
,
schar
*
dst
,
int
width
,
float
scale
)
const
{
int
x
=
0
;
if
(
!
haveSSE
)
return
x
;
__m128i
v_zero
=
_mm_setzero_si128
();
if
(
scale
==
1.0
f
)
for
(
;
x
<=
width
-
8
;
x
+=
8
)
{
__m128i
v_src1
=
_mm_loadl_epi64
((
__m128i
const
*
)(
src1
+
x
));
__m128i
v_src2
=
_mm_loadl_epi64
((
__m128i
const
*
)(
src2
+
x
));
v_src1
=
_mm_srai_epi16
(
_mm_unpacklo_epi8
(
v_zero
,
v_src1
),
8
);
v_src2
=
_mm_srai_epi16
(
_mm_unpacklo_epi8
(
v_zero
,
v_src2
),
8
);
__m128
v_dst1
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpacklo_epi16
(
v_zero
,
v_src1
),
16
)),
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpacklo_epi16
(
v_zero
,
v_src2
),
16
)));
__m128
v_dst2
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpackhi_epi16
(
v_zero
,
v_src1
),
16
)),
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpackhi_epi16
(
v_zero
,
v_src2
),
16
)));
__m128i
v_dsti
=
_mm_packs_epi32
(
_mm_cvtps_epi32
(
v_dst1
),
_mm_cvtps_epi32
(
v_dst2
));
_mm_storel_epi64
((
__m128i
*
)(
dst
+
x
),
_mm_packs_epi16
(
v_dsti
,
v_zero
));
}
else
{
__m128
v_scale
=
_mm_set1_ps
(
scale
);
for
(
;
x
<=
width
-
8
;
x
+=
8
)
{
__m128i
v_src1
=
_mm_loadl_epi64
((
__m128i
const
*
)(
src1
+
x
));
__m128i
v_src2
=
_mm_loadl_epi64
((
__m128i
const
*
)(
src2
+
x
));
v_src1
=
_mm_srai_epi16
(
_mm_unpacklo_epi8
(
v_zero
,
v_src1
),
8
);
v_src2
=
_mm_srai_epi16
(
_mm_unpacklo_epi8
(
v_zero
,
v_src2
),
8
);
__m128
v_dst1
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpacklo_epi16
(
v_zero
,
v_src1
),
16
)),
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpacklo_epi16
(
v_zero
,
v_src2
),
16
)));
v_dst1
=
_mm_mul_ps
(
v_dst1
,
v_scale
);
__m128
v_dst2
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpackhi_epi16
(
v_zero
,
v_src1
),
16
)),
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpackhi_epi16
(
v_zero
,
v_src2
),
16
)));
v_dst2
=
_mm_mul_ps
(
v_dst2
,
v_scale
);
__m128i
v_dsti
=
_mm_packs_epi32
(
_mm_cvtps_epi32
(
v_dst1
),
_mm_cvtps_epi32
(
v_dst2
));
_mm_storel_epi64
((
__m128i
*
)(
dst
+
x
),
_mm_packs_epi16
(
v_dsti
,
v_zero
));
}
}
return
x
;
}
bool
haveSSE
;
};
template
<>
struct
Mul_SIMD
<
short
,
float
>
{
Mul_SIMD
()
{
haveSSE
=
checkHardwareSupport
(
CV_CPU_SSE2
);
}
int
operator
()
(
const
short
*
src1
,
const
short
*
src2
,
short
*
dst
,
int
width
,
float
scale
)
const
{
int
x
=
0
;
if
(
!
haveSSE
)
return
x
;
__m128i
v_zero
=
_mm_setzero_si128
();
if
(
scale
!=
1.0
f
)
{
__m128
v_scale
=
_mm_set1_ps
(
scale
);
for
(
;
x
<=
width
-
8
;
x
+=
8
)
{
__m128i
v_src1
=
_mm_loadu_si128
((
__m128i
const
*
)(
src1
+
x
));
__m128i
v_src2
=
_mm_loadu_si128
((
__m128i
const
*
)(
src2
+
x
));
__m128
v_dst1
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpacklo_epi16
(
v_zero
,
v_src1
),
16
)),
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpacklo_epi16
(
v_zero
,
v_src2
),
16
)));
v_dst1
=
_mm_mul_ps
(
v_dst1
,
v_scale
);
__m128
v_dst2
=
_mm_mul_ps
(
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpackhi_epi16
(
v_zero
,
v_src1
),
16
)),
_mm_cvtepi32_ps
(
_mm_srai_epi32
(
_mm_unpackhi_epi16
(
v_zero
,
v_src2
),
16
)));
v_dst2
=
_mm_mul_ps
(
v_dst2
,
v_scale
);
__m128i
v_dsti
=
_mm_packs_epi32
(
_mm_cvtps_epi32
(
v_dst1
),
_mm_cvtps_epi32
(
v_dst2
));
_mm_storeu_si128
((
__m128i
*
)(
dst
+
x
),
v_dsti
);
}
}
return
x
;
}
bool
haveSSE
;
};
#endif
template
<
typename
T
,
typename
WT
>
static
void
...
...
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