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
composable_kernel
Commits
58d1924b
Commit
58d1924b
authored
Jun 02, 2023
by
Po-Yen, Chen
Browse files
Extract common logic out as helper method
parent
65a317de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
include/ck/utility/amd_wave_read_first_lane.hpp
include/ck/utility/amd_wave_read_first_lane.hpp
+20
-14
No files found.
include/ck/utility/amd_wave_read_first_lane.hpp
View file @
58d1924b
...
@@ -40,24 +40,34 @@ struct get_carrier<3>
...
@@ -40,24 +40,34 @@ struct get_carrier<3>
std
::
array
<
std
::
byte
,
3
>
bytes
;
std
::
array
<
std
::
byte
,
3
>
bytes
;
static_assert
(
sizeof
(
bytes
)
<=
sizeof
(
value_type
));
static_assert
(
sizeof
(
bytes
)
<=
sizeof
(
value_type
));
public:
// replacement of host std::copy_n()
__device__
carrier
(
value_type
value
)
noexcept
template
<
typename
InputIterator
,
typename
Size
,
typename
OutputIterator
>
__device__
static
OutputIterator
copy_n
(
InputIterator
from
,
Size
size
,
OutputIterator
to
)
{
{
auto
from
=
reinterpret_cast
<
const
std
::
byte
*>
(
&
value
);
if
(
0
<
size
)
for
(
auto
to
=
bytes
.
begin
();
to
!=
bytes
.
end
();
++
to
,
++
from
)
{
{
*
to
=
*
from
;
*
to
=
*
from
;
++
to
;
for
(
Size
count
=
1
;
count
<
size
;
++
count
)
{
*
to
=
*++
from
;
++
to
;
}
}
}
return
to
;
}
public:
__device__
carrier
(
value_type
value
)
noexcept
{
copy_n
(
reinterpret_cast
<
const
std
::
byte
*>
(
&
value
),
bytes
.
size
(),
bytes
.
begin
());
}
}
// method to trigger template substitution failure
// method to trigger template substitution failure
__device__
carrier
&
operator
=
(
const
carrier
&
other
)
noexcept
__device__
carrier
&
operator
=
(
const
carrier
&
other
)
noexcept
{
{
auto
from
=
other
.
bytes
.
begin
();
copy_n
(
other
.
bytes
.
begin
(),
bytes
.
size
(),
bytes
.
begin
());
for
(
auto
to
=
bytes
.
begin
();
to
!=
bytes
.
end
();
++
to
,
++
from
)
{
*
to
=
*
from
;
}
return
*
this
;
return
*
this
;
}
}
...
@@ -66,11 +76,7 @@ struct get_carrier<3>
...
@@ -66,11 +76,7 @@ struct get_carrier<3>
{
{
std
::
byte
result
[
sizeof
(
value_type
)];
std
::
byte
result
[
sizeof
(
value_type
)];
auto
to
=
result
;
copy_n
(
bytes
.
begin
(),
bytes
.
size
(),
result
);
for
(
auto
from
=
bytes
.
begin
();
from
!=
bytes
.
end
();
++
to
,
++
from
)
{
*
to
=
*
from
;
}
return
*
reinterpret_cast
<
const
value_type
*>
(
result
);
return
*
reinterpret_cast
<
const
value_type
*>
(
result
);
}
}
...
...
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