Commit 52da087e by Marcus Winter

task_cpp: refactored namespace from mtapi to tasks

parent a97a72c1
......@@ -125,7 +125,7 @@ CheckPartestInstall(${BUILD_TESTS} partest_includepath partest_libpath)
add_subdirectory(base_c)
add_subdirectory(base_cpp)
add_subdirectory(mtapi_c)
add_subdirectory(mtapi_cpp)
add_subdirectory(tasks_cpp)
add_subdirectory(mtapi_cpp_ext)
add_subdirectory(containers_cpp)
add_subdirectory(algorithms_cpp)
......
project (project_mtapi_cpp)
project (project_tasks_cpp)
file(GLOB_RECURSE EMBB_MTAPI_CPP_SOURCES "src/*.cc" "src/*.h")
file(GLOB_RECURSE EMBB_MTAPI_CPP_HEADERS "include/*.h")
file(GLOB_RECURSE EMBB_MTAPI_CPP_TEST_SOURCES "test/*.cc" "test/*.h")
file(GLOB_RECURSE EMBB_TASKS_CPP_SOURCES "src/*.cc" "src/*.h")
file(GLOB_RECURSE EMBB_TASKS_CPP_HEADERS "include/*.h")
file(GLOB_RECURSE EMBB_TASKS_CPP_TEST_SOURCES "test/*.cc" "test/*.h")
if (USE_AUTOMATIC_INITIALIZATION STREQUAL ON)
message("-- Automatic initialization enabled (default)")
set(MTAPI_CPP_AUTOMATIC_INITIALIZE 1)
set(TASKS_CPP_AUTOMATIC_INITIALIZE 1)
else()
set(MTAPI_CPP_AUTOMATIC_INITIALIZE 0)
set(TASKS_CPP_AUTOMATIC_INITIALIZE 0)
message("-- Automatic initialization disabled")
endif()
message(" (set with command line option -DUSE_AUTOMATIC_INITIALIZATION=ON/OFF)")
configure_file("include/embb/mtapi/internal/cmake_config.h.in"
"include/embb/mtapi/internal/cmake_config.h")
configure_file("include/embb/tasks/internal/cmake_config.h.in"
"include/embb/tasks/internal/cmake_config.h")
# Execute the GroupSources macro
include(${CMAKE_SOURCE_DIR}/CMakeCommon/GroupSourcesMSVC.cmake)
......@@ -22,8 +22,8 @@ GroupSourcesMSVC(include)
GroupSourcesMSVC(src)
GroupSourcesMSVC(test)
set (EMBB_MTAPI_CPP_INCLUDE_DIRS "include" "src" "test")
include_directories(${EMBB_MTAPI_CPP_INCLUDE_DIRS}
set (EMBB_TASKS_CPP_INCLUDE_DIRS "include" "src" "test")
include_directories(${EMBB_TASKS_CPP_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/../base_c/include
${CMAKE_CURRENT_BINARY_DIR}/../base_c/include
......@@ -31,19 +31,19 @@ include_directories(${EMBB_MTAPI_CPP_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include
${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include)
add_library (embb_mtapi_cpp ${EMBB_MTAPI_CPP_SOURCES} ${EMBB_MTAPI_CPP_HEADERS})
target_link_libraries(embb_mtapi_cpp embb_mtapi_c)
add_library (embb_tasks_cpp ${EMBB_TASKS_CPP_SOURCES} ${EMBB_TASKS_CPP_HEADERS})
target_link_libraries(embb_tasks_cpp embb_mtapi_c)
if (BUILD_TESTS STREQUAL ON)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../partest/include)
add_executable (embb_mtapi_cpp_test ${EMBB_MTAPI_CPP_TEST_SOURCES})
target_link_libraries(embb_mtapi_cpp_test embb_mtapi_cpp embb_mtapi_c partest
add_executable (embb_tasks_cpp_test ${EMBB_TASKS_CPP_TEST_SOURCES})
target_link_libraries(embb_tasks_cpp_test embb_tasks_cpp embb_mtapi_c partest
embb_base_cpp embb_base_c ${compiler_libs})
CopyBin(BIN embb_mtapi_cpp_test DEST ${local_install_dir})
CopyBin(BIN embb_tasks_cpp_test DEST ${local_install_dir})
endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION include FILES_MATCHING PATTERN "*.h")
install(TARGETS embb_mtapi_cpp DESTINATION lib)
install(TARGETS embb_tasks_cpp DESTINATION lib)
......@@ -24,15 +24,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_ACTION_H_
#define EMBB_MTAPI_ACTION_H_
#ifndef EMBB_TASKS_ACTION_H_
#define EMBB_TASKS_ACTION_H_
#include <embb/base/function.h>
#include <embb/mtapi/taskcontext.h>
#include <embb/mtapi/execution_policy.h>
#include <embb/tasks/task_context.h>
#include <embb/tasks/execution_policy.h>
namespace embb {
namespace mtapi {
namespace tasks {
/**
* A function to be spawned as a Task.
......@@ -103,7 +103,7 @@ class Action {
ExecutionPolicy execution_policy_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_ACTION_H_
#endif // EMBB_TASKS_ACTION_H_
......@@ -24,66 +24,66 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_CONTINUATION_H_
#define EMBB_MTAPI_CONTINUATION_H_
#ifndef EMBB_TASKS_CONTINUATION_H_
#define EMBB_TASKS_CONTINUATION_H_
#include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/taskcontext.h>
#include <embb/mtapi/action.h>
#include <embb/mtapi/task.h>
#include <embb/tasks/task_context.h>
#include <embb/tasks/action.h>
#include <embb/tasks/task.h>
namespace embb {
namespace mtapi {
namespace tasks {
/**
* Helper struct for Continuation.
*
* \ingroup CPP_MTAPI
*/
* Helper struct for Continuation.
*
* \ingroup CPP_TASKS
*/
struct ContinuationStage;
/**
* A Continuation encapsulates a chain of \link Action Actions \endlink to be
* executed consecutively.
*
* \ingroup CPP_MTAPI
*/
* A Continuation encapsulates a chain of \link Action Actions \endlink to be
* executed consecutively.
*
* \ingroup CPP_TASKS
*/
class Continuation {
public:
/**
* Copy constructor.
*/
* Copies a Continuation.
*/
Continuation(
Continuation const & cont /**< [in] The Continuation to copy. */
);
/**
* Destructor.
*/
* Destroys a Continuation.
*/
~Continuation();
/**
* Appends an Action to the Continuation chain.
* \returns A reference to this Continuation chain.
* \notthreadsafe
*/
* Appends an Action to the Continuation chain.
* \returns A reference to this Continuation chain.
* \notthreadsafe
*/
Continuation & Then(
Action action /**< [in] The Action to append to the
continuation */
);
/**
* Runs the Continuation chain.
* \returns The Task representing the Continuation chain.
* \notthreadsafe
*/
* Runs the Continuation chain.
* \returns The Task representing the Continuation chain.
* \notthreadsafe
*/
Task Spawn();
/**
* Runs the Continuation chain with the specified execution_policy.
* \returns The Task representing the Continuation chain.
* \notthreadsafe
*/
* Runs the Continuation chain with the specified execution_policy.
* \returns The Task representing the Continuation chain.
* \notthreadsafe
*/
Task Spawn(
ExecutionPolicy execution_policy /**< [in] The execution policy to use */
);
......@@ -99,7 +99,7 @@ class Continuation {
ContinuationStage * last_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_CONTINUATION_H_
#endif // EMBB_TASKS_CONTINUATION_H_
......@@ -24,13 +24,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_EXECUTION_POLICY_H_
#define EMBB_MTAPI_EXECUTION_POLICY_H_
#ifndef EMBB_TASKS_EXECUTION_POLICY_H_
#define EMBB_TASKS_EXECUTION_POLICY_H_
#include <embb/mtapi/c/mtapi.h>
namespace embb {
namespace mtapi {
namespace tasks {
/**
* Describes the execution policy of a parallel algorithm.
* The execution policy comprises
......@@ -41,7 +42,7 @@ namespace mtapi {
* max_priorities - 1 as given during initialization using Node::Initialize().
* The default value of max_priorities is 4.
*
* \ingroup CPP_MTAPI
* \ingroup CPP_TASKS
*/
class ExecutionPolicy{
public:
......@@ -145,7 +146,8 @@ class ExecutionPolicy{
*/
mtapi_uint_t priority_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_EXECUTION_POLICY_H_
#endif // EMBB_TASKS_EXECUTION_POLICY_H_
......@@ -24,12 +24,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_GROUP_H_
#define EMBB_MTAPI_GROUP_H_
#ifndef EMBB_TASKS_GROUP_H_
#define EMBB_TASKS_GROUP_H_
#include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h>
#include <embb/mtapi/task.h>
#include <embb/tasks/action.h>
#include <embb/tasks/task.h>
namespace embb {
......@@ -39,13 +39,13 @@ class Allocation;
} // namespace base
namespace mtapi {
namespace tasks {
/**
* Represents a facility to wait for multiple related
* \link Task Tasks\endlink.
*
* \ingroup CPP_MTAPI
* \ingroup CPP_TASKS
*/
class Group {
public:
......@@ -119,7 +119,7 @@ class Group {
mtapi_group_hndl_t handle_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_GROUP_H_
#endif // EMBB_TASKS_GROUP_H_
......@@ -24,18 +24,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_
#define EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_
#ifndef EMBB_TASKS_INTERNAL_CMAKE_CONFIG_H_
#define EMBB_TASKS_INTERNAL_CMAKE_CONFIG_H_
/* This file is used as input for CMake. CMake creates a file cmake_config.h in
its current build directory under the path builddir/embb/mtapi/internal/. From
its current build directory under the path builddir/embb/tasks/internal/. From
there, the cmake_config.h can be included as usual using
#include <embb/mtapi/internal/cmake_config.h>
#include <embb/tasks/internal/cmake_config.h>
*/
/**
* Is used to enable automatic initialization of the MTAPI node
*/
#define MTAPI_CPP_AUTOMATIC_INITIALIZE ${MTAPI_CPP_AUTOMATIC_INITIALIZE}
#define TASKS_CPP_AUTOMATIC_INITIALIZE ${TASKS_CPP_AUTOMATIC_INITIALIZE}
#endif // EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_
#endif // EMBB_TASKS_INTERNAL_CMAKE_CONFIG_H_
......@@ -24,17 +24,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_NODE_H_
#define EMBB_MTAPI_NODE_H_
#ifndef EMBB_TASKS_NODE_H_
#define EMBB_TASKS_NODE_H_
#include <list>
#include <embb/base/core_set.h>
#include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h>
#include <embb/mtapi/task.h>
#include <embb/mtapi/continuation.h>
#include <embb/mtapi/group.h>
#include <embb/mtapi/queue.h>
#include <embb/tasks/action.h>
#include <embb/tasks/task.h>
#include <embb/tasks/continuation.h>
#include <embb/tasks/group.h>
#include <embb/tasks/queue.h>
namespace embb {
......@@ -44,12 +44,12 @@ class Allocation;
} // namespace base
namespace mtapi {
namespace tasks {
/**
* A singleton representing the MTAPI runtime.
*
* \ingroup CPP_MTAPI
* \ingroup CPP_TASKS
*/
class Node {
public:
......@@ -225,7 +225,7 @@ class Node {
std::list<Group*> groups_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_NODE_H_
#endif // EMBB_TASKS_NODE_H_
......@@ -24,13 +24,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_QUEUE_H_
#define EMBB_MTAPI_QUEUE_H_
#ifndef EMBB_TASKS_QUEUE_H_
#define EMBB_TASKS_QUEUE_H_
#include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h>
#include <embb/mtapi/task.h>
#include <embb/mtapi/group.h>
#include <embb/tasks/action.h>
#include <embb/tasks/task.h>
#include <embb/tasks/group.h>
namespace embb {
......@@ -40,12 +40,12 @@ class Allocation;
} // namespace base
namespace mtapi {
namespace tasks {
/**
* Allows for stream processing, either ordered or unordered.
*
* \ingroup CPP_MTAPI
* \ingroup CPP_TASKS
*/
class Queue {
public:
......@@ -110,7 +110,7 @@ class Queue {
mtapi_queue_hndl_t handle_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_QUEUE_H_
#endif // EMBB_TASKS_QUEUE_H_
......@@ -24,19 +24,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_TASK_H_
#define EMBB_MTAPI_TASK_H_
#ifndef EMBB_TASKS_TASK_H_
#define EMBB_TASKS_TASK_H_
#include <embb/mtapi/c/mtapi.h>
#include <embb/mtapi/action.h>
#include <embb/tasks/action.h>
namespace embb {
namespace mtapi {
namespace tasks {
/**
* A Task represents a running Action.
*
* \ingroup CPP_MTAPI
* \ingroup CPP_TASKS
*/
class Task {
public:
......@@ -109,7 +109,7 @@ class Task {
mtapi_task_hndl_t handle_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_TASK_H_
#endif // EMBB_TASKS_TASK_H_
......@@ -24,18 +24,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_TASKCONTEXT_H_
#define EMBB_MTAPI_TASKCONTEXT_H_
#ifndef EMBB_TASKS_TASK_CONTEXT_H_
#define EMBB_TASKS_TASK_CONTEXT_H_
#include <embb/mtapi/c/mtapi.h>
namespace embb {
namespace mtapi {
namespace tasks {
/**
* Provides information about the status of the currently running Task.
*
* \ingroup CPP_MTAPI
* \ingroup CPP_TASKS
*/
class TaskContext {
public:
......@@ -72,7 +72,7 @@ class TaskContext {
mtapi_task_context_t * context_;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // EMBB_MTAPI_TASKCONTEXT_H_
#endif // EMBB_TASKS_TASK_CONTEXT_H_
......@@ -24,32 +24,30 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef EMBB_MTAPI_MTAPI_H_
#define EMBB_MTAPI_MTAPI_H_
#ifndef EMBB_TASKS_TASKS_H_
#define EMBB_TASKS_TASKS_H_
/**
* \defgroup CPP_MTAPI MTAPI
* C++ wrapper around C implementation of MTAPI.
* For a description of the basic concepts, see the
* \ref C_MTAPI "C implementation of MTAPI".
* \defgroup CPP_TASKS Tasks
* Simple task management based on MTAPI.
* \ingroup CPP
*/
#include <embb/mtapi/internal/cmake_config.h>
#include <embb/tasks/internal/cmake_config.h>
#define MTAPI_CPP_TASK_JOB 1
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
#define MTAPI_CPP_AUTOMATIC_DOMAIN_ID 1
#define MTAPI_CPP_AUTOMATIC_NODE_ID 1
#define TASKS_CPP_JOB 1
#if TASKS_CPP_AUTOMATIC_INITIALIZE
#define TASKS_CPP_AUTOMATIC_DOMAIN_ID 1
#define TASKS_CPP_AUTOMATIC_NODE_ID 1
#endif
#include <embb/mtapi/execution_policy.h>
#include <embb/mtapi/action.h>
#include <embb/mtapi/continuation.h>
#include <embb/mtapi/group.h>
#include <embb/mtapi/node.h>
#include <embb/mtapi/queue.h>
#include <embb/mtapi/task.h>
#include <embb/mtapi/taskcontext.h>
#include <embb/tasks/execution_policy.h>
#include <embb/tasks/action.h>
#include <embb/tasks/continuation.h>
#include <embb/tasks/group.h>
#include <embb/tasks/node.h>
#include <embb/tasks/queue.h>
#include <embb/tasks/task.h>
#include <embb/tasks/task_context.h>
#endif // EMBB_MTAPI_MTAPI_H_
#endif // EMBB_TASKS_TASKS_H_
......@@ -28,12 +28,12 @@
#include <embb/base/memory_allocation.h>
#include <embb/base/function.h>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
#include <continuationstage.h>
namespace embb {
namespace mtapi {
namespace tasks {
Continuation::Continuation(Action action) {
first_ = last_ = embb::base::Allocation::New<ContinuationStage>();
......@@ -50,10 +50,10 @@ Continuation::~Continuation() {
}
void Continuation::ExecuteContinuation(TaskContext &) {
mtapi::ContinuationStage * stage = first_;
mtapi::Node & node = mtapi::Node::GetInstance();
ContinuationStage * stage = first_;
Node & node = Node::GetInstance();
while (NULL != stage) {
mtapi::Task task = node.Spawn(stage->action);
Task task = node.Spawn(stage->action);
task.Wait(MTAPI_INFINITE);
stage = stage->next;
}
......@@ -61,7 +61,7 @@ void Continuation::ExecuteContinuation(TaskContext &) {
// delete stages
stage = first_;
while (NULL != stage) {
mtapi::ContinuationStage * next = stage->next;
ContinuationStage * next = stage->next;
embb::base::Allocation::Delete(stage);
stage = next;
}
......@@ -90,5 +90,5 @@ Task Continuation::Spawn(ExecutionPolicy execution_policy) {
ExecutionPolicy(execution_policy)));
}
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -24,20 +24,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MTAPI_CPP_SRC_CONTINUATIONSTAGE_H_
#define MTAPI_CPP_SRC_CONTINUATIONSTAGE_H_
#ifndef TASKS_CPP_SRC_CONTINUATIONSTAGE_H_
#define TASKS_CPP_SRC_CONTINUATIONSTAGE_H_
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
namespace embb {
namespace mtapi {
namespace tasks {
struct ContinuationStage {
mtapi::Action action;
Action action;
ContinuationStage * next;
};
} // namespace mtapi
} // namespace tasks
} // namespace embb
#endif // MTAPI_CPP_SRC_CONTINUATIONSTAGE_H_
#endif // TASKS_CPP_SRC_CONTINUATIONSTAGE_H_
......@@ -24,14 +24,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <embb/mtapi/execution_policy.h>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/execution_policy.h>
#include <embb/tasks/tasks.h>
#include <embb/base/exceptions.h>
#include <embb/base/c/internal/bitset.h>
#include <cassert>
namespace embb {
namespace mtapi {
namespace tasks {
ExecutionPolicy::ExecutionPolicy() :
priority_(DefaultPriority) {
......@@ -120,5 +120,5 @@ mtapi_uint_t ExecutionPolicy::GetPriority() const {
const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0;
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -28,10 +28,10 @@
#include <cassert>
#include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
namespace embb {
namespace mtapi {
namespace tasks {
Group::Group() {
Create();
......@@ -92,5 +92,5 @@ mtapi_status_t Group::WaitAll(mtapi_timeout_t timeout) {
return status;
}
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -31,22 +31,22 @@
#include <embb/base/memory_allocation.h>
#include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h>
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
#include <embb/tasks/tasks.h>
#if TASKS_CPP_AUTOMATIC_INITIALIZE
#include <embb/base/mutex.h>
#endif
namespace {
static embb::mtapi::Node * node_instance = NULL;
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
static embb::tasks::Node * node_instance = NULL;
#if TASKS_CPP_AUTOMATIC_INITIALIZE
static embb::base::Mutex init_mutex;
#endif
}
namespace embb {
namespace mtapi {
namespace tasks {
void Node::action_func(
const void* args,
......@@ -56,9 +56,9 @@ void Node::action_func(
const void* /*node_local_data*/,
mtapi_size_t /*node_local_data_size*/,
mtapi_task_context_t * context) {
mtapi::Action * action =
reinterpret_cast<mtapi::Action*>(const_cast<void*>(args));
mtapi::TaskContext task_context(context);
Action * action =
reinterpret_cast<Action*>(const_cast<void*>(args));
TaskContext task_context(context);
(*action)(task_context);
embb::base::Allocation::Delete(action);
}
......@@ -76,7 +76,7 @@ Node::Node(
}
core_count_ = info.hardware_concurrency;
worker_thread_count_ = embb_core_set_count(&attr->core_affinity);
action_handle_ = mtapi_action_create(MTAPI_CPP_TASK_JOB, action_func,
action_handle_ = mtapi_action_create(TASKS_CPP_JOB, action_func,
MTAPI_NULL, 0, MTAPI_NULL, &status);
if (MTAPI_SUCCESS != status) {
EMBB_THROW(embb::base::ErrorException,
......@@ -201,12 +201,12 @@ bool Node::IsInitialized() {
}
Node & Node::GetInstance() {
#if MTAPI_CPP_AUTOMATIC_INITIALIZE
#if TASKS_CPP_AUTOMATIC_INITIALIZE
if (!IsInitialized()) {
init_mutex.Lock();
if (!IsInitialized()) {
Node::Initialize(
MTAPI_CPP_AUTOMATIC_DOMAIN_ID, MTAPI_CPP_AUTOMATIC_NODE_ID);
TASKS_CPP_AUTOMATIC_DOMAIN_ID, TASKS_CPP_AUTOMATIC_NODE_ID);
atexit(Node::Finalize);
}
init_mutex.Unlock();
......@@ -217,7 +217,7 @@ Node & Node::GetInstance() {
return *node_instance;
} else {
EMBB_THROW(embb::base::ErrorException,
"mtapi::Node is not initialized");
"embb::tasks::Node is not initialized");
}
#endif
}
......@@ -228,7 +228,7 @@ void Node::Finalize() {
node_instance = NULL;
} else {
EMBB_THROW(embb::base::ErrorException,
"mtapi::Node is not initialized");
"embb::tasks::Node is not initialized");
}
}
......@@ -270,5 +270,5 @@ Continuation Node::First(Action action) {
return Continuation(action);
}
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -27,10 +27,10 @@
#include <cassert>
#include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
namespace embb {
namespace mtapi {
namespace tasks {
Queue::Queue(mtapi_uint_t priority, bool ordered) {
mtapi_status_t status;
......@@ -51,7 +51,7 @@ Queue::Queue(mtapi_uint_t priority, bool ordered) {
assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status);
mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status);
handle_ = mtapi_queue_create(MTAPI_QUEUE_ID_NONE, job, &attr, &status);
if (MTAPI_SUCCESS != status) {
......@@ -86,5 +86,5 @@ Task Queue::Spawn(Group const * group, Action action) {
return Task(action, handle_, group->handle_);
}
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -29,10 +29,10 @@
#include <embb/base/memory_allocation.h>
#include <embb/base/exceptions.h>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
namespace embb {
namespace mtapi {
namespace tasks {
Task::Task() {
handle_.id = 0;
......@@ -59,7 +59,7 @@ Task::Task(
assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status);
mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status);
Action* holder = embb::base::Allocation::New<Action>(action);
handle_ = mtapi_task_start(MTAPI_TASK_ID_NONE, job,
......@@ -86,7 +86,7 @@ Task::Task(
assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status);
mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status);
Action* holder = embb::base::Allocation::New<Action>(action);
handle_ = mtapi_task_start(MTAPI_TASK_ID_NONE, job,
......@@ -114,7 +114,7 @@ Task::Task(
assert(MTAPI_SUCCESS == status);
mtapi_domain_t domain_id = mtapi_domain_id_get(&status);
assert(MTAPI_SUCCESS == status);
mtapi_job_hndl_t job = mtapi_job_get(MTAPI_CPP_TASK_JOB, domain_id, &status);
mtapi_job_hndl_t job = mtapi_job_get(TASKS_CPP_JOB, domain_id, &status);
assert(MTAPI_SUCCESS == status);
Action* holder = embb::base::Allocation::New<Action>(action);
void * idptr = MTAPI_NULL;
......@@ -216,5 +216,5 @@ void Task::Cancel() {
assert(MTAPI_SUCCESS == status);
}
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -26,10 +26,10 @@
#include <cassert>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
namespace embb {
namespace mtapi {
namespace tasks {
TaskContext::TaskContext(mtapi_task_context_t * task_context)
: context_(task_context) {
......@@ -57,5 +57,5 @@ void TaskContext::SetStatus(mtapi_status_t error_code) {
assert(MTAPI_SUCCESS == status);
}
} // namespace mtapi
} // namespace tasks
} // namespace embb
......@@ -28,12 +28,12 @@
#include <iostream>
#include <mtapi_cpp_test_task.h>
#include <mtapi_cpp_test_group.h>
#include <mtapi_cpp_test_queue.h>
#include <tasks_cpp_test_task.h>
#include <tasks_cpp_test_group.h>
#include <tasks_cpp_test_queue.h>
PT_MAIN("MTAPI C++") {
PT_MAIN("TASKS") {
PT_RUN(TaskTest);
PT_RUN(GroupTest);
PT_RUN(QueueTest);
......
......@@ -24,13 +24,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MTAPI_CPP_TEST_MTAPI_CPP_TEST_CONFIG_H_
#define MTAPI_CPP_TEST_MTAPI_CPP_TEST_CONFIG_H_
#ifndef TASKS_CPP_TEST_TASKS_CPP_TEST_CONFIG_H_
#define TASKS_CPP_TEST_TASKS_CPP_TEST_CONFIG_H_
#include <partest/partest.h>
#include <embb/mtapi/mtapi.h>
#include <embb/tasks/tasks.h>
#define THIS_DOMAIN_ID 1
#define THIS_NODE_ID 1
#endif // MTAPI_CPP_TEST_MTAPI_CPP_TEST_CONFIG_H_
#endif // TASKS_CPP_TEST_TASKS_CPP_TEST_CONFIG_H_
......@@ -26,8 +26,8 @@
#include <iostream>
#include <mtapi_cpp_test_config.h>
#include <mtapi_cpp_test_group.h>
#include <tasks_cpp_test_config.h>
#include <tasks_cpp_test_group.h>
#include <embb/base/c/memory_allocation.h>
......@@ -38,7 +38,7 @@ struct result_example_struct {
typedef struct result_example_struct result_example_t;
static void testGroupAction(embb::mtapi::TaskContext & /*context*/) {
static void testGroupAction(embb::tasks::TaskContext & /*context*/) {
//std::cout << "testGroupAction on core " <<
// context.GetCurrentCoreNumber() << std::endl;
}
......@@ -47,17 +47,17 @@ static void testDoSomethingElse() {
}
GroupTest::GroupTest() {
CreateUnit("mtapi group test").Add(&GroupTest::TestBasic, this);
CreateUnit("tasks_cpp group test").Add(&GroupTest::TestBasic, this);
}
void GroupTest::TestBasic() {
//std::cout << "running testGroup..." << std::endl;
embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::tasks::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance();
embb::mtapi::Group & group = node.CreateGroup();
embb::mtapi::Task task;
embb::tasks::Node & node = embb::tasks::Node::GetInstance();
embb::tasks::Group & group = node.CreateGroup();
embb::tasks::Task task;
//std::cout << "wait all..." << std::endl;
......@@ -81,8 +81,8 @@ void GroupTest::TestBasic() {
node.DestroyGroup(group);
embb::mtapi::Node::Finalize();
embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0);
PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u);
//std::cout << "...done" << std::endl << std::endl;
}
......@@ -24,8 +24,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MTAPI_CPP_TEST_MTAPI_CPP_TEST_GROUP_H_
#define MTAPI_CPP_TEST_MTAPI_CPP_TEST_GROUP_H_
#ifndef TASKS_CPP_TEST_TASKS_CPP_TEST_GROUP_H_
#define TASKS_CPP_TEST_TASKS_CPP_TEST_GROUP_H_
#include <partest/partest.h>
......@@ -37,4 +37,4 @@ class GroupTest : public partest::TestCase {
void TestBasic();
};
#endif // MTAPI_CPP_TEST_MTAPI_CPP_TEST_GROUP_H_
#endif // TASKS_CPP_TEST_TASKS_CPP_TEST_GROUP_H_
......@@ -26,8 +26,8 @@
#include <cstdlib>
#include <mtapi_cpp_test_config.h>
#include <mtapi_cpp_test_queue.h>
#include <tasks_cpp_test_config.h>
#include <tasks_cpp_test_queue.h>
#include <embb/base/c/memory_allocation.h>
......@@ -35,7 +35,7 @@
#define TASK_TEST_ID 23
#define QUEUE_TEST_ID 17
static void testQueueAction(embb::mtapi::TaskContext & /*context*/) {
static void testQueueAction(embb::tasks::TaskContext & /*context*/) {
//std::cout << "testQueueAction on core " <<
// context.GetCurrentCoreNumber() << std::endl;
}
......@@ -44,18 +44,18 @@ static void testDoSomethingElse() {
}
QueueTest::QueueTest() {
CreateUnit("mtapi queue test").Add(&QueueTest::TestBasic, this);
CreateUnit("tasks_cpp queue test").Add(&QueueTest::TestBasic, this);
}
void QueueTest::TestBasic() {
//std::cout << "running testQueue..." << std::endl;
embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::tasks::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance();
embb::mtapi::Queue & queue = node.CreateQueue(0, false);
embb::tasks::Node & node = embb::tasks::Node::GetInstance();
embb::tasks::Queue & queue = node.CreateQueue(0, false);
embb::mtapi::Task task = queue.Spawn(testQueueAction);
embb::tasks::Task task = queue.Spawn(testQueueAction);
testDoSomethingElse();
......@@ -63,8 +63,8 @@ void QueueTest::TestBasic() {
node.DestroyQueue(queue);
embb::mtapi::Node::Finalize();
embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0);
PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u);
//std::cout << "...done" << std::endl << std::endl;
}
......@@ -24,8 +24,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MTAPI_CPP_TEST_MTAPI_CPP_TEST_QUEUE_H_
#define MTAPI_CPP_TEST_MTAPI_CPP_TEST_QUEUE_H_
#ifndef TASKS_CPP_TEST_TASKS_CPP_TEST_QUEUE_H_
#define TASKS_CPP_TEST_TASKS_CPP_TEST_QUEUE_H_
#include <partest/partest.h>
......@@ -37,4 +37,4 @@ class QueueTest : public partest::TestCase {
void TestBasic();
};
#endif // MTAPI_CPP_TEST_MTAPI_CPP_TEST_QUEUE_H_
#endif // TASKS_CPP_TEST_TASKS_CPP_TEST_QUEUE_H_
......@@ -28,8 +28,8 @@
#include <string>
#include <cassert>
#include <mtapi_cpp_test_config.h>
#include <mtapi_cpp_test_task.h>
#include <tasks_cpp_test_config.h>
#include <tasks_cpp_test_task.h>
#include <embb/base/c/memory_allocation.h>
......@@ -39,7 +39,7 @@
static void testTaskAction(
char const * msg,
std::string * output,
embb::mtapi::TaskContext & /*context*/) {
embb::tasks::TaskContext & /*context*/) {
//std::cout << "testTaskAction " << msg << " on core " <<
// context.GetCurrentCoreNumber() << std::endl;
*output = msg;
......@@ -47,11 +47,11 @@ static void testTaskAction(
static void testRecursiveTaskAction(
int * value,
embb::mtapi::TaskContext & /*context*/) {
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance();
embb::tasks::TaskContext & /*context*/) {
embb::tasks::Node & node = embb::tasks::Node::GetInstance();
*value = *value + 1;
if (*value < 1000) {
embb::mtapi::Task task = node.Spawn(
embb::tasks::Task task = node.Spawn(
embb::base::Bind(
testRecursiveTaskAction, value, embb::base::Placeholder::_1));
task.Wait(MTAPI_INFINITE);
......@@ -59,7 +59,7 @@ static void testRecursiveTaskAction(
PT_EXPECT(*value == 1000);
}
static void testErrorTaskAction(embb::mtapi::TaskContext & context) {
static void testErrorTaskAction(embb::tasks::TaskContext & context) {
context.SetStatus(MTAPI_ERR_ACTION_FAILED);
}
......@@ -67,17 +67,17 @@ static void testDoSomethingElse() {
}
TaskTest::TaskTest() {
CreateUnit("mtapi_cpp task test").Add(&TaskTest::TestBasic, this);
CreateUnit("tasks_cpp task test").Add(&TaskTest::TestBasic, this);
}
void TaskTest::TestBasic() {
//std::cout << "running testTask..." << std::endl;
embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::tasks::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID);
embb::mtapi::Node & node = embb::mtapi::Node::GetInstance();
embb::tasks::Node & node = embb::tasks::Node::GetInstance();
embb::mtapi::ExecutionPolicy policy(false);
embb::tasks::ExecutionPolicy policy(false);
PT_EXPECT_EQ(policy.GetAffinity(), 0u);
PT_EXPECT_EQ(policy.GetPriority(), 0u);
policy.AddWorker(0u);
......@@ -90,7 +90,7 @@ void TaskTest::TestBasic() {
PT_EXPECT_EQ(policy.IsSetWorker(1), true);
std::string test;
embb::mtapi::Task task = node.Spawn(
embb::tasks::Task task = node.Spawn(
embb::base::Bind(
testTaskAction, "simple", &test, embb::base::Placeholder::_1));
testDoSomethingElse();
......@@ -129,7 +129,7 @@ void TaskTest::TestBasic() {
status = task.Wait(MTAPI_INFINITE);
PT_EXPECT(MTAPI_ERR_ACTION_FAILED == status);
embb::mtapi::Node::Finalize();
embb::tasks::Node::Finalize();
PT_EXPECT(embb_get_bytes_allocated() == 0);
//std::cout << "...done" << std::endl << std::endl;
......
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