6 #include <hip/hip_runtime.h>
13 template <
typename... Args,
typename F>
26 printf(
"%s: grid_dim {%u, %u, %u}, block_dim {%u, %u, %u} \n",
35 printf(
"Warm up %d times\n", stream_config.
cold_niters_);
40 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
44 const int nrepeat = stream_config.
nrepeat_;
47 printf(
"Start running %d times...\n", nrepeat);
49 hipEvent_t start, stop;
57 for(
int i = 0; i < nrepeat; ++i)
59 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
73 return total_time / nrepeat;
77 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
83 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
90 template <
typename... Args,
typename F,
typename PreProcessFunc>
92 PreProcessFunc preprocess,
104 printf(
"%s: grid_dim {%u, %u, %u}, block_dim {%u, %u, %u} \n",
113 printf(
"Warm up %d times\n", stream_config.
cold_niters_);
119 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
123 const int nrepeat = stream_config.
nrepeat_;
126 printf(
"Start running %d times...\n", nrepeat);
128 hipEvent_t start, stop;
136 for(
int i = 0; i < nrepeat; ++i)
139 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
146 float total_time = 0;
153 return total_time / nrepeat;
158 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
164 kernel<<<grid_dim, block_dim, lds_byte, stream_config.
stream_id_>>>(args...);
void hip_check_error(hipError_t x)
Definition: hip_check_error.hpp:10
float launch_and_time_kernel(const StreamConfig &stream_config, F kernel, dim3 grid_dim, dim3 block_dim, std::size_t lds_byte, Args... args)
Definition: kernel_launch.hpp:14
float launch_and_time_kernel_with_preprocess(const StreamConfig &stream_config, PreProcessFunc preprocess, F kernel, dim3 grid_dim, dim3 block_dim, std::size_t lds_byte, Args... args)
Definition: kernel_launch.hpp:91
bool EnvIsEnabled(EnvVar)
Definition: env.hpp:140
Definition: stream_config.hpp:10
int cold_niters_
Definition: stream_config.hpp:14
bool time_kernel_
Definition: stream_config.hpp:12
int nrepeat_
Definition: stream_config.hpp:15
hipStream_t stream_id_
Definition: stream_config.hpp:11
#define CK_ENV(name)
Definition: env.hpp:129