From f4dced2e6e5b14f4ba4260571bbb3d9fa8094659 Mon Sep 17 00:00:00 2001 From: "Wang, Yang" Date: Fri, 26 Apr 2024 00:39:51 +0800 Subject: [PATCH] [AUTO] Update the CPU resources for GPU compilation when using CPU as accelerator (#23974) ### Details: - Update the usage of CPU resources for GPU compilation when CPU as acceleration device - Don't prioritize to load dynamic model to CPU, but follow the device::priorities - Add logs for compilation time and first inference time ### Tickets: - CVS-138196 --------- Co-authored-by: Chen Peter --- src/plugins/auto/src/auto_schedule.cpp | 64 +++++++++++-------- src/plugins/auto/src/plugin.cpp | 22 +++++-- src/plugins/auto/src/plugin_config.hpp | 1 + src/plugins/auto/src/schedule.cpp | 5 ++ .../auto/tests/unit/dynamic_output_test.cpp | 63 +++++++----------- .../auto/tests/unit/stateful_model_test.cpp | 8 +-- 6 files changed, 84 insertions(+), 79 deletions(-) diff --git a/src/plugins/auto/src/auto_schedule.cpp b/src/plugins/auto/src/auto_schedule.cpp index b154bdf1b2a..0bf1acbbd17 100644 --- a/src/plugins/auto/src/auto_schedule.cpp +++ b/src/plugins/auto/src/auto_schedule.cpp @@ -18,7 +18,7 @@ bool AutoSchedule::select_other_device(const std::string& cur_dev_name) { get_execution_devices = [&](const std::string& device_name) { std::string real_device_name; bool is_cpuhelp = false; - m_compile_context[FALLBACKDEVICE].m_model_precision = m_context->m_model_precision; + m_compile_context[FALLBACKDEVICE].m_model_precision = m_context->m_model_precision; if (device_name == "CPU_HELP") { // if infer failed in CPU_HELP, we will remove CPU from m_device_priorities // and re-run infer request when m_compile_context[ACTUALDEVICE] is ready @@ -49,8 +49,8 @@ bool AutoSchedule::select_other_device(const std::string& cur_dev_name) { m_compile_context[FALLBACKDEVICE].m_is_reload_success = false; m_compile_context[FALLBACKDEVICE].m_device_info = m_plugin->select_device(m_context->m_device_priorities, - m_compile_context[FALLBACKDEVICE].m_model_precision, - m_context->m_model_priority); + m_compile_context[FALLBACKDEVICE].m_model_precision, + m_context->m_model_priority); try { m_compile_context[FALLBACKDEVICE].m_task(); // FALLBACKDEVICE need to be load again if infer failed, so reset promise here @@ -165,9 +165,9 @@ void AutoSchedule::init() { // so use executor as a member of AutoSchedule. m_executor = m_plugin->get_executor_manager()->get_idle_cpu_streams_executor( ov::threading::IStreamsExecutor::Config{"AutoDeviceAsyncCompile", - static_cast(std::thread::hardware_concurrency()) /* max possible #streams*/, - 0 /*default threads per stream, workaround for ticket 62376*/, - ov::threading::IStreamsExecutor::ThreadBindingType::NONE}); + static_cast(std::thread::hardware_concurrency()) /* max possible #streams*/, + 0 /*default threads per stream, workaround for ticket 62376*/, + ov::threading::IStreamsExecutor::ThreadBindingType::NONE}); for (auto&& device : m_context->m_device_priorities) { // initialize containers before run async task m_idle_worker_requests[device.device_name]; @@ -206,6 +206,8 @@ void AutoSchedule::init() { cpuhelp_all_end_times.splice(cpuhelp_all_end_times.end(), worker.second->m_end_times); }); } + std::chrono::duration first_infer_time = + cpuhelp_all_end_times.front() - cpuhelp_all_start_times.front(); INFO_RUN([this, &cpuhelp_all_start_times, &cpuhelp_all_end_times]() { cpuhelp_all_start_times.sort(std::less