Commit 5b5fdc8c by Marcus Winter

dataflow_cpp: refactored to use tasks_cpp

parent a7bc2f9b
...@@ -17,16 +17,16 @@ include_directories(${EMBB_DATAFLOW_CPP_INCLUDE_DIRS} ...@@ -17,16 +17,16 @@ include_directories(${EMBB_DATAFLOW_CPP_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../base_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../base_cpp/include
${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include ${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include
${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include
${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../tasks_cpp/include
${CMAKE_CURRENT_BINARY_DIR}/../mtapi_cpp/include) ${CMAKE_CURRENT_BINARY_DIR}/../tasks_cpp/include)
add_library (embb_dataflow_cpp ${EMBB_DATAFLOW_CPP_SOURCES} ${EMBB_DATAFLOW_CPP_HEADERS}) add_library (embb_dataflow_cpp ${EMBB_DATAFLOW_CPP_SOURCES} ${EMBB_DATAFLOW_CPP_HEADERS})
target_link_libraries(embb_dataflow_cpp embb_mtapi_cpp embb_base_cpp embb_mtapi_c embb_base_c) target_link_libraries(embb_dataflow_cpp embb_tasks_cpp embb_base_cpp embb_mtapi_c embb_base_c)
if (BUILD_TESTS STREQUAL ON) if (BUILD_TESTS STREQUAL ON)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../partest/include) include_directories(${CMAKE_CURRENT_BINARY_DIR}/../partest/include)
add_executable (embb_dataflow_cpp_test ${EMBB_DATAFLOW_CPP_TEST_SOURCES}) add_executable (embb_dataflow_cpp_test ${EMBB_DATAFLOW_CPP_TEST_SOURCES})
target_link_libraries(embb_dataflow_cpp_test embb_dataflow_cpp embb_mtapi_cpp embb_mtapi_c partest target_link_libraries(embb_dataflow_cpp_test embb_dataflow_cpp embb_tasks_cpp embb_mtapi_c partest
embb_base_cpp embb_base_c ${compiler_libs}) embb_base_cpp embb_base_c ${compiler_libs})
CopyBin(BIN embb_dataflow_cpp_test DEST ${local_install_dir}) CopyBin(BIN embb_dataflow_cpp_test DEST ${local_install_dir})
endif() endif()
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <cstddef> #include <cstddef>
#include <embb/mtapi/taskcontext.h> #include <embb/tasks/task_context.h>
#include <embb/dataflow/internal/node.h> #include <embb/dataflow/internal/node.h>
...@@ -48,7 +48,7 @@ class Action { ...@@ -48,7 +48,7 @@ class Action {
pending_ = 0; pending_ = 0;
} }
void RunMTAPI(embb::mtapi::TaskContext & /*context*/) { void RunMTAPI(embb::tasks::TaskContext & /*context*/) {
pending_ = 1; pending_ = 1;
node_->Run(clock_); node_->Run(clock_);
pending_ = 0; pending_ = 0;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <embb/dataflow/internal/action.h> #include <embb/dataflow/internal/action.h>
#include <embb/dataflow/internal/scheduler.h> #include <embb/dataflow/internal/scheduler.h>
#include <embb/mtapi/node.h> #include <embb/tasks/node.h>
#include <embb/base/function.h> #include <embb/base/function.h>
namespace embb { namespace embb {
...@@ -40,24 +40,24 @@ template <int Slices> ...@@ -40,24 +40,24 @@ template <int Slices>
class SchedulerMTAPI : public Scheduler { class SchedulerMTAPI : public Scheduler {
public: public:
SchedulerMTAPI() { SchedulerMTAPI() {
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); embb::tasks::Node & node = embb::tasks::Node::GetInstance();
for (int ii = 0; ii < Slices; ii++) { for (int ii = 0; ii < Slices; ii++) {
embb::mtapi::Group & group = node.CreateGroup(); embb::tasks::Group & group = node.CreateGroup();
group_[ii] = &group; group_[ii] = &group;
} }
queue_count_ = static_cast<int>(node.GetWorkerThreadCount()); queue_count_ = static_cast<int>(node.GetWorkerThreadCount());
queue_ = reinterpret_cast<embb::mtapi::Queue**>( queue_ = reinterpret_cast<embb::tasks::Queue**>(
embb::base::Allocation::Allocate( embb::base::Allocation::Allocate(
sizeof(embb::mtapi::Queue*)*queue_count_)); sizeof(embb::tasks::Queue*)*queue_count_));
for (int ii = 0; ii < queue_count_; ii++) { for (int ii = 0; ii < queue_count_; ii++) {
embb::mtapi::Queue & queue = node.CreateQueue(0, true); embb::tasks::Queue & queue = node.CreateQueue(0, true);
queue_[ii] = &queue; queue_[ii] = &queue;
} }
} }
virtual ~SchedulerMTAPI() { virtual ~SchedulerMTAPI() {
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); embb::tasks::Node & node = embb::tasks::Node::GetInstance();
for (int ii = 0; ii < Slices; ii++) { for (int ii = 0; ii < Slices; ii++) {
group_[ii]->WaitAll(MTAPI_INFINITE); group_[ii]->WaitAll(MTAPI_INFINITE);
node.DestroyGroup(*group_[ii]); node.DestroyGroup(*group_[ii]);
...@@ -82,8 +82,8 @@ class SchedulerMTAPI : public Scheduler { ...@@ -82,8 +82,8 @@ class SchedulerMTAPI : public Scheduler {
} }
private: private:
embb::mtapi::Group * group_[Slices]; embb::tasks::Group * group_[Slices];
embb::mtapi::Queue ** queue_; embb::tasks::Queue ** queue_;
int queue_count_; int queue_count_;
}; };
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <embb/mtapi/mtapi.h> #include <embb/tasks/tasks.h>
#include <embb/base/function.h> #include <embb/base/function.h>
#include <embb/base/c/memory_allocation.h> #include <embb/base/c/memory_allocation.h>
...@@ -143,7 +143,7 @@ SimpleTest::SimpleTest() { ...@@ -143,7 +143,7 @@ SimpleTest::SimpleTest() {
} }
void SimpleTest::TestBasic() { void SimpleTest::TestBasic() {
embb::mtapi::Node::Initialize(1, 1); embb::tasks::Node::Initialize(1, 1);
for (int ii = 0; ii < 10000; ii++) { for (int ii = 0; ii < 10000; ii++) {
ArraySink<TEST_COUNT> asink; ArraySink<TEST_COUNT> asink;
...@@ -203,7 +203,7 @@ void SimpleTest::TestBasic() { ...@@ -203,7 +203,7 @@ void SimpleTest::TestBasic() {
PT_EXPECT(asink.Check()); PT_EXPECT(asink.Check());
} }
embb::mtapi::Node::Finalize(); embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0); PT_EXPECT(embb_get_bytes_allocated() == 0);
} }
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 sign in to comment