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