Tengine多线程CPU/GPU异构调度执行MobilenetSSD

本例子教程,我们的硬件平台为RK3399,我们创建3个线程来执行Mobilenet-SSD网络:

  • thread 0 for CPU 2 A72
  • thread 1 for GPU + 1A53
  • thread 2 for CPU 4 A53

源码Tengine/tests/bin/mt_mssd.cpp.

对每个线程thread,我们独立地创建图graph, 并设置相应的设备devices.

graph_t graph=create_runtime_graph("cpu_a72",model_name,NULL);

graph_t graph=create_runtime_graph("gpu"    ,model_name,NULL);

graph_t graph=create_runtime_graph("cpu_a53",model_name,NULL);

set_graph_device(graph,"a72");

set_graph_device(graph,"acl_opencl");

set_graph_device(graph,"a53");


创建3个线程:

 std::thread * t0=new std::thread(cpu_thread_a72,model_name,&avg_times[0]);

std::thread * t1=new std::thread(gpu_thread    ,model_name,&avg_times[1]);

std::thread * t2=new std::thread(cpu_thread_a53,model_name,&avg_times[2]);


执行后,可以看到性能数据为:

=================================================

Using 3 thread, MSSD performance 23.1135  FPS

=================================================





可以查看结果图片验证网络执行结果的正确性:

  • cpu_2A72_save.jpg
  • gpu_save.jpg
  • cpu_4A53_save.jpg