"git@developer.sourcefind.cn:gaoqiong/migraphx.git" did not exist on "9a2c733962d585ff1467cbf3a06bc1c76782f1aa"
Commit f923d0ee authored by Paul's avatar Paul
Browse files

Run cpu and gpu at the same time

parent f0604d78
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include <miopen/miopen.h> #include <miopen/miopen.h>
#include <future>
#include <thread>
#include "test.hpp" #include "test.hpp"
#include "verify.hpp" #include "verify.hpp"
...@@ -19,6 +22,17 @@ ...@@ -19,6 +22,17 @@
#pragma clang diagnostic ignored "-Wglobal-constructors" #pragma clang diagnostic ignored "-Wglobal-constructors"
#endif #endif
// An improved async, that doesn't block
template <class Function>
std::future<typename std::result_of<Function()>::type> detach_async(Function&& f)
{
using result_type = typename std::result_of<Function()>::type;
std::packaged_task<result_type()> task(std::forward<Function>(f));
auto fut = task.get_future();
std::thread(std::move(task)).detach();
return std::move(fut);
}
struct auto_print struct auto_print
{ {
static std::array<std::function<void()>, 2> handlers; static std::array<std::function<void()>, 2> handlers;
...@@ -85,9 +99,9 @@ void verify_program() ...@@ -85,9 +99,9 @@ void verify_program()
for(auto&& handle : auto_print::handlers) for(auto&& handle : auto_print::handlers)
handle(); handle();
}); });
auto cpu_arg = run_cpu<V>(); auto cpu_arg_f = detach_async([] { return run_cpu<V>(); });
auto gpu_arg = run_gpu<V>(); auto gpu_arg = run_gpu<V>();
visit_all(cpu_arg, gpu_arg)([](auto cpu, auto gpu) { visit_all(cpu_arg_f.get(), gpu_arg)([](auto cpu, auto gpu) {
if(not test::verify_range(cpu, gpu)) if(not test::verify_range(cpu, gpu))
{ {
std::cout << "FAILED: " << migraph::get_type_name<V>() << std::endl; std::cout << "FAILED: " << migraph::get_type_name<V>() << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment