diff --git a/.travis.yml b/.travis.yml index 055ea59..bcf3c95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # SPDX-License-Identifier: BSD-2-Clause language: cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c1c673..6d7fa45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,52 @@ Embedded Multicore Building Blocks (EMB²) ========================================= +Version 0.2.2 +------------- + +### Bug fixes: +- Fixed 64bit problem in atomics +- Fixed bug in dataflow_cpp causing network to hang +- Fixed bug in conversion of core_set +- Fixed fetch-and-add implementation to support armv7-a +- Fixed missing freeing of mutex attributes in case of error +- Fixed bug where closure was allocated with Allocation::New but deleted with operator delete +- Fixed inconsistent naming of unit test cases +- Fixed memory allocation in hazard pointer implementation by replacing calls to new and delete with EMB²-specific functions +- Fixed memory leak in tests for containers +- Fixed affinity implementation for FreeBSD + +### Changes and improvements: +- Added checks for memory leaks in tests +- Added block size support in MergeSort +- Renamed all platform specific defines to EMBB_PLATFORM_* +- Changed all checks for platform specific defines to checks for EMBB_* defines +- Replaced C++11 initializer lists in examples with C++03 compliant statements +- Extended unit tests for MPMC queue with checks for relative order +- Added check for result of pthread_attr_destroy +- Added assert in embb_tss_get +- Moved ExecutionPolicy from algorithms to mtapi_cpp, removed Affinity + +### Features: +- None + +### Build system: +- Removed cppcheck warnings +- Removed cpplint warnings + +### Documentation: +- Improved documentation of default values and priorities +- Revised template argument names in base_cpp and containers_cpp +- Moved ExecutionPolicy to CPP_MTAPI and Identity to CPP_ALGORITHMS Doxygen group +- Fixed description of token limit in tutorial +- Added Clang support to README +- Mentioned the ability to cross compile in README +- Added link to release files in README +- Minor corrections in README +- Updated copyright notice +- Changed year in tutorial.tex to 2015 + + Version 0.2.1 ------------- diff --git a/CMakeCommon/CheckEnableTests.cmake b/CMakeCommon/CheckEnableTests.cmake index b1dddfd..7a28984 100644 --- a/CMakeCommon/CheckEnableTests.cmake +++ b/CMakeCommon/CheckEnableTests.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/CMakeCommon/CopyInstallFiles.cmake b/CMakeCommon/CopyInstallFiles.cmake index 23e57e0..321b62e 100644 --- a/CMakeCommon/CopyInstallFiles.cmake +++ b/CMakeCommon/CopyInstallFiles.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/CMakeCommon/CreateDoxygenDocumentationTarget.cmake b/CMakeCommon/CreateDoxygenDocumentationTarget.cmake index dedac2e..1e04009 100644 --- a/CMakeCommon/CreateDoxygenDocumentationTarget.cmake +++ b/CMakeCommon/CreateDoxygenDocumentationTarget.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/CMakeCommon/GroupSourcesMSVC.cmake b/CMakeCommon/GroupSourcesMSVC.cmake index 2568d00..e74470b 100644 --- a/CMakeCommon/GroupSourcesMSVC.cmake +++ b/CMakeCommon/GroupSourcesMSVC.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/CMakeCommon/SetCompilerFlags.cmake b/CMakeCommon/SetCompilerFlags.cmake index 1aeba45..dc07374 100644 --- a/CMakeCommon/SetCompilerFlags.cmake +++ b/CMakeCommon/SetCompilerFlags.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/CMakeCommon/SetInstallPaths.cmake b/CMakeCommon/SetInstallPaths.cmake index 2b4cfda..ae498bb 100644 --- a/CMakeCommon/SetInstallPaths.cmake +++ b/CMakeCommon/SetInstallPaths.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/CMakeLists.txt b/CMakeLists.txt index 78acdc5..252897f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ cmake_minimum_required (VERSION 2.8.9) # Version number set (EMBB_BASE_VERSION_MAJOR 0) set (EMBB_BASE_VERSION_MINOR 2) -set (EMBB_BASE_VERSION_PATCH 1) +set (EMBB_BASE_VERSION_PATCH 2) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING @@ -54,6 +54,7 @@ option(BUILD_EXAMPLES "Specify whether examples should be built" OFF) option(USE_EXCEPTIONS "Specify whether exceptions should be activated in C++" ON) option(INSTALL_DOCS "Specify whether Doxygen docs should be installed" ON) option(WARNINGS_ARE_ERRORS "Specify whether warnings should be treated as errors" OFF) +option(USE_AUTOMATIC_INITIALIZATION "Specify whether the MTAPI C++ interface, algorithms and dataflow should automatically intialize the MTAPI node if no explicit initialization is present" ON) ## LOCAL INSTALLATION OF SUBPROJECT BINARIES # diff --git a/COPYING.md b/COPYING.md index ad0a9ac..da45e32 100644 --- a/COPYING.md +++ b/COPYING.md @@ -1,4 +1,4 @@ -Embedded Multicore Building Blocks (EMB²) +Embedded Multicore Building Blocks (EMB²) ========================================= Overview @@ -13,7 +13,7 @@ license (see file include\embb\mtapi\c\mtapi.h). License ------- -Copyright (c) 2014, Siemens AG. All rights reserved. +Copyright (c) 2014-2015, Siemens AG. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -35,4 +35,4 @@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index e5d88ca..f3c8f35 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,9 @@ data structures for storing object in an organized and thread-safe way. Build and Installation ---------------------- -Note: It is recommended to build from a packaged release file and not from a -snapshot of the repository in order to get the documentation and the examples -out-of-the box. +Note: It is recommended to build from a release file and not from a repository +snapshot in order to get the documentation and the examples out-of-the box. +The release files can be found at https://github.com/siemens/embb/releases. EMB² is built using CMake (version 2.8.9 or higher). CMake is a build file generator which allows to abstract from the concrete build tools. To generate @@ -159,11 +159,24 @@ use: cmake .. -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang +In the same way you may cross compile to another platform. For example, to cross +compile to ARM Linux using GCC, you need to specify the cross compiler itself and +the target architecture as an argument to the compiler: + + cmake .. -DCMAKE_CXX_COMPILER=arm-linux-gnueabi-gcc++ + -DCMAKE_CXX_FLAGS=-march=armv7-a + -DCMAKE_C_COMPILER=arm-linux-gnueabi-gcc + -DCMAKE_C_FLAGS=-march=armv7-a + EMB² can be built with and without C++ exception handling, which has to be specified on build file generation. When exceptions are turned off, an error message is emitted and the program aborts in case of an exception within EMB². To disable exceptions, add the option -DUSE_EXCEPTIONS=OFF. +Similarly, automatic initialization of the task scheduler by the MTAPI C++ +interface can be disabled with -DUSE_AUTOMATIC_INITIALIZATION=OFF. This way, +unexpected delays after startup can be avoided, e.g. for timing measurements. + The tutorial of EMB² comes with example source files in doc/examples/. These can be built with the other source files using CMake option -DBUILD_EXAMPLES=ON in the generation step. Note, however, that the examples use C++11 features and @@ -175,6 +188,10 @@ For a Linux Debug build with exception handling, type cmake -G "Unix Makefiles" .. -DCMAKE_BUILD_TYPE=Debug +For a default Linux build without automatic MTAPI C++ initialization, type + + cmake .. -DUSE_AUTOMATIC_INITIALIZATION=OFF + For a Windows build (VS 2013, x86) without exception handling, type cmake -G "Visual Studio 12" .. -DUSE_EXCEPTIONS=OFF @@ -275,9 +292,13 @@ The C header files can be included as follows: Documentation ------------- -EMB² comes with a tutorial, example programs, and an HTML reference -documentation describing the APIs, which can be found in the "doc" folder. -The root document of the HTML reference is "doc/reference/index.html". +The release files of EMB² come with a tutorial, example programs, and a +reference manual (HTML) describing the APIs. All documentation is contained in +the "doc" folder. The root document of the HTML reference is +"doc/reference/index.html". Note that generated documentation files are not +under version control and hence not contained in the repository. As mentioned +above, it is therefore recommended to download one of the packaged release +files in order to have ready-to-use documentation. Code Quality @@ -310,6 +331,42 @@ The EMB² team welcomes all kinds of contributions, preferably as pull requests or patches via the development mailing lists (see above). If possible, please refer to a current snapshot of the development branch. +EMB² is supposed to be easily portable to platforms unsupported so far. Almost +all platform specific code is located in the base_c and base_cpp modules. All +existing platform specific code is fenced by EMBB_PLATFORM_* defines. + +To distinguish between compilers, EMB² currently uses the following defines: + + - EMBB_PLATFORM_COMPILER_GNUC + - EMBB_PLATFORM_COMPILER_MSVC + - EMBB_PLATFORM_COMPILER_UNKNOWN + +Different architectures are distinguished using: + + - EMBB_PLATFORM_ARCH_X86 + - EMBB_PLATFORM_ARCH_X86_32 + - EMBB_PLATFORM_ARCH_X86_64 + - EMBB_PLATFORM_ARCH_ARM + - EMBB_PLATFORM_ARCH_UNKNOWN + +Threading APIs are switched by: + + - EMBB_PLATFORM_THREADING_WINTHREADS + - EMBB_PLATFORM_THREADING_POSIXTHREADS + +Please use these defines for new platform specific code. If additional defines +are needed, they can be defined in the config.h or cmake_config.h.in files. + + +Important Notes +--------------- + +- The MTAPI C++ interface supports automatic initialization, which allows for + easy usage of the MTAPI C++, Algorithms, and Dataflow components. For + performance measurements, explicit initialization is strongly recommended + since the measurements will otherwise include the initialization time of + MTAPI. + Links ----- diff --git a/algorithms_cpp/CMakeLists.txt b/algorithms_cpp/CMakeLists.txt index b5ce17f..bf9f799 100644 --- a/algorithms_cpp/CMakeLists.txt +++ b/algorithms_cpp/CMakeLists.txt @@ -17,7 +17,8 @@ include_directories(${EMBB_ALGORITHMS_CPP_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../base_cpp/include ${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include - ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_cpp/include) + ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_cpp/include + ${CMAKE_CURRENT_BINARY_DIR}/../mtapi_cpp/include) add_library(embb_algorithms_cpp ${EMBB_ALGORITHMS_CPP_SOURCES} ${EMBB_ALGORITHMS_CPP_HEADERS}) diff --git a/algorithms_cpp/include/embb/algorithms/algorithms.h b/algorithms_cpp/include/embb/algorithms/algorithms.h index 56f3eb4..a4df292 100644 --- a/algorithms_cpp/include/embb/algorithms/algorithms.h +++ b/algorithms_cpp/include/embb/algorithms/algorithms.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,7 +34,6 @@ */ #include -#include #include #include #include diff --git a/algorithms_cpp/include/embb/algorithms/count.h b/algorithms_cpp/include/embb/algorithms/count.h index 7e9a9ea..90dae22 100644 --- a/algorithms_cpp/include/embb/algorithms/count.h +++ b/algorithms_cpp/include/embb/algorithms/count.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,7 +27,8 @@ #ifndef EMBB_ALGORITHMS_COUNT_H_ #define EMBB_ALGORITHMS_COUNT_H_ -#include +#include +#include namespace embb { namespace algorithms { @@ -55,7 +56,7 @@ namespace algorithms { * while the algorithm is executed. * \note No guarantee is given on the execution order of the comparison * operations. - * \see CountIf(), ExecutionPolicy + * \see CountIf(), embb::mtapi::ExecutionPolicy * \tparam RAI Random access iterator * \tparam ValueType Type of \c value that is compared to the elements in the * range using the \c operator==. @@ -70,8 +71,8 @@ typename std::iterator_traits::difference_type Count( const ValueType& value, /**< [IN] Value that the elements in the range are compared to using \c operator== */ - const ExecutionPolicy& policy = ExecutionPolicy(), - /**< [IN] ExecutionPolicy for the counting algorithm */ + const embb::mtapi::ExecutionPolicy& policy = embb::mtapi::ExecutionPolicy(), + /**< [IN] embb::mtapi::ExecutionPolicy for the counting algorithm */ size_t block_size = 0 /**< [IN] Lower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size @@ -95,7 +96,7 @@ typename std::iterator_traits::difference_type Count( * while the algorithm is executed. * \note No guarantee is given on the execution order of the comparison * function. - * \see Count(), ExecutionPolicy + * \see Count(), embb::mtapi::ExecutionPolicy * \tparam RAI Random access iterator * \tparam ComparisonFunction Unary predicate with argument of type * std::iterator_traits::value_type. @@ -110,8 +111,8 @@ typename std::iterator_traits::difference_type CountIf( ComparisonFunction comparison, /**< [IN] Unary predicate used to test the elements in the range. Elements for which \c comparison returns true are counted. */ - const ExecutionPolicy& policy = ExecutionPolicy(), - /**< [IN] ExecutionPolicy for the counting algorithm */ + const embb::mtapi::ExecutionPolicy& policy = embb::mtapi::ExecutionPolicy(), + /**< [IN] embb::mtapi::ExecutionPolicy for the counting algorithm */ size_t block_size = 0 /**< [IN] Lower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size @@ -124,6 +125,18 @@ typename std::iterator_traits::difference_type CountIf( #else // DOXYGEN /** + * Overload of above described Doxygen dummy. + */ +template +typename std::iterator_traits::difference_type Count( + RAI first, + RAI last, + const ValueType& value, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size + ); + +/** * Overload of above described Doxygen dummy with less arguments. */ template @@ -132,7 +145,7 @@ typename std::iterator_traits::difference_type Count( RAI last, const ValueType& value ) { - return Count(first, last, value, ExecutionPolicy(), 0); + return Count(first, last, value, embb::mtapi::ExecutionPolicy(), 0); } /** @@ -143,7 +156,7 @@ typename std::iterator_traits::difference_type Count( RAI first, RAI last, const ValueType& value, - const ExecutionPolicy& policy + const embb::mtapi::ExecutionPolicy& policy ) { return Count(first, last, value, policy, 0); } @@ -151,12 +164,12 @@ typename std::iterator_traits::difference_type Count( /** * Overload of above described Doxygen dummy. */ -template -typename std::iterator_traits::difference_type Count( +template +typename std::iterator_traits::difference_type CountIf( RAI first, RAI last, - const ValueType& value, - const ExecutionPolicy& policy, + ComparisonFunction comparison, + const embb::mtapi::ExecutionPolicy& policy, size_t block_size ); @@ -169,7 +182,7 @@ typename std::iterator_traits::difference_type CountIf( RAI last, ComparisonFunction comparison ) { - return CountIf(first, last, comparison, ExecutionPolicy(), 0); + return CountIf(first, last, comparison, embb::mtapi::ExecutionPolicy(), 0); } /** @@ -180,23 +193,11 @@ typename std::iterator_traits::difference_type CountIf( RAI first, RAI last, ComparisonFunction comparison, - const ExecutionPolicy& policy + const embb::mtapi::ExecutionPolicy& policy ) { return CountIf(first, last, comparison, policy, 0); } -/** - * Overload of above described Doxygen dummy. - */ -template -typename std::iterator_traits::difference_type CountIf( - RAI first, - RAI last, - ComparisonFunction comparison, - const ExecutionPolicy& policy, - size_t block_size - ); - #endif // else DOXYGEN /** diff --git a/algorithms_cpp/include/embb/algorithms/for_each.h b/algorithms_cpp/include/embb/algorithms/for_each.h index e775cff..7812949 100644 --- a/algorithms_cpp/include/embb/algorithms/for_each.h +++ b/algorithms_cpp/include/embb/algorithms/for_each.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,7 +27,7 @@ #ifndef EMBB_ALGORITHMS_FOR_EACH_H_ #define EMBB_ALGORITHMS_FOR_EACH_H_ -#include +#include namespace embb { namespace algorithms { @@ -53,7 +53,7 @@ namespace algorithms { * while the algorithm is executed. * \note No guarantee is given on the order in which the function is applied to * the elements. - * \see ExecutionPolicy, ZipIterator + * \see embb::mtapi::ExecutionPolicy, ZipIterator * \tparam RAI Random access iterator * \tparam Function Unary function with argument of type * std::iterator_traits::value_type. @@ -67,8 +67,8 @@ void ForEach( range */ Function unary, /**< [IN] Unary function applied to each element in the range */ - const ExecutionPolicy& policy = ExecutionPolicy(), - /**< [IN] ExecutionPolicy for the foreach loop execution */ + const embb::mtapi::ExecutionPolicy& policy = embb::mtapi::ExecutionPolicy(), + /**< [IN] embb::mtapi::ExecutionPolicy for the foreach loop execution */ size_t block_size = 0 /**< [IN] Lower bound for partitioning the range of elements into blocks that are treated in parallel. Partitioning of a block stops if its size @@ -81,16 +81,16 @@ void ForEach( #else // DOXYGEN /** - * Overload of above described Doxygen dummy with less arguments. + * Overload of above described Doxygen dummy. */ template void ForEach( RAI first, RAI last, - Function unary - ) { - ForEach(first, last, unary, ExecutionPolicy(), 0); -} + Function unary, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size + ); /** * Overload of above described Doxygen dummy with less arguments. @@ -99,23 +99,23 @@ template void ForEach( RAI first, RAI last, - Function unary, - const ExecutionPolicy& policy + Function unary ) { - ForEach(first, last, unary, policy, 0); + ForEach(first, last, unary, embb::mtapi::ExecutionPolicy(), 0); } /** - * Overload of above described Doxygen dummy. + * Overload of above described Doxygen dummy with less arguments. */ template void ForEach( RAI first, RAI last, Function unary, - const ExecutionPolicy& policy, - size_t block_size - ); + const embb::mtapi::ExecutionPolicy& policy + ) { + ForEach(first, last, unary, policy, 0); +} #endif // else DOXYGEN diff --git a/algorithms_cpp/include/embb/algorithms/identity.h b/algorithms_cpp/include/embb/algorithms/identity.h index b8d5ed3..26235ce 100644 --- a/algorithms_cpp/include/embb/algorithms/identity.h +++ b/algorithms_cpp/include/embb/algorithms/identity.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/include/embb/algorithms/internal/count-inl.h b/algorithms_cpp/include/embb/algorithms/internal/count-inl.h index c43e41b..51aa34a 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/count-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/count-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -37,42 +37,45 @@ namespace internal { template class ValueComparisonFunction{ public: - explicit ValueComparisonFunction(const ValueType &value) - :value_(value) {} - ValueComparisonFunction(const ValueComparisonFunction &other) - :value_(other.value_) {} + explicit ValueComparisonFunction(const ValueType& value) + : value_(value) {} + ValueComparisonFunction(const ValueComparisonFunction& other) + : value_(other.value_) {} template int operator()(ElementType element) { - if(element == value_) + if (element == value_) { return 1; - else + } else { return 0; + } } private: const ValueType &value_; - ValueComparisonFunction &operator=(const ValueComparisonFunction &other); + ValueComparisonFunction &operator=( + const ValueComparisonFunction& other); }; template class FunctionComparisonFunction{ public: explicit FunctionComparisonFunction(Function function) - :function_(function) {} + : function_(function) {} FunctionComparisonFunction(const FunctionComparisonFunction &other) - :function_(other.function_) {} + : function_(other.function_) {} template int operator()(ElementType element) { - if(function_(element)) + if (function_(element)) { return 1; - else + } else { return 0; + } } private: Function function_; - FunctionComparisonFunction &operator=(const FunctionComparisonFunction & - other); + FunctionComparisonFunction &operator=( + const FunctionComparisonFunction& other); }; } // namespace internal @@ -80,7 +83,7 @@ class FunctionComparisonFunction{ template typename std::iterator_traits::difference_type Count(RAI first, RAI last, const ValueType& value, - const ExecutionPolicy& policy, size_t block_size) { + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) { typedef typename std::iterator_traits::difference_type Difference; return Reduce(first, last, Difference(0), std::plus(), internal::ValueComparisonFunction(value), policy, @@ -90,7 +93,7 @@ typename std::iterator_traits::difference_type template typename std::iterator_traits::difference_type CountIf(RAI first, RAI last, ComparisonFunction comparison, - const ExecutionPolicy& policy, size_t block_size) { + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) { typedef typename std::iterator_traits::difference_type Difference; return Reduce(first, last, Difference(0), std::plus(), internal::FunctionComparisonFunction diff --git a/algorithms_cpp/include/embb/algorithms/internal/for_each-inl.h b/algorithms_cpp/include/embb/algorithms/internal/for_each-inl.h index f8263ad..a6cd15f 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/for_each-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/for_each-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -45,44 +45,54 @@ class ForEachFunctor { /** * Constructs a for-each functor with arguments. */ - ForEachFunctor(RAI first, RAI last, Function unary, - const ExecutionPolicy& policy, size_t block_size) - : first_(first), last_(last), unary_(unary), policy_(policy), - block_size_(block_size) { + ForEachFunctor(size_t chunk_first, size_t chunk_last, Function unary, + const embb::mtapi::ExecutionPolicy& policy, + const BlockSizePartitioner& partitioner) + : chunk_first_(chunk_first), chunk_last_(chunk_last), + unary_(unary), policy_(policy), partitioner_(partitioner) { } void Action(mtapi::TaskContext&) { - size_t distance = static_cast(std::distance(first_, last_)); - if (distance == 0) return; - if (distance <= block_size_) { // leaf case -> do work - for (RAI curIter(first_); curIter != last_; ++curIter) { - unary_(*curIter); + if (chunk_first_ == chunk_last_) { + // Leaf case, recursed to single chunk. Do work on chunk: + ChunkDescriptor chunk = partitioner_[chunk_first_]; + RAI first = chunk.GetFirst(); + RAI last = chunk.GetLast(); + for (RAI it = first; it != last; ++it) { + unary_(*it); } - } else { // recurse further - ChunkPartitioner partitioner(first_, last_, 2); - ForEachFunctor functorL(partitioner[0].GetFirst(), - partitioner[0].GetLast(), unary_, policy_, block_size_); - ForEachFunctor functorR(partitioner[1].GetFirst(), - partitioner[1].GetLast(), unary_, policy_, block_size_); - - mtapi::Node& node = mtapi::Node::GetInstance(); - mtapi::Task taskL = node.Spawn(mtapi::Action(base::MakeFunction( - functorL, &ForEachFunctor::Action), - policy_.GetAffinity()), policy_.GetPriority()); - mtapi::Task taskR = node.Spawn(mtapi::Action(base::MakeFunction( - functorR, &ForEachFunctor::Action), - policy_.GetAffinity()), policy_.GetPriority()); - taskL.Wait(MTAPI_INFINITE); - taskR.Wait(MTAPI_INFINITE); + } else { + // Recurse further: + size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2; + // Split chunks into left / right branches: + self_t functor_l(chunk_first_, + chunk_split_index, + unary_, policy_, partitioner_); + self_t functor_r(chunk_split_index + 1, + chunk_last_, + unary_, policy_, partitioner_); + mtapi::Task task_l = mtapi::Node::GetInstance().Spawn( + mtapi::Action( + base::MakeFunction(functor_l, &self_t::Action), + policy_)); + mtapi::Task task_r = mtapi::Node::GetInstance().Spawn( + mtapi::Action( + base::MakeFunction(functor_r, &self_t::Action), + policy_)); + task_l.Wait(MTAPI_INFINITE); + task_r.Wait(MTAPI_INFINITE); } } private: - RAI first_; - RAI last_; + typedef ForEachFunctor self_t; + + private: + size_t chunk_first_; + size_t chunk_last_; Function unary_; - const ExecutionPolicy& policy_; - size_t block_size_; + const embb::mtapi::ExecutionPolicy& policy_; + const BlockSizePartitioner& partitioner_; /** * Disables assignment. @@ -92,34 +102,44 @@ class ForEachFunctor { template void ForEachRecursive(RAI first, RAI last, Function unary, - const ExecutionPolicy& policy, size_t block_size) { + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) { typedef typename std::iterator_traits::difference_type difference_type; difference_type distance = std::distance(first, last); - assert(distance > 0); + if (distance == 0) { + return; + } + unsigned int num_cores = policy.GetCoreCount(); + if (num_cores == 0) { + EMBB_THROW(embb::base::ErrorException, "No cores in execution policy"); + } mtapi::Node& node = mtapi::Node::GetInstance(); // Determine actually used block size if (block_size == 0) { - block_size = (static_cast(distance) / node.GetCoreCount()); + block_size = (static_cast(distance) / num_cores); if (block_size == 0) { block_size = 1; } } - // Perform check of task number sufficiency + // Check task number sufficiency if (((distance / block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { - EMBB_THROW(embb::base::ErrorException, "Not enough MTAPI tasks available " - "to perform the parallel foreach loop"); + EMBB_THROW(embb::base::ErrorException, + "Not enough MTAPI tasks available for parallel foreach"); } - ForEachFunctor functor(first, last, unary, policy, block_size); + + BlockSizePartitioner partitioner(first, last, block_size); + ForEachFunctor functor(0, + partitioner.Size() - 1, + unary, policy, partitioner); mtapi::Task task = node.Spawn(mtapi::Action( base::MakeFunction(functor, &ForEachFunctor::Action), - policy.GetAffinity()), policy.GetPriority()); + policy)); task.Wait(MTAPI_INFINITE); } template void ForEachIteratorCheck(RAI first, RAI last, Function unary, - const ExecutionPolicy& policy, size_t block_size, + const embb::mtapi::ExecutionPolicy& policy, size_t block_size, std::random_access_iterator_tag) { return ForEachRecursive(first, last, unary, policy, block_size); } @@ -127,8 +147,8 @@ void ForEachIteratorCheck(RAI first, RAI last, Function unary, } // namespace internal template -void ForEach(RAI first, RAI last, Function unary, const ExecutionPolicy& policy, - size_t block_size) { +void ForEach(RAI first, const RAI last, Function unary, + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) { typename std::iterator_traits::iterator_category category; internal::ForEachIteratorCheck(first, last, unary, policy, block_size, category); diff --git a/algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h b/algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h index 10b1ca0..7e7b0f7 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/merge_sort-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -48,58 +48,112 @@ class MergeSortFunctor { public: typedef typename std::iterator_traits::value_type value_type; - MergeSortFunctor(RAI first, RAI last, RAITemp temporary_first, - ComparisonFunction comparison, const ExecutionPolicy& policy, - size_t block_size, const RAI& global_first, int depth) - : first_(first), last_(last), temp_first_(temporary_first), - comparison_(comparison), policy_(policy), block_size_(block_size), - global_first_(global_first), depth_(depth) { + MergeSortFunctor(size_t chunk_first, size_t chunk_last, + RAITemp temporary_first, ComparisonFunction comparison, + const embb::mtapi::ExecutionPolicy& policy, + const BlockSizePartitioner& partitioner, + const RAI& global_first, int depth) + : chunk_first_(chunk_first), chunk_last_(chunk_last), + temp_first_(temporary_first), + comparison_(comparison), policy_(policy), partitioner_(partitioner), + global_first_(global_first), depth_(depth) { } - void Action(mtapi::TaskContext& context) { - typedef typename std::iterator_traits::difference_type difference_type; - size_t distance = static_cast(std::distance(first_, last_)); + void Action(mtapi::TaskContext&) { + size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2; + if (chunk_first_ == chunk_last_) { + // Leaf case: recurse into a single chunk's elements: + ChunkDescriptor chunk = partitioner_[chunk_first_]; + MergeSortChunk(chunk.GetFirst(), chunk.GetLast(), depth_); + } else { + // Recurse further, split chunks: + self_t functor_l(chunk_first_, + chunk_split_index, + temp_first_, + comparison_, policy_, partitioner_, + global_first_, depth_ + 1); + self_t functor_r(chunk_split_index + 1, + chunk_last_, + temp_first_, + comparison_, policy_, partitioner_, + global_first_, depth_ + 1); + mtapi::Node& node = mtapi::Node::GetInstance(); + mtapi::Task task_l = node.Spawn( + mtapi::Action( + base::MakeFunction(functor_l, &self_t::Action), + policy_)); + mtapi::Task task_r = node.Spawn( + mtapi::Action( + base::MakeFunction(functor_r, &self_t::Action), + policy_)); + task_l.Wait(MTAPI_INFINITE); + task_r.Wait(MTAPI_INFINITE); + + ChunkDescriptor ck_f = partitioner_[chunk_first_]; + ChunkDescriptor ck_m = partitioner_[chunk_split_index + 1]; + ChunkDescriptor ck_l = partitioner_[chunk_last_]; + if(CloneBackToInput(depth_)) { + // Merge from temp into input: + difference_type first = std::distance(global_first_, ck_f.GetFirst()); + difference_type mid = std::distance(global_first_, ck_m.GetFirst()); + difference_type last = std::distance(global_first_, ck_l.GetLast()); + SerialMerge(temp_first_ + first, temp_first_ + mid, temp_first_ + last, + ck_f.GetFirst(), + comparison_); + } else { + // Merge from input into temp: + SerialMerge(ck_f.GetFirst(), ck_m.GetFirst(), ck_l.GetLast(), + temp_first_ + std::distance(global_first_, ck_f.GetFirst()), + comparison_); + } + } + } + + /** + * Serial merge sort of elements within a single chunk. + */ + void MergeSortChunk(RAI first, + RAI last, + int depth) { + size_t distance = static_cast( + std::distance(first, last)); if (distance <= 1) { - if(!CloneBackToInput() && distance != 0) { + // Leaf case: + if (!CloneBackToInput(depth) && distance != 0) { RAITemp temp_first = temp_first_; - temp_first += std::distance(global_first_, first_); - *temp_first = *first_; + std::advance(temp_first, std::distance(global_first_, first)); + *temp_first = *first; } return; } - internal::ChunkPartitioner partitioner(first_, last_, 2); - MergeSortFunctor functorL( - partitioner[0].GetFirst(), partitioner[0].GetLast(), temp_first_, - comparison_, policy_, block_size_, global_first_, depth_ + 1); - MergeSortFunctor functorR( - partitioner[1].GetFirst(), partitioner[1].GetLast(), temp_first_, - comparison_, policy_, block_size_, global_first_, depth_ + 1); - - if (distance <= block_size_) { - functorL.Action(context); - functorR.Action(context); + // Recurse further. Use binary split, ignoring chunk size as this + // recursion is serial and has leaf size 1: + ChunkPartitioner partitioner(first, last, 2); + ChunkDescriptor ck_l = partitioner[0]; + ChunkDescriptor ck_r = partitioner[1]; + MergeSortChunk( + ck_l.GetFirst(), + ck_l.GetLast(), + depth + 1); + MergeSortChunk( + ck_r.GetFirst(), + ck_r.GetLast(), + depth + 1); + if (CloneBackToInput(depth)) { + // Merge from temp into input: + difference_type d_first = std::distance(global_first_, ck_l.GetFirst()); + difference_type d_mid = std::distance(global_first_, ck_r.GetFirst()); + difference_type d_last = std::distance(global_first_, ck_r.GetLast()); + SerialMerge( + temp_first_ + d_first, temp_first_ + d_mid, temp_first_ + d_last, + ck_l.GetFirst(), + comparison_); } else { - mtapi::Node& node = mtapi::Node::GetInstance(); - mtapi::Task taskL = node.Spawn(mtapi::Action(base::MakeFunction(functorL, - &MergeSortFunctor::Action), - policy_.GetAffinity()), policy_.GetPriority()); - mtapi::Task taskR = node.Spawn(mtapi::Action(base::MakeFunction(functorR, - &MergeSortFunctor::Action), - policy_.GetAffinity()), policy_.GetPriority()); - taskL.Wait(MTAPI_INFINITE); - taskR.Wait(MTAPI_INFINITE); - } - - if(CloneBackToInput()) { - difference_type first = std::distance(global_first_, functorL.first_); - difference_type mid = std::distance(global_first_, functorR.first_); - difference_type last = std::distance(global_first_, functorR.last_); - SerialMerge(temp_first_ + first, temp_first_ + mid, - temp_first_ + last, functorL.first_, comparison_); - } else { - SerialMerge(functorL.first_, functorR.first_, functorR.last_, - temp_first_ + std::distance(global_first_, functorL.first_), - comparison_); + // Merge from input into temp: + SerialMerge( + ck_l.GetFirst(), ck_r.GetFirst(), ck_r.GetLast(), + temp_first_ + std::distance(global_first_, ck_l.GetFirst()), + comparison_); } } @@ -109,17 +163,22 @@ class MergeSortFunctor { * \return \c true if the temporary data range is input and the array to be * sorted is output. \c false, if the other way around. */ - bool CloneBackToInput() { - return depth_ % 2 == 0 ? true : false; + bool CloneBackToInput(int depth) { + return depth % 2 == 0 ? true : false; } private: - RAI first_; - RAI last_; + typedef MergeSortFunctor self_t; + typedef typename std::iterator_traits::difference_type + difference_type; + + private: + size_t chunk_first_; + size_t chunk_last_; RAITemp temp_first_; ComparisonFunction comparison_; - const ExecutionPolicy &policy_; - size_t block_size_; + const embb::mtapi::ExecutionPolicy& policy_; + const BlockSizePartitioner& partitioner_; const RAI& global_first_; int depth_; @@ -162,33 +221,51 @@ void MergeSort( RAI last, RAITemp temporary_first, ComparisonFunction comparison, - const ExecutionPolicy& policy, + const embb::mtapi::ExecutionPolicy& policy, size_t block_size ) { typedef typename std::iterator_traits::difference_type difference_type; - embb::mtapi::Node &node = embb::mtapi::Node::GetInstance(); - difference_type distance = last - first; - assert(distance >= 0); - + typedef internal::MergeSortFunctor + functor_t; + difference_type distance = std::distance(first, last); + if (distance == 0) { + EMBB_THROW(embb::base::ErrorException, "Distance for ForEach is 0"); + } + unsigned int num_cores = policy.GetCoreCount(); + if (num_cores == 0) { + EMBB_THROW(embb::base::ErrorException, "No cores in execution policy"); + } + // Determine actually used block size if (block_size == 0) { - block_size= (static_cast(distance) / node.GetCoreCount()); + block_size = (static_cast(distance) / num_cores); if (block_size == 0) block_size = 1; } - if (((distance/block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { + // Check task number sufficiency + if (((distance / block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { EMBB_THROW(embb::base::ErrorException, - "Not enough MTAPI tasks available to perform the merge sort"); + "Not enough MTAPI tasks available to perform merge sort"); } - internal::MergeSortFunctor functor( - first, last, temporary_first, comparison, policy, block_size, first, 0); - mtapi::Task task = node.Spawn(mtapi::Action(base::MakeFunction(functor, - &internal::MergeSortFunctor::Action), - policy.GetAffinity()), policy.GetPriority()); + internal::BlockSizePartitioner partitioner(first, last, block_size); + functor_t functor(0, + partitioner.Size() - 1, + temporary_first, + comparison, + policy, + partitioner, + first, + 0); + mtapi::Task task = embb::mtapi::Node::GetInstance().Spawn( + mtapi::Action( + base::MakeFunction(functor, &functor_t::Action), + policy)); task.Wait(MTAPI_INFINITE); } +// @NOTE: Why is there no type guard for RAI? + } // namespace algorithms } // namespace embb diff --git a/algorithms_cpp/include/embb/algorithms/internal/partition-inl.h b/algorithms_cpp/include/embb/algorithms/internal/partition-inl.h index a58ac48..434af54 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/partition-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/partition-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -71,8 +71,8 @@ const ChunkDescriptor ForwardIterator last_new = first_new; - if (index == elements_count / chunkSize) { - std::advance(last_new, elements_count % chunkSize); + if (index >= chunks - 1) { + last_new = last; } else { std::advance(last_new, chunkSize); } @@ -94,7 +94,7 @@ ChunkPartitioner::ChunkPartitioner(ForwardIterator first, } else { // if no concrete chunk size was given, use number of cores... mtapi::Node& node = mtapi::Node::GetInstance(); - size = node.GetCoreCount(); + size = node.GetWorkerThreadCount(); } elements_count = static_cast(std::distance(first, last)); diff --git a/algorithms_cpp/include/embb/algorithms/internal/partition.h b/algorithms_cpp/include/embb/algorithms/internal/partition.h index 83a3933..403cb65 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/partition.h +++ b/algorithms_cpp/include/embb/algorithms/internal/partition.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h b/algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h index 2e831d1..4ce296f 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/quick_sort-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -48,7 +48,7 @@ class QuickSortFunctor { * Constructs a functor. */ QuickSortFunctor(RAI first, RAI last, ComparisonFunction comparison, - const ExecutionPolicy& policy, size_t block_size) + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) : first_(first), last_(last), comparison_(comparison), policy_(policy), block_size_(block_size) { } @@ -87,7 +87,7 @@ class QuickSortFunctor { RAI first_; RAI last_; ComparisonFunction comparison_; - const ExecutionPolicy& policy_; + const embb::mtapi::ExecutionPolicy& policy_; size_t block_size_; typedef typename std::iterator_traits::difference_type Difference; @@ -190,12 +190,19 @@ class QuickSortFunctor { template void QuickSort(RAI first, RAI last, ComparisonFunction comparison, - const ExecutionPolicy& policy, size_t block_size) { + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) { embb::mtapi::Node& node = embb::mtapi::Node::GetInstance(); - typename std::iterator_traits::difference_type distance = last - first; - assert(distance > 0); + typedef typename std::iterator_traits::difference_type difference_type; + difference_type distance = std::distance(first, last); + if (distance <= 0) { + return; + } + unsigned int num_cores = policy.GetCoreCount(); + if (num_cores == 0) { + EMBB_THROW(embb::base::ErrorException, "No cores in execution policy"); + } if (block_size == 0) { - block_size= (static_cast(distance) / node.GetCoreCount()); + block_size = (static_cast(distance) / num_cores); if (block_size == 0) block_size = 1; } diff --git a/algorithms_cpp/include/embb/algorithms/internal/reduce-inl.h b/algorithms_cpp/include/embb/algorithms/internal/reduce-inl.h index d2a8178..e8fb907 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/reduce-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/reduce-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,47 +42,55 @@ template class ReduceFunctor { public: - ReduceFunctor(RAI first, RAI last, ReturnType neutral, + ReduceFunctor(size_t chunk_first, size_t chunk_last, + ReturnType neutral, ReductionFunction reduction, TransformationFunction transformation, - const ExecutionPolicy &policy, size_t block_size, + const embb::mtapi::ExecutionPolicy& policy, + const BlockSizePartitioner& partitioner, ReturnType& result) - : - first_(first), last_(last), neutral_(neutral), reduction_(reduction), - transformation_(transformation), policy_(policy), - block_size_(block_size), result_(result) { + : chunk_first_(chunk_first), chunk_last_(chunk_last), neutral_(neutral), + reduction_(reduction), transformation_(transformation), policy_(policy), + partitioner_(partitioner), result_(result) { } void Action(mtapi::TaskContext&) { - if (first_ == last_) { - return; - } - size_t distance = static_cast(std::distance(first_, last_)); - if (distance <= block_size_) { // leaf case -> do work + if (chunk_first_ == chunk_last_) { + // Leaf case, recursed to single chunk. Do work on chunk: + ChunkDescriptor chunk = partitioner_[chunk_first_]; + RAI first = chunk.GetFirst(); + RAI last = chunk.GetLast(); ReturnType result(neutral_); - for (RAI iter = first_; iter != last_; ++iter) { - result = reduction_(result, transformation_(*iter)); + for (RAI it = first; it != last; ++it) { + result = reduction_(result, transformation_(*it)); } result_ = result; - } else { // recurse further - internal::ChunkPartitioner partitioner(first_, last_, 2); + } else { + // Recurse further: + size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2; + // Split chunks into left / right branches: ReturnType result_l(neutral_); ReturnType result_r(neutral_); - ReduceFunctor functor_l(partitioner[0].GetFirst(), - partitioner[0].GetLast(), - neutral_, reduction_, transformation_, policy_, - block_size_, result_l); - ReduceFunctor functor_r(partitioner[1].GetFirst(), - partitioner[1].GetLast(), - neutral_, reduction_, transformation_, policy_, - block_size_, result_r); - mtapi::Node& node = mtapi::Node::GetInstance(); - mtapi::Task task_l = node.Spawn(mtapi::Action(base::MakeFunction( - functor_l, &ReduceFunctor::Action), policy_.GetAffinity()), - policy_.GetPriority()); - mtapi::Task task_r = node.Spawn(mtapi::Action(base::MakeFunction( - functor_r, &ReduceFunctor::Action), policy_.GetAffinity()), - policy_.GetPriority()); + self_t functor_l(chunk_first_, + chunk_split_index, + neutral_, reduction_, transformation_, policy_, + partitioner_, + result_l); + self_t functor_r(chunk_split_index + 1, + chunk_last_, + neutral_, reduction_, transformation_, policy_, + partitioner_, + result_r); + mtapi::Task task_l = mtapi::Node::GetInstance().Spawn( + mtapi::Action( + base::MakeFunction( + functor_l, &self_t::Action), + policy_)); + mtapi::Task task_r = mtapi::Node::GetInstance().Spawn( + mtapi::Action( + base::MakeFunction( + functor_r, &self_t::Action), + policy_)); task_l.Wait(MTAPI_INFINITE); task_r.Wait(MTAPI_INFINITE); result_ = reduction_(result_l, result_r); @@ -90,15 +98,23 @@ class ReduceFunctor { } private: - RAI first_; - RAI last_; + typedef ReduceFunctor self_t; + + private: + size_t chunk_first_; + size_t chunk_last_; ReturnType neutral_; ReductionFunction reduction_; TransformationFunction transformation_; - const ExecutionPolicy& policy_; - size_t block_size_; + const embb::mtapi::ExecutionPolicy& policy_; + const BlockSizePartitioner& partitioner_; ReturnType& result_; + /** + * Disables assignment and copy-construction. + */ ReduceFunctor& operator=(const ReduceFunctor&); ReduceFunctor(const ReduceFunctor&); }; @@ -108,31 +124,45 @@ template::difference_type difference_type; difference_type distance = std::distance(first, last); - assert(distance > 0); - + if (distance == 0) { + EMBB_THROW(embb::base::ErrorException, "Distance for Reduce is 0"); + } + unsigned int num_cores = policy.GetCoreCount(); + if (num_cores == 0) { + EMBB_THROW(embb::base::ErrorException, "No cores in execution policy"); + } mtapi::Node& node = mtapi::Node::GetInstance(); - size_t used_block_size = block_size; - if (used_block_size == 0) { - used_block_size = static_cast(distance) / node.GetCoreCount(); - if (used_block_size == 0) used_block_size = 1; + // Determine actually used block size + if (block_size == 0) { + block_size = (static_cast(distance) / num_cores); + if (block_size == 0) { + block_size = 1; + } } - - if (((distance / used_block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { + // Perform check of task number sufficiency + if (((distance / block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { EMBB_THROW(embb::base::ErrorException, "Number of computation tasks required in reduction would " "exceed MTAPI maximum number of tasks"); } - - ReturnType result = neutral; typedef ReduceFunctor Functor; - Functor functor(first, last, neutral, reduction, transformation, policy, - used_block_size, result); - mtapi::Task task = node.Spawn(mtapi::Action(base::MakeFunction( - functor, &Functor::Action), policy.GetAffinity()), policy.GetPriority()); + BlockSizePartitioner partitioner(first, last, block_size); + ReturnType result = neutral; + Functor functor(0, + partitioner.Size() - 1, + neutral, + reduction, transformation, + policy, + partitioner, + result); + mtapi::Task task = node.Spawn( + mtapi::Action(base::MakeFunction( + functor, &Functor::Action), policy)); task.Wait(MTAPI_INFINITE); return result; } @@ -142,7 +172,8 @@ template::iterator_category category; return internal::ReduceIteratorCheck(first, last, reduction, transformation, neutral, policy, block_size, category); diff --git a/algorithms_cpp/include/embb/algorithms/internal/scan-inl.h b/algorithms_cpp/include/embb/algorithms/internal/scan-inl.h index 95b65bb..3e645af 100644 --- a/algorithms_cpp/include/embb/algorithms/internal/scan-inl.h +++ b/algorithms_cpp/include/embb/algorithms/internal/scan-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include namespace embb { @@ -41,75 +41,79 @@ template class ScanFunctor { public: - ScanFunctor(RAIIn first, RAIIn last, RAIOut output_iterator, + ScanFunctor(size_t chunk_first, size_t chunk_last, RAIOut output_iterator, ReturnType neutral, ScanFunction scan, TransformationFunction transformation, - const ExecutionPolicy& policy, - size_t block_size, ReturnType* tree_values, size_t node_id, + const embb::mtapi::ExecutionPolicy& policy, + const BlockSizePartitioner& partitioner, + ReturnType* tree_values, size_t node_id, bool going_down) - : policy_(policy), first_(first), last_(last), + : policy_(policy), chunk_first_(chunk_first), chunk_last_(chunk_last), output_iterator_(output_iterator), scan_(scan), transformation_(transformation), - neutral_(neutral), block_size_(block_size), tree_values_(tree_values), + neutral_(neutral), partitioner_(partitioner), tree_values_(tree_values), node_id_(node_id), parent_value_(neutral), is_first_pass_(going_down) { } void Action(mtapi::TaskContext&) { - if (first_ == last_) { - return; - } - size_t distance = static_cast(std::distance(first_, last_)); - if (distance <= block_size_) { // leaf case -> do work + if (chunk_first_ == chunk_last_) { + ChunkDescriptor chunk = partitioner_[chunk_first_]; + RAIIn iter_in = chunk.GetFirst(); + RAIIn last_in = chunk.GetLast(); + RAIOut iter_out = output_iterator_; + // leaf case -> do work if (is_first_pass_) { - RAIIn iter_in = first_; - RAIOut iter_out = output_iterator_; - ReturnType result = transformation_(*first_); + ReturnType result = transformation_(*iter_in); *iter_out = result; ++iter_in; ++iter_out; - while (iter_in != last_) { + for (; iter_in != last_in; ++iter_in, ++iter_out) { result = scan_(result, transformation_(*iter_in)); *iter_out = result; - ++iter_in; - ++iter_out; } SetTreeValue(result); - } else { // Second pass - RAIIn iter_in = first_; - RAIOut iter_out = output_iterator_; - while (iter_in != last_) { + } else { + // Second pass + for (; iter_in != last_in; ++iter_in, ++iter_out) { *iter_out = scan_(parent_value_, *iter_out); - ++iter_in; - ++iter_out; } } } else { - internal::ChunkPartitioner partitioner(first_, last_, 2); - ScanFunctor functor_l(partitioner[0].GetFirst(), partitioner[0].GetLast(), - output_iterator_, neutral_, scan_, transformation_, - policy_, block_size_, tree_values_, node_id_, - is_first_pass_); - ScanFunctor functor_r(partitioner[1].GetFirst(), partitioner[1].GetLast(), - output_iterator_, neutral_, scan_, transformation_, - policy_, block_size_, tree_values_, node_id_, - is_first_pass_); - functor_l.SetID(1); - functor_r.SetID(2); + // recurse further + size_t chunk_split_index = (chunk_first_ + chunk_last_) / 2; + // Split chunks into left / right branches: + ScanFunctor functor_l( + chunk_first_, chunk_split_index, + output_iterator_, neutral_, scan_, transformation_, + policy_, partitioner_, tree_values_, node_id_, + is_first_pass_); + ScanFunctor functor_r( + chunk_split_index + 1, chunk_last_, + output_iterator_, neutral_, scan_, transformation_, + policy_, partitioner_, tree_values_, node_id_, + is_first_pass_); + functor_l.SetID(LEFT); + functor_r.SetID(RIGHT); + // Advance output iterator of right branch: + ChunkDescriptor chunk_left = partitioner_[chunk_first_]; + ChunkDescriptor chunk_right = partitioner_[chunk_split_index + 1]; std::advance(functor_r.output_iterator_, - std::distance(functor_l.first_, functor_r.first_)); + std::distance(chunk_left.GetFirst(), chunk_right.GetFirst())); if (!is_first_pass_) { functor_l.parent_value_ = parent_value_; functor_r.parent_value_ = functor_l.GetTreeValue() + parent_value_; } + // Spawn tasks to recurse: mtapi::Node& node = mtapi::Node::GetInstance(); - mtapi::Task task_l = node.Spawn(mtapi::Action(base::MakeFunction( - functor_l, &ScanFunctor::Action), - policy_.GetAffinity()), - policy_.GetPriority()); - mtapi::Task task_r = node.Spawn(mtapi::Action(base::MakeFunction( - functor_r, &ScanFunctor::Action), - policy_.GetAffinity()), - policy_.GetPriority()); + mtapi::Task task_l = node.Spawn( + mtapi::Action( + base::MakeFunction(functor_l, &ScanFunctor::Action), + policy_)); + mtapi::Task task_r = node.Spawn( + mtapi::Action( + base::MakeFunction(functor_r, &ScanFunctor::Action), + policy_)); + // Wait for tasks to complete: task_l.Wait(MTAPI_INFINITE); task_r.Wait(MTAPI_INFINITE); SetTreeValue(scan_(functor_l.GetTreeValue(), functor_r.GetTreeValue())); @@ -125,23 +129,25 @@ class ScanFunctor { } private: - const ExecutionPolicy& policy_; - RAIIn first_; - RAIIn last_; + static const int LEFT = 1; + static const int RIGHT = 2; + const embb::mtapi::ExecutionPolicy& policy_; + size_t chunk_first_; + size_t chunk_last_; RAIOut output_iterator_; ScanFunction scan_; TransformationFunction transformation_; ReturnType neutral_; - size_t block_size_; + const BlockSizePartitioner& partitioner_; ReturnType* tree_values_; size_t node_id_; ReturnType parent_value_; bool is_first_pass_; - void SetID(int is_left) { - if (is_left == 1) { + void SetID(int branch) { + if (branch == LEFT) { node_id_ = 2 * node_id_ + 1; - } else if (is_left == 2) { + } else if (branch == RIGHT) { node_id_ = 2 * node_id_ + 2; } } @@ -162,44 +168,54 @@ typename ScanFunction, typename TransformationFunction> void ScanIteratorCheck(RAIIn first, RAIIn last, RAIOut output_iterator, ReturnType neutral, ScanFunction scan, TransformationFunction transformation, - const ExecutionPolicy& policy, size_t block_size, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size, std::random_access_iterator_tag) { typedef typename std::iterator_traits::difference_type difference_type; difference_type distance = std::distance(first, last); if (distance <= 0) { return; } - mtapi::Node& node = mtapi::Node::GetInstance(); + unsigned int num_cores = policy.GetCoreCount(); + if (num_cores == 0) { + EMBB_THROW(embb::base::ErrorException, "No cores in execution policy"); + } + ReturnType values[MTAPI_NODE_MAX_TASKS_DEFAULT]; - size_t used_block_size = block_size; if (block_size == 0) { - used_block_size = static_cast(distance) / node.GetCoreCount(); - if (used_block_size == 0) used_block_size = 1; + block_size = static_cast(distance) / num_cores; + if (block_size == 0) { + block_size = 1; + } } - if (((distance / used_block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { + if (((distance / block_size) * 2) + 1 > MTAPI_NODE_MAX_TASKS_DEFAULT) { EMBB_THROW(embb::base::ErrorException, - "Number of computation tasks required in scan " - "exceeds MTAPI maximum number of tasks"); + "Not enough MTAPI tasks available for parallel scan"); } // first pass. Calculates prefix sums for leaves and when recursion returns // it creates the tree. typedef ScanFunctor Functor; - Functor functor_down(first, last, output_iterator, neutral, scan, - transformation, policy, used_block_size, values, 0, - true); + mtapi::Node& node = mtapi::Node::GetInstance(); + + BlockSizePartitioner partitioner_down(first, last, block_size); + Functor functor_down(0, partitioner_down.Size() - 1, output_iterator, + neutral, scan, transformation, policy, partitioner_down, + values, 0, true); mtapi::Task task_down = node.Spawn(mtapi::Action(base::MakeFunction( functor_down, &Functor::Action), - policy.GetAffinity()), policy.GetPriority()); + policy)); task_down.Wait(MTAPI_INFINITE); // Second pass. Gives to each leaf the part of the prefix missing - Functor functor_up(first, last, output_iterator, neutral, scan, - transformation, policy, used_block_size, values, 0, false); + BlockSizePartitioner partitioner_up(first, last, block_size); + Functor functor_up(0, partitioner_up.Size() - 1, output_iterator, + neutral, scan, transformation, policy, partitioner_up, + values, 0, false); mtapi::Task task_up = node.Spawn(mtapi::Action(base::MakeFunction( functor_up, &Functor::Action), - policy.GetAffinity()), policy.GetPriority()); + policy)); task_up.Wait(MTAPI_INFINITE); } @@ -209,7 +225,7 @@ template void Scan(RAIIn first, RAIIn last, RAIOut output_iterator, ReturnType neutral, ScanFunction scan, TransformationFunction transformation, - const ExecutionPolicy& policy, size_t block_size) { + const embb::mtapi::ExecutionPolicy& policy, size_t block_size) { typedef typename std::iterator_traits::iterator_category category; internal::ScanIteratorCheck(first, last, output_iterator, neutral, scan, transformation, policy, block_size, category()); diff --git a/algorithms_cpp/include/embb/algorithms/invoke.h b/algorithms_cpp/include/embb/algorithms/invoke.h index 80765fa..1484d5a 100644 --- a/algorithms_cpp/include/embb/algorithms/invoke.h +++ b/algorithms_cpp/include/embb/algorithms/invoke.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ #define EMBB_ALGORITHMS_INVOKE_H_ #include -#include +#include namespace embb { namespace algorithms { @@ -58,12 +58,12 @@ typedef embb::base::Function InvokeFunctionType; template void Invoke( Function1 func1, - /**< [in] First function to invoke */ + /**< [in] First function object to invoke */ ...); /** * Spawns one to ten function objects at once and runs them in parallel using the -* given ExecutionPolicy. +* given embb::mtapi::ExecutionPolicy. * * Blocks until all of them are done. * @@ -72,9 +72,10 @@ void Invoke( template void Invoke( Function1 func1, - /**< [in] Function to invoke */ + /**< [in] Function object to invoke */ ..., - const ExecutionPolicy & policy /**< [in] ExecutionPolicy to use */ + const embb::mtapi::ExecutionPolicy & policy + /**< [in] embb::mtapi::ExecutionPolicy to use */ ); #else // DOXYGEN @@ -92,11 +93,11 @@ class TaskWrapper { */ explicit TaskWrapper( Function function, - const ExecutionPolicy& policy) + const embb::mtapi::ExecutionPolicy& policy) : function_(function), task_() { mtapi::Action action(embb::base::MakeFunction(*this, &TaskWrapper::Run), - policy.GetAffinity()); - task_ = mtapi::Node::GetInstance().Spawn(action, policy.GetPriority()); + policy); + task_ = mtapi::Node::GetInstance().Spawn(action); } /** @@ -118,75 +119,104 @@ class TaskWrapper { template void Invoke( - Function1 func1) { - Invoke(func1, ExecutionPolicy()); + Function1 func1, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); } template void Invoke( Function1 func1, - Function2 func2) { - Invoke(func1, func2, ExecutionPolicy()); + Function2 func2, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); } + template void Invoke( Function1 func1, Function2 func2, - Function3 func3) { - Invoke(func1, func2, func3, ExecutionPolicy()); + Function3 func3, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); } template -void Invoke( + typename Function4> + void Invoke( Function1 func1, Function2 func2, Function3 func3, - Function4 func4) { - Invoke(func1, func2, func3, func4, ExecutionPolicy()); + Function4 func4, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); } template -void Invoke( + typename Function4, typename Function5> + void Invoke( Function1 func1, Function2 func2, Function3 func3, Function4 func4, - Function5 func5) { - Invoke(func1, func2, func3, func4, func5, ExecutionPolicy()); + Function5 func5, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); + internal::TaskWrapper wrap5(func5, policy); } template -void Invoke( + typename Function4, typename Function5, typename Function6> + void Invoke( Function1 func1, Function2 func2, Function3 func3, Function4 func4, Function5 func5, - Function6 func6) { - Invoke(func1, func2, func3, func4, func5, func6, ExecutionPolicy()); + Function6 func6, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); + internal::TaskWrapper wrap5(func5, policy); + internal::TaskWrapper wrap6(func6, policy); } template -void Invoke( + typename Function4, typename Function5, typename Function6, + typename Function7> + void Invoke( Function1 func1, Function2 func2, Function3 func3, Function4 func4, Function5 func5, Function6 func6, - Function7 func7) { - Invoke(func1, func2, func3, func4, func5, func6, func7, ExecutionPolicy()); + Function7 func7, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); + internal::TaskWrapper wrap5(func5, policy); + internal::TaskWrapper wrap6(func6, policy); + internal::TaskWrapper wrap7(func7, policy); } template -void Invoke( + typename Function4, typename Function5, typename Function6, + typename Function7, typename Function8> + void Invoke( Function1 func1, Function2 func2, Function3 func3, @@ -194,15 +224,22 @@ void Invoke( Function5 func5, Function6 func6, Function7 func7, - Function8 func8) { - Invoke(func1, func2, func3, func4, func5, func6, func7, func8, - ExecutionPolicy()); + Function8 func8, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); + internal::TaskWrapper wrap5(func5, policy); + internal::TaskWrapper wrap6(func6, policy); + internal::TaskWrapper wrap7(func7, policy); + internal::TaskWrapper wrap8(func8, policy); } template -void Invoke( + typename Function4, typename Function5, typename Function6, + typename Function7, typename Function8, typename Function9> + void Invoke( Function1 func1, Function2 func2, Function3 func3, @@ -211,16 +248,24 @@ void Invoke( Function6 func6, Function7 func7, Function8 func8, - Function9 func9) { - Invoke(func1, func2, func3, func4, func5, func6, func7, func8, func9, - ExecutionPolicy()); + Function9 func9, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); + internal::TaskWrapper wrap5(func5, policy); + internal::TaskWrapper wrap6(func6, policy); + internal::TaskWrapper wrap7(func7, policy); + internal::TaskWrapper wrap8(func8, policy); + internal::TaskWrapper wrap9(func9, policy); } template -void Invoke( + typename Function4, typename Function5, typename Function6, + typename Function7, typename Function8, typename Function9, + typename Function10> + void Invoke( Function1 func1, Function2 func2, Function3 func3, @@ -230,36 +275,38 @@ void Invoke( Function7 func7, Function8 func8, Function9 func9, - Function10 func10) { - Invoke(func1, func2, func3, func4, func5, func6, func7, func8, func9, func10, - ExecutionPolicy()); + Function10 func10, + const embb::mtapi::ExecutionPolicy& policy) { + internal::TaskWrapper wrap1(func1, policy); + internal::TaskWrapper wrap2(func2, policy); + internal::TaskWrapper wrap3(func3, policy); + internal::TaskWrapper wrap4(func4, policy); + internal::TaskWrapper wrap5(func5, policy); + internal::TaskWrapper wrap6(func6, policy); + internal::TaskWrapper wrap7(func7, policy); + internal::TaskWrapper wrap8(func8, policy); + internal::TaskWrapper wrap9(func9, policy); + internal::TaskWrapper wrap10(func10, policy); } template void Invoke( - Function1 func1, - const ExecutionPolicy& policy) { - internal::TaskWrapper wrap1(func1, policy); + Function1 func1) { + Invoke(func1, embb::mtapi::ExecutionPolicy()); } template void Invoke( Function1 func1, - Function2 func2, - const ExecutionPolicy& policy) { - internal::TaskWrapper wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); + Function2 func2) { + Invoke(func1, func2, embb::mtapi::ExecutionPolicy()); } - template void Invoke( Function1 func1, Function2 func2, - Function3 func3, - const ExecutionPolicy& policy) { - internal::TaskWrapper wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); + Function3 func3) { + Invoke(func1, func2, func3, embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); + Function4 func4) { + Invoke(func1, func2, func3, func4, embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); - internal::TaskWrapper wrap5(func5, policy); + Function5 func5) { + Invoke(func1, func2, func3, func4, func5, embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); - internal::TaskWrapper wrap5(func5, policy); - internal::TaskWrapper wrap6(func6, policy); + Function6 func6) { + Invoke(func1, func2, func3, func4, func5, func6, + embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); - internal::TaskWrapper wrap5(func5, policy); - internal::TaskWrapper wrap6(func6, policy); - internal::TaskWrapper wrap7(func7, policy); + Function7 func7) { + Invoke(func1, func2, func3, func4, func5, func6, func7, + embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); - internal::TaskWrapper wrap5(func5, policy); - internal::TaskWrapper wrap6(func6, policy); - internal::TaskWrapper wrap7(func7, policy); - internal::TaskWrapper wrap8(func8, policy); + Function8 func8) { + Invoke(func1, func2, func3, func4, func5, func6, func7, func8, + embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); - internal::TaskWrapper wrap5(func5, policy); - internal::TaskWrapper wrap6(func6, policy); - internal::TaskWrapper wrap7(func7, policy); - internal::TaskWrapper wrap8(func8, policy); - internal::TaskWrapper wrap9(func9, policy); + Function9 func9) { + Invoke(func1, func2, func3, func4, func5, func6, func7, func8, func9, + embb::mtapi::ExecutionPolicy()); } template wrap1(func1, policy); - internal::TaskWrapper wrap2(func2, policy); - internal::TaskWrapper wrap3(func3, policy); - internal::TaskWrapper wrap4(func4, policy); - internal::TaskWrapper wrap5(func5, policy); - internal::TaskWrapper wrap6(func6, policy); - internal::TaskWrapper wrap7(func7, policy); - internal::TaskWrapper wrap8(func8, policy); - internal::TaskWrapper wrap9(func9, policy); - internal::TaskWrapper wrap10(func10, policy); + Function10 func10) { + Invoke(func1, func2, func3, func4, func5, func6, func7, func8, func9, func10, + embb::mtapi::ExecutionPolicy()); } #endif // else DOXYGEN diff --git a/algorithms_cpp/include/embb/algorithms/merge_sort.h b/algorithms_cpp/include/embb/algorithms/merge_sort.h index 1cb2304..5b921f2 100644 --- a/algorithms_cpp/include/embb/algorithms/merge_sort.h +++ b/algorithms_cpp/include/embb/algorithms/merge_sort.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ #define EMBB_ALGORITHMS_MERGE_SORT_H_ #include -#include +#include #include namespace embb { @@ -59,7 +59,7 @@ namespace algorithms { * modified by another thread while the algorithm is executed. * \note No guarantee is given on the execution order of the comparison operations. - * \see ExecutionPolicy, MergeSort() + * \see embb::mtapi::ExecutionPolicy, MergeSort() * \tparam RAI Random access iterator * \tparam ComparisonFunction Binary predicate with both arguments of type * std::iterator_traits::value_type. @@ -77,8 +77,8 @@ void MergeSortAllocate( \c a appears before an element \c b in the sorted range if comparison(a, b) == true. The default value uses the less-than relation. */ - const ExecutionPolicy& policy = ExecutionPolicy(), - /**< [IN] ExecutionPolicy for the merge sort algorithm */ + const embb::mtapi::ExecutionPolicy& policy = embb::mtapi::ExecutionPolicy(), + /**< [IN] embb::mtapi::ExecutionPolicy for the merge sort algorithm */ size_t block_size = 0 /**< [IN] Lower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size @@ -105,7 +105,7 @@ void MergeSortAllocate( * modified by another thread while the algorithm is executed. * \note No guarantee is given on the execution order of the comparison * operations. - * \see ExecutionPolicy, MergeSortAllocate() + * \see embb::mtapi::ExecutionPolicy, MergeSortAllocate() * \tparam RAI Random access iterator * \tparam RAITemp Random access iterator for temporary memory. Has to have the * same value type as RAI. @@ -127,8 +127,8 @@ void MergeSort( \c a appears before an element \c b in the sorted range if comparison(a, b) == true. The default value uses the less-than relation. */ - const ExecutionPolicy& policy = ExecutionPolicy(), - /**< [IN] ExecutionPolicy for the merge sort algorithm */ + const embb::mtapi::ExecutionPolicy& policy = embb::mtapi::ExecutionPolicy(), + /**< [IN] embb::mtapi::ExecutionPolicy for the merge sort algorithm */ size_t block_size = 0 /**< [IN] Lower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size @@ -141,28 +141,49 @@ void MergeSort( #else // DOXYGEN /** - * Overload of above described Doxygen dummy with less arguments. + * Overload of above described Doxygen dummy. */ -template +template +void MergeSort( + RAI first, + RAI last, + RAITemp temporary_first, + ComparisonFunction comparison, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size + ); + +/** + * Overload of above described Doxygen dummy. + */ +template void MergeSortAllocate( RAI first, - RAI last + RAI last, + ComparisonFunction comparison, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size ) { - MergeSortAllocate(first, last, - std::less::value_type>(), - ExecutionPolicy(), 0); + typedef base::Allocation Alloc; + typename std::iterator_traits::difference_type distance = last - first; + typedef typename std::iterator_traits::value_type value_type; + value_type* temporary = static_cast( + Alloc::Allocate(distance * sizeof(value_type))); + MergeSort(first, last, temporary, comparison, policy, block_size); + Alloc::Free(temporary); } /** * Overload of above described Doxygen dummy with less arguments. */ -template +template void MergeSortAllocate( RAI first, - RAI last, - ComparisonFunction comparison + RAI last ) { - MergeSortAllocate(first, last, comparison, ExecutionPolicy(), 0); + MergeSortAllocate(first, last, + std::less::value_type>(), + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -172,30 +193,22 @@ template void MergeSortAllocate( RAI first, RAI last, - ComparisonFunction comparison, - const ExecutionPolicy& policy + ComparisonFunction comparison ) { - MergeSortAllocate(first, last, comparison, policy, 0); + MergeSortAllocate(first, last, comparison, embb::mtapi::ExecutionPolicy(), 0); } /** - * Overload of above described Doxygen dummy. + * Overload of above described Doxygen dummy with less arguments. */ template void MergeSortAllocate( RAI first, RAI last, ComparisonFunction comparison, - const ExecutionPolicy& policy, - size_t block_size + const embb::mtapi::ExecutionPolicy& policy ) { - typedef base::Allocation Alloc; - typename std::iterator_traits::difference_type distance = last - first; - typedef typename std::iterator_traits::value_type value_type; - value_type* temporary = static_cast( - Alloc::Allocate(distance * sizeof(value_type))); - MergeSort(first, last, temporary, comparison, policy, block_size); - Alloc::Free(temporary); + MergeSortAllocate(first, last, comparison, policy, 0); } /** @@ -209,7 +222,7 @@ void MergeSort( ) { MergeSort(first, last, temporary_first, std::less::value_type>(), - ExecutionPolicy(), 0); + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -222,7 +235,8 @@ void MergeSort( RAITemp temporary_first, ComparisonFunction comparison ) { - MergeSort(first, last, temporary_first, comparison, ExecutionPolicy(), 0); + MergeSort(first, last, temporary_first, comparison, + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -234,24 +248,11 @@ void MergeSort( RAI last, RAITemp temporary_first, ComparisonFunction comparison, - const ExecutionPolicy& policy + const embb::mtapi::ExecutionPolicy& policy ) { MergeSort(first, last, temporary_first, comparison, policy, 0); } -/** - * Overload of above described Doxygen dummy. - */ -template -void MergeSort( - const ExecutionPolicy& policy, - RAI first, - RAI last, - RAITemp temporary_first, - ComparisonFunction comparison, - size_t block_size - ); - #endif // else DOXYGEN /** diff --git a/algorithms_cpp/include/embb/algorithms/quick_sort.h b/algorithms_cpp/include/embb/algorithms/quick_sort.h index cc61330..cf25020 100644 --- a/algorithms_cpp/include/embb/algorithms/quick_sort.h +++ b/algorithms_cpp/include/embb/algorithms/quick_sort.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -28,7 +28,7 @@ #define EMBB_ALGORITHMS_QUICK_SORT_H_ #include -#include +#include namespace embb { namespace algorithms { @@ -54,7 +54,7 @@ namespace algorithms { * modified by another thread while the algorithm is executed. * \note No guarantee is given on the execution order of the comparison * operations. - * \see ExecutionPolicy, MergeSort() + * \see embb::mtapi::ExecutionPolicy, MergeSort() * \tparam RAI Random access iterator * \tparam ComparisonFunction Binary predicate with both arguments of type * std::iterator_traits::value_type. @@ -72,8 +72,8 @@ void QuickSort( \c a appears before an element \c b in the sorted range if comparison(a, b) == true. The default value uses the less-than relation. */ - const ExecutionPolicy& policy = ExecutionPolicy(), - /**< [IN] ExecutionPolicy for the quick sort algorithm */ + const embb::mtapi::ExecutionPolicy& policy = embb::mtapi::ExecutionPolicy(), + /**< [IN] embb::mtapi::ExecutionPolicy for the quick sort algorithm */ size_t block_size = 0 /**< [IN] Lower bound for partitioning the range of elements into blocks that are sorted in parallel. Partitioning of a block stops if its size @@ -88,6 +88,18 @@ void QuickSort( #else // DOXYGEN /** + * Overload of above described Doxygen dummy. + */ +template +void QuickSort( + RAI first, + RAI last, + ComparisonFunction comparison, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size + ); + +/** * Overload of above described Doxygen dummy with less arguments. */ template @@ -97,7 +109,7 @@ void QuickSort( ) { QuickSort(first, last, std::less::value_type>(), - ExecutionPolicy(), 0); + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -109,7 +121,7 @@ void QuickSort( RAI last, ComparisonFunction comparison ) { - QuickSort(first, last, comparison, ExecutionPolicy(), 0); + QuickSort(first, last, comparison, embb::mtapi::ExecutionPolicy(), 0); } /** @@ -120,23 +132,11 @@ void QuickSort( RAI first, RAI last, ComparisonFunction comparison, - const ExecutionPolicy& policy + const embb::mtapi::ExecutionPolicy& policy ) { QuickSort(first, last, comparison, policy, 0); } -/** - * Overload of above described Doxygen dummy. - */ -template -void QuickSort( - RAI first, - RAI last, - ComparisonFunction comparison, - const ExecutionPolicy& policy, - size_t block_size - ); - #endif // else DOXYGEN /** diff --git a/algorithms_cpp/include/embb/algorithms/reduce.h b/algorithms_cpp/include/embb/algorithms/reduce.h index 015ce76..9058ee9 100644 --- a/algorithms_cpp/include/embb/algorithms/reduce.h +++ b/algorithms_cpp/include/embb/algorithms/reduce.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,7 +27,7 @@ #ifndef EMBB_ALGORITHMS_REDUCE_H_ #define EMBB_ALGORITHMS_REDUCE_H_ -#include +#include #include namespace embb { @@ -64,14 +64,14 @@ namespace algorithms { * associative, i.e., reduction(x, reduction(y, z)) == * reduction(reduction(x, y), z)) for all \c x, \c y, \c z of type * \c ReturnType. - * \see ExecutionPolicy, ZipIterator, Identity + * \see embb::mtapi::ExecutionPolicy, ZipIterator, Identity * \tparam RAI Random access iterator * \tparam ReturnType Type of result of reduction operation, deduced from * \c neutral - * \tparam ReductionFunction Binary reduction function with signature + * \tparam ReductionFunction Binary reduction function object with signature * ReturnType ReductionFunction(ReturnType, ReturnType). - * \tparam TransformationFunction Unary transformation function with signature - * ReturnType TransformationFunction(typename + * \tparam TransformationFunction Unary transformation function object with + * signature ReturnType TransformationFunction(typename * std::iterator_traits::value_type) */ template +ReturnType Reduce( + RAI first, + RAI last, + ReturnType neutral, + ReductionFunction reduction, + TransformationFunction transformation, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size + ); + +/** * Overload of above described Doxygen dummy with less arguments. */ template @@ -112,8 +127,8 @@ ReturnType Reduce( ReturnType neutral, ReductionFunction reduction ) { - return Reduce(first, last, neutral, reduction, Identity(), ExecutionPolicy(), - 0); + return Reduce(first, last, neutral, reduction, Identity(), + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -129,7 +144,7 @@ ReturnType Reduce( TransformationFunction transformation ) { return Reduce(first, last, neutral, reduction, transformation, - ExecutionPolicy(), 0); + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -143,26 +158,11 @@ ReturnType Reduce( ReturnType neutral, ReductionFunction reduction, TransformationFunction transformation, - const ExecutionPolicy& policy + const embb::mtapi::ExecutionPolicy& policy ) { return Reduce(first, last, neutral, reduction, transformation, policy, 0); } -/** - * Overload of above described Doxygen dummy. - */ -template -ReturnType Reduce( - RAI first, - RAI last, - ReturnType neutral, - ReductionFunction reduction, - TransformationFunction transformation, - const ExecutionPolicy& policy, - size_t block_size - ); - #endif // else DOXYGEN /** diff --git a/algorithms_cpp/include/embb/algorithms/scan.h b/algorithms_cpp/include/embb/algorithms/scan.h index aa6f0c8..5d019cb 100644 --- a/algorithms_cpp/include/embb/algorithms/scan.h +++ b/algorithms_cpp/include/embb/algorithms/scan.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,7 +27,7 @@ #ifndef EMBB_ALGORITHMS_SCAN_H_ #define EMBB_ALGORITHMS_SCAN_H_ -#include +#include #include namespace embb { @@ -66,15 +66,15 @@ namespace algorithms { * associative, i.e., reduction(x, reduction(y, z)) == * reduction(reduction(x, y), z)) for all \c x, \c y, \c z of type * \c ReturnType. - * \see ExecutionPolicy, Identity, ZipIterator + * \see embb::mtapi::ExecutionPolicy, Identity, ZipIterator * \tparam RAIIn Random access iterator type of input range * \tparam RAIOut Random access iterator type of output range * \tparam ReturnType Type of output elements of scan operation, deduced from * \c neutral - * \tparam ScanFunction Binary scan function with signature + * \tparam ScanFunction Binary scan function object with signature * ReturnType ScanFunction(ReturnType, ReturnType) - * \tparam TransformationFunction Unary transformation function with signature - * ReturnType TransformationFunction(typename + * \tparam TransformationFunction Unary transformation function object with + * signature ReturnType TransformationFunction(typename * std::iterator_traits::value_type). */ template + typename ScanFunction, typename TransformationFunction> void Scan( RAIIn first, RAIIn last, RAIOut output_iterator, ReturnType neutral, - ScanFunction scan - ) { - Scan(first, last, output_iterator, neutral, scan, Identity(), - ExecutionPolicy(), 0); -} + ScanFunction scan, + TransformationFunction transformation, + const embb::mtapi::ExecutionPolicy& policy, + size_t block_size + ); /** * Overload of above described Doxygen dummy with less arguments. */ template + typename ScanFunction> void Scan( RAIIn first, RAIIn last, RAIOut output_iterator, ReturnType neutral, - ScanFunction scan, - TransformationFunction transformation + ScanFunction scan ) { - Scan(first, last, output_iterator, neutral, scan, transformation, - ExecutionPolicy(), 0); + Scan(first, last, output_iterator, neutral, scan, Identity(), + embb::mtapi::ExecutionPolicy(), 0); } /** @@ -153,14 +152,14 @@ void Scan( RAIOut output_iterator, ReturnType neutral, ScanFunction scan, - TransformationFunction transformation, - const ExecutionPolicy& policy + TransformationFunction transformation ) { - Scan(first, last, output_iterator, neutral, scan, transformation, policy, 0); + Scan(first, last, output_iterator, neutral, scan, transformation, + embb::mtapi::ExecutionPolicy(), 0); } /** - * Overload of above described Doxygen dummy. + * Overload of above described Doxygen dummy with less arguments. */ template @@ -171,9 +170,10 @@ void Scan( ReturnType neutral, ScanFunction scan, TransformationFunction transformation, - const ExecutionPolicy& policy, - size_t block_size - ); + const embb::mtapi::ExecutionPolicy& policy + ) { + Scan(first, last, output_iterator, neutral, scan, transformation, policy, 0); +} #endif // else DOXYGEN diff --git a/algorithms_cpp/include/embb/algorithms/zip_iterator.h b/algorithms_cpp/include/embb/algorithms/zip_iterator.h index a509136..a3e033d 100644 --- a/algorithms_cpp/include/embb/algorithms/zip_iterator.h +++ b/algorithms_cpp/include/embb/algorithms/zip_iterator.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/src/dummy.cc b/algorithms_cpp/src/dummy.cc index cbdaf49..13566b9 100644 --- a/algorithms_cpp/src/dummy.cc +++ b/algorithms_cpp/src/dummy.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/count_test.cc b/algorithms_cpp/test/count_test.cc index e04d15d..fdc5993 100644 --- a/algorithms_cpp/test/count_test.cc +++ b/algorithms_cpp/test/count_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -59,8 +59,8 @@ CountTest::CountTest() { void CountTest::TestDataStructures() { using embb::algorithms::Count; - const int size =10; - int array[] = {10, 20, 30, 30, 20, 10, 10, 20, 20, 20}; + const int size = 10; + int array[] = { 10, 20, 30, 30, 20, 10, 10, 20, 20, 20 }; std::vector vector(array, array + size); std::deque deque(array, array + size); const std::vector const_vector(array, array + size); @@ -73,8 +73,8 @@ void CountTest::TestDataStructures() { void CountTest::TestCountIf() { using embb::algorithms::CountIf; - const int size =10; - int array[] = {10, 21, 30, 31, 20, 11, 10, 21, 20, 20}; + const int size = 10; + int array[] = { 10, 21, 30, 31, 20, 11, 10, 21, 20, 20 }; PT_EXPECT_EQ(CountIf(array, array + size, IsEven()), 6); PT_EXPECT_EQ(CountIf(array, array + size, &IsEvenFunction), 6); } @@ -122,14 +122,12 @@ void CountTest::TestBlockSizes() { void CountTest::TestPolicy() { using embb::algorithms::Count; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; int a[] = { 10, 20, 30, 30, 20, 10, 10, 20, 20, 20 }; std::vector vector(a, a + (sizeof a / sizeof a[0])); PT_EXPECT_EQ(Count(vector.begin(), vector.end(), 10, ExecutionPolicy()), 3); PT_EXPECT_EQ(Count(vector.begin(), vector.end(), 10, ExecutionPolicy(true)), 3); - PT_EXPECT_EQ(Count(vector.begin(), vector.end(), 10, ExecutionPolicy(false)), - 3); PT_EXPECT_EQ(Count(vector.begin(), vector.end(), 10, ExecutionPolicy(true, 1)), 3); } diff --git a/algorithms_cpp/test/count_test.h b/algorithms_cpp/test/count_test.h index 31a4a6c..95f2a32 100644 --- a/algorithms_cpp/test/count_test.h +++ b/algorithms_cpp/test/count_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/for_each_test.cc b/algorithms_cpp/test/for_each_test.cc index a8c58ae..3a0e303 100644 --- a/algorithms_cpp/test/for_each_test.cc +++ b/algorithms_cpp/test/for_each_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -166,7 +166,7 @@ void ForEachTest::TestRanges() { void ForEachTest::TestBlockSizes() { using embb::algorithms::ForEach; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = 4; std::vector init(count); std::vector vector(count); @@ -186,7 +186,7 @@ void ForEachTest::TestBlockSizes() { void ForEachTest::TestPolicy() { using embb::algorithms::ForEach; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = 4; std::vector init(count); std::vector vector(count); @@ -207,12 +207,6 @@ void ForEachTest::TestPolicy() { } vector = init; - ForEach(vector.begin(), vector.end(), Square(), ExecutionPolicy(false)); - for (size_t i = 0; i < count; i++) { - PT_EXPECT_EQ(vector[i], init[i]*init[i]); - } - - vector = init; ForEach(vector.begin(), vector.end(), Square(), ExecutionPolicy(true, 1)); for (size_t i = 0; i < count; i++) { PT_EXPECT_EQ(vector[i], init[i]*init[i]); @@ -221,7 +215,7 @@ void ForEachTest::TestPolicy() { void ForEachTest::StressTest() { using embb::algorithms::ForEach; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = embb::mtapi::Node::GetInstance().GetCoreCount() *10; std::vector large_vector(count); for (size_t i = 0; i < count; i++) { diff --git a/algorithms_cpp/test/for_each_test.h b/algorithms_cpp/test/for_each_test.h index a72302d..f768662 100644 --- a/algorithms_cpp/test/for_each_test.h +++ b/algorithms_cpp/test/for_each_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/invoke_test.cc b/algorithms_cpp/test/invoke_test.cc index 08fba2c..361e73a 100644 --- a/algorithms_cpp/test/invoke_test.cc +++ b/algorithms_cpp/test/invoke_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/invoke_test.h b/algorithms_cpp/test/invoke_test.h index 2e3c896..e75ecc3 100644 --- a/algorithms_cpp/test/invoke_test.h +++ b/algorithms_cpp/test/invoke_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/main.cc b/algorithms_cpp/test/main.cc index 5613342..4b5bf5e 100644 --- a/algorithms_cpp/test/main.cc +++ b/algorithms_cpp/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -67,6 +67,7 @@ int compute1_() { PT_MAIN("Algorithms") { embb::mtapi::Node::Initialize(THIS_DOMAIN_ID, THIS_NODE_ID); + PT_RUN(PartitionerTest); PT_RUN(ForEachTest); PT_RUN(ReduceTest); diff --git a/algorithms_cpp/test/merge_sort_test.cc b/algorithms_cpp/test/merge_sort_test.cc index 5e7331d..cbcbf0b 100644 --- a/algorithms_cpp/test/merge_sort_test.cc +++ b/algorithms_cpp/test/merge_sort_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -50,7 +50,7 @@ MergeSortTest::MergeSortTest() { void MergeSortTest::TestDataStructures() { using embb::algorithms::MergeSortAllocate; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; int array[kCountSize]; std::vector vector(kCountSize); std::deque deque(kCountSize); @@ -75,7 +75,7 @@ void MergeSortTest::TestDataStructures() { void MergeSortTest::TestFunctionPointers() { using embb::algorithms::MergeSortAllocate; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; std::vector vector(kCountSize); for (size_t i = kCountSize - 1; i > 0; i--) { @@ -181,7 +181,7 @@ void MergeSortTest::TestRanges() { void MergeSortTest::TestPolicy() { using embb::algorithms::MergeSortAllocate; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = 4; std::vector init(count); std::vector vector(count); @@ -208,13 +208,6 @@ void MergeSortTest::TestPolicy() { vector = init; MergeSortAllocate(vector.begin(), vector.end(), std::less(), - ExecutionPolicy(false)); - for (size_t i = 0; i < count; i++) { - PT_EXPECT_EQ(vector_copy[i], vector[i]); - } - - vector = init; - MergeSortAllocate(vector.begin(), vector.end(), std::less(), ExecutionPolicy(true, 1)); for (size_t i = 0; i < count; i++) { PT_EXPECT_EQ(vector_copy[i], vector[i]); diff --git a/algorithms_cpp/test/merge_sort_test.h b/algorithms_cpp/test/merge_sort_test.h index a4d770b..10545fb 100644 --- a/algorithms_cpp/test/merge_sort_test.h +++ b/algorithms_cpp/test/merge_sort_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/partitioner_test.cc b/algorithms_cpp/test/partitioner_test.cc index 63df878..bed03dc 100644 --- a/algorithms_cpp/test/partitioner_test.cc +++ b/algorithms_cpp/test/partitioner_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/partitioner_test.h b/algorithms_cpp/test/partitioner_test.h index 464b5a2..b188740 100644 --- a/algorithms_cpp/test/partitioner_test.h +++ b/algorithms_cpp/test/partitioner_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/quick_sort_test.cc b/algorithms_cpp/test/quick_sort_test.cc index 8d6cf65..8f724ca 100644 --- a/algorithms_cpp/test/quick_sort_test.cc +++ b/algorithms_cpp/test/quick_sort_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -54,7 +54,7 @@ QuickSortTest::QuickSortTest() { void QuickSortTest::TestDataStructures() { using embb::algorithms::QuickSort; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; int array[kCountSize]; std::vector vector(kCountSize); @@ -163,7 +163,7 @@ void QuickSortTest::TestRanges() { void QuickSortTest::TestBlockSizes() { using embb::algorithms::QuickSort; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = 4; std::vector init(count); @@ -187,7 +187,7 @@ void QuickSortTest::TestBlockSizes() { void QuickSortTest::TestPolicy() { using embb::algorithms::QuickSort; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = 4; std::vector init(count); std::vector vector(count); @@ -214,13 +214,6 @@ void QuickSortTest::TestPolicy() { vector = init; QuickSort(vector.begin(), vector.end(), std::greater(), - ExecutionPolicy(false)); - for (size_t i = 0; i < count; i++) { - PT_EXPECT_EQ(vector_copy[i], vector[i]); - } - - vector = init; - QuickSort(vector.begin(), vector.end(), std::greater(), ExecutionPolicy(true, 1)); for (size_t i = 0; i < count; i++) { PT_EXPECT_EQ(vector_copy[i], vector[i]); diff --git a/algorithms_cpp/test/quick_sort_test.h b/algorithms_cpp/test/quick_sort_test.h index 220043e..1d2ef03 100644 --- a/algorithms_cpp/test/quick_sort_test.h +++ b/algorithms_cpp/test/quick_sort_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/reduce_test.cc b/algorithms_cpp/test/reduce_test.cc index 6922594..2ebebe5 100644 --- a/algorithms_cpp/test/reduce_test.cc +++ b/algorithms_cpp/test/reduce_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -163,7 +163,7 @@ void ReduceTest::TestBlockSizes() { void ReduceTest::TestPolicy() { using embb::algorithms::Reduce; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; using embb::algorithms::Identity; size_t count = 4; int sum = 0; @@ -179,15 +179,13 @@ void ReduceTest::TestPolicy() { Identity(), ExecutionPolicy()), sum); PT_EXPECT_EQ(Reduce(vector.begin(), vector.end(), 0, std::plus(), Identity(), ExecutionPolicy(true)), sum); - PT_EXPECT_EQ(Reduce(vector.begin(), vector.end(), 0, - std::plus(), Identity(), ExecutionPolicy(false)), sum); PT_EXPECT_EQ(Reduce(vector.begin(), vector.end(), 0, std::plus(), Identity(), ExecutionPolicy(true, 1)), sum); } void ReduceTest::StressTest() { using embb::algorithms::Reduce; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; using embb::algorithms::Identity; size_t count = embb::mtapi::Node::GetInstance().GetCoreCount() *10; std::vector large_vector(count); diff --git a/algorithms_cpp/test/reduce_test.h b/algorithms_cpp/test/reduce_test.h index 5bb7037..50ab6ca 100644 --- a/algorithms_cpp/test/reduce_test.h +++ b/algorithms_cpp/test/reduce_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/scan_test.cc b/algorithms_cpp/test/scan_test.cc index 3597dda..e88effd 100644 --- a/algorithms_cpp/test/scan_test.cc +++ b/algorithms_cpp/test/scan_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -228,7 +228,7 @@ void ScanTest::TestRanges() { void ScanTest::TestBlockSizes() { using embb::algorithms::Scan; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; using embb::algorithms::Identity; size_t count = 4; std::vector init(count); @@ -253,7 +253,7 @@ void ScanTest::TestBlockSizes() { void ScanTest::TestPolicy() { using embb::algorithms::Scan; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; using embb::algorithms::Identity; size_t count = 4; std::vector init(count); @@ -284,15 +284,6 @@ void ScanTest::TestPolicy() { outputVector = init; Scan(vector.begin(), vector.end(), outputVector.begin(), 0, std::plus(), - Identity(), ExecutionPolicy(false)); - expected = 0; - for (size_t i = 0; i < count; i++) { - expected += vector[i]; - PT_EXPECT_EQ(expected, outputVector[i]); - } - - outputVector = init; - Scan(vector.begin(), vector.end(), outputVector.begin(), 0, std::plus(), Identity(), ExecutionPolicy(true, 1)); expected = 0; for (size_t i = 0; i < count; i++) { @@ -304,7 +295,7 @@ void ScanTest::TestPolicy() { void ScanTest::StressTest() { using embb::algorithms::Scan; using embb::algorithms::Identity; - using embb::algorithms::ExecutionPolicy; + using embb::mtapi::ExecutionPolicy; size_t count = embb::mtapi::Node::GetInstance().GetCoreCount() *10; std::vector large_vector(count); std::vector large_vector_output(count); diff --git a/algorithms_cpp/test/scan_test.h b/algorithms_cpp/test/scan_test.h index e1716ee..553f8bc 100644 --- a/algorithms_cpp/test/scan_test.h +++ b/algorithms_cpp/test/scan_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/algorithms_cpp/test/zip_iterator_test.cc b/algorithms_cpp/test/zip_iterator_test.cc index 7ac51c1..52c1f59 100644 --- a/algorithms_cpp/test/zip_iterator_test.cc +++ b/algorithms_cpp/test/zip_iterator_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -136,7 +136,7 @@ void ZipIteratorTest::TestZipScan() { Scan(embb::algorithms::Zip(vectorA.begin(), vectorB.begin()), embb::algorithms::Zip(vectorA.end(), vectorB.end()), vectorOut.begin(), 0, std::plus(), DotProductFunctor(), - embb::algorithms::ExecutionPolicy(), 0); + embb::mtapi::ExecutionPolicy(), 0); long sum = 0; for (size_t i = 0; i < kCountSize; i++) { diff --git a/algorithms_cpp/test/zip_iterator_test.h b/algorithms_cpp/test/zip_iterator_test.h index 954a404..56b4639 100644 --- a/algorithms_cpp/test/zip_iterator_test.h +++ b/algorithms_cpp/test/zip_iterator_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/CMakeLists.txt b/base_c/CMakeLists.txt index 8c3ba96..a05179d 100644 --- a/base_c/CMakeLists.txt +++ b/base_c/CMakeLists.txt @@ -77,14 +77,14 @@ endif() # Check headers and create configure file with preprocessor defines include(CheckIncludeFiles) # Includes module to perform checks include(CheckSymbolExists) # Includes module to perform symbol checks -check_include_files("sys/sysinfo.h" EMBB_HAS_HEADER_SYSINFO) -check_include_files("sys/types.h;sys/sysctl.h" EMBB_HAS_HEADER_SYSCTL) -check_include_files("sys/param.h;sys/cpuset.h" EMBB_HAS_HEADER_CPUSET) +check_include_files("sys/sysinfo.h" EMBB_PLATFORM_HAS_HEADER_SYSINFO) +check_include_files("sys/types.h;sys/sysctl.h" EMBB_PLATFORM_HAS_HEADER_SYSCTL) +check_include_files("sys/param.h;sys/cpuset.h" EMBB_PLATFORM_HAS_HEADER_CPUSET) link_libraries(${link_libraries} ${gnu_libs}) set(CMAKE_EXTRA_INCLUDE_FILES sched.h) - check_type_size(cpu_set_t EMBB_HAS_GLIB_CPU) + check_type_size(cpu_set_t EMBB_PLATFORM_HAS_GLIB_CPU) set(CMAKE_EXTRA_INCLUDE_FILES) -if(DEFINED EMBB_HAS_GLIB_CPU) +if(DEFINED EMBB_PLATFORM_HAS_GLIB_CPU) add_definitions(-D_GNU_SOURCE) # Needed to activate CPU_ macros endif() diff --git a/base_c/include/embb/base/c/atomic.h b/base_c/include/embb/base/c/atomic.h index ebf4f09..8875432 100644 --- a/base_c/include/embb/base/c/atomic.h +++ b/base_c/include/embb/base/c/atomic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -95,7 +95,7 @@ * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE void embb_atomic_and_assign_TYPE( +EMBB_PLATFORM_INLINE void embb_atomic_and_assign_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable which serves as left-hand side for the "and" operation and is used to store the result. */ @@ -120,7 +120,7 @@ EMBB_INLINE void embb_atomic_and_assign_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE int embb_atomic_compare_and_swap_TYPE( +EMBB_PLATFORM_INLINE int embb_atomic_compare_and_swap_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable */ TYPE* expected, @@ -140,7 +140,7 @@ EMBB_INLINE int embb_atomic_compare_and_swap_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE TYPE embb_atomic_fetch_and_add_TYPE( +EMBB_PLATFORM_INLINE TYPE embb_atomic_fetch_and_add_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable*/ TYPE value @@ -158,7 +158,7 @@ EMBB_INLINE TYPE embb_atomic_fetch_and_add_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE TYPE embb_atomic_load_TYPE( +EMBB_PLATFORM_INLINE TYPE embb_atomic_load_TYPE( const embb_atomic_TYPE* variable /**< [IN] Pointer to atomic variable */ ); @@ -169,7 +169,7 @@ EMBB_INLINE TYPE embb_atomic_load_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE void embb_atomic_memory_barrier(); +EMBB_PLATFORM_INLINE void embb_atomic_memory_barrier(); /** * Computes the logical "or" of the value stored in \p variable and \c value. @@ -182,7 +182,7 @@ EMBB_INLINE void embb_atomic_memory_barrier(); * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE void embb_atomic_or_assign_TYPE( +EMBB_PLATFORM_INLINE void embb_atomic_or_assign_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable which serves as left-hand side for the "or" operation and is used to store the result. */ @@ -199,7 +199,7 @@ EMBB_INLINE void embb_atomic_or_assign_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE void embb_atomic_store_TYPE( +EMBB_PLATFORM_INLINE void embb_atomic_store_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable */ int value @@ -217,7 +217,7 @@ EMBB_INLINE void embb_atomic_store_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE TYPE embb_atomic_swap_TYPE( +EMBB_PLATFORM_INLINE TYPE embb_atomic_swap_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable whose value is swapped */ TYPE value @@ -235,7 +235,7 @@ EMBB_INLINE TYPE embb_atomic_swap_TYPE( * \ingroup C_BASE_ATOMIC * \waitfree */ -EMBB_INLINE void embb_atomic_xor_assign_TYPE( +EMBB_PLATFORM_INLINE void embb_atomic_xor_assign_TYPE( embb_atomic_TYPE* variable, /**< [IN,OUT] Pointer to atomic variable which serves as left-hand side for the "xor" operation and is used to store the result. */ diff --git a/base_c/include/embb/base/c/base.h b/base_c/include/embb/base/c/base.h index bf13b59..0251a43 100644 --- a/base_c/include/embb/base/c/base.h +++ b/base_c/include/embb/base/c/base.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/condition_variable.h b/base_c/include/embb/base/c/condition_variable.h index f26a0a4..86143cc 100644 --- a/base_c/include/embb/base/c/condition_variable.h +++ b/base_c/include/embb/base/c/condition_variable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/core_set.h b/base_c/include/embb/base/c/core_set.h index 876bb54..0980fef 100644 --- a/base_c/include/embb/base/c/core_set.h +++ b/base_c/include/embb/base/c/core_set.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/counter.h b/base_c/include/embb/base/c/counter.h index bf6ed07..05536a2 100644 --- a/base_c/include/embb/base/c/counter.h +++ b/base_c/include/embb/base/c/counter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/duration.h b/base_c/include/embb/base/c/duration.h index 75f3040..fe1b435 100644 --- a/base_c/include/embb/base/c/duration.h +++ b/base_c/include/embb/base/c/duration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/errors.h b/base_c/include/embb/base/c/errors.h index 0f46373..3276dfc 100644 --- a/base_c/include/embb/base/c/errors.h +++ b/base_c/include/embb/base/c/errors.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/internal/atomic/and_assign.h b/base_c/include/embb/base/c/internal/atomic/and_assign.h index 86a0209..9a99f51 100644 --- a/base_c/include/embb/base/c/internal/atomic/and_assign.h +++ b/base_c/include/embb/base/c/internal/atomic/and_assign.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -53,21 +53,21 @@ * BYTE_SIZE is the number of bytes passed to the macro. * */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_AND_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern void __fastcall EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm( \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value); \ - EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \ + EMBB_PLATFORM_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \ _ReadWriteBarrier(); \ EMBB_CAT2(embb_internal__atomic_and_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, value); \ _ReadWriteBarrier(); \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_AND_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX)\ - EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_and_assign_, \ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_internal__atomic_and_assign_, \ EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \ __asm__ __volatile__("lock and" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \ : "+m" (*pointer_to_value), "+q" (value) \ @@ -89,12 +89,12 @@ EMBB_DEFINE_AND_ASSIGN(4, "l") EMBB_DEFINE_AND_ASSIGN(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_AND_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, \ EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ void EMBB_CAT2(embb_internal__atomic_and_assign_, \ EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ @@ -148,7 +148,7 @@ EMBB_DEFINE_AND_ASSIGN(4, "") * This generated function is supposed to be called by the user of the lib. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_AND_ASSIGN_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE void EMBB_CAT2(embb_atomic_and_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_atomic_and_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun;\ memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\ diff --git a/base_c/include/embb/base/c/internal/atomic/atomic_sizes.h.in b/base_c/include/embb/base/c/internal/atomic/atomic_sizes.h.in index b44d1f3..972239b 100644 --- a/base_c/include/embb/base/c/internal/atomic/atomic_sizes.h.in +++ b/base_c/include/embb/base/c/internal/atomic/atomic_sizes.h.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -56,7 +56,7 @@ typedef uint64_t EMBB_BASE_BASIC_TYPE_SIZE_8; #define EMBB_UINTMAX_T_TYPE_SIZE ${EMBB_UINTMAX_T_TYPE_SIZE} -#ifdef EMBB_ARCH_X86_64 +#ifdef EMBB_PLATFORM_ARCH_X86_64 # define EMBB_64_BIT_ATOMIC_AVAILABLE_VAL 1 # define EMBB_64_BIT_ATOMIC_AVAILABLE #else diff --git a/base_c/include/embb/base/c/internal/atomic/atomic_variables.h b/base_c/include/embb/base/c/internal/atomic/atomic_variables.h index 57aa9b3..1b06df9 100644 --- a/base_c/include/embb/base/c/internal/atomic/atomic_variables.h +++ b/base_c/include/embb/base/c/internal/atomic/atomic_variables.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,7 +30,7 @@ #include #include -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #include #endif diff --git a/base_c/include/embb/base/c/internal/atomic/compare_and_swap.h b/base_c/include/embb/base/c/internal/atomic/compare_and_swap.h index 2837589..bf6c273 100644 --- a/base_c/include/embb/base/c/internal/atomic/compare_and_swap.h +++ b/base_c/include/embb/base/c/internal/atomic/compare_and_swap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,13 +39,13 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_COMPARE_AND_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern int __fastcall EMBB_CAT2(embb_internal__atomic_compare_and_swap_, EMBB_PARAMETER_SIZE_BYTE)_asm( \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired); \ - EMBB_INLINE int __fastcall EMBB_CAT2(embb_internal__atomic_compare_and_swap_, EMBB_PARAMETER_SIZE_BYTE)( \ + EMBB_PLATFORM_INLINE int __fastcall EMBB_CAT2(embb_internal__atomic_compare_and_swap_, EMBB_PARAMETER_SIZE_BYTE)( \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired) { \ int result; \ _ReadWriteBarrier(); \ @@ -53,9 +53,9 @@ _ReadWriteBarrier(); \ return result; \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_COMPARE_AND_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ - EMBB_INLINE int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \ + EMBB_PLATFORM_INLINE int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \ EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* expected, \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) desired) { \ char result; \ @@ -82,12 +82,12 @@ EMBB_DEFINE_COMPARE_AND_SWAP(4, "l") EMBB_DEFINE_COMPARE_AND_SWAP(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_COMPARE_AND_SWAP(EMBB_PARAMETER_SIZE_BYTE, \ EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ int EMBB_CAT2(embb_internal__atomic_compare_and_swap_, \ EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ @@ -134,7 +134,7 @@ EMBB_DEFINE_COMPARE_AND_SWAP(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_COMPARE_AND_SWAP_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE int EMBB_CAT2(embb_atomic_compare_and_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ + EMBB_PLATFORM_INLINE int EMBB_CAT2(embb_atomic_compare_and_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE* expected, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE desired) {\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) desired_pun;\ memcpy(&desired_pun, &desired, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\ diff --git a/base_c/include/embb/base/c/internal/atomic/fetch_and_add.h b/base_c/include/embb/base/c/internal/atomic/fetch_and_add.h index b0061a4..627c817 100644 --- a/base_c/include/embb/base/c/internal/atomic/fetch_and_add.h +++ b/base_c/include/embb/base/c/internal/atomic/fetch_and_add.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -38,13 +38,13 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_FETCH_AND_ADD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE)_asm( \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value); \ - EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) (\ + EMBB_PLATFORM_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) (\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) {\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \ _ReadWriteBarrier(); \ @@ -53,9 +53,9 @@ _ReadWriteBarrier(); \ return result; \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_FETCH_AND_ADD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ - EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) \ + EMBB_PLATFORM_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_fetch_and_add_, EMBB_PARAMETER_SIZE_BYTE) \ (EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) { \ __asm__ __volatile__ ("lock xadd" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \ : "+m" (*pointer_to_value), "+q" (new_value) \ @@ -78,12 +78,12 @@ EMBB_DEFINE_FETCH_AND_ADD(4, "l") EMBB_DEFINE_FETCH_AND_ADD(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_FETCH_AND_ADD(EMBB_PARAMETER_SIZE_BYTE, \ EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ EMBB_CAT2(embb_internal__atomic_fetch_and_add_, \ EMBB_PARAMETER_SIZE_BYTE)(\ @@ -92,17 +92,17 @@ EMBB_DEFINE_FETCH_AND_ADD(8, "q") EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ new_value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ - tmp, result; \ + tmp1, tmp2, result; \ __asm__ __volatile__ ( \ "dmb\n\t" \ "loop_%=:\n\t" \ - "ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %0, [%2]\n\t" \ - "add %1, %0, %3\n\t" \ - "strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %1, %1, [%2]\n\t" \ - "teq %1, #0\n\t" \ + "ldrex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %0, [%3]\n\t" \ + "add %1, %0, %4\n\t" \ + "strex" EMBB_ATOMIC_ARM_SIZE_SUFFIX " %2, %1, [%3]\n\t" \ + "teq %2, #0\n\t" \ "bne loop_%=\n\t" \ "isb" \ - : "=&r" (result), "=&r" (tmp) \ + : "=&r" (result), "=&r" (tmp1), "=&r" (tmp2) \ : "r" (pointer_to_value), "r" (new_value) \ : "memory", "cc" ); \ return result; \ @@ -127,7 +127,7 @@ EMBB_DEFINE_FETCH_AND_ADD(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_FETCH_AND_ADD_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_fetch_and_add_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ + EMBB_PLATFORM_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_fetch_and_add_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun; \ memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE)); \ diff --git a/base_c/include/embb/base/c/internal/atomic/generate_atomic_implementation_template.h b/base_c/include/embb/base/c/internal/atomic/generate_atomic_implementation_template.h index 6f7ab9a..49a38f7 100644 --- a/base_c/include/embb/base/c/internal/atomic/generate_atomic_implementation_template.h +++ b/base_c/include/embb/base/c/internal/atomic/generate_atomic_implementation_template.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/internal/atomic/load.h b/base_c/include/embb/base/c/internal/atomic/load.h index eb689d1..8a01f08 100644 --- a/base_c/include/embb/base/c/internal/atomic/load.h +++ b/base_c/include/embb/base/c/internal/atomic/load.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,13 +39,13 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_LOAD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)_asm( \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value); \ - EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value) { \ register EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \ _ReadWriteBarrier(); \ @@ -54,9 +54,9 @@ _ReadWriteBarrier(); \ return result; \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_LOAD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ - EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ + EMBB_PLATFORM_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value) { \ /* no fence required for loads */ \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \ @@ -81,11 +81,11 @@ EMBB_DEFINE_LOAD(4, "l") EMBB_DEFINE_LOAD(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_LOAD(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ EMBB_CAT2(embb_internal__atomic_load_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ @@ -118,7 +118,7 @@ EMBB_DEFINE_LOAD(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_LOAD_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_load_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ + EMBB_PLATFORM_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_load_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ const EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ return_val = (EMBB_CAT2(embb_internal__atomic_load_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE)(\ diff --git a/base_c/include/embb/base/c/internal/atomic/memory_barrier.h b/base_c/include/embb/base/c/internal/atomic/memory_barrier.h index 3fc1fb2..a7e0966 100644 --- a/base_c/include/embb/base/c/internal/atomic/memory_barrier.h +++ b/base_c/include/embb/base/c/internal/atomic/memory_barrier.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -31,32 +31,32 @@ #ifndef DOXYGEN -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #include #endif -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC extern void __fastcall embb_internal__atomic_memory_barrier_asm(); // Read/write barrier -EMBB_INLINE void __fastcall embb_atomic_memory_barrier() { +EMBB_PLATFORM_INLINE void __fastcall embb_atomic_memory_barrier() { _ReadWriteBarrier(); embb_internal__atomic_memory_barrier_asm(); _ReadWriteBarrier(); } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) // Read/write barrier -EMBB_INLINE void embb_atomic_memory_barrier() { +EMBB_PLATFORM_INLINE void embb_atomic_memory_barrier() { __asm__ __volatile__ ("mfence" : : : "memory"); } #else #error "No atomic fetch and store implementation found" #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -EMBB_INLINE void embb_atomic_memory_barrier() { +EMBB_PLATFORM_INLINE void embb_atomic_memory_barrier() { __asm__ __volatile__ ("dmb" : : : "memory"); } diff --git a/base_c/include/embb/base/c/internal/atomic/or_assign.h b/base_c/include/embb/base/c/internal/atomic/or_assign.h index a1f2b12..b492529 100644 --- a/base_c/include/embb/base/c/internal/atomic/or_assign.h +++ b/base_c/include/embb/base/c/internal/atomic/or_assign.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,22 +39,22 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_OR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern void __fastcall EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value); \ - EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \ _ReadWriteBarrier(); \ EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, value); \ _ReadWriteBarrier(); \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_OR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ - EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \ __asm__ __volatile__("lock or" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \ : "+m" (*pointer_to_value), "+q" (value) \ @@ -77,12 +77,12 @@ EMBB_DEFINE_OR_ASSIGN(4, "l") EMBB_DEFINE_OR_ASSIGN(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_OR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, \ EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ void EMBB_CAT2(embb_internal__atomic_or_assign_, \ EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ @@ -120,7 +120,7 @@ EMBB_DEFINE_OR_ASSIGN(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_OR_ASSIGN_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE void EMBB_CAT2(embb_atomic_or_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_atomic_or_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun;\ memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\ EMBB_CAT2(embb_internal__atomic_or_assign_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE)((EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) volatile *)\ diff --git a/base_c/include/embb/base/c/internal/atomic/store.h b/base_c/include/embb/base/c/internal/atomic/store.h index 060385c..c139f2e 100644 --- a/base_c/include/embb/base/c/internal/atomic/store.h +++ b/base_c/include/embb/base/c/internal/atomic/store.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,13 +39,13 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_STORE(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX)\ extern void __fastcall EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)_asm( \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value); \ - EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) \ { \ _ReadWriteBarrier(); \ @@ -53,9 +53,9 @@ EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, new_value); \ _ReadWriteBarrier(); \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_STORE(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX)\ - EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) {\ /*the lock prefix is implicit for xchg*/ \ __asm__ __volatile__("xchg" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \ @@ -78,11 +78,11 @@ EMBB_DEFINE_STORE(4, "l") EMBB_DEFINE_STORE(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_STORE(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_ARM_SIZE_SUFFIX)\ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ void EMBB_CAT2(embb_internal__atomic_store_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* \ pointer_to_value, \ @@ -115,7 +115,7 @@ EMBB_DEFINE_STORE(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_STORE_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE void EMBB_CAT2(embb_atomic_store_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_atomic_store_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun; \ memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE)); \ EMBB_CAT2(embb_internal__atomic_store_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE)((EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) volatile *)\ diff --git a/base_c/include/embb/base/c/internal/atomic/swap.h b/base_c/include/embb/base/c/internal/atomic/swap.h index e0e80ed..0c53f63 100644 --- a/base_c/include/embb/base/c/internal/atomic/swap.h +++ b/base_c/include/embb/base/c/internal/atomic/swap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,13 +39,13 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2 (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)_asm(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value); \ - EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2 (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) __fastcall EMBB_CAT2 (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) result; \ _ReadWriteBarrier(); \ @@ -53,9 +53,9 @@ _ReadWriteBarrier(); \ return result; \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ - EMBB_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2(embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) new_value)\ { \ /*the lock prefix is implicit for xchg*/ \ @@ -80,11 +80,11 @@ EMBB_DEFINE_SWAP(4, "l") EMBB_DEFINE_SWAP(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_SWAP(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) EMBB_CAT2 \ (embb_internal__atomic_swap_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ @@ -123,7 +123,7 @@ EMBB_DEFINE_SWAP(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_SWAP_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ + EMBB_PLATFORM_INLINE EMBB_ATOMIC_PARAMETER_TYPE_NATIVE EMBB_CAT2(embb_atomic_swap_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun; \ memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE)); \ diff --git a/base_c/include/embb/base/c/internal/atomic/xor_assign.h b/base_c/include/embb/base/c/internal/atomic/xor_assign.h index 3e2b908..823dee0 100644 --- a/base_c/include/embb/base/c/internal/atomic/xor_assign.h +++ b/base_c/include/embb/base/c/internal/atomic/xor_assign.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,22 +39,22 @@ * See file and_assign.h for a detailed (and operation independent) description * of the following macro. */ -#ifdef EMBB_ARCH_X86 +#ifdef EMBB_PLATFORM_ARCH_X86 -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #define EMBB_DEFINE_XOR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ extern void __fastcall EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)_asm(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value); \ - EMBB_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE void __fastcall EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \ _ReadWriteBarrier(); \ EMBB_CAT2(embb_internal__atomic_xor_assign_, \ EMBB_PARAMETER_SIZE_BYTE)_asm(pointer_to_value, value); \ _ReadWriteBarrier(); \ } -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_XOR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, EMBB_ATOMIC_X86_SIZE_SUFFIX) \ - EMBB_INLINE void EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_internal__atomic_xor_assign_, EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) volatile* pointer_to_value, \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) value) { \ __asm__ __volatile__("lock xor" EMBB_ATOMIC_X86_SIZE_SUFFIX " %1, %0" \ @@ -78,12 +78,12 @@ EMBB_DEFINE_XOR_ASSIGN(4, "l") EMBB_DEFINE_XOR_ASSIGN(8, "q") #endif -#elif defined(EMBB_ARCH_ARM) +#elif defined(EMBB_PLATFORM_ARCH_ARM) -#if defined(EMBB_COMPILER_GNUC) +#if defined(EMBB_PLATFORM_COMPILER_GNUC) #define EMBB_DEFINE_XOR_ASSIGN(EMBB_PARAMETER_SIZE_BYTE, \ EMBB_ATOMIC_ARM_SIZE_SUFFIX) \ - EMBB_INLINE \ + EMBB_PLATFORM_INLINE \ void EMBB_CAT2(embb_internal__atomic_xor_assign_, \ EMBB_PARAMETER_SIZE_BYTE)(\ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_PARAMETER_SIZE_BYTE) \ @@ -121,7 +121,7 @@ EMBB_DEFINE_XOR_ASSIGN(4, "") * of the following macro. */ #define EMBB_ATOMIC_INTERNAL_DEFINE_XOR_ASSIGN_METHOD(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) \ - EMBB_INLINE void EMBB_CAT2(embb_atomic_xor_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ + EMBB_PLATFORM_INLINE void EMBB_CAT2(embb_atomic_xor_assign_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)(\ EMBB_CAT2(embb_atomic_, EMBB_ATOMIC_PARAMETER_ATOMIC_TYPE_SUFFIX)* variable, EMBB_ATOMIC_PARAMETER_TYPE_NATIVE value) { \ EMBB_CAT2(EMBB_BASE_BASIC_TYPE_SIZE_, EMBB_ATOMIC_PARAMETER_TYPE_SIZE) value_pun;\ memcpy(&value_pun, &value, sizeof(EMBB_ATOMIC_PARAMETER_TYPE_NATIVE));\ diff --git a/base_c/include/embb/base/c/internal/bitset.h b/base_c/include/embb/base/c/internal/bitset.h index 6ff6959..b32e6c7 100644 --- a/base_c/include/embb/base/c/internal/bitset.h +++ b/base_c/include/embb/base/c/internal/bitset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -33,7 +33,7 @@ #include -EMBB_INLINE void embb_bitset_set( +EMBB_PLATFORM_INLINE void embb_bitset_set( uint64_t * that, unsigned int bit ) { @@ -42,7 +42,7 @@ EMBB_INLINE void embb_bitset_set( *that |= (1ull << bit); } -EMBB_INLINE void embb_bitset_set_n( +EMBB_PLATFORM_INLINE void embb_bitset_set_n( uint64_t * that, unsigned int count) { assert(NULL != that); @@ -55,7 +55,7 @@ EMBB_INLINE void embb_bitset_set_n( } } -EMBB_INLINE void embb_bitset_clear( +EMBB_PLATFORM_INLINE void embb_bitset_clear( uint64_t * that, unsigned int bit ) { @@ -64,21 +64,21 @@ EMBB_INLINE void embb_bitset_clear( *that &= ~(1ull << bit); } -EMBB_INLINE void embb_bitset_clear_all( +EMBB_PLATFORM_INLINE void embb_bitset_clear_all( uint64_t * that ) { assert(NULL != that); *that = 0ull; } -EMBB_INLINE unsigned int embb_bitset_is_set( +EMBB_PLATFORM_INLINE unsigned int embb_bitset_is_set( uint64_t const * that, unsigned int bit ) { return (unsigned int)((*that & (1ull << bit)) ? 1 : 0); } -EMBB_INLINE void embb_bitset_intersect( +EMBB_PLATFORM_INLINE void embb_bitset_intersect( uint64_t * that, uint64_t mask ) { @@ -86,7 +86,7 @@ EMBB_INLINE void embb_bitset_intersect( *that &= mask; } -EMBB_INLINE void embb_bitset_union( +EMBB_PLATFORM_INLINE void embb_bitset_union( uint64_t * that, uint64_t mask ) { @@ -94,7 +94,7 @@ EMBB_INLINE void embb_bitset_union( *that |= mask; } -EMBB_INLINE unsigned int embb_bitset_count( +EMBB_PLATFORM_INLINE unsigned int embb_bitset_count( uint64_t const * that ) { unsigned int count = 0; diff --git a/base_c/include/embb/base/c/internal/cmake_config.h.in b/base_c/include/embb/base/c/internal/cmake_config.h.in index 7b53f82..12eae11 100644 --- a/base_c/include/embb/base/c/internal/cmake_config.h.in +++ b/base_c/include/embb/base/c/internal/cmake_config.h.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -36,21 +36,21 @@ /** * Is used to get the number of cores on certain systems. */ -#cmakedefine EMBB_HAS_HEADER_SYSINFO +#cmakedefine EMBB_PLATFORM_HAS_HEADER_SYSINFO /** * Is used to get the number of cores on certain systems. */ -#cmakedefine EMBB_HAS_HEADER_SYSCTL +#cmakedefine EMBB_PLATFORM_HAS_HEADER_SYSCTL /** * Is used to set thread affinities on certain systems. */ -#cmakedefine EMBB_HAS_HEADER_CPUSET +#cmakedefine EMBB_PLATFORM_HAS_HEADER_CPUSET /** * Is used for Linux thread affinities. */ -#cmakedefine EMBB_HAS_GLIB_CPU +#cmakedefine EMBB_PLATFORM_HAS_GLIB_CPU -#endif /* EMBB_BASE_INTERNAL_CMAKE_CONFIG_H_ */ \ No newline at end of file +#endif /* EMBB_BASE_INTERNAL_CMAKE_CONFIG_H_ */ diff --git a/base_c/include/embb/base/c/internal/config.h b/base_c/include/embb/base/c/internal/config.h index daf563a..3c34467 100644 --- a/base_c/include/embb/base/c/internal/config.h +++ b/base_c/include/embb/base/c/internal/config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -45,9 +45,9 @@ * which has 128 bytes. */ #if defined(_M_IA64) || defined(_IA64) -#define EMBB_CACHE_LINE_SIZE 128 +#define EMBB_PLATFORM_CACHE_LINE_SIZE 128 #else -#define EMBB_CACHE_LINE_SIZE 64 +#define EMBB_PLATFORM_CACHE_LINE_SIZE 64 #endif /* For MSVC, if _DEBUG is set, set also EMBB_DEBUG. @@ -59,41 +59,41 @@ #endif #ifdef __GNUC__ -#define EMBB_ALIGN(size) __attribute__ ((aligned(size))) +#define EMBB_PLATFORM_ALIGN(size) __attribute__ ((aligned(size))) #elif defined _MSC_VER || defined __INTEL_COMPILER -#define EMBB_ALIGN(size) __declspec(align(size)) +#define EMBB_PLATFORM_ALIGN(size) __declspec(align(size)) #else #error "Unsupported compiler" #endif #if __GNUC__ -#define EMBB_INLINE static inline -#define EMBB_COMPILER_GNUC +#define EMBB_PLATFORM_INLINE static inline +#define EMBB_PLATFORM_COMPILER_GNUC #elif _MSC_VER -#define EMBB_INLINE __inline -#define EMBB_COMPILER_MSVC +#define EMBB_PLATFORM_INLINE __inline +#define EMBB_PLATFORM_COMPILER_MSVC #else -#define EMBB_INLINE inline -#define EMBB_COMPILER_UNKNOWN +#define EMBB_PLATFORM_INLINE inline +#define EMBB_PLATFORM_COMPILER_UNKNOWN #endif #if defined(__x86_64__) || defined(_M_X64) -#define EMBB_ARCH_X86_64 -#define EMBB_ARCH_X86 -#define EMBB_HAS_CAS_64 +#define EMBB_PLATFORM_ARCH_X86_64 +#define EMBB_PLATFORM_ARCH_X86 +#define EMBB_PLATFORM_HAS_CAS_64 #elif defined(__i386) || defined(_M_IX86) -#define EMBB_ARCH_X86_32 -#define EMBB_ARCH_X86 +#define EMBB_PLATFORM_ARCH_X86_32 +#define EMBB_PLATFORM_ARCH_X86 #elif defined(__arm__) -#define EMBB_ARCH_ARM +#define EMBB_PLATFORM_ARCH_ARM #else -#define EMBB_ARCH_UNKNOWN +#define EMBB_PLATFORM_ARCH_UNKNOWN #endif -#if defined(EMBB_COMPILER_MSVC) -#define EMBB_THREADING_WINTHREADS -#elif defined(EMBB_COMPILER_GNUC) -#define EMBB_THREADING_POSIXTHREADS +#if defined(EMBB_PLATFORM_COMPILER_MSVC) +#define EMBB_PLATFORM_THREADING_WINTHREADS +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) +#define EMBB_PLATFORM_THREADING_POSIXTHREADS #else #error "No thread implementation could be determined" #endif diff --git a/base_c/include/embb/base/c/internal/macro_helper.h b/base_c/include/embb/base/c/internal/macro_helper.h index 71bceb2..857d71d 100644 --- a/base_c/include/embb/base/c/internal/macro_helper.h +++ b/base_c/include/embb/base/c/internal/macro_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/internal/platform.h b/base_c/include/embb/base/c/internal/platform.h index 4ed71f4..7f025fc 100644 --- a/base_c/include/embb/base/c/internal/platform.h +++ b/base_c/include/embb/base/c/internal/platform.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -37,9 +37,9 @@ extern "C" { #define EMBB_TIME_MAX_SECONDS ULLONG_MAX #define EMBB_DURATION_MAX_SECONDS 60 * 60 * 24 * 7 -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC // Suppress virtual functions but non-virtual constructor warning // in windows headers #pragma warning(push) @@ -49,7 +49,7 @@ extern "C" { #define NOMINMAX #include -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(pop) // Reset warning 4640 #endif @@ -71,7 +71,7 @@ typedef CONDITION_VARIABLE embb_condition_t; #define EMBB_THREAD_SPECIFIC static __declspec(thread) -#elif defined EMBB_THREADING_POSIXTHREADS /* EMBB_THREADING_WINTHREADS */ +#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS #include #include @@ -95,7 +95,7 @@ typedef pthread_cond_t embb_condition_t; #define EMBB_THREAD_SPECIFIC __thread -#else /* EMBB_THREADING_POSIXTHREADS */ +#else /* EMBB_PLATFORM_THREADING_POSIXTHREADS */ #error "No threading platform defined!" @@ -105,4 +105,4 @@ typedef pthread_cond_t embb_condition_t; } /* Close extern "C" { */ #endif -#endif /* EMBB_BASE_C_INTERNAL_PLATFORM_H_ */ +#endif // EMBB_BASE_C_INTERNAL_PLATFORM_H_ diff --git a/base_c/include/embb/base/c/internal/thread_index.h b/base_c/include/embb/base/c/internal/thread_index.h index 67c6ba1..0bda787 100644 --- a/base_c/include/embb/base/c/internal/thread_index.h +++ b/base_c/include/embb/base/c/internal/thread_index.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/internal/unused.h b/base_c/include/embb/base/c/internal/unused.h index 5e8d18d..2109249 100644 --- a/base_c/include/embb/base/c/internal/unused.h +++ b/base_c/include/embb/base/c/internal/unused.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/log.h b/base_c/include/embb/base/c/log.h index 3faacc5..68419c4 100644 --- a/base_c/include/embb/base/c/log.h +++ b/base_c/include/embb/base/c/log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/memory_allocation.h b/base_c/include/embb/base/c/memory_allocation.h index d263cb0..c9d797d 100644 --- a/base_c/include/embb/base/c/memory_allocation.h +++ b/base_c/include/embb/base/c/memory_allocation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/mutex.h b/base_c/include/embb/base/c/mutex.h index 53f5e73..ffd2c7f 100644 --- a/base_c/include/embb/base/c/mutex.h +++ b/base_c/include/embb/base/c/mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/thread.h b/base_c/include/embb/base/c/thread.h index 183731e..0e9efd2 100644 --- a/base_c/include/embb/base/c/thread.h +++ b/base_c/include/embb/base/c/thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/thread_specific_storage.h b/base_c/include/embb/base/c/thread_specific_storage.h index 38457d6..3b70bed 100644 --- a/base_c/include/embb/base/c/thread_specific_storage.h +++ b/base_c/include/embb/base/c/thread_specific_storage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/include/embb/base/c/time.h b/base_c/include/embb/base/c/time.h index 271242d..a220ce7 100644 --- a/base_c/include/embb/base/c/time.h +++ b/base_c/include/embb/base/c/time.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/src/atomic.c b/base_c/src/atomic.c index efb2242..e21603e 100644 --- a/base_c/src/atomic.c +++ b/base_c/src/atomic.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/src/condition_variable.c b/base_c/src/condition_variable.c index f0880ab..81f8c3b 100644 --- a/base_c/src/condition_variable.c +++ b/base_c/src/condition_variable.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -43,7 +43,7 @@ int embb_condition_wait_for(embb_condition_t* condition_var, return embb_condition_wait_until(condition_var, mutex, &time); } -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS int embb_condition_init(embb_condition_t* condition_var) { assert(condition_var != NULL); @@ -108,9 +108,9 @@ int embb_condition_destroy(embb_condition_t* condition_var) { return EMBB_SUCCESS; } -#endif /* EMBB_THREADING_WINTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_WINTHREADS */ -#ifdef EMBB_THREADING_POSIXTHREADS +#ifdef EMBB_PLATFORM_THREADING_POSIXTHREADS int embb_condition_init(embb_condition_t* condition_var) { assert(condition_var != NULL); @@ -165,4 +165,4 @@ int embb_condition_destroy(embb_condition_t* condition_var) { return EMBB_SUCCESS; } -#endif /* EMBB_THREADING_POSIXTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_POSIXTHREADS */ diff --git a/base_c/src/core_set.c b/base_c/src/core_set.c index dc19ad7..aa142f3 100644 --- a/base_c/src/core_set.c +++ b/base_c/src/core_set.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -31,7 +31,7 @@ #include #include -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS /** * For handling of more than 64 logical processors on Windows. @@ -87,21 +87,21 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) { } } -#endif /* EMBB_THREADING_WINTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_WINTHREADS */ -#ifdef EMBB_THREADING_POSIXTHREADS +#ifdef EMBB_PLATFORM_THREADING_POSIXTHREADS -#ifdef EMBB_HAS_HEADER_SYSINFO +#ifdef EMBB_PLATFORM_HAS_HEADER_SYSINFO #include -#elif defined EMBB_HAS_HEADER_SYSCTL +#elif defined EMBB_PLATFORM_HAS_HEADER_SYSCTL #include #include #endif unsigned int embb_core_count_available() { -#ifdef EMBB_HAS_HEADER_SYSINFO +#ifdef EMBB_PLATFORM_HAS_HEADER_SYSINFO return get_nprocs(); -#elif defined EMBB_HAS_HEADER_SYSCTL +#elif defined EMBB_PLATFORM_HAS_HEADER_SYSCTL const size_t kBufferSize = sizeof(unsigned int); char buf[kBufferSize]; size_t len = kBufferSize; @@ -123,7 +123,7 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) { } } -#endif /* EMBB_THREADING_POSIXTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_POSIXTHREADS */ void embb_core_set_add(embb_core_set_t* core_set, unsigned int core_number) { assert(core_set != NULL); diff --git a/base_c/src/counter.c b/base_c/src/counter.c index 1e8bb1c..d71eb4d 100644 --- a/base_c/src/counter.c +++ b/base_c/src/counter.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/src/duration.c b/base_c/src/duration.c index 62b5283..8db8c7c 100644 --- a/base_c/src/duration.c +++ b/base_c/src/duration.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/src/internal/thread_index.c b/base_c/src/internal/thread_index.c index fe3dbab..80f6d1f 100644 --- a/base_c/src/internal/thread_index.c +++ b/base_c/src/internal/thread_index.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/src/log.c b/base_c/src/log.c index 0c16228..c544947 100644 --- a/base_c/src/log.c +++ b/base_c/src/log.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -91,14 +91,14 @@ static void embb_log_write_internal( log_level_str = " "; break; } -#if defined(EMBB_COMPILER_MSVC) +#if defined(EMBB_PLATFORM_COMPILER_MSVC) char msg_buffer[400]; char buffer[500]; vsprintf_s(msg_buffer, sizeof(msg_buffer), message, argp); sprintf_s(buffer, sizeof(buffer), "[%s] - [%s] %s", channel_str, log_level_str, msg_buffer); embb_log_global_log_function(log_context, buffer); -#elif defined(EMBB_COMPILER_GNUC) +#elif defined(EMBB_PLATFORM_COMPILER_GNUC) char msg_buffer[400]; char buffer[500]; vsnprintf(msg_buffer, sizeof(msg_buffer), message, argp); diff --git a/base_c/src/memory_allocation.c b/base_c/src/memory_allocation.c index c6f8bfc..e1462db 100644 --- a/base_c/src/memory_allocation.c +++ b/base_c/src/memory_allocation.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -166,7 +166,7 @@ void embb_free(void * ptr) { void *embb_alloc_aligned(size_t alignment, size_t size) { void* malloc_addr = NULL; -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC /* * From the Documentation: * Allocates memory on a specified alignment boundary. @@ -176,7 +176,7 @@ void *embb_alloc_aligned(size_t alignment, size_t size) { * failed. The pointer is a multiple of alignment. */ malloc_addr = _aligned_malloc(size, alignment); -#elif defined EMBB_COMPILER_GNUC +#elif defined EMBB_PLATFORM_COMPILER_GNUC /* * From the Documentation: * The posix_memalign() function shall allocate size bytes aligned on a @@ -193,10 +193,10 @@ void *embb_alloc_aligned(size_t alignment, size_t size) { } void embb_free_aligned(void* ptr) { -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC _aligned_free(ptr); #else -#ifdef EMBB_COMPILER_GNUC +#ifdef EMBB_PLATFORM_COMPILER_GNUC free(ptr); #else #error Unsupported compiler @@ -211,5 +211,5 @@ size_t embb_get_bytes_allocated() { #endif void *embb_alloc_cache_aligned(size_t size) { - return embb_alloc_aligned(EMBB_CACHE_LINE_SIZE, size); + return embb_alloc_aligned(EMBB_PLATFORM_CACHE_LINE_SIZE, size); } diff --git a/base_c/src/mutex.c b/base_c/src/mutex.c index 47ff982..cd32696 100644 --- a/base_c/src/mutex.c +++ b/base_c/src/mutex.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -29,7 +29,7 @@ #include -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS int embb_mutex_init(embb_mutex_t* mutex, int type) { /* Critical sections in Windows are always recursive */ @@ -59,9 +59,9 @@ void embb_mutex_destroy(embb_mutex_t* mutex) { DeleteCriticalSection(mutex); } -#endif /* EMBB_THREADING_WINTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_WINTHREADS */ -#ifdef EMBB_THREADING_POSIXTHREADS +#ifdef EMBB_PLATFORM_THREADING_POSIXTHREADS int embb_mutex_init(embb_mutex_t* mutex, int type) { if (type == EMBB_MUTEX_PLAIN) { @@ -71,9 +71,13 @@ int embb_mutex_init(embb_mutex_t* mutex, int type) { pthread_mutexattr_t attributes; if (pthread_mutexattr_init(&attributes) != 0) return EMBB_ERROR; if (pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_RECURSIVE) != 0) { + pthread_mutexattr_destroy(&attributes); + return EMBB_ERROR; + } + if (pthread_mutex_init(mutex, &attributes) != 0) { + pthread_mutexattr_destroy(&attributes); return EMBB_ERROR; } - if (pthread_mutex_init(mutex, &attributes) != 0) return EMBB_ERROR; if (pthread_mutexattr_destroy(&attributes) != 0) return EMBB_ERROR; } return EMBB_SUCCESS; @@ -110,4 +114,4 @@ void embb_mutex_destroy(embb_mutex_t* mutex) { pthread_mutex_destroy(mutex); } -#endif /* EMBB_THREADING_POSIXTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_POSIXTHREADS */ diff --git a/base_c/src/thread.c b/base_c/src/thread.c index dc62dce..e7abb40 100644 --- a/base_c/src/thread.c +++ b/base_c/src/thread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -40,7 +40,7 @@ void embb_thread_set_max_count(unsigned int max) { embb_internal_thread_index_set_max(max); } -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS /** * Used to wrap client thread start function and argument when calling internal @@ -151,21 +151,21 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) { return 0; } -#endif /* EMBB_THREADING_WINTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_WINTHREADS */ -#ifdef EMBB_THREADING_POSIXTHREADS +#ifdef EMBB_PLATFORM_THREADING_POSIXTHREADS -#ifdef EMBB_HAS_GLIB_CPU +#ifdef EMBB_PLATFORM_HAS_GLIB_CPU #include -#elif defined EMBB_HAS_HEADER_CPUSET +#elif defined EMBB_PLATFORM_HAS_HEADER_CPUSET #include #include #include #endif -#ifdef EMBB_HAS_HEADER_SYSINFO +#ifdef EMBB_PLATFORM_HAS_HEADER_SYSINFO #include /* Used to get number of processors */ -#endif /* EMBB_HAS_HEADER_SYSINFO */ +#endif /* EMBB_PLATFORM_HAS_HEADER_SYSINFO */ /** * Used to wrap client thread start function and argument when calling internal @@ -207,10 +207,11 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set, int status = pthread_attr_init(&attr); if (status != 0) return EMBB_ERROR; if (core_set != NULL) { -#if defined(EMBB_HAS_GLIB_CPU) || defined(EMBB_HAS_HEADER_CPUSET) +#if defined(EMBB_PLATFORM_HAS_GLIB_CPU) || \ + defined(EMBB_PLATFORM_HAS_HEADER_CPUSET) assert(embb_core_count_available() < CPU_SETSIZE && "Core sets are only supported up to CPU_SETSIZE processors!"); -#ifdef EMBB_HAS_GLIB_CPU +#ifdef EMBB_PLATFORM_HAS_GLIB_CPU cpu_set_t cpuset; #else cpuset_t cpuset; @@ -243,7 +244,7 @@ int embb_thread_create(embb_thread_t* thread, const embb_core_set_t* core_set, (void*)(thread->embb_internal_arg)); /* arguments to thread start func. */ if (status != 0) return EMBB_ERROR; - pthread_attr_destroy(&attr); + status = pthread_attr_destroy(&attr); if (status != 0) return EMBB_ERROR; return EMBB_SUCCESS; } @@ -265,4 +266,4 @@ int embb_thread_equal(const embb_thread_t* lhs, const embb_thread_t* rhs) { return pthread_equal(lhs->embb_internal_handle, rhs->embb_internal_handle); } -#endif /* EMBB_THREADING_POSIXTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_POSIXTHREADS */ diff --git a/base_c/src/thread_specific_storage.c b/base_c/src/thread_specific_storage.c index a925462..fea5d18 100644 --- a/base_c/src/thread_specific_storage.c +++ b/base_c/src/thread_specific_storage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -57,6 +57,7 @@ int embb_tss_set(embb_tss_t* tss, void* value) { void* embb_tss_get(const embb_tss_t* tss) { assert(tss != NULL); + assert(tss->values != NULL); unsigned int index = 0; int status = embb_internal_thread_index(&index); if ((status != EMBB_SUCCESS) || (index >= tss->size)) { diff --git a/base_c/src/time.c b/base_c/src/time.c index 04f3968..bc92363 100644 --- a/base_c/src/time.c +++ b/base_c/src/time.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -53,7 +53,7 @@ int embb_time_compare(const embb_time_t* lhs, const embb_time_t* rhs) { } -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS int embb_time_in(embb_time_t* time, const embb_duration_t* duration) { assert(time != NULL); @@ -81,10 +81,10 @@ int embb_time_in(embb_time_t* time, const embb_duration_t* duration) { return EMBB_SUCCESS; } -#endif /* EMBB_THREADING_WINTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_WINTHREADS */ -#ifdef EMBB_THREADING_POSIXTHREADS +#ifdef EMBB_PLATFORM_THREADING_POSIXTHREADS int embb_time_in(embb_time_t* time, const embb_duration_t* duration) { assert(time != NULL); @@ -102,5 +102,5 @@ int embb_time_in(embb_time_t* time, const embb_duration_t* duration) { return EMBB_SUCCESS; } -#endif /* EMBB_THREADING_POSIXTHREADS */ +#endif /* EMBB_PLATFORM_THREADING_POSIXTHREADS */ diff --git a/base_c/test/alloc_test.cc b/base_c/test/alloc_test.cc index 0e32bb8..3ddaf4a 100644 --- a/base_c/test/alloc_test.cc +++ b/base_c/test/alloc_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -174,7 +174,7 @@ void AllocTest::TestMixedAllocs() { PT_EXPECT_NE(cache_aligned, static_cast(NULL)); allocated = embb_get_bytes_allocated(); #ifdef EMBB_DEBUG - expected += (1 + 1) * EMBB_CACHE_LINE_SIZE + 3 * sizeof(size_t) - 1; + expected += (1 + 1) * EMBB_PLATFORM_CACHE_LINE_SIZE + 3 * sizeof(size_t) - 1; #endif // else EMBB_DEBUG PT_EXPECT_EQ(allocated, expected); diff --git a/base_c/test/alloc_test.h b/base_c/test/alloc_test.h index 77ca14b..b83c8bf 100644 --- a/base_c/test/alloc_test.h +++ b/base_c/test/alloc_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -81,4 +81,4 @@ class AllocTest : public partest::TestCase { } // namespace base } // namespace embb -#endif /* BASE_C_TEST_ALLOC_TEST_H_ */ +#endif // BASE_C_TEST_ALLOC_TEST_H_ diff --git a/base_c/test/condition_var_test.cc b/base_c/test/condition_var_test.cc index ceb0830..f292d3c 100644 --- a/base_c/test/condition_var_test.cc +++ b/base_c/test/condition_var_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/condition_var_test.h b/base_c/test/condition_var_test.h index 7fb1428..23b56be 100644 --- a/base_c/test/condition_var_test.h +++ b/base_c/test/condition_var_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -65,4 +65,4 @@ class ConditionVarTest : public partest::TestCase { } // namespace base } // namespace embb -#endif /* BASE_C_TEST_CONDITION_VAR_TEST_H_ */ +#endif // BASE_C_TEST_CONDITION_VAR_TEST_H_ diff --git a/base_c/test/core_set_test.cc b/base_c/test/core_set_test.cc index 3b59922..38e8e39 100644 --- a/base_c/test/core_set_test.cc +++ b/base_c/test/core_set_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/core_set_test.h b/base_c/test/core_set_test.h index 43a73b8..1c6dbfb 100644 --- a/base_c/test/core_set_test.h +++ b/base_c/test/core_set_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -51,4 +51,4 @@ class CoreSetTest : public partest::TestCase { } // namespace base } // namespace embb -#endif /* BASE_C_TEST_CORE_SET_TEST_H_ */ +#endif // BASE_C_TEST_CORE_SET_TEST_H_ diff --git a/base_c/test/counter_test.cc b/base_c/test/counter_test.cc index e1cdf27..e6b9950 100644 --- a/base_c/test/counter_test.cc +++ b/base_c/test/counter_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/counter_test.h b/base_c/test/counter_test.h index 24e280f..cf3297b 100644 --- a/base_c/test/counter_test.h +++ b/base_c/test/counter_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -97,4 +97,4 @@ class CounterTest : public partest::TestCase { } // namespace base } // namespace embb -#endif /* BASE_C_TEST_COUNTER_TEST_H_ */ +#endif // BASE_C_TEST_COUNTER_TEST_H_ diff --git a/base_c/test/duration_test.cc b/base_c/test/duration_test.cc index 061fe67..9b93ce3 100644 --- a/base_c/test/duration_test.cc +++ b/base_c/test/duration_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/duration_test.h b/base_c/test/duration_test.h index 7afb2f4..d2a7d2f 100644 --- a/base_c/test/duration_test.h +++ b/base_c/test/duration_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -73,4 +73,4 @@ class DurationTest : public partest::TestCase { } // namespace base } // namespace embb -#endif /* BASE_C_TEST_DURATION_TEST_H_ */ +#endif // BASE_C_TEST_DURATION_TEST_H_ diff --git a/base_c/test/main.cc b/base_c/test/main.cc index eb0dc83..54ce031 100644 --- a/base_c/test/main.cc +++ b/base_c/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -41,22 +41,33 @@ #include +using embb::base::test::AllocTest; +using embb::base::test::DurationTest; +using embb::base::test::TimeTest; +using embb::base::test::CounterTest; +using embb::base::test::MutexTest; +using embb::base::test::ThreadIndexTest; +using embb::base::test::CoreSetTest; +using embb::base::test::ConditionVarTest; +using embb::base::test::ThreadTest; +using embb::base::test::ThreadSpecificStorageTest; + PT_MAIN("Base C") { embb_log_set_log_level(EMBB_LOG_LEVEL_WARNING); unsigned int max_threads = static_cast(2 * partest::TestSuite::GetDefaultNumThreads()); embb_thread_set_max_count(max_threads); - PT_RUN(embb::base::test::AllocTest); - PT_RUN(embb::base::test::DurationTest); - PT_RUN(embb::base::test::TimeTest); - PT_RUN(embb::base::test::CounterTest); - PT_RUN(embb::base::test::MutexTest); - PT_RUN(embb::base::test::ThreadIndexTest); - PT_RUN(embb::base::test::CoreSetTest); - PT_RUN(embb::base::test::ConditionVarTest); - PT_RUN(embb::base::test::ThreadTest); - PT_RUN(embb::base::test::ThreadSpecificStorageTest); + PT_RUN(AllocTest); + PT_RUN(DurationTest); + PT_RUN(TimeTest); + PT_RUN(CounterTest); + PT_RUN(MutexTest); + PT_RUN(ThreadIndexTest); + PT_RUN(CoreSetTest); + PT_RUN(ConditionVarTest); + PT_RUN(ThreadTest); + PT_RUN(ThreadSpecificStorageTest); PT_EXPECT(embb_get_bytes_allocated() == 0); } diff --git a/base_c/test/mutex_test.cc b/base_c/test/mutex_test.cc index 3b22d96..ab2be92 100644 --- a/base_c/test/mutex_test.cc +++ b/base_c/test/mutex_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/mutex_test.h b/base_c/test/mutex_test.h index 57abf28..012df6f 100644 --- a/base_c/test/mutex_test.h +++ b/base_c/test/mutex_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/thread_index_test.cc b/base_c/test/thread_index_test.cc index d7db983..1dd5c13 100644 --- a/base_c/test/thread_index_test.cc +++ b/base_c/test/thread_index_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/thread_index_test.h b/base_c/test/thread_index_test.h index 579ad28..1f07630 100644 --- a/base_c/test/thread_index_test.h +++ b/base_c/test/thread_index_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -78,4 +78,4 @@ int ThreadStart(void* arg); -#endif /* BASE_C_TEST_THREAD_INDEX_TEST_H_ */ +#endif // BASE_C_TEST_THREAD_INDEX_TEST_H_ diff --git a/base_c/test/thread_specific_storage_test.cc b/base_c/test/thread_specific_storage_test.cc index 0194e6c..50e7b0c 100644 --- a/base_c/test/thread_specific_storage_test.cc +++ b/base_c/test/thread_specific_storage_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/thread_specific_storage_test.h b/base_c/test/thread_specific_storage_test.h index c524b57..1d77e3e 100644 --- a/base_c/test/thread_specific_storage_test.h +++ b/base_c/test/thread_specific_storage_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -61,4 +61,4 @@ class ThreadSpecificStorageTest : public partest::TestCase { -#endif /* BASE_C_TEST_THREAD_SPECIFIC_STORAGE_TEST_H_ */ +#endif // BASE_C_TEST_THREAD_SPECIFIC_STORAGE_TEST_H_ diff --git a/base_c/test/thread_test.cc b/base_c/test/thread_test.cc index d27a87e..6308f78 100644 --- a/base_c/test/thread_test.cc +++ b/base_c/test/thread_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/thread_test.h b/base_c/test/thread_test.h index 743494c..6cdd684 100644 --- a/base_c/test/thread_test.h +++ b/base_c/test/thread_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -66,4 +66,4 @@ int ThreadStartFunction(void* arg); } // namespace base } // namespace embb -#endif /* BASE_C_TEST_THREAD_TEST_H_ */ +#endif // BASE_C_TEST_THREAD_TEST_H_ diff --git a/base_c/test/time_test.cc b/base_c/test/time_test.cc index d0f07b2..94d6d1c 100644 --- a/base_c/test/time_test.cc +++ b/base_c/test/time_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_c/test/time_test.h b/base_c/test/time_test.h index 3529ad1..629befc 100644 --- a/base_c/test/time_test.h +++ b/base_c/test/time_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -53,4 +53,4 @@ class TimeTest : public partest::TestCase { -#endif /* BASE_C_TEST_TIME_TEST_H_ */ +#endif // BASE_C_TEST_TIME_TEST_H_ diff --git a/base_cpp/include/embb/base/atomic.h b/base_cpp/include/embb/base/atomic.h index 684fecc..990b2e0 100644 --- a/base_cpp/include/embb/base/atomic.h +++ b/base_cpp/include/embb/base/atomic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -531,7 +531,7 @@ __EMBB_ATOMIC_INTEGER_SPECIALIZATION(unsigned short); __EMBB_ATOMIC_INTEGER_SPECIALIZATION(signed int); __EMBB_ATOMIC_INTEGER_SPECIALIZATION(unsigned int); -#ifdef EMBB_ARCH_X86_64 +#ifdef EMBB_PLATFORM_ARCH_X86_64 __EMBB_ATOMIC_INTEGER_SPECIALIZATION(size_t); #endif diff --git a/base_cpp/include/embb/base/base.h b/base_cpp/include/embb/base/base.h index bac7338..bf7e903 100644 --- a/base_cpp/include/embb/base/base.h +++ b/base_cpp/include/embb/base/base.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/condition_variable.h b/base_cpp/include/embb/base/condition_variable.h index 2fc7268..8f72e5e 100644 --- a/base_cpp/include/embb/base/condition_variable.h +++ b/base_cpp/include/embb/base/condition_variable.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/core_set.h b/base_cpp/include/embb/base/core_set.h index 7857111..74c1360 100644 --- a/base_cpp/include/embb/base/core_set.h +++ b/base_cpp/include/embb/base/core_set.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -201,4 +201,4 @@ class CoreSet { -#endif /* EMBB_BASE_CORE_SET_H_ */ +#endif // EMBB_BASE_CORE_SET_H_ diff --git a/base_cpp/include/embb/base/duration.h b/base_cpp/include/embb/base/duration.h index c35a0ec..5c6d2e8 100644 --- a/base_cpp/include/embb/base/duration.h +++ b/base_cpp/include/embb/base/duration.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -522,4 +522,4 @@ class Nanoseconds : public Tick { #include -#endif /* EMBB_BASE_DURATION_H_ */ +#endif // EMBB_BASE_DURATION_H_ diff --git a/base_cpp/include/embb/base/exceptions.h b/base_cpp/include/embb/base/exceptions.h index 4feb3fc..abcc09d 100644 --- a/base_cpp/include/embb/base/exceptions.h +++ b/base_cpp/include/embb/base/exceptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,16 +27,16 @@ #ifndef EMBB_BASE_EXCEPTIONS_H_ #define EMBB_BASE_EXCEPTIONS_H_ -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(push) // Disable warning that exceptions are disabled but try/catch is used. #pragma warning(disable : 4530) -#endif // EMBB_COMPILER_MSVC +#endif // EMBB_PLATFORM_COMPILER_MSVC #include #include -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(pop) #endif @@ -276,4 +276,4 @@ class ErrorException : public Exception { } // namespace base } // namespace embb -#endif /* EMBB_BASE_EXCEPTIONS_H_ */ +#endif // EMBB_BASE_EXCEPTIONS_H_ diff --git a/base_cpp/include/embb/base/function.h b/base_cpp/include/embb/base/function.h index 494fe7e..0abad4e 100644 --- a/base_cpp/include/embb/base/function.h +++ b/base_cpp/include/embb/base/function.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h b/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h index 399cf5d..2709dca 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_arithmetic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_base.h b/base_cpp/include/embb/base/internal/atomic/atomic_base.h index b44b024..258a686 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_base.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_base.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_implementation.h b/base_cpp/include/embb/base/internal/atomic/atomic_implementation.h index ce60555..c877564 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_implementation.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_implementation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_integer.h b/base_cpp/include/embb/base/internal/atomic/atomic_integer.h index 78f19d4..2c1476c 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_integer.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_integer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_pointer.h b/base_cpp/include/embb/base/internal/atomic/atomic_pointer.h index 26a8aa6..d7fd970 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_pointer.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_pointer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/atomic/atomic_utility.h b/base_cpp/include/embb/base/internal/atomic/atomic_utility.h index 3427f0c..b8051ee 100644 --- a/base_cpp/include/embb/base/internal/atomic/atomic_utility.h +++ b/base_cpp/include/embb/base/internal/atomic/atomic_utility.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/cmake_config.h.in b/base_cpp/include/embb/base/internal/cmake_config.h.in index 28059d2..0c6d975 100644 --- a/base_cpp/include/embb/base/internal/cmake_config.h.in +++ b/base_cpp/include/embb/base/internal/cmake_config.h.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -41,4 +41,4 @@ */ #cmakedefine EMBB_USE_EXCEPTIONS -#endif /* EMBB_BASE_CPP_INTERNAL_CMAKE_CONFIG_H_ */ \ No newline at end of file +#endif /* EMBB_BASE_CPP_INTERNAL_CMAKE_CONFIG_H_ */ diff --git a/base_cpp/include/embb/base/internal/condition_variable-inl.h b/base_cpp/include/embb/base/internal/condition_variable-inl.h index b3b39ce..25b65aa 100644 --- a/base_cpp/include/embb/base/internal/condition_variable-inl.h +++ b/base_cpp/include/embb/base/internal/condition_variable-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/config.h b/base_cpp/include/embb/base/internal/config.h index d076dc3..ceddb94 100644 --- a/base_cpp/include/embb/base/internal/config.h +++ b/base_cpp/include/embb/base/internal/config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -31,7 +31,7 @@ #include /* Disable exceptions in STL of MSVC. Leads to errors when used like this!!! */ -/*#if defined(EMBB_COMPILER_MSVC) && !defined(EMBB_USE_EXCEPTIONS) +/*#if defined(EMBB_PLATFORM_COMPILER_MSVC) && !defined(EMBB_USE_EXCEPTIONS) #define _HAS_EXCEPTIONS 0 #endif*/ diff --git a/base_cpp/include/embb/base/internal/duration-inl.h b/base_cpp/include/embb/base/internal/duration-inl.h index 3a8f486..2d502fd 100644 --- a/base_cpp/include/embb/base/internal/duration-inl.h +++ b/base_cpp/include/embb/base/internal/duration-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -38,7 +38,7 @@ const Duration& Duration::Zero() { return zero; } -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC // Suppress non-thread-safe static initialization warning // in Max() and Min() #pragma warning(push) @@ -57,7 +57,7 @@ const Duration& Duration::Min() { return minimum; } -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(pop) // Reset warning 4640 #endif @@ -112,4 +112,4 @@ Duration::Duration(const embb_duration_t& duration) : rep_() { } // namespace base } // namespace embb -#endif /* EMBB_BASE_INTERNAL_DURATION_INL_H_ */ +#endif // EMBB_BASE_INTERNAL_DURATION_INL_H_ diff --git a/base_cpp/include/embb/base/internal/function0.h b/base_cpp/include/embb/base/internal/function0.h index cfadde8..99f9ff2 100644 --- a/base_cpp/include/embb/base/internal/function0.h +++ b/base_cpp/include/embb/base/internal/function0.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/function1.h b/base_cpp/include/embb/base/internal/function1.h index 830df3c..4951140 100644 --- a/base_cpp/include/embb/base/internal/function1.h +++ b/base_cpp/include/embb/base/internal/function1.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/function2.h b/base_cpp/include/embb/base/internal/function2.h index f5f767f..079b663 100644 --- a/base_cpp/include/embb/base/internal/function2.h +++ b/base_cpp/include/embb/base/internal/function2.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/function3.h b/base_cpp/include/embb/base/internal/function3.h index 002dcaf..343001b 100644 --- a/base_cpp/include/embb/base/internal/function3.h +++ b/base_cpp/include/embb/base/internal/function3.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/function4.h b/base_cpp/include/embb/base/internal/function4.h index a813a9f..67de1d2 100644 --- a/base_cpp/include/embb/base/internal/function4.h +++ b/base_cpp/include/embb/base/internal/function4.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/function5.h b/base_cpp/include/embb/base/internal/function5.h index c7b0645..c6ad05f 100644 --- a/base_cpp/include/embb/base/internal/function5.h +++ b/base_cpp/include/embb/base/internal/function5.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/functionT.h b/base_cpp/include/embb/base/internal/functionT.h index 84ef320..0c80b6b 100644 --- a/base_cpp/include/embb/base/internal/functionT.h +++ b/base_cpp/include/embb/base/internal/functionT.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/memory_allocation-inl.h b/base_cpp/include/embb/base/internal/memory_allocation-inl.h index 1c997b6..3f6f6cb 100644 --- a/base_cpp/include/embb/base/internal/memory_allocation-inl.h +++ b/base_cpp/include/embb/base/internal/memory_allocation-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/mutex-inl.h b/base_cpp/include/embb/base/internal/mutex-inl.h index 6de19c3..0d9b336 100644 --- a/base_cpp/include/embb/base/internal/mutex-inl.h +++ b/base_cpp/include/embb/base/internal/mutex-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -116,4 +116,4 @@ bool UniqueLock::OwnsLock() const { } // namespace base } // namespace embb -#endif /* EMBB_BASE_INTERNAL_MUTEX_INL_H_ */ +#endif // EMBB_BASE_INTERNAL_MUTEX_INL_H_ diff --git a/base_cpp/include/embb/base/internal/nil.h b/base_cpp/include/embb/base/internal/nil.h index 60611c1..5d46990 100644 --- a/base_cpp/include/embb/base/internal/nil.h +++ b/base_cpp/include/embb/base/internal/nil.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/internal/platform.h b/base_cpp/include/embb/base/internal/platform.h index 5fe2cbf..6258563 100644 --- a/base_cpp/include/embb/base/internal/platform.h +++ b/base_cpp/include/embb/base/internal/platform.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,7 +34,7 @@ #include #include -#ifdef EMBB_THREADING_WINTHREADS +#ifdef EMBB_PLATFORM_THREADING_WINTHREADS namespace embb { namespace base { @@ -49,7 +49,7 @@ typedef embb_condition_t ConditionVariableType; } // namespace base } // namespace embb -#elif defined EMBB_THREADING_POSIXTHREADS // EMBB_THREADING_WINTHREADS +#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS namespace embb { namespace base { @@ -64,7 +64,7 @@ typedef embb_condition_t ConditionVariableType; } // namespace base } // namespace embb -#else // EMBB_THREADING_POSIXTHREADS +#else // EMBB_PLATFORM_THREADING_POSIXTHREADS #error "No threading platform defined!" diff --git a/base_cpp/include/embb/base/internal/thread-inl.h b/base_cpp/include/embb/base/internal/thread-inl.h index 46e81bd..454f75a 100644 --- a/base_cpp/include/embb/base/internal/thread-inl.h +++ b/base_cpp/include/embb/base/internal/thread-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -88,7 +88,7 @@ template void Thread::CheckThreadCreationErrors(int result, ThreadClosure* closure) { if (result != EMBB_SUCCESS) { if (closure != NULL) { - delete closure; + Allocation::Delete(closure); } const char* message = "Could not create thread."; if (result == EMBB_NOMEM) { @@ -107,4 +107,4 @@ std::basic_ostream& } // namespace base } // namespace embb -#endif /* EMBB_BASE_INTERNAL_THREAD_INL_H_ */ +#endif // EMBB_BASE_INTERNAL_THREAD_INL_H_ diff --git a/base_cpp/include/embb/base/internal/thread_closures.h b/base_cpp/include/embb/base/internal/thread_closures.h index 3752b42..03273ac 100644 --- a/base_cpp/include/embb/base/internal/thread_closures.h +++ b/base_cpp/include/embb/base/internal/thread_closures.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -36,8 +36,8 @@ namespace internal { /** * Thread closure for thread start function with no arguments. * - * Provides a thread start function calling a callable entity such as a function - * pointer or functor. + * Provides a thread start function from which a priorly stored function object + * is called. */ template struct ThreadClosure { @@ -56,8 +56,8 @@ struct ThreadClosure { /** * Thread closure for thread start function with one argument. * - * Provides a thread start function calling a callable entity such as a function - * pointer or functor. + * Provides a thread start function from which a priorly stored function object + * is called. */ template struct ThreadClosureArg1 { @@ -78,8 +78,8 @@ struct ThreadClosureArg1 { /** * Thread closure for thread start function with two arguments. * - * Provides a thread start function calling a callable entity such as a function - * pointer or functor. + * Provides a thread start function from which a priorly stored function object + * is called. */ template struct ThreadClosureArg2 { @@ -103,4 +103,4 @@ struct ThreadClosureArg2 { } // namespace base } // namespace embb -#endif /* EMBB_BASE_INTERNAL_THREAD_CLOSURES_H_ */ +#endif // EMBB_BASE_INTERNAL_THREAD_CLOSURES_H_ diff --git a/base_cpp/include/embb/base/internal/thread_specific_storage-inl.h b/base_cpp/include/embb/base/internal/thread_specific_storage-inl.h index b206991..00b81c3 100644 --- a/base_cpp/include/embb/base/internal/thread_specific_storage-inl.h +++ b/base_cpp/include/embb/base/internal/thread_specific_storage-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -149,4 +149,4 @@ void ThreadSpecificStorage::Prepare() { } // namespace base } // namespace embb -#endif /* EMBB_BASE_INTERNAL_THREAD_SPECIFIC_STORAGE_INL_H_ */ +#endif // EMBB_BASE_INTERNAL_THREAD_SPECIFIC_STORAGE_INL_H_ diff --git a/base_cpp/include/embb/base/memory_allocation.h b/base_cpp/include/embb/base/memory_allocation.h index 3e6e565..0eb03b7 100644 --- a/base_cpp/include/embb/base/memory_allocation.h +++ b/base_cpp/include/embb/base/memory_allocation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/mutex.h b/base_cpp/include/embb/base/mutex.h index b1461ca..0b8c7e3 100644 --- a/base_cpp/include/embb/base/mutex.h +++ b/base_cpp/include/embb/base/mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/include/embb/base/thread.h b/base_cpp/include/embb/base/thread.h index 5951747..a2278ea 100644 --- a/base_cpp/include/embb/base/thread.h +++ b/base_cpp/include/embb/base/thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -154,12 +154,12 @@ class Thread { * \memory A small constant amount of memory to store the function. This * memory is freed the thread is joined. * \notthreadsafe - * \tparam Function Type of callable + * \tparam Function Function object type */ template explicit Thread( Function function - /**< [IN] Callable (without arguments, must be copyable) */ + /**< [IN] Copyable function object, callable without arguments */ ); /** @@ -174,14 +174,14 @@ class Thread { * \memory A small constant amount of memory to store the function. This * memory is freed the thread is joined. * \notthreadsafe - * \tparam Function Type of callable + * \tparam Function Function object type */ template explicit Thread( CoreSet& core_set, /**< [IN] Set of cores on which the thread shall be executed. */ Function function - /**< [IN] Callable (without arguments, must be copyable) */ + /**< [IN] Copyable function object, callable without arguments */ ); /** @@ -196,13 +196,13 @@ class Thread { * \memory A small constant amount of memory to store the function. This * memory is freed the thread is joined. * \notthreadsafe - * \tparam Function Type of callable + * \tparam Function Function object type * \tparam Argument Type of argument */ template Thread( Function function, - /**< [IN] Callable (with one argument, must be copyable) */ + /**< [IN] Copyable function object, callable with one argument */ Arg arg /**< [IN] Argument for function (must be copyable) */ ); @@ -219,14 +219,14 @@ class Thread { * \memory A small constant amount of memory to store the function. This * memory is freed the thread is joined. * \notthreadsafe - * \tparam Function Type of callable + * \tparam Function Function object type * \tparam Arg1 Type of first argument * \tparam Arg2 Type of second argument */ template Thread( Function function, - /**< [IN] Callable (with two arguments, must be copyable) */ + /**< [IN] Copyable function object, callable with two arguments */ Arg1 arg1, /**< [IN] First argument for function (must be copyable) */ Arg2 arg2 diff --git a/base_cpp/include/embb/base/thread_specific_storage.h b/base_cpp/include/embb/base/thread_specific_storage.h index cb3a421..fa2191e 100644 --- a/base_cpp/include/embb/base/thread_specific_storage.h +++ b/base_cpp/include/embb/base/thread_specific_storage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -35,10 +35,10 @@ namespace embb { namespace base { namespace test { - /** - * Forward declaration for friending. - */ - class ThreadSpecificStorageTest; +/** + * Forward declaration for friending. + */ +class ThreadSpecificStorageTest; } /** @@ -176,4 +176,4 @@ class ThreadSpecificStorage { #include -#endif /* EMBB_BASE_THREAD_SPECIFIC_STORAGE_H_ */ +#endif // EMBB_BASE_THREAD_SPECIFIC_STORAGE_H_ diff --git a/base_cpp/include/embb/base/time.h b/base_cpp/include/embb/base/time.h index 1a36470..06f9ee8 100644 --- a/base_cpp/include/embb/base/time.h +++ b/base_cpp/include/embb/base/time.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -78,4 +78,4 @@ class Time { } // namespace base } // namespace embb -#endif /* EMBB_BASE_TIME_H_ */ +#endif // EMBB_BASE_TIME_H_ diff --git a/base_cpp/src/condition_variable.cc b/base_cpp/src/condition_variable.cc index b03de2c..9a6a2a8 100644 --- a/base_cpp/src/condition_variable.cc +++ b/base_cpp/src/condition_variable.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/core_set.cc b/base_cpp/src/core_set.cc index 7aafca4..eb7ce6b 100644 --- a/base_cpp/src/core_set.cc +++ b/base_cpp/src/core_set.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/duration.cc b/base_cpp/src/duration.cc index 3ede886..38ed5d1 100644 --- a/base_cpp/src/duration.cc +++ b/base_cpp/src/duration.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/function.cc b/base_cpp/src/function.cc index f48eaf9..118035a 100644 --- a/base_cpp/src/function.cc +++ b/base_cpp/src/function.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/functionN.lua b/base_cpp/src/functionN.lua index 33601ba..8a311a8 100644 --- a/base_cpp/src/functionN.lua +++ b/base_cpp/src/functionN.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2014, Siemens AG. All rights reserved. +-- Copyright (c) 2014-2015, Siemens AG. All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/memory_allocation.cc b/base_cpp/src/memory_allocation.cc index 69337b1..73ac560 100644 --- a/base_cpp/src/memory_allocation.cc +++ b/base_cpp/src/memory_allocation.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/mutex.cc b/base_cpp/src/mutex.cc index 7fcffde..61693ba 100644 --- a/base_cpp/src/mutex.cc +++ b/base_cpp/src/mutex.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/src/thread.cc b/base_cpp/src/thread.cc index c5a125b..6f6259e 100644 --- a/base_cpp/src/thread.cc +++ b/base_cpp/src/thread.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -41,7 +41,7 @@ void Thread::SetThreadsMaxCount(unsigned int max_count) { } Thread::ID Thread::CurrentGetID() { -#if defined EMBB_THREADING_WINTHREADS +#if defined EMBB_PLATFORM_THREADING_WINTHREADS return Thread::ID(GetCurrentThreadId()); #else return Thread::ID(embb_thread_current().embb_internal_handle); @@ -59,15 +59,15 @@ void Thread::Join() { } Thread::ID Thread::GetID() { -#if defined EMBB_THREADING_WINTHREADS +#if defined EMBB_PLATFORM_THREADING_WINTHREADS return Thread::ID(GetCurrentThreadId()); -#elif defined EMBB_THREADING_POSIXTHREADS +#elif defined EMBB_PLATFORM_THREADING_POSIXTHREADS return Thread::ID(rep_.embb_internal_handle); #endif } bool operator==(Thread::ID lhs, Thread::ID rhs) { -#if defined EMBB_THREADING_WINTHREADS +#if defined EMBB_PLATFORM_THREADING_WINTHREADS return lhs.id_ == rhs.id_; #else return pthread_equal(lhs.id_, rhs.id_) != 0; @@ -75,7 +75,7 @@ bool operator==(Thread::ID lhs, Thread::ID rhs) { } bool operator!=(Thread::ID lhs, Thread::ID rhs) { -#if defined EMBB_THREADING_WINTHREADS +#if defined EMBB_PLATFORM_THREADING_WINTHREADS return lhs.id_ != rhs.id_; #else return pthread_equal(lhs.id_, rhs.id_) == 0; diff --git a/base_cpp/src/time.cc b/base_cpp/src/time.cc index d4fb449..8f99b01 100644 --- a/base_cpp/src/time.cc +++ b/base_cpp/src/time.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/atomic_test.cc b/base_cpp/test/atomic_test.cc index 6ce9e25..580859c 100644 --- a/base_cpp/test/atomic_test.cc +++ b/base_cpp/test/atomic_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/atomic_test.h b/base_cpp/test/atomic_test.h index 4e7d74f..6696d29 100644 --- a/base_cpp/test/atomic_test.h +++ b/base_cpp/test/atomic_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/condition_var_test.cc b/base_cpp/test/condition_var_test.cc index 52900e0..fd7a3e6 100644 --- a/base_cpp/test/condition_var_test.cc +++ b/base_cpp/test/condition_var_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/condition_var_test.h b/base_cpp/test/condition_var_test.h index 7cacd42..a2fefb7 100644 --- a/base_cpp/test/condition_var_test.h +++ b/base_cpp/test/condition_var_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/core_set_test.cc b/base_cpp/test/core_set_test.cc index 5c9b9a3..9dff77f 100644 --- a/base_cpp/test/core_set_test.cc +++ b/base_cpp/test/core_set_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/core_set_test.h b/base_cpp/test/core_set_test.h index c8274ff..d9579a9 100644 --- a/base_cpp/test/core_set_test.h +++ b/base_cpp/test/core_set_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/duration_test.cc b/base_cpp/test/duration_test.cc index cb12add..c7da972 100644 --- a/base_cpp/test/duration_test.cc +++ b/base_cpp/test/duration_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/duration_test.h b/base_cpp/test/duration_test.h index 34dbb51..48b8509 100644 --- a/base_cpp/test/duration_test.h +++ b/base_cpp/test/duration_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/main.cc b/base_cpp/test/main.cc index 6184ee8..5d7626d 100644 --- a/base_cpp/test/main.cc +++ b/base_cpp/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -37,18 +37,27 @@ #include +using embb::base::test::CoreSetTest; +using embb::base::test::DurationTest; +using embb::base::test::ConditionVarTest; +using embb::base::test::MutexTest; +using embb::base::test::ThreadSpecificStorageTest; +using embb::base::test::AtomicTest; +using embb::base::test::MemoryAllocationTest; +using embb::base::test::ThreadTest; + PT_MAIN("Base C++") { unsigned int max_threads = static_cast(2 * partest::TestSuite::GetDefaultNumThreads()); embb_thread_set_max_count(max_threads); - PT_RUN(embb::base::test::CoreSetTest); - PT_RUN(embb::base::test::DurationTest); - PT_RUN(embb::base::test::ConditionVarTest); - PT_RUN(embb::base::test::MutexTest); - PT_RUN(embb::base::test::ThreadSpecificStorageTest); - PT_RUN(embb::base::test::AtomicTest); - PT_RUN(embb::base::test::MemoryAllocationTest); - PT_RUN(embb::base::test::ThreadTest); + PT_RUN(CoreSetTest); + PT_RUN(DurationTest); + PT_RUN(ConditionVarTest); + PT_RUN(MutexTest); + PT_RUN(ThreadSpecificStorageTest); + PT_RUN(AtomicTest); + PT_RUN(MemoryAllocationTest); + PT_RUN(ThreadTest); PT_EXPECT(embb_get_bytes_allocated() == 0); } diff --git a/base_cpp/test/memory_allocation_test.cc b/base_cpp/test/memory_allocation_test.cc index 188a83d..8d75726 100644 --- a/base_cpp/test/memory_allocation_test.cc +++ b/base_cpp/test/memory_allocation_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -84,12 +84,13 @@ void MemoryAllocationTest::ClassAllocationTest() { aligned_allocs[i]->b = 0xF000 | i; #ifdef EMBB_DEBUG size_t n = (sizeof(DummyClassForAlignedAllocation) - + (EMBB_CACHE_LINE_SIZE - 1)) / EMBB_CACHE_LINE_SIZE; - expected += (n + 1)*EMBB_CACHE_LINE_SIZE + (sizeof(size_t) * 3 - 1); + + (EMBB_PLATFORM_CACHE_LINE_SIZE - 1)) / EMBB_PLATFORM_CACHE_LINE_SIZE; + expected += (n + 1)*EMBB_PLATFORM_CACHE_LINE_SIZE + + (sizeof(size_t) * 3 - 1); #endif // else EMBB_DEBUG //check that the memory is aligned! - PT_ASSERT_EQ((uintptr_t)aligned_allocs[i] % EMBB_CACHE_LINE_SIZE, + PT_ASSERT_EQ((uintptr_t)aligned_allocs[i] % EMBB_PLATFORM_CACHE_LINE_SIZE, (uintptr_t)0); } @@ -135,15 +136,17 @@ void MemoryAllocationTest::ClassAllocationTest() { new DummyClassForAlignedAllocation[alloc_iterations]; #ifdef EMBB_DEBUG size_t n = (sizeof(DummyClassForAlignedAllocation)*alloc_iterations - + (EMBB_CACHE_LINE_SIZE - 1)) / EMBB_CACHE_LINE_SIZE; - expected += (n + 1)*EMBB_CACHE_LINE_SIZE + (sizeof(size_t) * 3 - 1); + + (EMBB_PLATFORM_CACHE_LINE_SIZE - 1)) / EMBB_PLATFORM_CACHE_LINE_SIZE; + expected += (n + 1)*EMBB_PLATFORM_CACHE_LINE_SIZE + + (sizeof(size_t) * 3 - 1); #endif // else EMBB_DEBUG // This assert does _not_ hold, but is left for documentation. // It is not guaranteed that the pointer to the array is aligned. // See the documentation of the overloaded new[] operator in // class MemoryAllocation. - // PT_ASSERT_EQ((uintptr_t)aligned_allocated % EMBB_CACHE_LINE_SIZE, 0); + // PT_ASSERT_EQ((uintptr_t)aligned_allocated % + // EMBB_PLATFORM_CACHE_LINE_SIZE, 0); //delete! expected = 0; diff --git a/base_cpp/test/memory_allocation_test.h b/base_cpp/test/memory_allocation_test.h index f93cf4f..58a360a 100644 --- a/base_cpp/test/memory_allocation_test.h +++ b/base_cpp/test/memory_allocation_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/mutex_test.cc b/base_cpp/test/mutex_test.cc index 5b3be62..17e5c9e 100644 --- a/base_cpp/test/mutex_test.cc +++ b/base_cpp/test/mutex_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/mutex_test.h b/base_cpp/test/mutex_test.h index dc21c8d..80579a8 100644 --- a/base_cpp/test/mutex_test.h +++ b/base_cpp/test/mutex_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/thread_specific_storage_test.cc b/base_cpp/test/thread_specific_storage_test.cc index 5fc8141..f979b50 100644 --- a/base_cpp/test/thread_specific_storage_test.cc +++ b/base_cpp/test/thread_specific_storage_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/base_cpp/test/thread_specific_storage_test.h b/base_cpp/test/thread_specific_storage_test.h index f6c93e7..1c94e2a 100644 --- a/base_cpp/test/thread_specific_storage_test.h +++ b/base_cpp/test/thread_specific_storage_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -42,7 +42,7 @@ class ThreadSpecificStorageTest : public partest::TestCase { /** * Adds test units. */ - explicit ThreadSpecificStorageTest(); + ThreadSpecificStorageTest(); private: /** diff --git a/base_cpp/test/thread_test.cc b/base_cpp/test/thread_test.cc index 6412b7a..f8af461 100644 --- a/base_cpp/test/thread_test.cc +++ b/base_cpp/test/thread_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -61,6 +61,9 @@ void ThreadTest::TestStartingAndJoining() { embb::base::Thread thread2(ThreadTest::StaticThreadStartArg1, arg1); double arg2 = 3.0; embb::base::Thread thread3(ThreadTest::StaticThreadStartArg2, arg1, arg2); + embb::base::Thread::ID thread3id; + thread3id = thread3.GetID(); + PT_EXPECT_EQ(thread3id, thread3.GetID()); // Non-static member start methods with functor MemberStart start4(&ThreadTest::ThreadStart, this); diff --git a/base_cpp/test/thread_test.h b/base_cpp/test/thread_test.h index 6f59ce9..3d27579 100644 --- a/base_cpp/test/thread_test.h +++ b/base_cpp/test/thread_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -43,8 +43,7 @@ class ThreadTest : public partest::TestCase { /** * Adds test methods. */ - explicit ThreadTest(); /**< - number of threads concurrently running test methods */ + ThreadTest(); private: /** diff --git a/base_cpp/test/time_test.h b/base_cpp/test/time_test.h index 41fc157..d49a1fb 100644 --- a/base_cpp/test/time_test.h +++ b/base_cpp/test/time_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/containers.h b/containers_cpp/include/embb/containers/containers.h index 0c7a25b..8cc7c79 100644 --- a/containers_cpp/include/embb/containers/containers.h +++ b/containers_cpp/include/embb/containers/containers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h b/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h index c29eb28..3873dba 100644 --- a/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h +++ b/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,8 +34,9 @@ template< typename ElementT > FixedSizeList::FixedSizeList(size_t max_size) : max_size(max_size), size(0) { - elementsArray = - new ElementT[max_size]; + elementsArray = static_cast( + embb::base::Allocation::Allocate(sizeof(ElementT) * + max_size)); } template< typename ElementT > @@ -92,7 +93,7 @@ bool FixedSizeList::PushBack(ElementT const el) { template< typename ElementT > FixedSizeList::~FixedSizeList() { - delete[] elementsArray; + embb::base::Allocation::Free(elementsArray); } template< typename GuardType > diff --git a/containers_cpp/include/embb/containers/internal/hazard_pointer.h b/containers_cpp/include/embb/containers/internal/hazard_pointer.h index 03dc57c..e1e5f49 100644 --- a/containers_cpp/include/embb/containers/internal/hazard_pointer.h +++ b/containers_cpp/include/embb/containers/internal/hazard_pointer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,7 +34,7 @@ #include #include -#if defined(EMBB_COMPILER_MSVC) +#if defined(EMBB_PLATFORM_COMPILER_MSVC) #define EMBB_CONTAINERS_CPP_DEPENDANT_TYPENAME #else #define EMBB_CONTAINERS_CPP_DEPENDANT_TYPENAME typename diff --git a/containers_cpp/include/embb/containers/internal/lock_free_mpmc_queue-inl.h b/containers_cpp/include/embb/containers/internal/lock_free_mpmc_queue-inl.h index 9c61388..c4914e9 100644 --- a/containers_cpp/include/embb/containers/internal/lock_free_mpmc_queue-inl.h +++ b/containers_cpp/include/embb/containers/internal/lock_free_mpmc_queue-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -80,13 +80,13 @@ LockFreeMPMCQueue::LockFreeMPMCQueue(size_t capacity) : capacity(capacity), // Disable "this is used in base member initializer" warning. // We explicitly want this. -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(push) #pragma warning(disable:4355) #endif delete_pointer_callback(*this, &LockFreeMPMCQueue::DeletePointerCallback), -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(pop) #endif hazardPointer(delete_pointer_callback, NULL, 2), diff --git a/containers_cpp/include/embb/containers/internal/lock_free_stack-inl.h b/containers_cpp/include/embb/containers/internal/lock_free_stack-inl.h index 7c6e9ab..2c29395 100644 --- a/containers_cpp/include/embb/containers/internal/lock_free_stack-inl.h +++ b/containers_cpp/include/embb/containers/internal/lock_free_stack-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -72,13 +72,13 @@ LockFreeStack< Type, ValuePool >::LockFreeStack(size_t capacity) : capacity(capacity), // Disable "this is used in base member initializer" warning. // We explicitly want this. -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(push) #pragma warning(disable:4355) #endif delete_pointer_callback(*this, &LockFreeStack::DeletePointerCallback), -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(pop) #endif hazardPointer(delete_pointer_callback, NULL, 1), diff --git a/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h b/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h index 2e50e3b..2049174 100644 --- a/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h +++ b/containers_cpp/include/embb/containers/internal/lock_free_tree_value_pool-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/internal/object_pool-inl.h b/containers_cpp/include/embb/containers/internal/object_pool-inl.h index 38b14f7..61711d5 100644 --- a/containers_cpp/include/embb/containers/internal/object_pool-inl.h +++ b/containers_cpp/include/embb/containers/internal/object_pool-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/internal/wait_free_array_value_pool-inl.h b/containers_cpp/include/embb/containers/internal/wait_free_array_value_pool-inl.h index 01cfe4f..1453f1f 100644 --- a/containers_cpp/include/embb/containers/internal/wait_free_array_value_pool-inl.h +++ b/containers_cpp/include/embb/containers/internal/wait_free_array_value_pool-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/internal/wait_free_spsc_queue-inl.h b/containers_cpp/include/embb/containers/internal/wait_free_spsc_queue-inl.h index f41e59b..05638db 100644 --- a/containers_cpp/include/embb/containers/internal/wait_free_spsc_queue-inl.h +++ b/containers_cpp/include/embb/containers/internal/wait_free_spsc_queue-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h b/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h index 1318836..37c5439 100644 --- a/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h +++ b/containers_cpp/include/embb/containers/lock_free_mpmc_queue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/lock_free_stack.h b/containers_cpp/include/embb/containers/lock_free_stack.h index 640cd16..fdcb70c 100644 --- a/containers_cpp/include/embb/containers/lock_free_stack.h +++ b/containers_cpp/include/embb/containers/lock_free_stack.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/lock_free_tree_value_pool.h b/containers_cpp/include/embb/containers/lock_free_tree_value_pool.h index 83f9e17..2a14d4c 100644 --- a/containers_cpp/include/embb/containers/lock_free_tree_value_pool.h +++ b/containers_cpp/include/embb/containers/lock_free_tree_value_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/object_pool.h b/containers_cpp/include/embb/containers/object_pool.h index abd7c67..0a94708 100644 --- a/containers_cpp/include/embb/containers/object_pool.h +++ b/containers_cpp/include/embb/containers/object_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/wait_free_array_value_pool.h b/containers_cpp/include/embb/containers/wait_free_array_value_pool.h index 8c99323..8289ca6 100644 --- a/containers_cpp/include/embb/containers/wait_free_array_value_pool.h +++ b/containers_cpp/include/embb/containers/wait_free_array_value_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/include/embb/containers/wait_free_spsc_queue.h b/containers_cpp/include/embb/containers/wait_free_spsc_queue.h index c459f33..a0f0cdc 100644 --- a/containers_cpp/include/embb/containers/wait_free_spsc_queue.h +++ b/containers_cpp/include/embb/containers/wait_free_spsc_queue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/src/dummy.cc b/containers_cpp/src/dummy.cc index eb34253..e95756a 100644 --- a/containers_cpp/src/dummy.cc +++ b/containers_cpp/src/dummy.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/hazard_pointer_test.cc b/containers_cpp/test/hazard_pointer_test.cc index 56f455b..17a4c38 100644 --- a/containers_cpp/test/hazard_pointer_test.cc +++ b/containers_cpp/test/hazard_pointer_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -32,12 +32,12 @@ namespace embb { namespace containers { namespace test { HazardPointerTest::HazardPointerTest() : -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(push) #pragma warning(disable:4355) #endif delete_pointer_callback(*this, &HazardPointerTest::DeletePointerCallback), -#ifdef EMBB_COMPILER_MSVC +#ifdef EMBB_PLATFORM_COMPILER_MSVC #pragma warning(pop) #endif object_pool(NULL), diff --git a/containers_cpp/test/hazard_pointer_test.h b/containers_cpp/test/hazard_pointer_test.h index d0e6bc2..3e02c6a 100644 --- a/containers_cpp/test/hazard_pointer_test.h +++ b/containers_cpp/test/hazard_pointer_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/main.cc b/containers_cpp/test/main.cc index fe51456..0e26fee 100644 --- a/containers_cpp/test/main.cc +++ b/containers_cpp/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -24,6 +24,14 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include +#include +#include +#include +#include +#include +#include + #include #include @@ -32,43 +40,36 @@ #include "./stack_test.h" #include "./hazard_pointer_test.h" #include "./object_pool_test.h" -#include -#include -#include -#include -#include -#include - -#include #define COMMA , +using embb::containers::WaitFreeArrayValuePool; +using embb::containers::LockFreeTreeValuePool; +using embb::containers::WaitFreeSPSCQueue; +using embb::containers::LockFreeMPMCQueue; +using embb::containers::LockFreeStack; +using embb::containers::LockFreeTreeValuePool; +using embb::containers::WaitFreeArrayValuePool; +using embb::containers::test::PoolTest; +using embb::containers::test::HazardPointerTest; +using embb::containers::test::QueueTest; +using embb::containers::test::StackTest; +using embb::containers::test::ObjectPoolTest; + PT_MAIN("Data Structures C++") { - unsigned int max_threads = - static_cast(2 * partest::TestSuite::GetDefaultNumThreads()); + unsigned int max_threads = static_cast( + 2 * partest::TestSuite::GetDefaultNumThreads()); embb_thread_set_max_count(max_threads); - PT_RUN(embb::containers::test::PoolTest< - embb::containers::WaitFreeArrayValuePool >); - PT_RUN(embb::containers::test::PoolTest< - embb::containers::LockFreeTreeValuePool >); - - PT_RUN(embb::containers::test::HazardPointerTest); - - PT_RUN(embb::containers::test::QueueTest< - embb::containers::WaitFreeSPSCQueue >); - - PT_RUN(embb::containers::test::QueueTest< - embb::containers::LockFreeMPMCQueue COMMA true COMMA true >); - - PT_RUN(embb::containers::test::StackTest< - embb::containers::LockFreeStack >); - - PT_RUN(embb::containers::test::ObjectPoolTest - >); - - PT_RUN(embb::containers::test::ObjectPoolTest - >); + PT_RUN(PoolTest< WaitFreeArrayValuePool >); + PT_RUN(PoolTest< LockFreeTreeValuePool >); + PT_RUN(HazardPointerTest); + PT_RUN(QueueTest< WaitFreeSPSCQueue< ::std::pair > >); + PT_RUN(QueueTest< LockFreeMPMCQueue< ::std::pair > + COMMA true COMMA true >); + PT_RUN(StackTest< LockFreeStack >); + PT_RUN(ObjectPoolTest< LockFreeTreeValuePool >); + PT_RUN(ObjectPoolTest< WaitFreeArrayValuePool >); PT_EXPECT(embb_get_bytes_allocated() == 0); } diff --git a/containers_cpp/test/object_pool_test-inl.h b/containers_cpp/test/object_pool_test-inl.h index 87dc77c..db340b2 100644 --- a/containers_cpp/test/object_pool_test-inl.h +++ b/containers_cpp/test/object_pool_test-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/object_pool_test.cc b/containers_cpp/test/object_pool_test.cc index 50fa605..ccc91ac 100644 --- a/containers_cpp/test/object_pool_test.cc +++ b/containers_cpp/test/object_pool_test.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/object_pool_test.h b/containers_cpp/test/object_pool_test.h index ebb7861..4c5c177 100644 --- a/containers_cpp/test/object_pool_test.h +++ b/containers_cpp/test/object_pool_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/pool_test-inl.h b/containers_cpp/test/pool_test-inl.h index 90142a2..2c74935 100644 --- a/containers_cpp/test/pool_test-inl.h +++ b/containers_cpp/test/pool_test-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/pool_test.h b/containers_cpp/test/pool_test.h index c7b8e06..16fcbd9 100644 --- a/containers_cpp/test/pool_test.h +++ b/containers_cpp/test/pool_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/queue_test-inl.h b/containers_cpp/test/queue_test-inl.h index 4cc7a95..97207b2 100644 --- a/containers_cpp/test/queue_test-inl.h +++ b/containers_cpp/test/queue_test-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,132 +30,191 @@ #include #include -#include - namespace embb { namespace containers { namespace test { template QueueTest::QueueTest() : -n_threads(static_cast - (partest::TestSuite::GetDefaultNumThreads())), - n_iterations(200), - n_queue_elements_per_thread(100), - n_queue_elements(n_queue_elements_per_thread*n_threads), - queueSize(0) { + n_threads(static_cast(partest::TestSuite::GetDefaultNumThreads())), + n_queue_size( + static_cast(partest::TestSuite::GetDefaultNumIterations()) * + MIN_TOTAL_PRODUCE_CONSUME_COUNT), + n_total_produce_consume_count(n_queue_size), + n_producers(1), + n_consumers(1), + next_producer_id(0), + next_consumer_id(0), + n_producer_elements( + static_cast(partest::TestSuite::GetDefaultNumIterations() * + MIN_ENQ_ELEMENTS)) { CreateUnit("QueueTestSingleThreadEnqueueDequeue"). Pre(&QueueTest::QueueTestSingleThreadEnqueueDequeue_Pre, this). Add(&QueueTest::QueueTestSingleThreadEnqueueDequeue_ThreadMethod, this). Post(&QueueTest::QueueTestSingleThreadEnqueueDequeue_Post, this); - CreateUnit("QueueTestTwoThreadsSingleProducerSingleConsumer"). - Pre(&QueueTest::QueueTestSingleProducedSingleConsumer_Pre, this). - Add(&QueueTest::QueueTestSingleProducedSingleConsumer_ThreadMethod, - this, - 2, - TOTAL_PRODUCE_CONSUME_COUNT). - Post(&QueueTest::QueueTestSingleProducedSingleConsumer_Post, this); - -#ifdef EMBB_COMPILER_MSVC + Pre(&QueueTest::QueueTestSingleProducerSingleConsumer_Pre, this). + Add(&QueueTest::QueueTestSingleProducerSingleConsumer_ThreadMethod, + this, + 2, + static_cast(n_total_produce_consume_count)). + Post(&QueueTest::QueueTestSingleProducerSingleConsumer_Post, this); + +#ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4127) #endif - if (MultipleProducers == true && - MultipleConsumers == true) { -#ifdef EMBB_COMPILER_MSVC + if (MultipleProducers == true && MultipleConsumers == true) { + // MP/MC + n_producers = n_threads / 2; + n_consumers = n_threads / 2; +#ifdef _MSC_VER #pragma warning(pop) #endif - CreateUnit("QueueTestMultipleThreadsMultipleProducerMultipleConsumer"). - Pre(&QueueTest::QueueTestMultipleProducerMultipleConsumer_Pre, this). - Add(&QueueTest::QueueTestMultipleProducerMultipleConsumer_ThreadMethod, - this, - static_cast(n_threads), - static_cast(n_iterations)). - Post(&QueueTest::QueueTestMultipleProducerMultipleConsumer_Post, this); + CreateUnit("QueueTestOrderMultipleProducerMultipleConsumer"). + Pre(&QueueTest::QueueTestOrderMPMC_Pre, this). + Add(&QueueTest::QueueTestOrderMPMC_ConsumerThreadMethod, + this, + static_cast(n_consumers), + static_cast(1)). + Add(&QueueTest::QueueTestOrderMPMC_ProducerThreadMethod, + this, + static_cast(n_producers), + static_cast(1)). + Post(&QueueTest::QueueTestOrderMPMC_Post, this); } } template void QueueTest:: -QueueTestMultipleProducerMultipleConsumer_Pre() { +QueueTestOrderMPMC_Pre() { + queue = new Queue_t(static_cast(n_producer_elements)); embb_internal_thread_index_reset(); - queue = new Queue_t(static_cast(n_queue_elements)); - - thread_local_vectors = - new std::vector[static_cast(n_threads)]; - - for (int i = 0; i != n_threads; ++i) { - int offset = n_queue_elements_per_thread * 2; - - for (int i2 = 0; i2 != n_queue_elements_per_thread; ++i2) { - int push_element = i2 + (offset*i); - thread_local_vectors[i].push_back(push_element); - expected_queue_elements.push_back(push_element); - } + next_producer_id = 0; + next_consumer_id = 0; + consumers.clear(); + producers.clear(); + for (size_t p = 0; p < static_cast(n_producers); ++p) { + producers.push_back(Producer(queue, p, n_producer_elements)); + } + for (size_t c = 0; c < static_cast(n_consumers); ++c) { + consumers.push_back(Consumer(queue, n_producers, n_producer_elements)); } } template void QueueTest:: -QueueTestMultipleProducerMultipleConsumer_Post() { - std::vector produced; - for (int i = 0; i != n_threads; ++i) { - std::vector& loc_elements = thread_local_vectors[i]; - for (std::vector::iterator it = loc_elements.begin(); - it != loc_elements.end(); - ++it) { - produced.push_back(*it); +QueueTestOrderMPMC_Post() { + delete queue; + // Tally for all elements enqueued by all producers, + // initialized with all 0: + ::std::vector total_tally; + size_t n_elements_total = + static_cast(n_producers * n_producer_elements); + for (size_t i = 0; i < n_elements_total / 8; ++i) { + total_tally.push_back(0); + } + // Collect all dequeued element flags from consumers: + for (size_t c = 0; c < static_cast(n_consumers); ++c) { + for (size_t e = 0; e < n_elements_total / 8; ++e) { + total_tally[e] |= consumers[c].Tally()[e]; } } - - PT_ASSERT(produced.size() == expected_queue_elements.size()); - - std::sort(expected_queue_elements.begin(), expected_queue_elements.end()); - std::sort(produced.begin(), produced.end()); - - for (unsigned int i = 0; - i != static_cast(produced.size()); ++i) { - PT_ASSERT(expected_queue_elements[i] == produced[i]); + // Test if all elements have been dequeued by any + // consumer. + // To avoid static cast warning: + for (size_t t = 0; + t < static_cast(n_producers * n_producer_elements / 8); + ++t) { + PT_ASSERT_EQ_MSG(total_tally[t], 0xff, + "missing dequeued elements"); } - - delete[] thread_local_vectors; - delete queue; } template void QueueTest:: -QueueTestMultipleProducerMultipleConsumer_ThreadMethod() { - unsigned int thread_index; - int return_val = embb_internal_thread_index(&thread_index); - - PT_ASSERT(EMBB_SUCCESS == return_val); +QueueTestOrderMPMC_ProducerThreadMethod() { + size_t p_id = next_producer_id.FetchAndAdd(1); + producers[p_id].Run(); +} - std::vector& my_elements = thread_local_vectors[thread_index]; +template +void QueueTest:: +QueueTestOrderMPMC_ConsumerThreadMethod() { + size_t c_id = next_consumer_id.FetchAndAdd(1); + consumers[c_id].Run(); +} - for (std::vector::iterator it = my_elements.begin(); - it != my_elements.end(); - ++it) { - int enq = *it; - bool success = queue->TryEnqueue(enq); - PT_ASSERT(success == true); +template +void QueueTest::Producer:: +Run() { + // Enqueue pairs of (producer id, counter): + for (int i = 0; i < n_producer_elements; ++i) { + while (!q->TryEnqueue(element_t(producer_id, i))) { + embb::base::Thread::CurrentYield(); + } + } + // Enqueue -1 as terminator element of this producer: + while (!q->TryEnqueue(element_t(producer_id, -1))) { + embb::base::Thread::CurrentYield(); } +} - my_elements.clear(); +template +QueueTest::Consumer:: +Consumer(Queue_t * const queue, int numProducers, int numProducerElements) : + q(queue), + n_producers(numProducers), + n_producer_elements(numProducerElements) { + for (int p_id = 0; p_id < n_producers; ++p_id) { + // Initialize last value dequeued from producers with + // below-minimum value: + sequence_number.push_back(-1); + // Initialize element tally for producer with all 0, + // 8 flags / char: + for (int i = 0; i < n_producer_elements / 8; ++i) { + consumer_tally.push_back(0); + } + } +} - for (int i = 0; i != n_queue_elements_per_thread; ++i) { - int dequ; - bool success = queue->TryDequeue(dequ); - PT_ASSERT(success == true); - my_elements.push_back(dequ); +template +void QueueTest::Consumer:: +Run() { + element_t element; + size_t producerId; + // To avoid compiler warning + bool forever = true; + while (forever) { + if (!q->TryDequeue(element)) { + continue; + } + if (element.second < 0) { + break; + } + producerId = element.first; + // Assert on dequeued element: + PT_ASSERT_LT_MSG(producerId, static_cast(n_producers), + "Invalid producer id in dequeue"); + PT_ASSERT_LT_MSG(sequence_number[producerId], element.second, + "Invalid element sequence"); + // Store last value received from the element's producer: + sequence_number[producerId] = element.second; + const size_t pos((producerId * n_producer_elements) + + static_cast(element.second)); + // Test dequeued element's position flag: tally[pos] == 1 + PT_ASSERT_EQ_MSG(consumer_tally[pos / 8] & (0x80 >> (pos % 8)), 0, + "Element dequeued twice"); + // Set flag at dequeued element's position: + // tally[pos] = 1 + consumer_tally[pos / 8] |= (0x80 >> (pos % 8)); } } template void QueueTest:: -QueueTestSingleProducedSingleConsumer_Pre() { +QueueTestSingleProducerSingleConsumer_Pre() { embb_internal_thread_index_reset(); - - queue = new Queue_t(QUEUE_SIZE); + queue = new Queue_t(static_cast(n_queue_size)); thread_selector_producer = -1; produce_count = 0; consume_count = 0; @@ -165,53 +224,47 @@ QueueTestSingleProducedSingleConsumer_Pre() { template void QueueTest:: -QueueTestSingleProducedSingleConsumer_Post() { +QueueTestSingleProducerSingleConsumer_Post() { embb_atomic_memory_barrier(); ::std::sort(consumed_elements.begin(), consumed_elements.end()); ::std::sort(produced_elements.begin(), produced_elements.end()); - PT_ASSERT(consumed_elements.size() == produced_elements.size()); - for (unsigned int i = 0; i != static_cast(consumed_elements.size()); i++) { PT_ASSERT(consumed_elements[i] == produced_elements[i]); } - delete queue; } template void QueueTest:: -QueueTestSingleProducedSingleConsumer_ThreadMethod() { +QueueTestSingleProducerSingleConsumer_ThreadMethod() { unsigned int thread_index; int return_val = embb_internal_thread_index(&thread_index); PT_ASSERT(return_val == EMBB_SUCCESS); - if (thread_selector_producer == -1) { int expected = -1; thread_selector_producer.CompareAndSwap(expected, static_cast(thread_index)); while (thread_selector_producer == -1) {} } - - // we are the producer if (static_cast(thread_selector_producer.Load()) == thread_index) { - while (produce_count >= QUEUE_SIZE) {} + // we are the producer + while (produce_count >= n_queue_size) { } - int random_var = rand() % 10000; + element_t random_var(0, rand() % 10000); bool success = queue->TryEnqueue(random_var); PT_ASSERT(success == true); produce_count++; produced_elements.push_back(random_var); - // we are the consumer } else { - while (consume_count < TOTAL_PRODUCE_CONSUME_COUNT) { + // we are the consumer + while (consume_count < n_total_produce_consume_count) { consume_count++; - while (produce_count == 0) {} - int consumed; + element_t consumed; bool success = queue->TryDequeue(consumed); PT_ASSERT(success == true); produce_count--; @@ -223,23 +276,24 @@ QueueTestSingleProducedSingleConsumer_ThreadMethod() { template void QueueTest:: QueueTestSingleThreadEnqueueDequeue_ThreadMethod() { - for (int i = 0; i != QUEUE_SIZE; ++i) { - bool success = queue->TryEnqueue(i * 133); + for (int i = 0; i != n_queue_size; ++i) { + bool success = queue->TryEnqueue(element_t(0, i * 133)); PT_ASSERT(success == true); } - for (int i = 0; i != QUEUE_SIZE; ++i) { - int dequ = -1; + for (int i = 0; i != n_queue_size; ++i) { + element_t dequ(0, -1); bool success = queue->TryDequeue(dequ); PT_ASSERT(success == true); - PT_ASSERT(dequ == i * 133); + PT_ASSERT(dequ.second == i * 133); } } template void QueueTest:: QueueTestSingleThreadEnqueueDequeue_Pre() { - queue = new Queue_t(QUEUE_SIZE); + queue = new Queue_t(static_cast(n_queue_size)); } + template void QueueTest:: QueueTestSingleThreadEnqueueDequeue_Post() { diff --git a/containers_cpp/test/queue_test.h b/containers_cpp/test/queue_test.h index c405b05..22b7381 100644 --- a/containers_cpp/test/queue_test.h +++ b/containers_cpp/test/queue_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,10 +27,10 @@ #ifndef CONTAINERS_CPP_TEST_QUEUE_TEST_H_ #define CONTAINERS_CPP_TEST_QUEUE_TEST_H_ -#include #include #include -#include +#include +#include namespace embb { namespace containers { @@ -39,42 +39,83 @@ template class QueueTest : public partest::TestCase { + public: + typedef ::std::pair element_t; + + private: + /// Minimum number of elements enqueued by every producer + /// in MP/MC unit test. Must be a multiple of 8. + static const int MIN_ENQ_ELEMENTS = 120; + static const int MIN_TOTAL_PRODUCE_CONSUME_COUNT = 1000; + + private: + class Consumer { + private: + Queue_t * q; + int n_producers; + int n_producer_elements; + ::std::vector consumer_tally; + ::std::vector sequence_number; + public: + Consumer(Queue_t * const queue, int numProducers, int numProducerElements); + void Run(); + const ::std::vector & Tally() const { + return consumer_tally; + } + }; + class Producer { + private: + Queue_t * q; + size_t producer_id; + int n_producer_elements; + public: + Producer(Queue_t * const queue, size_t id, int numProducerElements) : + q(queue), + producer_id(id), + n_producer_elements(numProducerElements) {} + void Run(); + }; + private: - static const int QUEUE_SIZE = 100; - static const int TOTAL_PRODUCE_CONSUME_COUNT = 10000; int n_threads; + int n_queue_size; + int n_total_produce_consume_count; embb::base::Atomic thread_selector_producer; embb::base::Atomic produce_count; - std::vector consumed_elements; - std::vector produced_elements; + ::std::vector consumed_elements; + ::std::vector produced_elements; + ::std::vector consumers; + ::std::vector producers; - //for multiple p/c - int n_iterations; - int n_queue_elements_per_thread; - int n_queue_elements; - std::vector expected_queue_elements; - std::vector* thread_local_vectors; - embb::base::Atomic queueSize; + // for multiple p/c + int n_producers; + int n_consumers; + embb::base::Atomic next_producer_id; + embb::base::Atomic next_consumer_id; + /// Number of elements enqueued by every producer, depending + /// on number of iterations for regression tests. + int n_producer_elements; int consume_count; Queue_t* queue; - void QueueTestMultipleProducerMultipleConsumer_Pre(); - void QueueTestMultipleProducerMultipleConsumer_Post(); - void QueueTestMultipleProducerMultipleConsumer_ThreadMethod(); - void QueueTestSingleProducedSingleConsumer_Pre(); - void QueueTestSingleProducedSingleConsumer_Post(); - void QueueTestSingleProducedSingleConsumer_ThreadMethod(); - void QueueTestSingleThreadEnqueueDequeue_ThreadMethod(); + void QueueTestOrderMPMC_Pre(); + void QueueTestOrderMPMC_Post(); + void QueueTestOrderMPMC_ProducerThreadMethod(); + void QueueTestOrderMPMC_ConsumerThreadMethod(); + void QueueTestSingleProducerSingleConsumer_Pre(); + void QueueTestSingleProducerSingleConsumer_Post(); + void QueueTestSingleProducerSingleConsumer_ThreadMethod(); void QueueTestSingleThreadEnqueueDequeue_Pre(); void QueueTestSingleThreadEnqueueDequeue_Post(); + void QueueTestSingleThreadEnqueueDequeue_ThreadMethod(); public: QueueTest(); }; -} // namespace test -} // namespace containers -} // namespace embb +} // namespace test +} // namespace containers +} // namespace embb #include "./queue_test-inl.h" diff --git a/containers_cpp/test/stack_test-inl.h b/containers_cpp/test/stack_test-inl.h index f71dab8..6e82d4d 100644 --- a/containers_cpp/test/stack_test-inl.h +++ b/containers_cpp/test/stack_test-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/containers_cpp/test/stack_test.h b/containers_cpp/test/stack_test.h index b8e25e9..449ae7e 100644 --- a/containers_cpp/test/stack_test.h +++ b/containers_cpp/test/stack_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/CMakeLists.txt b/dataflow_cpp/CMakeLists.txt index 6c5d4e6..0ad76a0 100644 --- a/dataflow_cpp/CMakeLists.txt +++ b/dataflow_cpp/CMakeLists.txt @@ -17,8 +17,8 @@ include_directories(${EMBB_DATAFLOW_CPP_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../base_cpp/include ${CMAKE_CURRENT_BINARY_DIR}/../base_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_c/include - ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_cpp/include - ) + ${CMAKE_CURRENT_SOURCE_DIR}/../mtapi_cpp/include + ${CMAKE_CURRENT_BINARY_DIR}/../mtapi_cpp/include) 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) diff --git a/dataflow_cpp/include/embb/dataflow/dataflow.h b/dataflow_cpp/include/embb/dataflow/dataflow.h index 0b9d98e..376206f 100644 --- a/dataflow_cpp/include/embb/dataflow/dataflow.h +++ b/dataflow_cpp/include/embb/dataflow/dataflow.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/action.h b/dataflow_cpp/include/embb/dataflow/internal/action.h index 79da9e1..d2d766b 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/action.h +++ b/dataflow_cpp/include/embb/dataflow/internal/action.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/clock_listener.h b/dataflow_cpp/include/embb/dataflow/internal/clock_listener.h index 493baf7..c8e7fd5 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/clock_listener.h +++ b/dataflow_cpp/include/embb/dataflow/internal/clock_listener.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/constant_source.h b/dataflow_cpp/include/embb/dataflow/internal/constant_source.h index 28d014a..58da428 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/constant_source.h +++ b/dataflow_cpp/include/embb/dataflow/internal/constant_source.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/in.h b/dataflow_cpp/include/embb/dataflow/internal/in.h index 3ac6fc1..84ad9a3 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/in.h +++ b/dataflow_cpp/include/embb/dataflow/internal/in.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/inputs.h b/dataflow_cpp/include/embb/dataflow/internal/inputs.h index 021f261..afcb011 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/inputs.h +++ b/dataflow_cpp/include/embb/dataflow/internal/inputs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -87,9 +87,10 @@ class InputsOnClock(clock); @@ -132,9 +133,10 @@ class InputsOnClock(clock); @@ -181,10 +183,11 @@ class InputsOnClock(clock); } @@ -233,9 +236,10 @@ class Inputs } virtual void OnClock(int clock) { const int idx = clock % Slices; - if (count_[idx] == 0) + if (count_[idx] == 0) { EMBB_THROW(embb::base::ErrorException, - "All inputs already fired for this clock.") + "All inputs already fired for this clock."); + } if (--count_[idx] == 0) { count_[idx] = 4; listener_->OnClock(clock); @@ -290,9 +294,10 @@ class Inputs } virtual void OnClock(int clock) { const int idx = clock % Slices; - if (count_[idx] == 0) + if (count_[idx] == 0) { EMBB_THROW(embb::base::ErrorException, - "All inputs already fired for this clock.") + "All inputs already fired for this clock."); + } if (--count_[idx] == 0) { count_[idx] = 5; listener_->OnClock(clock); diff --git a/dataflow_cpp/include/embb/dataflow/internal/node.h b/dataflow_cpp/include/embb/dataflow/internal/node.h index c446f10..daf80b3 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/node.h +++ b/dataflow_cpp/include/embb/dataflow/internal/node.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/out.h b/dataflow_cpp/include/embb/dataflow/internal/out.h index df20147..382f6ad 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/out.h +++ b/dataflow_cpp/include/embb/dataflow/internal/out.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/outputs.h b/dataflow_cpp/include/embb/dataflow/internal/outputs.h index 9fb26e7..cf926b0 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/outputs.h +++ b/dataflow_cpp/include/embb/dataflow/internal/outputs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/process.h b/dataflow_cpp/include/embb/dataflow/internal/process.h index ca201a7..1765db0 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/process.h +++ b/dataflow_cpp/include/embb/dataflow/internal/process.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/process_executor.h b/dataflow_cpp/include/embb/dataflow/internal/process_executor.h index 2602dc8..7756722 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/process_executor.h +++ b/dataflow_cpp/include/embb/dataflow/internal/process_executor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/scheduler.h b/dataflow_cpp/include/embb/dataflow/internal/scheduler.h index 1b0214b..811c7dd 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/scheduler.h +++ b/dataflow_cpp/include/embb/dataflow/internal/scheduler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/scheduler_mtapi.h b/dataflow_cpp/include/embb/dataflow/internal/scheduler_mtapi.h index 54f7c43..7e72812 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/scheduler_mtapi.h +++ b/dataflow_cpp/include/embb/dataflow/internal/scheduler_mtapi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/scheduler_sequential.h b/dataflow_cpp/include/embb/dataflow/internal/scheduler_sequential.h index 02ea744..a553548 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/scheduler_sequential.h +++ b/dataflow_cpp/include/embb/dataflow/internal/scheduler_sequential.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/select.h b/dataflow_cpp/include/embb/dataflow/internal/select.h index 1d62028..423e2a5 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/select.h +++ b/dataflow_cpp/include/embb/dataflow/internal/select.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/signal.h b/dataflow_cpp/include/embb/dataflow/internal/signal.h index f28f3f9..951e75a 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/signal.h +++ b/dataflow_cpp/include/embb/dataflow/internal/signal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/sink.h b/dataflow_cpp/include/embb/dataflow/internal/sink.h index 1dd8278..7066995 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/sink.h +++ b/dataflow_cpp/include/embb/dataflow/internal/sink.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/sink_executor.h b/dataflow_cpp/include/embb/dataflow/internal/sink_executor.h index 65dacf3..447602d 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/sink_executor.h +++ b/dataflow_cpp/include/embb/dataflow/internal/sink_executor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/source.h b/dataflow_cpp/include/embb/dataflow/internal/source.h index 0ad4784..48f5772 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/source.h +++ b/dataflow_cpp/include/embb/dataflow/internal/source.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/source_executor.h b/dataflow_cpp/include/embb/dataflow/internal/source_executor.h index 7d316e9..2e37faf 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/source_executor.h +++ b/dataflow_cpp/include/embb/dataflow/internal/source_executor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/spinlock.h b/dataflow_cpp/include/embb/dataflow/internal/spinlock.h index 8b0f275..bc28910 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/spinlock.h +++ b/dataflow_cpp/include/embb/dataflow/internal/spinlock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/switch.h b/dataflow_cpp/include/embb/dataflow/internal/switch.h index 396d9ac..7a1eb13 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/switch.h +++ b/dataflow_cpp/include/embb/dataflow/internal/switch.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/tuple.h b/dataflow_cpp/include/embb/dataflow/internal/tuple.h index 2df36c0..f03f9ff 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/tuple.h +++ b/dataflow_cpp/include/embb/dataflow/internal/tuple.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/internal/typelist.h b/dataflow_cpp/include/embb/dataflow/internal/typelist.h index eb5b286..4c25272 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/typelist.h +++ b/dataflow_cpp/include/embb/dataflow/internal/typelist.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/include/embb/dataflow/network.h b/dataflow_cpp/include/embb/dataflow/network.h index 625d269..ffe5633 100644 --- a/dataflow_cpp/include/embb/dataflow/network.h +++ b/dataflow_cpp/include/embb/dataflow/network.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/src/dummy.cc b/dataflow_cpp/src/dummy.cc index eb34253..e95756a 100644 --- a/dataflow_cpp/src/dummy.cc +++ b/dataflow_cpp/src/dummy.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/test/dataflow_cpp_test_simple.cc b/dataflow_cpp/test/dataflow_cpp_test_simple.cc index 952ada9..3fe9272 100644 --- a/dataflow_cpp/test/dataflow_cpp_test_simple.cc +++ b/dataflow_cpp/test/dataflow_cpp_test_simple.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/test/dataflow_cpp_test_simple.h b/dataflow_cpp/test/dataflow_cpp_test_simple.h index 35b7471..b1ffea9 100644 --- a/dataflow_cpp/test/dataflow_cpp_test_simple.h +++ b/dataflow_cpp/test/dataflow_cpp_test_simple.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/test/dataflow_cpp_test_tuple.cc b/dataflow_cpp/test/dataflow_cpp_test_tuple.cc index cd20ee2..0d54432 100644 --- a/dataflow_cpp/test/dataflow_cpp_test_tuple.cc +++ b/dataflow_cpp/test/dataflow_cpp_test_tuple.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/test/dataflow_cpp_test_tuple.h b/dataflow_cpp/test/dataflow_cpp_test_tuple.h index 1eb62bd..31bc3bb 100644 --- a/dataflow_cpp/test/dataflow_cpp_test_tuple.h +++ b/dataflow_cpp/test/dataflow_cpp_test_tuple.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/dataflow_cpp/test/main.cc b/dataflow_cpp/test/main.cc index fd36777..0db1d7c 100644 --- a/dataflow_cpp/test/main.cc +++ b/dataflow_cpp/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/CMakeLists.txt b/doc/examples/CMakeLists.txt index cff5224..9393c95 100644 --- a/doc/examples/CMakeLists.txt +++ b/doc/examples/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/../../base_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../../mtapi_c/include ${CMAKE_CURRENT_SOURCE_DIR}/../../mtapi_cpp/include + ${CMAKE_CURRENT_BINARY_DIR}/../../mtapi_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../../containers_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../../algorithms_cpp/include ${CMAKE_CURRENT_SOURCE_DIR}/../../dataflow_cpp/include diff --git a/doc/examples/algorithms/counting/counting-fragmented.cc b/doc/examples/algorithms/counting/counting-fragmented.cc index 0b9651a..a621d8b 100644 --- a/doc/examples/algorithms/counting/counting-fragmented.cc +++ b/doc/examples/algorithms/counting/counting-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/algorithms/for_each/for_each-fragmented.cc b/doc/examples/algorithms/for_each/for_each-fragmented.cc index 45cd69b..ab80a0c 100644 --- a/doc/examples/algorithms/for_each/for_each-fragmented.cc +++ b/doc/examples/algorithms/for_each/for_each-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/algorithms/invoke/invoke-fragmented.cc b/doc/examples/algorithms/invoke/invoke-fragmented.cc index 64c22fd..94cddd2 100644 --- a/doc/examples/algorithms/invoke/invoke-fragmented.cc +++ b/doc/examples/algorithms/invoke/invoke-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/algorithms/reduce/reduce-fragmented.cc b/doc/examples/algorithms/reduce/reduce-fragmented.cc index 87058d0..4c9f1df 100644 --- a/doc/examples/algorithms/reduce/reduce-fragmented.cc +++ b/doc/examples/algorithms/reduce/reduce-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/algorithms/scan/scan-fragmented.cc b/doc/examples/algorithms/scan/scan-fragmented.cc index ad552e3..3a9c1d3 100644 --- a/doc/examples/algorithms/scan/scan-fragmented.cc +++ b/doc/examples/algorithms/scan/scan-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/algorithms/sorting/sorting-fragmented.cc b/doc/examples/algorithms/sorting/sorting-fragmented.cc index e37996e..36cb1ed 100644 --- a/doc/examples/algorithms/sorting/sorting-fragmented.cc +++ b/doc/examples/algorithms/sorting/sorting-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,7 +34,11 @@ */ void RunSorting() { #include "algorithms/sorting/range_define-snippet.h" - range = {4, 2, 3, 5, 1}; + range.push_back(4); + range.push_back(2); + range.push_back(3); + range.push_back(5); + range.push_back(1); #include "algorithms/sorting/quick_sort-snippet.h" for (size_t i = 0; i < range.size(); i++) { diff --git a/doc/examples/containers/object_pool-fragmented.cc b/doc/examples/containers/object_pool-fragmented.cc index ef92266..fb7ee1b 100644 --- a/doc/examples/containers/object_pool-fragmented.cc +++ b/doc/examples/containers/object_pool-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/containers/queues-fragmented.cc b/doc/examples/containers/queues-fragmented.cc index bba8bc4..0b6eaff 100644 --- a/doc/examples/containers/queues-fragmented.cc +++ b/doc/examples/containers/queues-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/containers/stack-fragmented.cc b/doc/examples/containers/stack-fragmented.cc index 90dbb61..31adda7 100644 --- a/doc/examples/containers/stack-fragmented.cc +++ b/doc/examples/containers/stack-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/dataflow/dataflow_linear-fragmented.cc b/doc/examples/dataflow/dataflow_linear-fragmented.cc index 6fae31f..25bdacd 100644 --- a/doc/examples/dataflow/dataflow_linear-fragmented.cc +++ b/doc/examples/dataflow/dataflow_linear-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc b/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc index 9cf799f..5708773 100644 --- a/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc +++ b/doc/examples/dataflow/dataflow_nonlinear-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/main.cc b/doc/examples/main.cc index ab9a59c..08b2df6 100644 --- a/doc/examples/main.cc +++ b/doc/examples/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/mtapi/mtapi_c-fragmented.cc b/doc/examples/mtapi/mtapi_c-fragmented.cc index b902b8a..d543e12 100644 --- a/doc/examples/mtapi/mtapi_c-fragmented.cc +++ b/doc/examples/mtapi/mtapi_c-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/mtapi/mtapi_check_status-snippet.h b/doc/examples/mtapi/mtapi_check_status-snippet.h index d22c393..bf1d1d3 100644 --- a/doc/examples/mtapi/mtapi_check_status-snippet.h +++ b/doc/examples/mtapi/mtapi_check_status-snippet.h @@ -1,7 +1,8 @@ #include +#include #include #define MTAPI_CHECK_STATUS(status) \ if (MTAPI_SUCCESS != status) { \ - embb_log_error("MTAPI C Example", "...error %d\n\n", status); \ - abort(); \ + printf("...error %d\n\n", status); \ + exit(status); \ } diff --git a/doc/examples/mtapi/mtapi_cpp-fragmented.cc b/doc/examples/mtapi/mtapi_cpp-fragmented.cc index 3324c8b..700d758 100644 --- a/doc/examples/mtapi/mtapi_cpp-fragmented.cc +++ b/doc/examples/mtapi/mtapi_cpp-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/examples/stl_for_each/stl_for_each-fragmented.cc b/doc/examples/stl_for_each/stl_for_each-fragmented.cc index 220a41f..ecff00b 100644 --- a/doc/examples/stl_for_each/stl_for_each-fragmented.cc +++ b/doc/examples/stl_for_each/stl_for_each-fragmented.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/doc/reference/Doxyfile.in b/doc/reference/Doxyfile.in index 4c74646..5b7a861 100644 --- a/doc/reference/Doxyfile.in +++ b/doc/reference/Doxyfile.in @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/doc/tutorial/content/algorithms.tex b/doc/tutorial/content/algorithms.tex index 9a52973..14bff9f 100644 --- a/doc/tutorial/content/algorithms.tex +++ b/doc/tutorial/content/algorithms.tex @@ -1,7 +1,9 @@ \chapter{Algorithms} \label{cha:algorithms} -The \emph{Algorithms} building block of \embb provides high-level constructs for typical parallelization tasks. They are aligned to the functions provided by the C++ Standard Library, but contain additional functionality typical for embedded systems such as task priorities. Although the algorithms can be used in a black-box way, it is good to have a basic understanding of their implementation: The algorithms split computations to be performed in parallel into tasks which are executed by the MTAPI task scheduler (cf. Chapter~\ref{cha:mtapi}). For that purpose, the tasks are stored in queues and mapped to a fixed number of worker threads at runtime. Since MTAPI allocates the necessary data structures during initialization, the maximum number of tasks in flight is fixed. In case one of the algorithms exceeds this limit, an exception is thrown. +The \emph{Algorithms} building block of \embb provides high-level constructs for typical parallelization tasks. They are aligned to the functions provided by the C++ Standard Library, but contain additional functionality typical for embedded systems such as task priorities. Although the algorithms can be used in a black-box way, it is good to have a basic understanding of their implementation: The algorithms split computations to be performed in parallel into tasks which are executed by the MTAPI task scheduler (cf. Chapter~\ref{cha:mtapi}). For that purpose, the tasks are stored in queues and mapped to a fixed number of worker threads at runtime. Since MTAPI allocates the necessary data structures during initialization, the maximum number of tasks in flight is fixed. In case one of the algorithms exceeds this limit, an exception is thrown. + +\emph{\textbf{Note:} The \emph{Algorithms} building block is implemented using the MTAPI C++ interface. By calling \lstinline|embb::mtapi::Node::Initialize| task and other limits can be customized. Explicit initialization also eliminates unexpected delays when measuring performance. See Section~\ref{sec:mtapi_cpp_interface} for details.} In the following, we look at parallel function invocation (Section~\ref{sec:algorithms_invoke}), sorting (Section~\ref{sec:algorithms_sorting}), counting (Section~\ref{sec:algorithms_counting}), foreach loops (Section~\ref{sec:algorithms_foreach}), reductions (Section~\ref{sec:algorithms_reductions}), and prefix computations (Section~\ref{sec:algorithms_prefix}). diff --git a/doc/tutorial/content/dataflow.tex b/doc/tutorial/content/dataflow.tex index 3274bf8..7d09e6b 100644 --- a/doc/tutorial/content/dataflow.tex +++ b/doc/tutorial/content/dataflow.tex @@ -18,6 +18,8 @@ With the \emph{Dataflow} building block, \embb provides generic skeletons for th % \item dynamic control of data streams (conditional execution) %\end{itemize} +\emph{\textbf{Note:} The \emph{Dataflow} building block is implemented using the MTAPI C++ interface. Since MTAPI does not allocate memory after initialization, the number of tasks and other resources are limited. By calling \lstinline|embb::mtapi::Node::Initialize| these limits can be customized. Explicit initialization also eliminates unexpected delays when measuring performance. See Section~\ref{sec:mtapi_cpp_interface} for details.} + \section{Linear Pipelines} Before we go into detail, we demonstrate the basic concepts of this building block by means of a simple application which finds and replaces strings in a file. Let us start with the sequential implementation. The program shown in Listing~\ref{lst:replace_seq} reads a file line by line and replaces each occurrence of a given string with a new string. The main part consists of the \lstinline|while| loop which performs three steps: @@ -138,7 +140,7 @@ is used to construct the sink: % %In order to avoid that the received string is overwritten accidentally, the parameter \lstinline|str| corresponding to the input port of \lstinline|write| must be constant.\\ -\emph{Note: If you parallelize your own application using \embb and your compiler emits a lengthy error message containing lots of templates, it is very likely that for at least one process, the ports and their directions do not match the signature of the given function.} +\emph{\textbf{Note:} If you parallelize your own application using \embb and your compiler emits a lengthy error message containing lots of templates, it is very likely that for at least one process, the ports and their directions do not match the signature of the given function.} The network needs to know about the processes declared above, so we add them to our network: % diff --git a/doc/tutorial/content/mtapi.tex b/doc/tutorial/content/mtapi.tex index 06ea39e..e0cb5a3 100644 --- a/doc/tutorial/content/mtapi.tex +++ b/doc/tutorial/content/mtapi.tex @@ -160,6 +160,8 @@ First, the node instance needs to be obtained. If the node is not initialized ye % \\\inputlisting{../examples/mtapi/mtapi_cpp_get_node-snippet.h} % +\emph{\textbf{Note:} Automatic initialization allows for easy usage of the \emph{Algorithms} and \emph{Dataflow} building blocks. For performance measurements however, explicit initialization by calling \lstinline|embb::mtapi::Node::Initialize| is imperative since the measurements will otherwise include the initialization time of MTAPI.} + Checking the arguments and the result buffer is not necessary, since everything is safely typed. However, the terminating condition of the recursion still needs to be checked: % \\\inputlisting{../examples/mtapi/mtapi_terminating_condition-snippet.h} @@ -190,3 +192,5 @@ The root task can be started using \lstinline|embb::mtapi::Node::Spawn()| direct \\\inputlisting{../examples/mtapi/mtapi_cpp_start_task-snippet.h} % Again, the started task has to be waited for (using \lstinline|embb::mtapi::Task::Wait()|) before the result can be returned. The runtime is shut down automatically in an \lstinline|atexit()| handler. + +\emph{\textbf{Note:} If the node was initialized explicitly by calling \lstinline|embb::mtapi::Node::Initialize|, the runtime must also be shut down explicitly by calling \lstinline|embb::mtapi::Node::Finalize|.} diff --git a/mtapi_c/include/embb/mtapi/c/mtapi.h b/mtapi_c/include/embb/mtapi/c/mtapi.h index 4ebadba..65379b8 100644 --- a/mtapi_c/include/embb/mtapi/c/mtapi.h +++ b/mtapi_c/include/embb/mtapi/c/mtapi.h @@ -68,7 +68,7 @@ * * * Action Function - * The callable, an executable function of an action, invoked by the + * The executable function of an action, invoked by the * MTAPI runtime when a task is started. * * @@ -1064,8 +1064,14 @@ void mtapi_nodeattr_set( * * \c attributes is a pointer to a node attributes object that was previously * prepared with mtapi_nodeattr_init() and mtapi_nodeattr_set(). If - * \c attributes is \c MTAPI_NULL, then implementation-defined default - * attributes will be used. + * \c attributes is \c MTAPI_NULL, then the following default + * attributes will be used: + * - all available cores will be used + * - maximum number of tasks is 1024 + * - maximum number of groups is 128 + * - maximum number of queues is 16 + * - maximum queue capacity is 1024 + * - maximum number of priorities is 4. * * On success, \c *status is set to \c MTAPI_SUCCESS. On error, \c *status is * set to the appropriate error defined below. diff --git a/mtapi_c/include/mtapi.h b/mtapi_c/include/mtapi.h index 86ca961..e25eb56 100644 --- a/mtapi_c/include/mtapi.h +++ b/mtapi_c/include/mtapi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_action_t.c b/mtapi_c/src/embb_mtapi_action_t.c index 2aba718..c062bdd 100644 --- a/mtapi_c/src/embb_mtapi_action_t.c +++ b/mtapi_c/src/embb_mtapi_action_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -420,6 +420,7 @@ void mtapi_action_enable( embb_mtapi_action_pool_get_storage_for_handle( node->action_pool, action); local_action->enabled = MTAPI_TRUE; + local_status = MTAPI_SUCCESS; } else { local_status = MTAPI_ERR_ACTION_INVALID; } diff --git a/mtapi_c/src/embb_mtapi_action_t.h b/mtapi_c/src/embb_mtapi_action_t.h index 7cbb45b..0d6848f 100644 --- a/mtapi_c/src/embb_mtapi_action_t.h +++ b/mtapi_c/src/embb_mtapi_action_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_action_t_fwd.h b/mtapi_c/src/embb_mtapi_action_t_fwd.h index 9774070..27944d7 100644 --- a/mtapi_c/src/embb_mtapi_action_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_action_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_alloc.c b/mtapi_c/src/embb_mtapi_alloc.c index ac5c7a5..7a5d397 100644 --- a/mtapi_c/src/embb_mtapi_alloc.c +++ b/mtapi_c/src/embb_mtapi_alloc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_alloc.h b/mtapi_c/src/embb_mtapi_alloc.h index 41d69fd..f5a2ec1 100644 --- a/mtapi_c/src/embb_mtapi_alloc.h +++ b/mtapi_c/src/embb_mtapi_alloc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_attr.c b/mtapi_c/src/embb_mtapi_attr.c index ea14cb5..ca05372 100644 --- a/mtapi_c/src/embb_mtapi_attr.c +++ b/mtapi_c/src/embb_mtapi_attr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_attr.h b/mtapi_c/src/embb_mtapi_attr.h index d8023d5..46e4626 100644 --- a/mtapi_c/src/embb_mtapi_attr.h +++ b/mtapi_c/src/embb_mtapi_attr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_group_t.c b/mtapi_c/src/embb_mtapi_group_t.c index 13a099c..9e3b0a5 100644 --- a/mtapi_c/src/embb_mtapi_group_t.c +++ b/mtapi_c/src/embb_mtapi_group_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_group_t.h b/mtapi_c/src/embb_mtapi_group_t.h index d0d52e2..9f4a401 100644 --- a/mtapi_c/src/embb_mtapi_group_t.h +++ b/mtapi_c/src/embb_mtapi_group_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_group_t_fwd.h b/mtapi_c/src/embb_mtapi_group_t_fwd.h index 5759a05..66233b3 100644 --- a/mtapi_c/src/embb_mtapi_group_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_group_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_id_pool_t.c b/mtapi_c/src/embb_mtapi_id_pool_t.c index 87dca32..570fa98 100644 --- a/mtapi_c/src/embb_mtapi_id_pool_t.c +++ b/mtapi_c/src/embb_mtapi_id_pool_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -37,12 +37,12 @@ void embb_mtapi_id_pool_initialize( that->capacity = capacity; that->id_buffer = (mtapi_uint_t*) - embb_mtapi_alloc_allocate(sizeof(mtapi_uint_t)*(capacity)); + embb_mtapi_alloc_allocate(sizeof(mtapi_uint_t)*(capacity + 1)); that->id_buffer[0] = EMBB_MTAPI_IDPOOL_INVALID_ID; - for (ii = 1; ii < capacity; ii++) { + for (ii = 1; ii <= capacity; ii++) { that->id_buffer[ii] = ii; } - that->ids_available = capacity - 1; + that->ids_available = capacity; that->put_id_position = 0; that->get_id_position = 1; embb_mtapi_spinlock_initialize(&that->lock); diff --git a/mtapi_c/src/embb_mtapi_id_pool_t.h b/mtapi_c/src/embb_mtapi_id_pool_t.h index ec1bd7b..9d06f98 100644 --- a/mtapi_c/src/embb_mtapi_id_pool_t.h +++ b/mtapi_c/src/embb_mtapi_id_pool_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_job_t.c b/mtapi_c/src/embb_mtapi_job_t.c index 6523f9c..227666e 100644 --- a/mtapi_c/src/embb_mtapi_job_t.c +++ b/mtapi_c/src/embb_mtapi_job_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -40,9 +40,9 @@ mtapi_boolean_t embb_mtapi_job_initialize_list(embb_mtapi_node_t * node) { node->job_list = (embb_mtapi_job_t*)embb_mtapi_alloc_allocate( - sizeof(embb_mtapi_job_t)*node->attributes.max_jobs); + sizeof(embb_mtapi_job_t)*(node->attributes.max_jobs + 1)); mtapi_uint_t ii; - for (ii = 0; ii < node->attributes.max_jobs; ii++) { + for (ii = 0; ii <= node->attributes.max_jobs; ii++) { embb_mtapi_job_initialize( &node->job_list[ii], node->attributes.max_actions_per_job); node->job_list[ii].handle.id = ii; @@ -53,7 +53,7 @@ mtapi_boolean_t embb_mtapi_job_initialize_list(embb_mtapi_node_t * node) { void embb_mtapi_job_finalize_list(embb_mtapi_node_t * node) { mtapi_uint_t ii; - for (ii = 0; ii < node->attributes.max_jobs; ii++) { + for (ii = 0; ii <= node->attributes.max_jobs; ii++) { embb_mtapi_job_finalize(&node->job_list[ii]); node->job_list[ii].handle.id = 0; } @@ -69,7 +69,7 @@ mtapi_boolean_t embb_mtapi_job_is_handle_valid( mtapi_job_hndl_t handle) { assert(MTAPI_NULL != node); return ((0 < handle.id) && - (handle.id < node->attributes.max_jobs) && + (handle.id <= node->attributes.max_jobs) && (node->job_list[handle.id].handle.tag == handle.tag)) ? MTAPI_TRUE : MTAPI_FALSE; } @@ -87,7 +87,7 @@ mtapi_boolean_t embb_mtapi_job_is_id_valid( embb_mtapi_node_t * node, mtapi_job_id_t id) { assert(MTAPI_NULL != node); - return ((0 < id) && (id < node->attributes.max_jobs)) ? + return ((0 < id) && (id <= node->attributes.max_jobs)) ? MTAPI_TRUE : MTAPI_FALSE; } diff --git a/mtapi_c/src/embb_mtapi_job_t.h b/mtapi_c/src/embb_mtapi_job_t.h index ae18f26..9e2ec88 100644 --- a/mtapi_c/src/embb_mtapi_job_t.h +++ b/mtapi_c/src/embb_mtapi_job_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_job_t_fwd.h b/mtapi_c/src/embb_mtapi_job_t_fwd.h index 17dd76d..c986a86 100644 --- a/mtapi_c/src/embb_mtapi_job_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_job_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_log.h b/mtapi_c/src/embb_mtapi_log.h index da9ca59..8f98eaf 100644 --- a/mtapi_c/src/embb_mtapi_log.h +++ b/mtapi_c/src/embb_mtapi_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_node_t.c b/mtapi_c/src/embb_mtapi_node_t.c index f7a7ad7..327cd21 100644 --- a/mtapi_c/src/embb_mtapi_node_t.c +++ b/mtapi_c/src/embb_mtapi_node_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_node_t.h b/mtapi_c/src/embb_mtapi_node_t.h index f9a12b5..22fca86 100644 --- a/mtapi_c/src/embb_mtapi_node_t.h +++ b/mtapi_c/src/embb_mtapi_node_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_node_t_fwd.h b/mtapi_c/src/embb_mtapi_node_t_fwd.h index 0bb22fe..78ee823 100644 --- a/mtapi_c/src/embb_mtapi_node_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_node_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_pool_template-inl.h b/mtapi_c/src/embb_mtapi_pool_template-inl.h index 9d633f6..5366972 100644 --- a/mtapi_c/src/embb_mtapi_pool_template-inl.h +++ b/mtapi_c/src/embb_mtapi_pool_template-inl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -60,8 +60,8 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_initialize( \ assert(MTAPI_NULL != that); \ embb_mtapi_id_pool_initialize(&that->id_pool, capacity); \ that->storage = (embb_mtapi_##TYPE##_t*)embb_mtapi_alloc_allocate( \ - sizeof(embb_mtapi_##TYPE##_t)*capacity); \ - for (ii = 0; ii < capacity; ii++) { \ + sizeof(embb_mtapi_##TYPE##_t)*(capacity + 1)); \ + for (ii = 0; ii <= capacity; ii++) { \ that->storage[ii].handle.id = EMBB_MTAPI_IDPOOL_INVALID_ID; \ that->storage[ii].handle.tag = 0; \ } \ @@ -102,7 +102,7 @@ mtapi_boolean_t embb_mtapi_##TYPE##_pool_is_handle_valid( \ mtapi_##TYPE##_hndl_t handle) { \ assert(MTAPI_NULL != that); \ return ((0 < handle.id) && \ - (handle.id < that->id_pool.capacity) && \ + (handle.id <= that->id_pool.capacity) && \ (that->storage[handle.id].handle.tag == handle.tag)) ? \ MTAPI_TRUE : MTAPI_FALSE; \ } \ diff --git a/mtapi_c/src/embb_mtapi_pool_template.h b/mtapi_c/src/embb_mtapi_pool_template.h index 38803e1..1bace62 100644 --- a/mtapi_c/src/embb_mtapi_pool_template.h +++ b/mtapi_c/src/embb_mtapi_pool_template.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_queue_t.c b/mtapi_c/src/embb_mtapi_queue_t.c index 62d9fce..8288dab 100644 --- a/mtapi_c/src/embb_mtapi_queue_t.c +++ b/mtapi_c/src/embb_mtapi_queue_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -200,6 +200,7 @@ mtapi_queue_hndl_t mtapi_queue_create( queue->queue_id = queue_id; queue_hndl = queue->handle; } else { + embb_mtapi_queue_pool_deallocate(node->queue_pool, queue); local_status = MTAPI_ERR_JOB_INVALID; } } else { diff --git a/mtapi_c/src/embb_mtapi_queue_t.h b/mtapi_c/src/embb_mtapi_queue_t.h index 2ff2478..ff0abef 100644 --- a/mtapi_c/src/embb_mtapi_queue_t.h +++ b/mtapi_c/src/embb_mtapi_queue_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_queue_t_fwd.h b/mtapi_c/src/embb_mtapi_queue_t_fwd.h index 9d0a84f..0fb3824 100644 --- a/mtapi_c/src/embb_mtapi_queue_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_queue_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_scheduler_t.c b/mtapi_c/src/embb_mtapi_scheduler_t.c index cbcf914..54269dd 100644 --- a/mtapi_c/src/embb_mtapi_scheduler_t.c +++ b/mtapi_c/src/embb_mtapi_scheduler_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_scheduler_t.h b/mtapi_c/src/embb_mtapi_scheduler_t.h index 647281a..07ff116 100644 --- a/mtapi_c/src/embb_mtapi_scheduler_t.h +++ b/mtapi_c/src/embb_mtapi_scheduler_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_scheduler_t_fwd.h b/mtapi_c/src/embb_mtapi_scheduler_t_fwd.h index dc9425b..454c471 100644 --- a/mtapi_c/src/embb_mtapi_scheduler_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_scheduler_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_spinlock_t.c b/mtapi_c/src/embb_mtapi_spinlock_t.c index c61502f..0b3efa9 100644 --- a/mtapi_c/src/embb_mtapi_spinlock_t.c +++ b/mtapi_c/src/embb_mtapi_spinlock_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_spinlock_t.h b/mtapi_c/src/embb_mtapi_spinlock_t.h index d24521b..012cb1d 100644 --- a/mtapi_c/src/embb_mtapi_spinlock_t.h +++ b/mtapi_c/src/embb_mtapi_spinlock_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_context_t.c b/mtapi_c/src/embb_mtapi_task_context_t.c index 5e4b558..92be087 100644 --- a/mtapi_c/src/embb_mtapi_task_context_t.c +++ b/mtapi_c/src/embb_mtapi_task_context_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_context_t.h b/mtapi_c/src/embb_mtapi_task_context_t.h index 3a09ac3..8763b44 100644 --- a/mtapi_c/src/embb_mtapi_task_context_t.h +++ b/mtapi_c/src/embb_mtapi_task_context_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_context_t_fwd.h b/mtapi_c/src/embb_mtapi_task_context_t_fwd.h index b9c5061..0ecfb4e 100644 --- a/mtapi_c/src/embb_mtapi_task_context_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_task_context_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_queue_t.c b/mtapi_c/src/embb_mtapi_task_queue_t.c index 6e1b0de..d52a2bf 100644 --- a/mtapi_c/src/embb_mtapi_task_queue_t.c +++ b/mtapi_c/src/embb_mtapi_task_queue_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_queue_t.h b/mtapi_c/src/embb_mtapi_task_queue_t.h index bf859da..bd18fa7 100644 --- a/mtapi_c/src/embb_mtapi_task_queue_t.h +++ b/mtapi_c/src/embb_mtapi_task_queue_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_queue_t_fwd.h b/mtapi_c/src/embb_mtapi_task_queue_t_fwd.h index c75c283..f313556 100644 --- a/mtapi_c/src/embb_mtapi_task_queue_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_task_queue_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_t.c b/mtapi_c/src/embb_mtapi_task_t.c index f04830d..dfbd39b 100644 --- a/mtapi_c/src/embb_mtapi_task_t.c +++ b/mtapi_c/src/embb_mtapi_task_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_t.h b/mtapi_c/src/embb_mtapi_task_t.h index 3c994e5..77617b3 100644 --- a/mtapi_c/src/embb_mtapi_task_t.h +++ b/mtapi_c/src/embb_mtapi_task_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_t_fwd.h b/mtapi_c/src/embb_mtapi_task_t_fwd.h index 8062970..f44bba4 100644 --- a/mtapi_c/src/embb_mtapi_task_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_task_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_task_visitor_function_t.h b/mtapi_c/src/embb_mtapi_task_visitor_function_t.h index d1c67c0..54d2b8c 100644 --- a/mtapi_c/src/embb_mtapi_task_visitor_function_t.h +++ b/mtapi_c/src/embb_mtapi_task_visitor_function_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_thread_context_t.c b/mtapi_c/src/embb_mtapi_thread_context_t.c index e0e8cef..ea5d4d1 100644 --- a/mtapi_c/src/embb_mtapi_thread_context_t.c +++ b/mtapi_c/src/embb_mtapi_thread_context_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_thread_context_t.h b/mtapi_c/src/embb_mtapi_thread_context_t.h index 67ec3a1..0ed2dd3 100644 --- a/mtapi_c/src/embb_mtapi_thread_context_t.h +++ b/mtapi_c/src/embb_mtapi_thread_context_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/embb_mtapi_thread_context_t_fwd.h b/mtapi_c/src/embb_mtapi_thread_context_t_fwd.h index a38e875..dc19293 100644 --- a/mtapi_c/src/embb_mtapi_thread_context_t_fwd.h +++ b/mtapi_c/src/embb_mtapi_thread_context_t_fwd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/mtapi_action_attributes_t.c b/mtapi_c/src/mtapi_action_attributes_t.c index 308305f..9cbbfce 100644 --- a/mtapi_c/src/mtapi_action_attributes_t.c +++ b/mtapi_c/src/mtapi_action_attributes_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/mtapi_affinity_t.c b/mtapi_c/src/mtapi_affinity_t.c index baa5a99..cfb0b9f 100644 --- a/mtapi_c/src/mtapi_affinity_t.c +++ b/mtapi_c/src/mtapi_affinity_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/mtapi_group_attributes_t.c b/mtapi_c/src/mtapi_group_attributes_t.c index 63cfacc..5342bcd 100644 --- a/mtapi_c/src/mtapi_group_attributes_t.c +++ b/mtapi_c/src/mtapi_group_attributes_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/mtapi_node_attributes_t.c b/mtapi_c/src/mtapi_node_attributes_t.c index 9343bd3..53ebf4c 100644 --- a/mtapi_c/src/mtapi_node_attributes_t.c +++ b/mtapi_c/src/mtapi_node_attributes_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/mtapi_queue_attributes_t.c b/mtapi_c/src/mtapi_queue_attributes_t.c index 532a271..6f39b0c 100644 --- a/mtapi_c/src/mtapi_queue_attributes_t.c +++ b/mtapi_c/src/mtapi_queue_attributes_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/src/mtapi_status_t.h b/mtapi_c/src/mtapi_status_t.h index 51af480..39fe780 100644 --- a/mtapi_c/src/mtapi_status_t.h +++ b/mtapi_c/src/mtapi_status_t.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,7 +30,7 @@ #include #include -EMBB_INLINE void mtapi_status_set( +EMBB_PLATFORM_INLINE void mtapi_status_set( mtapi_status_t* status, mtapi_status_t value) { if (MTAPI_NULL != status) { diff --git a/mtapi_c/src/mtapi_task_attributes_t.c b/mtapi_c/src/mtapi_task_attributes_t.c index ee3e166..43d9004 100644 --- a/mtapi_c/src/mtapi_task_attributes_t.c +++ b/mtapi_c/src/mtapi_task_attributes_t.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_config.h b/mtapi_c/test/embb_mtapi_test_config.h index b63e80c..fb08d64 100644 --- a/mtapi_c/test/embb_mtapi_test_config.h +++ b/mtapi_c/test/embb_mtapi_test_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_error.cc b/mtapi_c/test/embb_mtapi_test_error.cc new file mode 100644 index 0000000..6b3450a --- /dev/null +++ b/mtapi_c/test/embb_mtapi_test_error.cc @@ -0,0 +1,740 @@ +/* + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include + + +#define JOB_TEST_TASK 42 +#define TASK_TEST_ID 23 +#define INVALID_ATTRIBUTE 255 + +static embb_atomic_int wait; + +static void testErrorAction( + const void* /*args*/, + mtapi_size_t /*arg_size*/, + void* /*result_buffer*/, + mtapi_size_t /*result_buffer_size*/, + const void* /*node_local_data*/, + mtapi_size_t /*node_local_data_size*/, + mtapi_task_context_t* /*task_context*/) { + while (1 == embb_atomic_load_int(&wait)) + embb_thread_yield(); + embb_atomic_store_int(&wait, 2); +} + +ErrorTest::ErrorTest() { + CreateUnit("mtapi error test").Add(&ErrorTest::TestBasic, this); +} + +static void TestNodeNotInit() { + mtapi_status_t status; + mtapi_affinity_t affinity; + mtapi_job_hndl_t job_hndl; + mtapi_queue_hndl_t queue_hndl; + mtapi_group_hndl_t group_hndl; + mtapi_action_hndl_t action_hndl; + + status = MTAPI_ERR_UNKNOWN; + mtapi_finalize(&status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_node_id_get(&status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_node_get_attribute(THIS_NODE_ID, + MTAPI_NODE_MAX_ACTIONS, MTAPI_NULL, 0, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_domain_id_get(&status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + + status = MTAPI_ERR_UNKNOWN; + action_hndl = mtapi_action_create(1, testErrorAction, MTAPI_NULL, 0, + MTAPI_DEFAULT_ACTION_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_set_attribute(action_hndl, + MTAPI_ACTION_GLOBAL, + MTAPI_ATTRIBUTE_VALUE(MTAPI_TRUE), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_get_attribute(action_hndl, + MTAPI_ACTION_GLOBAL, MTAPI_NULL, 0, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_enable(action_hndl, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_disable(action_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_delete(action_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + + status = MTAPI_ERR_UNKNOWN; + job_hndl = mtapi_job_get(1, THIS_DOMAIN_ID, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + + status = MTAPI_ERR_UNKNOWN; + queue_hndl = mtapi_queue_create(1, job_hndl, + MTAPI_DEFAULT_QUEUE_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_enable(queue_hndl, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_disable(queue_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_delete(queue_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_get_attribute(queue_hndl, + MTAPI_QUEUE_DOMAIN_SHARED, MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_set_attribute(queue_hndl, + MTAPI_QUEUE_DOMAIN_SHARED, MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + + status = MTAPI_ERR_UNKNOWN; + group_hndl = mtapi_group_create(MTAPI_GROUP_ID_NONE, + MTAPI_DEFAULT_GROUP_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_group_delete(group_hndl, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_group_get_attribute(group_hndl, + 0, MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_group_set_attribute(group_hndl, + 0, MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_affinity_init(&affinity, MTAPI_TRUE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_affinity_set(&affinity, 0, MTAPI_TRUE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_affinity_get(&affinity, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_NOTINIT); + + + PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u); +} + +static void TestLimits() { + mtapi_status_t status; + mtapi_node_attributes_t node_attr; + mtapi_action_hndl_t action_hndl, action_hndl_invalid; + mtapi_job_hndl_t job_hndl, job_hndl_invalid; + mtapi_task_hndl_t task_hndl, task_hndl_invalid; + mtapi_group_hndl_t group_hndl, group_hndl_invalid; + mtapi_queue_hndl_t queue_hndl, queue_hndl_invalid; + char buffer[128]; + + /* initialize a node with all limits set to 1 */ + status = MTAPI_ERR_UNKNOWN; + mtapi_nodeattr_init(&node_attr, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_ACTIONS, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_ACTIONS_PER_JOB, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_GROUPS, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_QUEUES, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_PRIORITIES, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_JOBS, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_MAX_TASKS, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_nodeattr_set(&node_attr, + MTAPI_NODE_QUEUE_LIMIT, + MTAPI_ATTRIBUTE_VALUE(1), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + mtapi_initialize(THIS_DOMAIN_ID, THIS_NODE_ID, + &node_attr, MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + + /* try to get an attribute with invalid attribute pointer */ + status = MTAPI_ERR_UNKNOWN; + mtapi_node_get_attribute(THIS_NODE_ID, + MTAPI_NODE_MAX_ACTIONS, MTAPI_NULL, 0, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + + /* create our test action */ + status = MTAPI_ERR_UNKNOWN; + action_hndl = mtapi_action_create(1, testErrorAction, MTAPI_NULL, 0, + MTAPI_DEFAULT_ACTION_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_disable(action_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_enable(action_hndl, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_set_attribute(action_hndl, MTAPI_ACTION_GLOBAL, + MTAPI_ATTRIBUTE_VALUE(MTAPI_TRUE), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_get_attribute(action_hndl, + MTAPI_ACTION_GLOBAL, &buffer, MTAPI_ACTION_GLOBAL_SIZE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try to get an attribute of that action with invalid attribute pointer */ + status = MTAPI_ERR_UNKNOWN; + mtapi_action_get_attribute(action_hndl, + MTAPI_ACTION_GLOBAL, MTAPI_NULL, 0, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + /* try to get an attribute of that action with invalid attribute number */ + status = MTAPI_ERR_UNKNOWN; + mtapi_action_get_attribute(action_hndl, + INVALID_ATTRIBUTE, &buffer, 0, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + /* try to create another action, since the limit is one this will fail */ + status = MTAPI_ERR_UNKNOWN; + action_hndl_invalid = mtapi_action_create(1, testErrorAction, MTAPI_NULL, 0, + MTAPI_DEFAULT_ACTION_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ACTION_LIMIT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_enable(action_hndl_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ACTION_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_disable(action_hndl_invalid, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ACTION_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_delete(action_hndl_invalid, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ACTION_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_set_attribute(action_hndl_invalid, MTAPI_ACTION_DOMAIN_SHARED, + MTAPI_ATTRIBUTE_VALUE(MTAPI_TRUE), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ACTION_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_action_get_attribute(action_hndl_invalid, MTAPI_ACTION_DOMAIN_SHARED, + MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ACTION_INVALID); + + + /* get handle for job number 1, associated with our action */ + status = MTAPI_ERR_UNKNOWN; + job_hndl = mtapi_job_get(1, THIS_DOMAIN_ID, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try to get the invalid job number 2, limit is 1 */ + status = MTAPI_ERR_UNKNOWN; + job_hndl_invalid = mtapi_job_get(2, THIS_DOMAIN_ID, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_JOB_INVALID); + + + /* start a task with the invalid job, this will fail */ + status = MTAPI_ERR_UNKNOWN; + mtapi_task_start(MTAPI_TASK_ID_NONE, job_hndl_invalid, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_JOB_INVALID); + + + /* test if executing a task works, so do not wait */ + embb_atomic_store_int(&wait, 0); + + status = MTAPI_ERR_UNKNOWN; + task_hndl = mtapi_task_start(MTAPI_TASK_ID_NONE, job_hndl, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_task_wait(task_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* task should have executed, wait contains 2 */ + PT_EXPECT_EQ(embb_atomic_load_int(&wait), 2); + + + /* this time wait, so we can test the task limit */ + embb_atomic_store_int(&wait, 1); + + /* this task will wait until wait is set to 0 */ + status = MTAPI_ERR_UNKNOWN; + task_hndl = mtapi_task_start(MTAPI_TASK_ID_NONE, job_hndl, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* we cannot start another task since the limit is 1 */ + status = MTAPI_ERR_UNKNOWN; + task_hndl_invalid = mtapi_task_start(MTAPI_TASK_ID_NONE, job_hndl, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_TASK_LIMIT); + + /* let the waiting task do its work */ + embb_atomic_store_int(&wait, 0); + + status = MTAPI_ERR_UNKNOWN; + mtapi_task_wait(task_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* task should have executed, wait contains 2 */ + PT_EXPECT_EQ(embb_atomic_load_int(&wait), 2); + + + /* create a group */ + status = MTAPI_ERR_UNKNOWN; + group_hndl = mtapi_group_create(MTAPI_GROUP_ID_NONE, + MTAPI_DEFAULT_GROUP_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try to create another group, this will fail since the limit is 1 */ + status = MTAPI_ERR_UNKNOWN; + group_hndl_invalid = mtapi_group_create(MTAPI_GROUP_ID_NONE, + MTAPI_DEFAULT_GROUP_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_GROUP_LIMIT); + + /* try to delete the invalid group, this will fail */ + status = MTAPI_ERR_UNKNOWN; + mtapi_group_delete(group_hndl_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_GROUP_INVALID); + + /* delete the valid group */ + status = MTAPI_ERR_UNKNOWN; + mtapi_group_delete(group_hndl, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try to get an attribute of the deleted group */ + status = MTAPI_ERR_UNKNOWN; + mtapi_group_get_attribute(group_hndl, 0, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_GROUP_INVALID); + + /* try to set an attribute of the deleted group */ + status = MTAPI_ERR_UNKNOWN; + mtapi_group_set_attribute(group_hndl, 0, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_GROUP_INVALID); + + + /* create a queue with invalid job */ + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_create(MTAPI_QUEUE_ID_NONE, job_hndl_invalid, + MTAPI_DEFAULT_QUEUE_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_JOB_INVALID); + + /* create a queue */ + status = MTAPI_ERR_UNKNOWN; + queue_hndl = mtapi_queue_create(MTAPI_QUEUE_ID_NONE, job_hndl, + MTAPI_DEFAULT_QUEUE_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_disable(queue_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_enable(queue_hndl, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try to create another queue, this will fail since the limit is 1 */ + status = MTAPI_ERR_UNKNOWN; + queue_hndl_invalid = mtapi_queue_create(MTAPI_QUEUE_ID_NONE, job_hndl, + MTAPI_DEFAULT_QUEUE_ATTRIBUTES, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_LIMIT); + + /* try to enable the invalid queue */ + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_enable(queue_hndl_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_INVALID); + + /* try to disable the invalid queue */ + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_disable(queue_hndl_invalid, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_INVALID); + + /* try to delete the invalid queue */ + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_delete(queue_hndl_invalid, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_set_attribute(queue_hndl_invalid, MTAPI_QUEUE_DOMAIN_SHARED, + MTAPI_ATTRIBUTE_VALUE(MTAPI_TRUE), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_get_attribute(queue_hndl_invalid, MTAPI_QUEUE_DOMAIN_SHARED, + MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_INVALID); + + + /* now test the task limit via queues, let the first one wait */ + embb_atomic_store_int(&wait, 1); + + /* enqueue the task */ + status = MTAPI_ERR_UNKNOWN; + task_hndl = mtapi_task_enqueue(MTAPI_TASK_ID_NONE, queue_hndl, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* enqueue another one, this will fail since the limit is one */ + status = MTAPI_ERR_UNKNOWN; + mtapi_task_enqueue(MTAPI_TASK_ID_NONE, queue_hndl, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_TASK_LIMIT); + + /* let the valid task do its work */ + embb_atomic_store_int(&wait, 0); + + status = MTAPI_ERR_UNKNOWN; + mtapi_task_wait(task_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* the task has completed, wait should contain 2 */ + PT_EXPECT_EQ(embb_atomic_load_int(&wait), 2); + + + /* disable our queue */ + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_disable(queue_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_set_attribute(queue_hndl, MTAPI_QUEUE_DOMAIN_SHARED, + MTAPI_ATTRIBUTE_VALUE(MTAPI_TRUE), MTAPI_ATTRIBUTE_POINTER_AS_VALUE, + &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_get_attribute(queue_hndl, MTAPI_QUEUE_DOMAIN_SHARED, + MTAPI_NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_get_attribute(queue_hndl, INVALID_ATTRIBUTE, + &buffer, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_get_attribute(queue_hndl, MTAPI_QUEUE_DOMAIN_SHARED, + &buffer, MTAPI_QUEUE_DOMAIN_SHARED_SIZE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try to enqueue another task, this will fail since the queue is disabled */ + status = MTAPI_ERR_UNKNOWN; + mtapi_task_enqueue(MTAPI_TASK_ID_NONE, queue_hndl, + MTAPI_NULL, 0, MTAPI_NULL, 0, + MTAPI_DEFAULT_TASK_ATTRIBUTES, MTAPI_GROUP_NONE, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_QUEUE_DISABLED); + + /* disable our queue */ + status = MTAPI_ERR_UNKNOWN; + mtapi_queue_delete(queue_hndl, MTAPI_INFINITE, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + + /* and we're done */ + mtapi_finalize(&status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u); +} + +static void TestParameter() { + mtapi_status_t status; + mtapi_node_attributes_t node_attr; + mtapi_action_attributes_t action_attr; + mtapi_task_attributes_t task_attr; + mtapi_queue_attributes_t queue_attr; + mtapi_group_attributes_t group_attr; + mtapi_info_t info; + + + status = MTAPI_ERR_UNKNOWN; + mtapi_nodeattr_init(MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + status = MTAPI_ERR_UNKNOWN; + mtapi_nodeattr_init(&node_attr, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_nodeattr_set(&node_attr, INVALID_ATTRIBUTE, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_initialize(THIS_DOMAIN_ID, THIS_NODE_ID, + MTAPI_DEFAULT_NODE_ATTRIBUTES, MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + /* try second init */ + status = MTAPI_ERR_UNKNOWN; + mtapi_initialize(THIS_DOMAIN_ID, THIS_NODE_ID, + MTAPI_DEFAULT_NODE_ATTRIBUTES, &info, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_NODE_INITIALIZED); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_actionattr_init(MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + status = MTAPI_ERR_UNKNOWN; + mtapi_actionattr_init(&action_attr, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_actionattr_set(&action_attr, INVALID_ATTRIBUTE, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_taskattr_init(MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + status = MTAPI_ERR_UNKNOWN; + mtapi_taskattr_init(&task_attr, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_taskattr_set(&task_attr, INVALID_ATTRIBUTE, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_queueattr_init(MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queueattr_init(&queue_attr, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_queueattr_set(&queue_attr, INVALID_ATTRIBUTE, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_groupattr_init(MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_PARAMETER); + + status = MTAPI_ERR_UNKNOWN; + mtapi_groupattr_init(&group_attr, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + status = MTAPI_ERR_UNKNOWN; + mtapi_groupattr_set(&group_attr, INVALID_ATTRIBUTE, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_ATTR_NUM); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_finalize(&status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u); +} + +void TestContext() { + mtapi_status_t status; + mtapi_task_context_t* task_ctx_invalid = MTAPI_NULL; + + /* the following context is considered valid although it is not a real one, + but is checked against the stored pointers and will lead to + MTAPI_ERR_CONTEXT_OUTOFCONTEXT */ + embb_mtapi_thread_context_t thread_ctx_storage; + embb_tss_create(&thread_ctx_storage.tss_id); + embb_mtapi_task_context_t task_ctx_storage; + task_ctx_storage.thread_context = &thread_ctx_storage; + mtapi_task_context_t* task_ctx = &task_ctx_storage; + + status = MTAPI_ERR_UNKNOWN; + mtapi_initialize(THIS_DOMAIN_ID, THIS_NODE_ID, + MTAPI_DEFAULT_NODE_ATTRIBUTES, MTAPI_NULL, &status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_corenum_get(task_ctx_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_instnum_get(task_ctx_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_numinst_get(task_ctx_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_status_set(task_ctx_invalid, MTAPI_SUCCESS, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_runtime_notify(task_ctx_invalid, + MTAPI_NOTIF_EXECUTE_NEXT, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_INVALID); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_taskstate_get(task_ctx_invalid, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_INVALID); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_corenum_get(task_ctx, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_OUTOFCONTEXT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_instnum_get(task_ctx, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_OUTOFCONTEXT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_numinst_get(task_ctx, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_OUTOFCONTEXT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_status_set(task_ctx, MTAPI_SUCCESS, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_OUTOFCONTEXT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_runtime_notify(task_ctx, + MTAPI_NOTIF_EXECUTE_NEXT, NULL, 0, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_OUTOFCONTEXT); + + status = MTAPI_ERR_UNKNOWN; + mtapi_context_taskstate_get(task_ctx, &status); + PT_EXPECT_EQ(status, MTAPI_ERR_CONTEXT_OUTOFCONTEXT); + + + status = MTAPI_ERR_UNKNOWN; + mtapi_finalize(&status); + PT_EXPECT_EQ(status, MTAPI_SUCCESS); + + embb_tss_delete(&thread_ctx_storage.tss_id); + + PT_EXPECT_EQ(embb_get_bytes_allocated(), 0u); +} + +void ErrorTest::TestBasic() { + TestNodeNotInit(); + TestParameter(); + TestLimits(); + TestContext(); +} diff --git a/algorithms_cpp/src/execution_policy.cc b/mtapi_c/test/embb_mtapi_test_error.h similarity index 51% rename from algorithms_cpp/src/execution_policy.cc rename to mtapi_c/test/embb_mtapi_test_error.h index 1ea0a2e..3759bdd 100644 --- a/algorithms_cpp/src/execution_policy.cc +++ b/mtapi_c/test/embb_mtapi_test_error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -24,48 +24,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#ifndef MTAPI_C_TEST_EMBB_MTAPI_TEST_ERROR_H_ +#define MTAPI_C_TEST_EMBB_MTAPI_TEST_ERROR_H_ -namespace embb { -namespace algorithms { +#include -ExecutionPolicy::ExecutionPolicy() : - affinity_(), priority_(DefaultPriority) { -} +class ErrorTest : public partest::TestCase { + public: + ErrorTest(); -ExecutionPolicy::ExecutionPolicy(bool initial_affinity, mtapi_uint_t priority) -:affinity_(initial_affinity), priority_(priority) { -} + private: + void TestBasic(); +}; -ExecutionPolicy::ExecutionPolicy(mtapi_uint_t priority) -:affinity_(), priority_(priority) { -} - -ExecutionPolicy::ExecutionPolicy(bool initial_affinity) -:affinity_(initial_affinity), priority_(DefaultPriority) { -} - -void ExecutionPolicy::AddWorker(mtapi_uint_t worker) { - affinity_.Add(worker); -} - -void ExecutionPolicy::RemoveWorker(mtapi_uint_t worker) { - affinity_.Remove(worker); -} - -bool ExecutionPolicy::IsSetWorker(mtapi_uint_t worker) { - return affinity_.IsSet(worker); -} - -const mtapi::Affinity &ExecutionPolicy::GetAffinity() const { - return affinity_; -} - -mtapi_uint_t ExecutionPolicy::GetPriority() const { - return priority_; -} - -const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0; - -} // namespace algorithms -} // namespace embb +#endif // MTAPI_C_TEST_EMBB_MTAPI_TEST_ERROR_H_ diff --git a/mtapi_c/test/embb_mtapi_test_group.cc b/mtapi_c/test/embb_mtapi_test_group.cc index 7f9059a..37f17d9 100644 --- a/mtapi_c/test/embb_mtapi_test_group.cc +++ b/mtapi_c/test/embb_mtapi_test_group.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_group.h b/mtapi_c/test/embb_mtapi_test_group.h index 6116e3d..578a34e 100644 --- a/mtapi_c/test/embb_mtapi_test_group.h +++ b/mtapi_c/test/embb_mtapi_test_group.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_init_finalize.cc b/mtapi_c/test/embb_mtapi_test_init_finalize.cc index 6d8eb18..710d6c1 100644 --- a/mtapi_c/test/embb_mtapi_test_init_finalize.cc +++ b/mtapi_c/test/embb_mtapi_test_init_finalize.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_init_finalize.h b/mtapi_c/test/embb_mtapi_test_init_finalize.h index fc66cb3..519ba18 100644 --- a/mtapi_c/test/embb_mtapi_test_init_finalize.h +++ b/mtapi_c/test/embb_mtapi_test_init_finalize.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_queue.cc b/mtapi_c/test/embb_mtapi_test_queue.cc index dff0baf..08a0933 100644 --- a/mtapi_c/test/embb_mtapi_test_queue.cc +++ b/mtapi_c/test/embb_mtapi_test_queue.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -52,7 +52,7 @@ static void testQueueAction( } embb_mtapi_log_info("testQueueAction %d called from worker %d...\n", workload_id, core_num); - EMBB_UNUSED_IN_RELEASE(workload_id); + EMBB_UNUSED(workload_id); } static void testDoSomethingElse() { diff --git a/mtapi_c/test/embb_mtapi_test_queue.h b/mtapi_c/test/embb_mtapi_test_queue.h index 1b256b3..1e123f9 100644 --- a/mtapi_c/test/embb_mtapi_test_queue.h +++ b/mtapi_c/test/embb_mtapi_test_queue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/embb_mtapi_test_task.cc b/mtapi_c/test/embb_mtapi_test_task.cc index 5f29c07..4b01445 100644 --- a/mtapi_c/test/embb_mtapi_test_task.cc +++ b/mtapi_c/test/embb_mtapi_test_task.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -50,7 +50,7 @@ static void testTaskAction( } embb_mtapi_log_info("testTaskAction %d called from worker %d...\n", *reinterpret_cast(args), core_num); - EMBB_UNUSED_IN_RELEASE(args); + EMBB_UNUSED(args); } static void testDoSomethingElse() { diff --git a/mtapi_c/test/embb_mtapi_test_task.h b/mtapi_c/test/embb_mtapi_test_task.h index 3b3e839..19ab8c8 100644 --- a/mtapi_c/test/embb_mtapi_test_task.h +++ b/mtapi_c/test/embb_mtapi_test_task.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_c/test/main.cc b/mtapi_c/test/main.cc index 04e4caf..3e9c5c7 100644 --- a/mtapi_c/test/main.cc +++ b/mtapi_c/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -35,11 +35,13 @@ #include #include #include +#include PT_MAIN("MTAPI C") { embb_log_set_log_level(EMBB_LOG_LEVEL_NONE); PT_RUN(PluginTest); + PT_RUN(ErrorTest); PT_RUN(InitFinalizeTest); PT_RUN(TaskTest); PT_RUN(GroupTest); diff --git a/mtapi_cpp/CMakeLists.txt b/mtapi_cpp/CMakeLists.txt index 301766c..19a6353 100644 --- a/mtapi_cpp/CMakeLists.txt +++ b/mtapi_cpp/CMakeLists.txt @@ -4,6 +4,18 @@ 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") +if (USE_AUTOMATIC_INITIALIZATION STREQUAL ON) + message("-- Automatic initialization enabled (default)") + set(MTAPI_CPP_AUTOMATIC_INITIALIZE 1) +else() + set(MTAPI_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") + # Execute the GroupSources macro include(${CMAKE_SOURCE_DIR}/CMakeCommon/GroupSourcesMSVC.cmake) GroupSourcesMSVC(include) @@ -12,12 +24,12 @@ GroupSourcesMSVC(test) set (EMBB_MTAPI_CPP_INCLUDE_DIRS "include" "src" "test") include_directories(${EMBB_MTAPI_CPP_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/../base_c/include ${CMAKE_CURRENT_BINARY_DIR}/../base_c/include ${CMAKE_CURRENT_SOURCE_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) add_library (embb_mtapi_cpp ${EMBB_MTAPI_CPP_SOURCES} ${EMBB_MTAPI_CPP_HEADERS}) target_link_libraries(embb_mtapi_cpp embb_mtapi_c) @@ -32,4 +44,6 @@ 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) diff --git a/mtapi_cpp/include/embb/mtapi/action.h b/mtapi_cpp/include/embb/mtapi/action.h index 240d323..68e9776 100644 --- a/mtapi_cpp/include/embb/mtapi/action.h +++ b/mtapi_cpp/include/embb/mtapi/action.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -29,7 +29,7 @@ #include #include -#include +#include namespace embb { namespace mtapi { @@ -46,36 +46,36 @@ class Action { */ Action() : function_() - , affinity_() { + , execution_policy_() { // empty } /** - * Constructs an Action from any entity that provides an - * operator() (TaskContext &). + * Constructs an Action from a function object. + * + * \tparam Function Function object */ template Action( - Function func /**< [in] Anything that provides an - operator() (TaskContext &). */ + Function func /**< [in] Function object */ ) : function_(func) - , affinity_() { + , execution_policy_() { // empty } /** - * Constructs an Action from any entity that provides an - * operator() (TaskContext &) and an Affinity. + * Constructs an Action from a function object and an Affinity. + * + * \tparam Function Function object */ template Action( - Function func, /**< [in] Anything that provides an - operator() (TaskContext &). */ - Affinity affinity /**< [in] Core affinity */ + Function func, /**< [in] Function object */ + ExecutionPolicy execution_policy /**< [in] Execution policy */ ) : function_(func) - , affinity_(affinity) { + , execution_policy_(execution_policy) { // empty } @@ -90,17 +90,17 @@ class Action { } /** - * Returns the Affinity specified during creation. - * \return The Affinity of the Action + * Returns the ExecutionPolicy specified during creation. + * \return The ExecutionPolicy of the Action * \waitfree */ - Affinity GetAffinity() const { - return affinity_; + ExecutionPolicy GetExecutionPolicy() const { + return execution_policy_; } private: embb::base::Function function_; - Affinity affinity_; + ExecutionPolicy execution_policy_; }; } // namespace mtapi diff --git a/mtapi_cpp/include/embb/mtapi/affinity.h b/mtapi_cpp/include/embb/mtapi/affinity.h deleted file mode 100644 index 486d51d..0000000 --- a/mtapi_cpp/include/embb/mtapi/affinity.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2014, Siemens AG. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef EMBB_MTAPI_AFFINITY_H_ -#define EMBB_MTAPI_AFFINITY_H_ - -#include - -namespace embb { -namespace mtapi { - -/** - * Describes the Affinity of a Task to worker threads. - * - * \ingroup CPP_MTAPI - */ -class Affinity { - public: - /** - * Constructs an Affinity including all worker threads. - * \memory Calls embb::mtapi::Node::Initialize() which potentially allocates - * \throws ErrorException if the Affinity object could not be constructed. - */ - Affinity(); - - /** - * Constructs an Affinity including all or no worker threads. - * \memory Calls embb::mtapi::Node::Initialize() which potentially allocates - * \throws ErrorException if the Affinity object could not be constructed. - */ - Affinity( - bool initial_affinity /**< [in] Initial affinity - (true = all worker threads, - false = no worker threads) */ - ); - - /** - * Sets Affinity to a specific worker thread. - * \threadsafe - */ - void Add( - mtapi_uint_t worker /**< [in] Worker thread index */ - ); - - /** - * Removes Affinity to a specific worker thread. - * \threadsafe - */ - void Remove( - mtapi_uint_t worker /**< [in] Worker thread index */ - ); - - /** - * Checks if Affinity to a specific worker thread is set. - * \return \c true if \c *this is affine to the given worker, otherwise - * \c false. - * \threadsafe - */ - bool IsSet( - mtapi_uint_t worker /**< [in] Worker thread index */ - ); - - friend class Task; - - private: - mtapi_affinity_t affinity_; -}; - -} // namespace mtapi -} // namespace embb - -#endif // EMBB_MTAPI_AFFINITY_H_ diff --git a/mtapi_cpp/include/embb/mtapi/continuation.h b/mtapi_cpp/include/embb/mtapi/continuation.h index 94b21f2..29789a2 100644 --- a/mtapi_cpp/include/embb/mtapi/continuation.h +++ b/mtapi_cpp/include/embb/mtapi/continuation.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -80,12 +80,12 @@ class Continuation { Task Spawn(); /** - * Runs the Continuation chain with the specified priority. + * Runs the Continuation chain with the specified execution_policy. * \returns The Task representing the Continuation chain. * \notthreadsafe */ Task Spawn( - mtapi_uint_t priority /**< [in] The priority to use */ + ExecutionPolicy execution_policy /**< [in] The execution policy to use */ ); friend class Node; @@ -97,8 +97,6 @@ class Continuation { ContinuationStage * first_; ContinuationStage * last_; - - mtapi_uint_t priority_; }; } // namespace mtapi diff --git a/algorithms_cpp/include/embb/algorithms/execution_policy.h b/mtapi_cpp/include/embb/mtapi/execution_policy.h similarity index 76% rename from algorithms_cpp/include/embb/algorithms/execution_policy.h rename to mtapi_cpp/include/embb/mtapi/execution_policy.h index de68cca..85727f3 100644 --- a/algorithms_cpp/include/embb/algorithms/execution_policy.h +++ b/mtapi_cpp/include/embb/mtapi/execution_policy.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -24,21 +24,24 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EMBB_ALGORITHMS_EXECUTION_POLICY_H_ -#define EMBB_ALGORITHMS_EXECUTION_POLICY_H_ +#ifndef EMBB_MTAPI_EXECUTION_POLICY_H_ +#define EMBB_MTAPI_EXECUTION_POLICY_H_ -#include -#include +#include namespace embb { -namespace algorithms { +namespace mtapi { /** * Describes the execution policy of a parallel algorithm. * The execution policy comprises * - the affinity of tasks to MTAPI worker threads (not CPU cores) and * - the priority of the spawned tasks. * - * \ingroup CPP_ALGORITHMS + * The priority is a number between 0 (denoting the highest priority) to + * max_priorities - 1 as given during initialization using Node::Initialize(). + * The default value of max_priorities is 4. + * + * \ingroup CPP_MTAPI */ class ExecutionPolicy{ public: @@ -53,11 +56,11 @@ class ExecutionPolicy{ * Constructs an execution policy with the specified affinity and priority. */ ExecutionPolicy( - bool initial_affinity, /**< - [IN] \c true sets the affinity to all worker threads, \c false to no - worker threads. */ - mtapi_uint_t priority /**< - [IN] Priority for the execution policy. */ + bool initial_affinity, /**< [in] \c true sets the affinity to + all worker threads, \c false to no + worker threads. */ + mtapi_uint_t priority /**< [in] Priority for the execution + policy. */ ); /** @@ -65,8 +68,8 @@ class ExecutionPolicy{ * Sets the affinity to all worker threads. */ explicit ExecutionPolicy( - mtapi_uint_t priority /**< - [IN] Priority for the execution policy. */ + mtapi_uint_t priority /**< [in] Priority for the execution + policy. */ ); /** @@ -74,25 +77,23 @@ class ExecutionPolicy{ * Sets the priority to the default value. */ explicit ExecutionPolicy( - bool initial_affinity /**< - [IN] \c true sets the affinity to all worker threads, \c false to no - worker threads. */ + bool initial_affinity /**< [in] \c true sets the affinity to + all worker threads, \c false to no + worker threads. */ ); /** * Sets affinity to a specific worker thread. */ void AddWorker( - mtapi_uint_t worker - /**< [IN] Worker thread index */ + mtapi_uint_t worker /**< [in] Worker thread index */ ); /** * Removes affinity to a specific worker thread. */ void RemoveWorker( - mtapi_uint_t worker - /**< [IN] Worker thread index */ + mtapi_uint_t worker /**< [in] Worker thread index */ ); /** @@ -101,16 +102,22 @@ class ExecutionPolicy{ * \return \c true if affinity is set, otherwise \c false */ bool IsSetWorker( - mtapi_uint_t worker - /**< [IN] Worker thread index */ + mtapi_uint_t worker /**< [in] Worker thread index */ ); /** + * Returns the number of cores the policy is affine to. + * + * \return the number of cores + */ + unsigned int GetCoreCount() const; + + /** * Returns the affinity * * \return the affinity */ - const mtapi::Affinity &GetAffinity() const; + const mtapi_affinity_t &GetAffinity() const; /** Returns the priority * @@ -118,6 +125,8 @@ class ExecutionPolicy{ */ mtapi_uint_t GetPriority() const; + friend class Task; + private: /** * Default priority. @@ -129,14 +138,14 @@ class ExecutionPolicy{ * Task Affinity. * Maps the affinity of tasks to MTAPI worker threads (not CPU cores). */ - mtapi::Affinity affinity_; + mtapi_affinity_t affinity_; /** * Task Priority. */ mtapi_uint_t priority_; }; -} // namespace algorithms +} // namespace mtapi } // namespace embb -#endif // EMBB_ALGORITHMS_EXECUTION_POLICY_H_ +#endif // EMBB_MTAPI_EXECUTION_POLICY_H_ diff --git a/mtapi_cpp/include/embb/mtapi/group.h b/mtapi_cpp/include/embb/mtapi/group.h index c2baea8..b3c4906 100644 --- a/mtapi_cpp/include/embb/mtapi/group.h +++ b/mtapi_cpp/include/embb/mtapi/group.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -60,16 +60,6 @@ class Group { ); /** - * Runs an Action within the Group with the specified priority. - * \return A Task identifying the Action to run - * \threadsafe - */ - Task Spawn( - Action action, /**< [in] The Action to run */ - mtapi_uint_t priority /**< [in] The priority to use */ - ); - - /** * Runs an Action within the Group. The \c id is returned by WaitAny(). * \return A Task identifying the Action to run * \throws ErrorException if the Task object could not be constructed. @@ -82,20 +72,6 @@ class Group { ); /** - * Runs an Action within the Group with the specified priority. The \c id is - * returned by WaitAny(). - * \return A Task identifying the Action to run - * \throws ErrorException if the Task object could not be constructed. - * \threadsafe - */ - Task Spawn( - mtapi_task_id_t id, /**< [in] The id to return by - WaitAny() */ - Action action, /**< [in] The Action to run */ - mtapi_uint_t priority /**< [in] The priority to use */ - ); - - /** * Waits for any Task in the Group to finish for \c timeout milliseconds. * \return The status of the Task that finished execution * \threadsafe diff --git a/mtapi_cpp/include/embb/mtapi/internal/cmake_config.h.in b/mtapi_cpp/include/embb/mtapi/internal/cmake_config.h.in new file mode 100644 index 0000000..32af64c --- /dev/null +++ b/mtapi_cpp/include/embb/mtapi/internal/cmake_config.h.in @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_ +#define EMBB_MTAPI_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 + there, the cmake_config.h can be included as usual using + #include + */ + +/** + * Is used to enable automatic initialization of the MTAPI node + */ +#define MTAPI_CPP_AUTOMATIC_INITIALIZE ${MTAPI_CPP_AUTOMATIC_INITIALIZE} + +#endif // EMBB_MTAPI_INTERNAL_CMAKE_CONFIG_H_ diff --git a/mtapi_cpp/include/embb/mtapi/mtapi.h b/mtapi_cpp/include/embb/mtapi/mtapi.h index 68138dd..4c83834 100644 --- a/mtapi_cpp/include/embb/mtapi/mtapi.h +++ b/mtapi_cpp/include/embb/mtapi/mtapi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -35,15 +35,16 @@ * \ingroup CPP */ +#include + #define MTAPI_CPP_TASK_JOB 1 -#define MTAPI_CPP_AUTOMATIC_INITIALIZE 1 #if MTAPI_CPP_AUTOMATIC_INITIALIZE #define MTAPI_CPP_AUTOMATIC_DOMAIN_ID 1 #define MTAPI_CPP_AUTOMATIC_NODE_ID 1 #endif +#include #include -#include #include #include #include diff --git a/mtapi_cpp/include/embb/mtapi/node.h b/mtapi_cpp/include/embb/mtapi/node.h index 8a5102c..a7c5d99 100644 --- a/mtapi_cpp/include/embb/mtapi/node.h +++ b/mtapi_cpp/include/embb/mtapi/node.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -54,7 +54,14 @@ namespace mtapi { class Node { public: /** - * Initializes the runtime singleton using default values. + * Initializes the runtime singleton using default values: + * - all available cores will be used + * - maximum number of tasks is 1024 + * - maximum number of groups is 128 + * - maximum number of queues is 16 + * - maximum queue capacity is 1024 + * - maximum number of priorities is 4. + * * \notthreadsafe * \throws ErrorException if the singleton was already initialized or the * Node could not be initialized. @@ -122,6 +129,15 @@ class Node { } /** + * Returns the number of worker threads. + * \return The number of worker threads. + * \waitfree + */ + mtapi_uint_t GetWorkerThreadCount() const { + return worker_thread_count_; + } + + /** * Creates a Group to launch \link Task Tasks \endlink in. * \return A reference to the created Group * \throws ErrorException if the Group object could not be constructed. @@ -174,17 +190,6 @@ class Node { ); /** - * Runs an Action with the specified priority. - * \return A Task identifying the Action to run - * \throws ErrorException if the Task object could not be constructed. - * \threadsafe - */ - Task Spawn( - Action action, /**< [in] The Action to execute */ - mtapi_uint_t priority /**< [in] The priority to use */ - ); - - /** * Creates a Continuation. * \return A Continuation chain * \threadsafe @@ -214,6 +219,7 @@ class Node { mtapi_task_context_t * context); mtapi_uint_t core_count_; + mtapi_uint_t worker_thread_count_; mtapi_action_hndl_t action_handle_; std::list queues_; std::list groups_; diff --git a/mtapi_cpp/include/embb/mtapi/queue.h b/mtapi_cpp/include/embb/mtapi/queue.h index 5ffd926..4671359 100644 --- a/mtapi_cpp/include/embb/mtapi/queue.h +++ b/mtapi_cpp/include/embb/mtapi/queue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/include/embb/mtapi/task.h b/mtapi_cpp/include/embb/mtapi/task.h index 27badf5..a98e09a 100644 --- a/mtapi_cpp/include/embb/mtapi/task.h +++ b/mtapi_cpp/include/embb/mtapi/task.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -80,38 +80,31 @@ class Task { private: Task( - Action action, - mtapi_uint_t priority - ); + Action action); Task( Action action, - mtapi_group_hndl_t group, - mtapi_uint_t priority); + mtapi_group_hndl_t group); Task( mtapi_task_id_t id, Action action, - mtapi_group_hndl_t group, - mtapi_uint_t priority); + mtapi_group_hndl_t group); Task( Action action, - mtapi_queue_hndl_t queue, - mtapi_uint_t priority); + mtapi_queue_hndl_t queue); Task( Action action, mtapi_queue_hndl_t queue, - mtapi_group_hndl_t group, - mtapi_uint_t priority); + mtapi_group_hndl_t group); Task( mtapi_task_id_t id, Action action, mtapi_queue_hndl_t queue, - mtapi_group_hndl_t group, - mtapi_uint_t priority); + mtapi_group_hndl_t group); mtapi_task_hndl_t handle_; }; diff --git a/mtapi_cpp/include/embb/mtapi/taskcontext.h b/mtapi_cpp/include/embb/mtapi/taskcontext.h index d1aeb0c..955991d 100644 --- a/mtapi_cpp/include/embb/mtapi/taskcontext.h +++ b/mtapi_cpp/include/embb/mtapi/taskcontext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/src/continuation.cc b/mtapi_cpp/src/continuation.cc index 031bd4b..40bbc30 100644 --- a/mtapi_cpp/src/continuation.cc +++ b/mtapi_cpp/src/continuation.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -53,7 +53,7 @@ void Continuation::ExecuteContinuation(TaskContext &) { mtapi::ContinuationStage * stage = first_; mtapi::Node & node = mtapi::Node::GetInstance(); while (NULL != stage) { - mtapi::Task task = node.Spawn(stage->action, priority_); + mtapi::Task task = node.Spawn(stage->action); task.Wait(MTAPI_INFINITE); stage = stage->next; } @@ -79,15 +79,15 @@ Continuation & Continuation::Then(Action action) { } Task Continuation::Spawn() { - return Spawn(0); + return Spawn(ExecutionPolicy()); } -Task Continuation::Spawn(mtapi_uint_t priority) { - priority_ = priority; +Task Continuation::Spawn(ExecutionPolicy execution_policy) { Node & node = Node::GetInstance(); return node.Spawn( - embb::base::MakeFunction(*this, &Continuation::ExecuteContinuation), - priority); + Action( + embb::base::MakeFunction(*this, &Continuation::ExecuteContinuation), + ExecutionPolicy(execution_policy))); } } // namespace mtapi diff --git a/mtapi_cpp/src/continuationstage.h b/mtapi_cpp/src/continuationstage.h index b649b01..1f37607 100644 --- a/mtapi_cpp/src/continuationstage.h +++ b/mtapi_cpp/src/continuationstage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/src/affinity.cc b/mtapi_cpp/src/execution_policy.cc similarity index 67% rename from mtapi_cpp/src/affinity.cc rename to mtapi_cpp/src/execution_policy.cc index 2dddbe4..157d0ac 100644 --- a/mtapi_cpp/src/affinity.cc +++ b/mtapi_cpp/src/execution_policy.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -24,15 +24,17 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include - -#include +#include #include +#include +#include +#include namespace embb { namespace mtapi { -Affinity::Affinity() { +ExecutionPolicy::ExecutionPolicy() : + priority_(DefaultPriority) { #if MTAPI_CPP_AUTOMATIC_INITIALIZE Node::GetInstance(); // MTAPI has to be initialized #endif @@ -44,37 +46,79 @@ Affinity::Affinity() { } } -Affinity::Affinity(bool initial_affinity) { +ExecutionPolicy::ExecutionPolicy(bool initial_affinity, mtapi_uint_t priority) +:priority_(priority) { #if MTAPI_CPP_AUTOMATIC_INITIALIZE Node::GetInstance(); // MTAPI has to be initialized #endif mtapi_status_t status; - mtapi_boolean_t aff = initial_affinity ? MTAPI_TRUE : MTAPI_FALSE; - mtapi_affinity_init(&affinity_, aff, &status); + mtapi_affinity_init(&affinity_, initial_affinity ? MTAPI_TRUE : MTAPI_FALSE, + &status); if (MTAPI_SUCCESS != status) { EMBB_THROW(embb::base::ErrorException, "Could not default construct Affinity."); } } -void Affinity::Add(mtapi_uint_t worker) { +ExecutionPolicy::ExecutionPolicy(mtapi_uint_t priority) +:priority_(priority) { +#if MTAPI_CPP_AUTOMATIC_INITIALIZE + Node::GetInstance(); // MTAPI has to be initialized +#endif + mtapi_status_t status; + mtapi_affinity_init(&affinity_, MTAPI_TRUE, &status); + if (MTAPI_SUCCESS != status) { + EMBB_THROW(embb::base::ErrorException, + "Could not default construct Affinity."); + } +} + +ExecutionPolicy::ExecutionPolicy(bool initial_affinity) +:priority_(DefaultPriority) { +#if MTAPI_CPP_AUTOMATIC_INITIALIZE + Node::GetInstance(); // MTAPI has to be initialized +#endif + mtapi_status_t status; + mtapi_affinity_init(&affinity_, initial_affinity ? MTAPI_TRUE : MTAPI_FALSE, + &status); + if (MTAPI_SUCCESS != status) { + EMBB_THROW(embb::base::ErrorException, + "Could not default construct Affinity."); + } +} + +void ExecutionPolicy::AddWorker(mtapi_uint_t worker) { mtapi_status_t status; mtapi_affinity_set(&affinity_, worker, MTAPI_TRUE, &status); assert(MTAPI_SUCCESS == status); } -void Affinity::Remove(mtapi_uint_t worker) { +void ExecutionPolicy::RemoveWorker(mtapi_uint_t worker) { mtapi_status_t status; mtapi_affinity_set(&affinity_, worker, MTAPI_FALSE, &status); assert(MTAPI_SUCCESS == status); } -bool Affinity::IsSet(mtapi_uint_t worker) { +bool ExecutionPolicy::IsSetWorker(mtapi_uint_t worker) { mtapi_status_t status; mtapi_boolean_t aff = mtapi_affinity_get(&affinity_, worker, &status); assert(MTAPI_SUCCESS == status); return MTAPI_TRUE == aff; } -} // namespace mtapi -} // namespace embb +unsigned int ExecutionPolicy::GetCoreCount() const { + return embb_bitset_count(&affinity_); +} + +const mtapi_affinity_t &ExecutionPolicy::GetAffinity() const { + return affinity_; +} + +mtapi_uint_t ExecutionPolicy::GetPriority() const { + return priority_; +} + +const mtapi_uint_t ExecutionPolicy::DefaultPriority = 0; + +} // namespace mtapi +} // namespace embb diff --git a/mtapi_cpp/src/group.cc b/mtapi_cpp/src/group.cc index adffa76..20dc0b2 100644 --- a/mtapi_cpp/src/group.cc +++ b/mtapi_cpp/src/group.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -53,19 +53,11 @@ void Group::Create() { } Task Group::Spawn(Action action) { - return Spawn(action, 0); -} - -Task Group::Spawn(Action action, mtapi_uint_t priority) { - return Task(action, handle_, priority); + return Task(action, handle_); } Task Group::Spawn(mtapi_task_id_t id, Action action) { - return Spawn(id, action, 0); -} - -Task Group::Spawn(mtapi_task_id_t id, Action action, mtapi_uint_t priority) { - return Task(id, action, handle_, priority); + return Task(id, action, handle_); } mtapi_status_t Group::WaitAny(mtapi_timeout_t timeout) { diff --git a/mtapi_cpp/src/node.cc b/mtapi_cpp/src/node.cc index 772b6c6..0ffe21a 100644 --- a/mtapi_cpp/src/node.cc +++ b/mtapi_cpp/src/node.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -39,7 +39,9 @@ namespace { static embb::mtapi::Node * node_instance = NULL; +#if MTAPI_CPP_AUTOMATIC_INITIALIZE static embb::base::Mutex init_mutex; +#endif } @@ -73,6 +75,7 @@ Node::Node( "mtapi::Node could not initialize mtapi"); } 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, MTAPI_NULL, 0, MTAPI_NULL, &status); if (MTAPI_SUCCESS != status) { @@ -152,7 +155,8 @@ void Node::Initialize( assert(MTAPI_SUCCESS == status); embb_core_set_t cs; embb_core_set_init(&cs, 0); - for (unsigned int ii = 0; ii < core_set.Count(); ii++) { + for (unsigned int ii = 0; embb_core_set_count(&cs) < core_set.Count(); + ii++) { if (core_set.IsContained(ii)) { embb_core_set_add(&cs, ii); } @@ -259,11 +263,7 @@ void Node::DestroyQueue(Queue & queue) { } Task Node::Spawn(Action action) { - return Spawn(action, 0); -} - -Task Node::Spawn(Action action, mtapi_uint_t priority) { - return Task(action, priority); + return Task(action); } Continuation Node::First(Action action) { diff --git a/mtapi_cpp/src/queue.cc b/mtapi_cpp/src/queue.cc index 6012524..a6e8371 100644 --- a/mtapi_cpp/src/queue.cc +++ b/mtapi_cpp/src/queue.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -79,11 +79,11 @@ void Queue::Disable() { } Task Queue::Spawn(Action action) { - return Task(action, handle_, 0); + return Task(action, handle_); } Task Queue::Spawn(Group const * group, Action action) { - return Task(action, handle_, group->handle_, 0); + return Task(action, handle_, group->handle_); } } // namespace mtapi diff --git a/mtapi_cpp/src/task.cc b/mtapi_cpp/src/task.cc index 07321cd..5239a3c 100644 --- a/mtapi_cpp/src/task.cc +++ b/mtapi_cpp/src/task.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -45,18 +45,17 @@ Task::Task(Task const & task) } Task::Task( - Action action, - mtapi_uint_t priority) { + Action action) { mtapi_status_t status; mtapi_task_attributes_t attr; - Affinity affinity = action.GetAffinity(); + ExecutionPolicy policy = action.GetExecutionPolicy(); mtapi_taskattr_init(&attr, &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_PRIORITY, - &priority, sizeof(priority), &status); + &policy.priority_, sizeof(policy.priority_), &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_AFFINITY, - &affinity.affinity_, sizeof(affinity.affinity_), &status); + &policy.affinity_, sizeof(policy.affinity_), &status); assert(MTAPI_SUCCESS == status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status); assert(MTAPI_SUCCESS == status); @@ -73,18 +72,17 @@ Task::Task( Task::Task( Action action, - mtapi_group_hndl_t group, - mtapi_uint_t priority) { + mtapi_group_hndl_t group) { mtapi_status_t status; mtapi_task_attributes_t attr; - Affinity affinity = action.GetAffinity(); + ExecutionPolicy policy = action.GetExecutionPolicy(); mtapi_taskattr_init(&attr, &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_PRIORITY, - &priority, sizeof(priority), &status); + &policy.priority_, sizeof(policy.priority_), &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_AFFINITY, - &affinity.affinity_, sizeof(affinity.affinity_), &status); + &policy.affinity_, sizeof(policy.affinity_), &status); assert(MTAPI_SUCCESS == status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status); assert(MTAPI_SUCCESS == status); @@ -102,18 +100,17 @@ Task::Task( Task::Task( mtapi_task_id_t id, Action action, - mtapi_group_hndl_t group, - mtapi_uint_t priority) { + mtapi_group_hndl_t group) { mtapi_status_t status; mtapi_task_attributes_t attr; - Affinity affinity = action.GetAffinity(); + ExecutionPolicy policy = action.GetExecutionPolicy(); mtapi_taskattr_init(&attr, &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_PRIORITY, - &priority, sizeof(priority), &status); + &policy.priority_, sizeof(policy.priority_), &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_AFFINITY, - &affinity.affinity_, sizeof(affinity.affinity_), &status); + &policy.affinity_, sizeof(policy.affinity_), &status); assert(MTAPI_SUCCESS == status); mtapi_domain_t domain_id = mtapi_domain_id_get(&status); assert(MTAPI_SUCCESS == status); @@ -132,18 +129,17 @@ Task::Task( Task::Task( Action action, - mtapi_queue_hndl_t queue, - mtapi_uint_t priority) { + mtapi_queue_hndl_t queue) { mtapi_status_t status; mtapi_task_attributes_t attr; - Affinity affinity = action.GetAffinity(); + ExecutionPolicy policy = action.GetExecutionPolicy(); mtapi_taskattr_init(&attr, &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_PRIORITY, - &priority, sizeof(priority), &status); + &policy.priority_, sizeof(policy.priority_), &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_AFFINITY, - &affinity.affinity_, sizeof(affinity.affinity_), &status); + &policy.affinity_, sizeof(policy.affinity_), &status); assert(MTAPI_SUCCESS == status); Action* holder = embb::base::Allocation::New(action); handle_ = mtapi_task_enqueue(MTAPI_TASK_ID_NONE, queue, @@ -157,18 +153,17 @@ Task::Task( Task::Task( Action action, mtapi_queue_hndl_t queue, - mtapi_group_hndl_t group, - mtapi_uint_t priority) { + mtapi_group_hndl_t group) { mtapi_status_t status; mtapi_task_attributes_t attr; - Affinity affinity = action.GetAffinity(); + ExecutionPolicy policy = action.GetExecutionPolicy(); mtapi_taskattr_init(&attr, &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_PRIORITY, - &priority, sizeof(priority), &status); + &policy.priority_, sizeof(policy.priority_), &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_AFFINITY, - &affinity.affinity_, sizeof(affinity.affinity_), &status); + &policy.affinity_, sizeof(policy.affinity_), &status); assert(MTAPI_SUCCESS == status); Action* holder = embb::base::Allocation::New(action); handle_ = mtapi_task_enqueue(MTAPI_TASK_ID_NONE, queue, @@ -183,18 +178,17 @@ Task::Task( mtapi_task_id_t id, Action action, mtapi_queue_hndl_t queue, - mtapi_group_hndl_t group, - mtapi_uint_t priority) { + mtapi_group_hndl_t group) { mtapi_status_t status; mtapi_task_attributes_t attr; - Affinity affinity = action.GetAffinity(); + ExecutionPolicy policy = action.GetExecutionPolicy(); mtapi_taskattr_init(&attr, &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_PRIORITY, - &priority, sizeof(priority), &status); + &policy.priority_, sizeof(policy.priority_), &status); assert(MTAPI_SUCCESS == status); mtapi_taskattr_set(&attr, MTAPI_TASK_AFFINITY, - &affinity.affinity_, sizeof(affinity.affinity_), &status); + &policy.affinity_, sizeof(policy.affinity_), &status); assert(MTAPI_SUCCESS == status); Action* holder = embb::base::Allocation::New(action); void * idptr = MTAPI_NULL; diff --git a/mtapi_cpp/src/taskcontext.cc b/mtapi_cpp/src/taskcontext.cc index e3ef4ef..71e28b3 100644 --- a/mtapi_cpp/src/taskcontext.cc +++ b/mtapi_cpp/src/taskcontext.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/main.cc b/mtapi_cpp/test/main.cc index b58e922..f5aa24a 100644 --- a/mtapi_cpp/test/main.cc +++ b/mtapi_cpp/test/main.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/mtapi_cpp_test_config.h b/mtapi_cpp/test/mtapi_cpp_test_config.h index 58b2ad8..4b3c2d7 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_config.h +++ b/mtapi_cpp/test/mtapi_cpp_test_config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/mtapi_cpp_test_group.cc b/mtapi_cpp/test/mtapi_cpp_test_group.cc index 665c7f4..6645dd5 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_group.cc +++ b/mtapi_cpp/test/mtapi_cpp_test_group.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/mtapi_cpp_test_group.h b/mtapi_cpp/test/mtapi_cpp_test_group.h index 7993751..7a1cf2c 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_group.h +++ b/mtapi_cpp/test/mtapi_cpp_test_group.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/mtapi_cpp_test_queue.cc b/mtapi_cpp/test/mtapi_cpp_test_queue.cc index 7948580..b8f7145 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_queue.cc +++ b/mtapi_cpp/test/mtapi_cpp_test_queue.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/mtapi_cpp_test_queue.h b/mtapi_cpp/test/mtapi_cpp_test_queue.h index 7f98a1c..9659ae2 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_queue.h +++ b/mtapi_cpp/test/mtapi_cpp_test_queue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/mtapi_cpp/test/mtapi_cpp_test_task.cc b/mtapi_cpp/test/mtapi_cpp_test_task.cc index 55a72bd..88242b3 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_task.cc +++ b/mtapi_cpp/test/mtapi_cpp_test_task.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -77,6 +77,18 @@ void TaskTest::TestBasic() { embb::mtapi::Node & node = embb::mtapi::Node::GetInstance(); + embb::mtapi::ExecutionPolicy policy(false); + PT_EXPECT_EQ(policy.GetAffinity(), 0u); + PT_EXPECT_EQ(policy.GetPriority(), 0u); + policy.AddWorker(0u); + PT_EXPECT_EQ(policy.GetAffinity(), 1u); + policy.AddWorker(1u); + PT_EXPECT_EQ(policy.GetAffinity(), 3u); + policy.RemoveWorker(0u); + PT_EXPECT_EQ(policy.GetAffinity(), 2u); + PT_EXPECT_EQ(policy.IsSetWorker(0), false); + PT_EXPECT_EQ(policy.IsSetWorker(1), true); + std::string test; embb::mtapi::Task task = node.Spawn( embb::base::Bind( diff --git a/mtapi_cpp/test/mtapi_cpp_test_task.h b/mtapi_cpp/test/mtapi_cpp_test_task.h index 17e8d69..f86b6fe 100644 --- a/mtapi_cpp/test/mtapi_cpp_test_task.h +++ b/mtapi_cpp/test/mtapi_cpp_test_task.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/partest.tar b/partest.tar old mode 100644 new mode 100755 index 5a3f65d..6ec9367 Binary files a/partest.tar and b/partest.tar differ diff --git a/scripts/create_tarball.sh b/scripts/create_tarball.sh index 9172f64..e1bad56 100755 --- a/scripts/create_tarball.sh +++ b/scripts/create_tarball.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/insert_license.sh b/scripts/insert_license.sh index 1f56ba5..3239574 100755 --- a/scripts/insert_license.sh +++ b/scripts/insert_license.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/license.txt b/scripts/license.txt index eb34253..e95756a 100644 --- a/scripts/license.txt +++ b/scripts/license.txt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Siemens AG. All rights reserved. + * Copyright (c) 2014-2015, Siemens AG. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: diff --git a/scripts/license_scripts.txt b/scripts/license_scripts.txt index 8180e7a..f6c8ca4 100644 --- a/scripts/license_scripts.txt +++ b/scripts/license_scripts.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/remove_license.sh b/scripts/remove_license.sh index 289ee86..a01d8d4 100755 --- a/scripts/remove_license.sh +++ b/scripts/remove_license.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/run_cpplint.sh b/scripts/run_cpplint.sh index a60201b..1aabd8a 100755 --- a/scripts/run_cpplint.sh +++ b/scripts/run_cpplint.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/run_tests_cygwin.sh b/scripts/run_tests_cygwin.sh index 2c0eebe..9196879 100755 --- a/scripts/run_tests_cygwin.sh +++ b/scripts/run_tests_cygwin.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/run_tests_unix.sh b/scripts/run_tests_unix.sh index 1af6aeb..cfd8a2d 100755 --- a/scripts/run_tests_unix.sh +++ b/scripts/run_tests_unix.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (c) 2014, Siemens AG. All rights reserved. +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: diff --git a/scripts/run_tests_windows.bat b/scripts/run_tests_windows.bat index 76044f1..69dffb1 100644 --- a/scripts/run_tests_windows.bat +++ b/scripts/run_tests_windows.bat @@ -1,4 +1,4 @@ -:: Copyright (c) 2014, Siemens AG. All rights reserved. +:: Copyright (c) 2014-2015, Siemens AG. All rights reserved. :: :: Redistribution and use in source and binary forms, with or without :: modification, are permitted provided that the following conditions are met: