Commit 981bf4f2 authored by Jayaram Bobba's avatar Jayaram Bobba Committed by Robert Kimball

Move to TBB2019 and bug fix to capture functor (#1917)

* Move to TBB2019 and bug fix to capture functor

* Change to use TBB release tag

* remove lightweight from codegen

* Enable TBB flow graph tracing
parent 58bd00de
......@@ -68,7 +68,7 @@ else()
endif()
# Prevent Eigen from using any LGPL3 code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY -DTBB_USE_THREADING_TOOLS")
if($ENV{NGRAPH_USE_PREBUILT_LLVM})
set(NGRAPH_USE_PREBUILT_LLVM TRUE)
......
......@@ -20,7 +20,7 @@
if(NGRAPH_TBB_ENABLE)
set(TBB_GIT_REPO_URL https://github.com/01org/tbb)
set(TBB_GIT_TAG "tbb_2018")
set(TBB_GIT_TAG "2019_U1")
configure_file(${CMAKE_SOURCE_DIR}/cmake/tbb_fetch.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tbb/CMakeLists.txt)
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" .
......
......@@ -23,14 +23,7 @@
#include <typeinfo>
#include <unordered_map>
// Kill clang diagnostics bug
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-id-macro"
#undef __TBB_PREVIEW_LIGHTWEIGHT_POLICY
#define __TBB_PREVIEW_LIGHTWEIGHT_POLICY 1
#pragma clang diagnostic pop
#define TBB_PREVIEW_FLOW_GRAPH_TRACE 1
#include <tbb/flow_graph.h>
......@@ -425,8 +418,6 @@ void runtime::cpu::CPU_ExternalFunction::compile()
"CPU Backend: Tracing and performance breakdowns might not be accurate with TBB "
"enabled due to concurrent graph execution");
}
writer << "#undef __TBB_PREVIEW_LIGHTWEIGHT_POLICY \n";
writer << "#define __TBB_PREVIEW_LIGHTWEIGHT_POLICY 1\n";
writer << "#include <tbb/flow_graph.h>";
}
......@@ -674,10 +665,9 @@ using namespace ngraph::runtime;
writer << "\n";
writer << "if (ctx->first_iteration) {\n";
writer.indent++;
writer << "tbb::flow::continue_node<tbb::flow::continue_msg, tbb::flow::lightweight>* "
writer << "tbb::flow::continue_node<tbb::flow::continue_msg>* "
"flowgraph_node_start"
<< " = new tbb::flow::continue_node<tbb::flow::continue_msg, "
"tbb::flow::lightweight>"
<< " = new tbb::flow::continue_node<tbb::flow::continue_msg> "
"(*(ctx->G), [&](const tbb::flow::continue_msg &msg)\n{});\n";
}
......@@ -774,12 +764,10 @@ using namespace ngraph::runtime;
}
if (m_use_tbb)
{
writer << "tbb::flow::continue_node<tbb::flow::continue_msg, "
"tbb::flow::lightweight>* "
writer << "tbb::flow::continue_node<tbb::flow::continue_msg>* "
"flowgraph_node_"
<< node->get_name()
<< " = new tbb::flow::continue_node<tbb::flow::continue_msg, "
"tbb::flow::lightweight>"
<< " = new tbb::flow::continue_node<tbb::flow::continue_msg> "
"(*(ctx->G), [&](const tbb::flow::continue_msg &msg)\n{\n";
writer.indent++;
}
......@@ -941,8 +929,8 @@ using namespace ngraph::runtime;
writer << "}\n";
// Execute the flow graph
writer << "(static_cast<tbb::flow::continue_node<tbb::flow::continue_msg, "
"tbb::flow::lightweight>*>(&(*(ctx->G->begin()))))"
writer << "(static_cast<tbb::flow::continue_node<tbb::flow::continue_msg>*>"
"(&(*(ctx->G->begin()))))"
<< "->try_put(tbb::flow::continue_msg());\n";
writer << "try { ctx->G->wait_for_all(); } catch(...) { throw; }\n";
}
......@@ -1631,22 +1619,18 @@ void runtime::cpu::CPU_ExternalFunction::build()
// Build the flow graph
if (ctx->first_iteration)
{
std::unordered_map<
std::string,
tbb::flow::continue_node<tbb::flow::continue_msg, tbb::flow::lightweight>*>
std::unordered_map<std::string, tbb::flow::continue_node<tbb::flow::continue_msg>*>
nodename_tbbnode_map;
tbb::flow::continue_node<tbb::flow::continue_msg,
tbb::flow::lightweight>* flowgraph_node_start =
new tbb::flow::continue_node<tbb::flow::continue_msg, tbb::flow::lightweight>(
tbb::flow::continue_node<tbb::flow::continue_msg>* flowgraph_node_start =
new tbb::flow::continue_node<tbb::flow::continue_msg>(
*(ctx->G), [&](const tbb::flow::continue_msg& msg) {});
auto it = enable_nodename_list.begin();
for (const auto& p : enables)
{
auto index = profiler_count++;
tbb::flow::continue_node<tbb::flow::continue_msg, tbb::flow::lightweight>*
flowgraph_node = new tbb::flow::continue_node<tbb::flow::continue_msg,
tbb::flow::lightweight>(
*(ctx->G), [&, index](const tbb::flow::continue_msg& msg) {
tbb::flow::continue_node<tbb::flow::continue_msg>* flowgraph_node =
new tbb::flow::continue_node<tbb::flow::continue_msg>(
*(ctx->G), [&, functor, index](const tbb::flow::continue_msg& msg) {
if (p(ctx) || ctx->first_iteration)
{
if (runtime::cpu::IsTracingEnabled() || m_emit_timing)
......@@ -1686,8 +1670,11 @@ void runtime::cpu::CPU_ExternalFunction::build()
m_perf_counters[index].m_call_count++;
}
}
std::advance(functor, 1);
});
#ifdef TBB_PREVIEW_FLOW_GRAPH_TRACE
flowgraph_node->set_name(it->second.c_str());
#endif
std::advance(functor, 1);
nodename_tbbnode_map.insert({it->second, flowgraph_node});
it++;
}
......@@ -1720,9 +1707,7 @@ void runtime::cpu::CPU_ExternalFunction::build()
}
}
// Execute the flow graph
(static_cast<
tbb::flow::continue_node<tbb::flow::continue_msg, tbb::flow::lightweight>*>(
&(*(ctx->G->begin()))))
(static_cast<tbb::flow::continue_node<tbb::flow::continue_msg>*>(&(*(ctx->G->begin()))))
->try_put(tbb::flow::continue_msg());
try
{
......
......@@ -21,6 +21,7 @@
#include <set>
#define TBB_PREVIEW_GLOBAL_CONTROL 1
#define TBB_PREVIEW_FLOW_GRAPH_TRACE 1
#include <tbb/flow_graph.h>
#include <tbb/global_control.h>
#include <tbb/task_scheduler_init.h>
......
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