Commit bd35edb5 authored by Amy Zhuang's avatar Amy Zhuang Committed by Scott Cyphers

Fix the cpu thread_safe_calls test on Windows. (#2861)

* Fix the cpu thread_safe_calls test on Windows.

* Use notify_one.
parent 44f7479d
...@@ -112,23 +112,21 @@ void runtime::cpu::CPU_CallFrame::inner_call( ...@@ -112,23 +112,21 @@ void runtime::cpu::CPU_CallFrame::inner_call(
m_ctx_vec[id]->op_durations, m_ctx_vec[id]->op_durations,
m_external_function->get_function_name() + ".timeline.json"); m_external_function->get_function_name() + ".timeline.json");
} }
std::unique_lock<std::mutex> lck(m_mutex);
m_id_pool[id] = true;
m_num_ctx_available++;
m_cv.notify_all();
} }
void runtime::cpu::CPU_CallFrame::call( void runtime::cpu::CPU_CallFrame::call(
const std::vector<std::shared_ptr<runtime::Tensor>>& output_tvs, const std::vector<std::shared_ptr<runtime::Tensor>>& output_tvs,
const std::vector<std::shared_ptr<runtime::Tensor>>& input_tvs) const std::vector<std::shared_ptr<runtime::Tensor>>& input_tvs)
{ {
auto id = 0;
auto disable_caching = false;
{
std::unique_lock<std::mutex> lck(m_mutex); std::unique_lock<std::mutex> lck(m_mutex);
while (m_num_ctx_available == 0) while (m_num_ctx_available == 0)
{ {
m_cv.wait(lck); m_cv.wait(lck);
} }
auto id = 0;
for (auto i = 0; i < m_num_ctx; i++) for (auto i = 0; i < m_num_ctx; i++)
{ {
if (m_id_pool[i]) if (m_id_pool[i])
...@@ -139,7 +137,6 @@ void runtime::cpu::CPU_CallFrame::call( ...@@ -139,7 +137,6 @@ void runtime::cpu::CPU_CallFrame::call(
} }
NGRAPH_CHECK(id != m_num_ctx); NGRAPH_CHECK(id != m_num_ctx);
m_id_pool[id] = false; m_id_pool[id] = false;
auto disable_caching = false;
if (id != m_prev_ctx) if (id != m_prev_ctx)
{ {
// Disable caching since staleness hints are no longer // Disable caching since staleness hints are no longer
...@@ -148,11 +145,17 @@ void runtime::cpu::CPU_CallFrame::call( ...@@ -148,11 +145,17 @@ void runtime::cpu::CPU_CallFrame::call(
} }
m_prev_ctx = id; m_prev_ctx = id;
m_num_ctx_available--; m_num_ctx_available--;
m_mutex.unlock(); }
m_ctx_vec[id]->pc = 0; m_ctx_vec[id]->pc = 0;
propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors()); propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors());
inner_call(output_tvs, input_tvs, id, disable_caching); inner_call(output_tvs, input_tvs, id, disable_caching);
m_mutex.lock();
m_id_pool[id] = true;
m_num_ctx_available++;
m_mutex.unlock();
m_cv.notify_one();
} }
void runtime::cpu::CPU_CallFrame::propagate_layouts( void runtime::cpu::CPU_CallFrame::propagate_layouts(
......
...@@ -951,8 +951,6 @@ TEST(cpu_test, rotated_pooling) ...@@ -951,8 +951,6 @@ TEST(cpu_test, rotated_pooling)
make_f(false, false), make_f(false, false), "INTERPRETER", "CPU"); // 5D MaxPool make_f(false, false), make_f(false, false), "INTERPRETER", "CPU"); // 5D MaxPool
} }
// TODO enable test for Windows
#ifndef _WIN32
// for float this will be 18 bits matching // for float this will be 18 bits matching
// for bfloat this will be 6 bits matching // for bfloat this will be 6 bits matching
constexpr int three_quarters_of_available_bits = (MAX_FLOAT_BITS * 3) / 4; constexpr int three_quarters_of_available_bits = (MAX_FLOAT_BITS * 3) / 4;
...@@ -1049,7 +1047,6 @@ TEST(cpu_test, thread_safe_calls_convolution_2d_2items) ...@@ -1049,7 +1047,6 @@ TEST(cpu_test, thread_safe_calls_convolution_2d_2items)
unset_environment("NGRAPH_CPU_CONCURRENCY"); unset_environment("NGRAPH_CPU_CONCURRENCY");
} }
#endif
TEST(cpu_test, constant_reshape) TEST(cpu_test, constant_reshape)
{ {
......
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