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,47 +112,50 @@ void runtime::cpu::CPU_CallFrame::inner_call(
m_ctx_vec[id]->op_durations,
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(
const std::vector<std::shared_ptr<runtime::Tensor>>& output_tvs,
const std::vector<std::shared_ptr<runtime::Tensor>>& input_tvs)
{
std::unique_lock<std::mutex> lck(m_mutex);
while (m_num_ctx_available == 0)
{
m_cv.wait(lck);
}
auto id = 0;
for (auto i = 0; i < m_num_ctx; i++)
auto disable_caching = false;
{
if (m_id_pool[i])
std::unique_lock<std::mutex> lck(m_mutex);
while (m_num_ctx_available == 0)
{
id = i;
break;
m_cv.wait(lck);
}
for (auto i = 0; i < m_num_ctx; i++)
{
if (m_id_pool[i])
{
id = i;
break;
}
}
NGRAPH_CHECK(id != m_num_ctx);
m_id_pool[id] = false;
if (id != m_prev_ctx)
{
// Disable caching since staleness hints are no longer
// applicable to this context
disable_caching = true;
}
m_prev_ctx = id;
m_num_ctx_available--;
}
NGRAPH_CHECK(id != m_num_ctx);
m_id_pool[id] = false;
auto disable_caching = false;
if (id != m_prev_ctx)
{
// Disable caching since staleness hints are no longer
// applicable to this context
disable_caching = true;
}
m_prev_ctx = id;
m_num_ctx_available--;
m_mutex.unlock();
m_ctx_vec[id]->pc = 0;
propagate_layouts(output_tvs, m_external_function->get_result_layout_descriptors());
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(
......
......@@ -951,8 +951,6 @@ TEST(cpu_test, rotated_pooling)
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 bfloat this will be 6 bits matching
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)
unset_environment("NGRAPH_CPU_CONCURRENCY");
}
#endif
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