diff --git a/CMakeCommon/CreateDoxygenDocumentationTarget.cmake b/CMakeCommon/CreateDoxygenDocumentationTarget.cmake index c3c759d..dedac2e 100644 --- a/CMakeCommon/CreateDoxygenDocumentationTarget.cmake +++ b/CMakeCommon/CreateDoxygenDocumentationTarget.cmake @@ -39,7 +39,12 @@ function (CreateDoxygenDocumentationTarget) #-- Add a custom target to run Doxygen when ever the project is built if (TARGET doxygen) # Do nothing, since the repeated adding causes an error - else() + else() + set(DOXYGEN_TEMPLATE_FILES + "doc/reference/header.html") + + file(COPY ${DOXYGEN_TEMPLATE_FILES} DESTINATION ${PROJECT_BINARY_DIR}) + add_custom_target ( doxygen #ALL diff --git a/CMakeCommon/SetInstallPaths.cmake b/CMakeCommon/SetInstallPaths.cmake index af791ff..7d39e20 100644 --- a/CMakeCommon/SetInstallPaths.cmake +++ b/CMakeCommon/SetInstallPaths.cmake @@ -33,7 +33,7 @@ function(SetInstallPaths) # Default install path is in build directory. if (DEFINED UNIX) set(CMAKE_INSTALL_PREFIX "/usr/local") - set(INSTALL_PREFIX_DOCS "/usr/local/share/doc/${CMAKE_PROJECT_NAME}-${EMBB_BASE_VERSION_MAJOR}.${EMBB_BASE_VERSION_MINOR}") + set(INSTALL_PREFIX_DOCS "/usr/local/share/doc/${CMAKE_PROJECT_NAME}-${EMBB_BASE_VERSION_MAJOR}.${EMBB_BASE_VERSION_MINOR}.${EMBB_BASE_VERSION_PATCH}") else() file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _PROG_FILES) # 32-bit dir on win32, useless to us on win64 file(TO_CMAKE_PATH "$ENV{ProgramFiles(x86)}" _PROG_FILES_X86) # 32-bit dir: only set on win64 diff --git a/CMakeLists.txt b/CMakeLists.txt index e68d998..aec5757 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,8 +135,11 @@ SetInstallPaths() ## DOXYGEN # -include(CMakeCommon/CreateDoxygenDocumentationTarget.cmake) -CreateDoxygenDocumentationTarget() +if(EXISTS "${EMBB_SOURCE_DIR}/doc/reference/Doxyfile.in") + include(CMakeCommon/CreateDoxygenDocumentationTarget.cmake) + CreateDoxygenDocumentationTarget() +endif() + if (INSTALL_DOCS STREQUAL ON) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/ diff --git a/README.txt b/README.md similarity index 100% rename from README.txt rename to README.md index e2ddc8b..e1a7392 100644 --- a/README.txt +++ b/README.md @@ -134,7 +134,7 @@ Choose an appropriate build file generator for your system. A list of all available generators can be displayed by typing "cmake" without any options. The build files can be generated using the following command: - cmake -G .. [OPTIONS] + cmake -G .. [OPTIONS] Note that on Linux, the architecture (32/64 bit) cannot be selected by the generator. However, the build mode (Release/Debug) can be specified using the @@ -156,11 +156,11 @@ Now you can generate the build files as shown by the following examples. For a Linux Debug build with exception handling, type - cmake -G "Unix Makefiles" .. -DCMAKE_BUILD_TYPE=Debug + cmake -G "Unix Makefiles" .. -DCMAKE_BUILD_TYPE=Debug For a Windows build (VS 2013, x86) without exception handling, type - cmake -G "Visual Studio 12" .. -DUSE_EXCEPTIONS=OFF + cmake -G "Visual Studio 12" .. -DUSE_EXCEPTIONS=OFF Note that "Visual Studio 12" refers to the version number of Visual Studio and not to the year in which it was released (2013). @@ -174,11 +174,11 @@ whereas on Windows, it has to be specified now. For a Linux build, type - cmake --build . + cmake --build . For a Windows Release build, type - cmake --build . --config Release + cmake --build . --config Release 3. Running the tests -------------------- @@ -188,11 +188,11 @@ executables are contained in the subfolder "binaries". On Linux, type - binaries/run_tests.sh + binaries/run_tests.sh On Windows, type - binaries\run_tests.bat + binaries\run_tests.bat If no error message occurs, EMBB is working fine. @@ -201,23 +201,23 @@ If no error message occurs, EMBB is working fine. The default installation path on Linux is - /usr/local/ + /usr/local/ and on Windows - C:\Program Files\embb-X.Y.Z\ or C:\Program Files (x86)\embb-X.Y.Z + C:\Program Files\embb-X.Y.Z\ or C:\Program Files (x86)\embb-X.Y.Z depending on the target architecture. If you want a different installation path, you can change it now by typing - cmake -DINSTALL_PREFIX=YourCustomPath .. + cmake -DINSTALL_PREFIX=YourCustomPath .. The option "-DINSTALL_PREFIX=YourCustomPath" can also be given in Step 1. To install the files, use the command - cmake --build . --target install + cmake --build . --target install which copies the contents of the "install" folder to the "bin", "lib", and "include" folders in the installation path. For the default paths, the @@ -237,27 +237,27 @@ If you want to use the C++ functionalities of EMBB, you have to link the following libraries (names will be different on Windows and on Linux) in the given order: - embb_base, embb_base_cpp, embb_mtapi_c, embb_mtapi_cpp, embb_containers_cpp, - embb_algorithms_cpp, embb_dataflow_cpp + embb_base, embb_base_cpp, embb_mtapi_c, embb_mtapi_cpp, embb_containers_cpp, + embb_algorithms_cpp, embb_dataflow_cpp The C++ header files can be included as follows: - #include - #include - #include - #include + #include + #include + #include + #include 2. Using C ---------- The following libraries have to be linked in the given order: - embb_base_c, mtapi_c + embb_base_c, mtapi_c The C header files can be included as follows: - #include or #include - #include + #include or #include + #include Documentation diff --git a/base_c/src/core_set.c b/base_c/src/core_set.c index d2e2e2e..81e419a 100644 --- a/base_c/src/core_set.c +++ b/base_c/src/core_set.c @@ -94,12 +94,22 @@ void embb_core_set_init(embb_core_set_t* core_set, int initializer) { #ifdef EMBB_HAS_HEADER_SYSINFO #include #endif +#ifdef __FreeBSD__ +#include +#include +#endif unsigned int embb_core_count_available() { #ifdef EMBB_HAS_HEADER_SYSINFO return get_nprocs(); +#elif defined __FreeBSD__ + const size_t bs = sizeof(unsigned int); + char buf[bs]; + size_t len = bs; + sysctlbyname("hw.ncpu", buf, &len, NULL, 0); + return *(unsigned int*)&buf; #else -#error "No header sysinfo available!" +#error "No implementation for embb_core_count_available()!" #endif } diff --git a/base_c/src/memory_allocation.c b/base_c/src/memory_allocation.c index 4e2e878..c6f8bfc 100644 --- a/base_c/src/memory_allocation.c +++ b/base_c/src/memory_allocation.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #ifdef EMBB_DEBUG 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 2877554..6d72bf2 100644 --- a/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h +++ b/containers_cpp/include/embb/containers/internal/hazard_pointer-inl.h @@ -144,9 +144,18 @@ template< typename GuardType > HazardPointerThreadEntry:: HazardPointerThreadEntry(GuardType undefined_guard, int guards_per_thread, size_t max_size_retired_list) : +#ifdef EMBB_DEBUG + who_is_scanning(-1), +#endif undefined_guard(undefined_guard), guards_per_thread(guards_per_thread), max_size_retired_list(max_size_retired_list), + // initially, each potential thread is active... if that is not the case + // another thread could call "HelpScan", and block this thread in making + // progress. + // Still, threads can be leave the hazard pointer processing (deactivation), + // but this can only be done once, i.e., this is not revertable... + is_active(1), retired_list(max_size_retired_list), retired_list_temp(max_size_retired_list), hazard_pointer_list_temp(embb::base::Thread::GetThreadsMaxCount() * @@ -190,7 +199,7 @@ GuardPointer(int guardNumber, GuardType pointerToGuard) { template< typename GuardType > void HazardPointerThreadEntry::SetActive(bool active) { if (active == true) - is_active = 1; + is_active = 1; else is_active = 0; } @@ -231,16 +240,6 @@ HazardPointer< GuardType >::GetHazardPointerElementForCurrentThread() { // stop operating, and the others are responsible for his retired // list. - // int expected = false; - HazardPointerThreadEntry_t* current_thread_entry = - &hazard_pointer_thread_entry_array[GetCurrentThreadIndex()]; - - // If not active, activate it - if (!current_thread_entry->IsActive()) { - current_thread_entry->SetActive(true); - active_hazard_pointer++; - } - return hazard_pointer_thread_entry_array[GetCurrentThreadIndex()]; } @@ -270,6 +269,16 @@ void HazardPointer< GuardType >::HelpScan() { template< typename GuardType > void HazardPointer< GuardType >:: Scan(HazardPointerThreadEntry_t* currentHazardPointerEntry) { +#ifdef EMBB_DEBUG + // scan should only be executed by one thread at a time, otherwise we have + // a bug... this assertions checks that + int expected = -1; + if (!currentHazardPointerEntry->GetScanningThread().CompareAndSwap( + expected, GetCurrentThreadIndex())) + { + assert(false); + } +#endif // In this function, we compute the intersection between local retired // pointers and all hazard pointers. This intersection cannot be deleted and // forms the new local retired pointers list. @@ -320,6 +329,10 @@ Scan(HazardPointerThreadEntry_t* currentHazardPointerEntry) { } currentHazardPointerEntry->SetRetired( currentHazardPointerEntry->GetRetiredTemp()); + +#ifdef EMBB_DEBUG + currentHazardPointerEntry->GetScanningThread().Store(-1); +#endif } template< typename GuardType > @@ -335,7 +348,8 @@ HazardPointer< GuardType >::HazardPointer( GuardType undefined_guard, int guards_per_thread) : undefined_guard(undefined_guard), guards_per_thread(guards_per_thread), - active_hazard_pointer(0), + //initially, all potential hazard pointers are active... + active_hazard_pointer(embb::base::Thread::GetThreadsMaxCount()), free_guard_callback(free_guard_callback) { hazard_pointers = embb::base::Thread::GetThreadsMaxCount(); @@ -388,6 +402,7 @@ void HazardPointer< GuardType >::EnqueuePointerForDeletion( if (IsThresholdExceeded()) { HazardPointerThreadEntry_t* currentHazardPointerEntry = &GetHazardPointerElementForCurrentThread(); + Scan(currentHazardPointerEntry); // Help deactivated threads to clean their retired nodes. diff --git a/containers_cpp/include/embb/containers/internal/hazard_pointer.h b/containers_cpp/include/embb/containers/internal/hazard_pointer.h index 1d3ded3..9a63823 100644 --- a/containers_cpp/include/embb/containers/internal/hazard_pointer.h +++ b/containers_cpp/include/embb/containers/internal/hazard_pointer.h @@ -169,7 +169,17 @@ class FixedSizeList { */ template< typename GuardType > class HazardPointerThreadEntry { - private: + +#ifdef EMBB_DEBUG + public: + embb::base::Atomic& GetScanningThread() + { + return who_is_scanning; + } + private: + embb::base::Atomic who_is_scanning; +#endif + private: /** * Value of the undefined guard (means that no guard is set). */ diff --git a/dataflow_cpp/include/embb/dataflow/internal/select.h b/dataflow_cpp/include/embb/dataflow/internal/select.h index e2c03c0..7744ca1 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/select.h +++ b/dataflow_cpp/include/embb/dataflow/internal/select.h @@ -27,6 +27,7 @@ #ifndef EMBB_DATAFLOW_INTERNAL_SELECT_H_ #define EMBB_DATAFLOW_INTERNAL_SELECT_H_ +#include #include #include #include diff --git a/dataflow_cpp/include/embb/dataflow/internal/switch.h b/dataflow_cpp/include/embb/dataflow/internal/switch.h index 6cd2df2..242e357 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/switch.h +++ b/dataflow_cpp/include/embb/dataflow/internal/switch.h @@ -27,6 +27,7 @@ #ifndef EMBB_DATAFLOW_INTERNAL_SWITCH_H_ #define EMBB_DATAFLOW_INTERNAL_SWITCH_H_ +#include #include #include #include diff --git a/doc/reference/Doxyfile.in b/doc/reference/Doxyfile.in index 9dd6791..8f6ce37 100644 --- a/doc/reference/Doxyfile.in +++ b/doc/reference/Doxyfile.in @@ -205,7 +205,7 @@ IGNORE_PREFIX = cm GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html -HTML_HEADER = +HTML_HEADER = header.html HTML_FOOTER = HTML_STYLESHEET = HTML_EXTRA_STYLESHEET = @CMAKE_SOURCE_DIR@/doc/reference/DoxygenHTMLStyle.css diff --git a/doc/reference/header.html b/doc/reference/header.html new file mode 100755 index 0000000..c212a3f --- /dev/null +++ b/doc/reference/header.html @@ -0,0 +1,59 @@ + + + + + + + +$projectname: $title +$title + + + + +$treeview +$search +$mathjax + +$extrastylesheet + + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + +
+
$projectname +  $projectnumber +
+
$projectbrief
+
+
$projectbrief
+
$searchbox
+
+ + diff --git a/mtapi_c/src/embb_mtapi_id_pool_t.c b/mtapi_c/src/embb_mtapi_id_pool_t.c index 9ee047d..87dca32 100644 --- a/mtapi_c/src/embb_mtapi_id_pool_t.c +++ b/mtapi_c/src/embb_mtapi_id_pool_t.c @@ -42,7 +42,7 @@ void embb_mtapi_id_pool_initialize( for (ii = 1; ii < capacity; ii++) { that->id_buffer[ii] = ii; } - that->ids_availabe = capacity - 1; + that->ids_available = capacity - 1; that->put_id_position = 0; that->get_id_position = 1; embb_mtapi_spinlock_initialize(&that->lock); @@ -50,7 +50,7 @@ void embb_mtapi_id_pool_initialize( void embb_mtapi_id_pool_finalize(embb_mtapi_id_pool_t * that) { that->capacity = 0; - that->ids_availabe = 0; + that->ids_available = 0; that->get_id_position = 0; that->put_id_position = 0; embb_mtapi_alloc_deallocate(that->id_buffer); @@ -64,9 +64,9 @@ mtapi_uint_t embb_mtapi_id_pool_allocate(embb_mtapi_id_pool_t * that) { assert(MTAPI_NULL != that); if (embb_mtapi_spinlock_acquire(&that->lock)) { - if (0 < that->ids_availabe) { + if (0 < that->ids_available) { /* take away one id */ - that->ids_availabe--; + that->ids_available--; /* acquire position to fetch id from */ mtapi_uint_t id_position = that->get_id_position; @@ -93,7 +93,7 @@ void embb_mtapi_id_pool_deallocate( assert(MTAPI_NULL != that); if (embb_mtapi_spinlock_acquire(&that->lock)) { - if (that->capacity > that->ids_availabe) { + if (that->capacity > that->ids_available) { /* acquire position to put id to */ mtapi_uint_t id_position = that->put_id_position; that->put_id_position++; @@ -105,7 +105,7 @@ void embb_mtapi_id_pool_deallocate( that->id_buffer[id_position] = id; /* make it available */ - that->ids_availabe++; + that->ids_available++; } embb_mtapi_spinlock_release(&that->lock); } else { diff --git a/mtapi_c/src/embb_mtapi_id_pool_t.h b/mtapi_c/src/embb_mtapi_id_pool_t.h index 71a5e87..ec1bd7b 100644 --- a/mtapi_c/src/embb_mtapi_id_pool_t.h +++ b/mtapi_c/src/embb_mtapi_id_pool_t.h @@ -48,7 +48,7 @@ extern "C" { struct embb_mtapi_id_pool_struct { mtapi_uint_t capacity; mtapi_uint_t *id_buffer; - mtapi_uint_t ids_availabe; + mtapi_uint_t ids_available; mtapi_uint_t get_id_position; mtapi_uint_t put_id_position; embb_mtapi_spinlock_t lock; diff --git a/scripts/create_tarball.sh b/scripts/create_tarball.sh old mode 100644 new mode 100755 index ceef8e5..2d0fedc --- a/scripts/create_tarball.sh +++ b/scripts/create_tarball.sh @@ -140,6 +140,11 @@ rsync \ --exclude "doc/tutorial/content" \ --exclude "doc/tutorial/*.tex" \ --exclude "doc/tutorial/*.bib" \ + --exclude "doc/reference/*.xml" \ + --exclude "doc/reference/*.dox" \ + --exclude "doc/reference/*.in" \ + --exclude "doc/reference/header.html" \ + --exclude "doc/reference/*.css" \ --exclude "doc/examples/insert_snippets.py" \ --archive --recursive ${d} $MYTMPDIR/${n} diff --git a/scripts/insert_license.sh b/scripts/insert_license.sh old mode 100644 new mode 100755 diff --git a/scripts/remove_license.sh b/scripts/remove_license.sh old mode 100644 new mode 100755 diff --git a/scripts/run_cpplint.sh b/scripts/run_cpplint.sh old mode 100644 new mode 100755 diff --git a/scripts/run_tests_cygwin.sh b/scripts/run_tests_cygwin.sh old mode 100644 new mode 100755 diff --git a/scripts/run_tests_linux.sh b/scripts/run_tests_linux.sh old mode 100644 new mode 100755