Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
8b5b6758
Commit
8b5b6758
authored
Aug 19, 2022
by
Paul
Browse files
Use vector types where possible
parent
73da1e4a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
2 deletions
+39
-2
src/targets/gpu/kernels/include/migraphx/kernels/array.hpp
src/targets/gpu/kernels/include/migraphx/kernels/array.hpp
+39
-2
No files found.
src/targets/gpu/kernels/include/migraphx/kernels/array.hpp
View file @
8b5b6758
...
@@ -68,12 +68,49 @@ namespace migraphx {
...
@@ -68,12 +68,49 @@ namespace migraphx {
return z; \
return z; \
}
}
template
<
class
T
>
constexpr
auto
is_vectorizable
()
{
return
not
is_same
<
T
,
bool
>
{}
and
(
is_fundamental
<
T
>
{}
or
is_same
<
T
,
half
>
{});
}
template
<
class
T
>
constexpr
auto
array2vec
(
T
x
)
{
using
value_type
=
typename
T
::
value_type
;
constexpr
auto
size
=
decltype
(
x
.
size
()){};
using
type
=
vec
<
value_type
,
size
>
;
static_assert
(
size
!=
3
,
"Wrong size"
);
return
__builtin_bit_cast
(
type
,
x
);
}
template
<
class
T
,
class
U
,
index_int
N
>
constexpr
void
vec2array
(
T
&
x
,
vec
<
U
,
N
>
v
)
{
if
constexpr
(
not
is_const
<
T
>
{})
x
=
__builtin_bit_cast
(
T
,
v
);
}
template
<
class
T
,
class
...
Ts
>
template
<
class
T
,
class
...
Ts
>
constexpr
auto
array_for_each
(
T
&
x
,
Ts
&
...
xs
)
constexpr
auto
array_for_each
(
T
&
x
,
Ts
&
...
xs
)
{
{
MIGRAPHX_ASSERT
((
x
.
size
()
==
xs
.
size
()
and
...));
return
[
&
](
auto
f
)
{
return
[
&
](
auto
f
)
{
for
(
index_int
i
=
0
;
i
<
x
.
size
();
i
++
)
constexpr
auto
size
=
decltype
(
x
.
size
()){};
if
constexpr
((
is_vectorizable
<
typename
T
::
value_type
>
()
or
(
is_vectorizable
<
typename
Ts
::
value_type
>
()
or
...))
and
size
<=
8
and
size
>
1
and
(
size
%
2
==
0
))
{
[
&
](
auto
v
,
auto
...
vs
)
{
f
(
v
,
vs
...);
vec2array
(
x
,
v
);
swallow
{(
vec2array
(
xs
,
vs
),
0
)...};
}(
array2vec
(
x
),
array2vec
(
xs
)...);
}
else
{
for
(
index_int
i
=
0
;
i
<
size
;
i
++
)
f
(
x
[
i
],
xs
[
i
]...);
f
(
x
[
i
],
xs
[
i
]...);
}
};
};
}
}
...
...
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