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

Function benchmark_impl_comp

dnn/test/x86/conv_bias.cpp:2281–2341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2279}
2280
2281void benchmark_impl_comp(
2282 const param::ConvBias param,
2283 std::vector<std::pair<SmallVector<TensorShape>, float>>& shapes_and_computation,
2284 const std::string algo_name, const std::string algo_name1, size_t RUNS,
2285 TaskExecutorConfig&& multi_thread_config,
2286 TaskExecutorConfig&& single_thread_config, std::vector<DType> dtype_v) {
2287 std::vector<DType> data_type = {
2288 dtype::Float32(), dtype::Float32(), dtype::Float32(), dtype::Float32()};
2289
2290 std::vector<float> multi_thread_times, single_thread_times;
2291 {
2292 auto multi_thread_hanle = create_cpu_handle(0, true, &multi_thread_config);
2293 auto benchmarker = Benchmarker<ConvBias>(multi_thread_hanle.get());
2294 benchmarker.set_times(RUNS)
2295 .set_display(false)
2296 .set_dtype(0, dtype_v[0])
2297 .set_dtype(1, dtype_v[1])
2298 .set_dtype(2, dtype_v[2])
2299 .set_dtype(4, dtype_v[3])
2300 .set_param(param)
2301 .set_before_exec_callback(
2302 conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name.c_str()));
2303 for (auto shape : shapes_and_computation) {
2304 multi_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
2305 }
2306 }
2307 {
2308 auto single_thread_handle = create_cpu_handle(0, true, &single_thread_config);
2309 auto benchmarker = Benchmarker<ConvBias>(single_thread_handle.get());
2310 benchmarker.set_times(RUNS)
2311 .set_display(false)
2312 .set_dtype(0, dtype_v[0])
2313 .set_dtype(1, dtype_v[1])
2314 .set_dtype(2, dtype_v[2])
2315 .set_dtype(4, dtype_v[3])
2316 .set_param(param)
2317 .set_before_exec_callback(
2318 conv_bias::ConvBiasAlgoChecker<ConvBias>(algo_name1.c_str()));
2319 for (auto shape : shapes_and_computation) {
2320 single_thread_times.push_back(benchmarker.exec(shape.first) / RUNS);
2321 }
2322 }
2323 printf("Benchmark : Multi threads %zu, ", multi_thread_config.nr_thread);
2324 printf("core_ids:");
2325 for (size_t i = 0; i < multi_thread_config.affinity_core_set.size(); i++) {
2326 printf("%zu ", multi_thread_config.affinity_core_set[i]);
2327 }
2328 for (size_t i = 0; i < shapes_and_computation.size(); i++) {
2329 auto shapes = shapes_and_computation[i];
2330 printf("Bench case: ");
2331 for (auto&& shape : shapes.first) {
2332 printf("%s ", shape.to_string().c_str());
2333 }
2334 float computations = shapes.second;
2335 printf("algo:%s gflops: %f,\n algo:%s gflops: "
2336 "%f. spead up = %f\n",
2337 algo_name.c_str(), computations / multi_thread_times[i],
2338 algo_name1.c_str(), computations / single_thread_times[i],

Callers 1

TEST_FFunction · 0.85

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