diff --git a/CMakeLists.txt b/CMakeLists.txt index 7828cff..2ed28cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,15 @@ else() set(PROFILING_FILES "") endif() +if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap/CMakeLists.txt) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap/) + set(PHMAP_ENABLED ON) +endif() + +configure_file(include/blt/config.h.in blt/config.h @ONLY) +# include the config file +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + include_directories(include/) message("Standard Files ${STD_FILES}") @@ -27,3 +36,4 @@ message("Current Source: ${CMAKE_CURRENT_SOURCE_DIR}") add_library(BLT ${STD_FILES} ${PROFILING_FILES}) target_include_directories(BLT PUBLIC include/) +target_link_libraries(BLT phmap) diff --git a/include/blt/config.h.in b/include/blt/config.h.in new file mode 100644 index 0000000..12106e2 --- /dev/null +++ b/include/blt/config.h.in @@ -0,0 +1,12 @@ +/* + * Created by Brett on 27/12/22. + * Licensed under GNU General Public License V3.0 + * See LICENSE file for license detail + */ + +#ifndef CMAKE_CONFIG + +#cmakedefine PHMAP_ENABLED + +#define CMAKE_CONFIG +#endif \ No newline at end of file diff --git a/include/blt/profiling/profiler.h b/include/blt/profiling/profiler.h index 6b32f62..78d2ed1 100644 --- a/include/blt/profiling/profiler.h +++ b/include/blt/profiling/profiler.h @@ -9,7 +9,13 @@ #include #include -#include +#include + +#ifdef PHMAP_ENABLED + #include +#else + #include +#endif namespace BLT { @@ -21,15 +27,20 @@ namespace BLT { CapturePoint start; CapturePoint end; }; +#ifdef PHMAP_ENABLED + typedef phmap::parallel_flat_hash_map INTERVAL_MAP; + typedef phmap::parallel_flat_hash_map POINT_MAP; +#else + typedef std::unordered_map INTERVAL_MAP; + typedef std::unordered_map POINT_MAP; +#endif class Profiler { private: - std::map* intervals; - std::map* points; + INTERVAL_MAP intervals; + POINT_MAP points; public: - Profiler(std::map* test) { - intervals = test; - } + Profiler(); }; }