MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / benchmark_impl

Function benchmark_impl

dnn/test/x86/conv_bias.cpp:2216–2279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2214#if MEGDNN_WITH_BENCHMARK
2215namespace {
2216void benchmark_impl(
2217 const param::ConvBias param,
2218 std::vector<std::pair<SmallVector<TensorShape>, float>>& shapes_and_computation,
2219 const std::string algo_name, size_t RUNS,
2220 TaskExecutorConfig&& multi_thread_config,
2221 TaskExecutorConfig&& single_thread_config, std::vector<DType> dtype_v) {
2222 std::vector<DType> data_type = {
2223 dtype::Float32(), dtype::Float32(), dtype::Float32(), dtype::Float32()};
2224
2225 std::vector<float> multi_thread_times, single_thread_times;
2226 {
2227 auto multi_thread_hanle = create_cpu_handle(0, true, &multi_thread_config);
2228 auto benchmarker = Benchmarker<ConvBias>(multi_thread_hanle.get());
2229 benchmarker.set_times(RUNS)
2230 .set_display(false)
2231 .set_dtype(0, dtype_v[0])
2232 .set_dtype(1, dtype_v[1])
2233 .set_dtype(2, dtype_v[2])
2234 .set_dtype(4, dtype_v[3])
2235 .set_param(param)
2236 .set_before_exec_callback(
2237 conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name.c_str()));
2238 for (auto shape : shapes_and_computation) {
2239 multi_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
2240 }
2241 }
2242 {
2243 auto single_thread_handle = create_cpu_handle(0, true, &single_thread_config);
2244 auto benchmarker = Benchmarker<ConvBias>(single_thread_handle.get());
2245 benchmarker.set_times(RUNS)
2246 .set_display(false)
2247 .set_dtype(0, dtype_v[0])
2248 .set_dtype(1, dtype_v[1])
2249 .set_dtype(2, dtype_v[2])
2250 .set_dtype(4, dtype_v[3])
2251 .set_param(param)
2252 .set_before_exec_callback(
2253 conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name.c_str()));
2254 for (auto shape : shapes_and_computation) {
2255 single_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
2256 }
2257 }
2258 printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread);
2259 printf("core_ids:");
2260 for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) {
2261 printf("%zu ", multi_thread_config.affinity_core_set[i]);
2262 }
2263 printf(", Single thread core_id %zu\n", single_thread_config.affinity_core_set[0]);
2264 for (size_t i = 0; i < shapes_and_computation.size(); i++) {
2265 auto shapes = shapes_and_computation[i];
2266 printf("Bench case: ");
2267 for (auto&& shape : shapes.first) {
2268 printf("%s ", shape.to_string().c_str());
2269 }
2270 float computations = shapes.second;
2271 printf("%zu threads gflops: %f,\n single thread gflops: "
2272 "%f. spead up = %f, speedup/cores=%f\n",
2273 multi_thread_config.nr_thread, computations / multi_thread_times[i],

Callers 2

TEST_FFunction · 0.70

Calls 6

set_dtypeMethod · 0.80
getMethod · 0.45
push_backMethod · 0.45
execMethod · 0.45
sizeMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected