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
cefd8a72
Commit
cefd8a72
authored
Jul 26, 2023
by
rocking
Browse files
Time multi-stream
parent
74284dd2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
include/ck/host_utility/kernel_launch.hpp
include/ck/host_utility/kernel_launch.hpp
+64
-0
No files found.
include/ck/host_utility/kernel_launch.hpp
View file @
cefd8a72
...
...
@@ -73,3 +73,67 @@ float launch_and_time_kernel(const StreamConfig& stream_config,
return
0
;
#endif
}
template
<
typename
...
Args
,
typename
F
>
float
launch_and_time_kernel_multi_stream
(
const
StreamConfig
&
stream_config
,
F
kernel
,
dim3
grid_dim
,
dim3
block_dim
,
std
::
size_t
lds_byte
,
Args
...
args
)
{
#if CK_TIME_KERNEL
if
(
stream_config
.
time_kernel_
)
{
const
int
nrepeat
=
10
;
std
::
vector
<
hipEvent_t
>
starts
,
stops
;
std
::
vector
<
hipStream_t
>
stream_ids
;
starts
.
resize
(
nrepeat
);
stops
.
resize
(
nrepeat
);
stream_ids
.
resize
(
nrepeat
);
for
(
int
i
=
0
;
i
<
nrepeat
;
++
i
)
{
hip_check_error
(
hipStreamCreate
(
&
stream_ids
[
i
]));
hip_check_error
(
hipEventCreate
(
&
starts
[
i
]));
hip_check_error
(
hipEventCreate
(
&
stops
[
i
]));
// warm up
kernel
<<<
grid_dim
,
block_dim
,
lds_byte
,
stream_ids
[
i
]
>>>
(
args
...);
}
hip_check_error
(
hipDeviceSynchronize
());
float
total_time
=
0
;
for
(
int
i
=
0
;
i
<
nrepeat
;
++
i
)
{
hip_check_error
(
hipEventRecord
(
starts
[
i
],
stream_config
.
stream_id_
));
kernel
<<<
grid_dim
,
block_dim
,
lds_byte
,
stream_ids
[
i
]
>>>
(
args
...);
hip_check_error
(
hipEventRecord
(
stops
[
i
],
stream_ids
[
i
]));
hip_check_error
(
hipEventSynchronize
(
stops
[
i
]));
}
for
(
int
i
=
0
;
i
<
nrepeat
;
++
i
)
{
float
tmp
=
0
;
hip_check_error
(
hipEventElapsedTime
(
&
tmp
,
starts
[
i
],
stops
[
i
]));
total_time
+=
tmp
;
}
return
total_time
/
nrepeat
;
}
else
{
kernel
<<<
grid_dim
,
block_dim
,
lds_byte
,
stream_config
.
stream_id_
>>>
(
args
...);
return
0
;
}
#else
kernel
<<<
grid_dim
,
block_dim
,
lds_byte
,
stream_config
.
stream_id_
>>>
(
args
...);
return
0
;
#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