diff --git a/VERSION b/VERSION index 5c7feaa80..580ab568f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.1.rc12 +3.2.1.rc14 diff --git a/cmake/Modules/ClangFormat.cmake b/cmake/Modules/ClangFormat.cmake index ef9d6a385..633dcb492 100644 --- a/cmake/Modules/ClangFormat.cmake +++ b/cmake/Modules/ClangFormat.cmake @@ -113,14 +113,18 @@ if(CLANG_FORMATTER) COMMAND ${CLANG_FORMATTER} -i ${examples}) endif() + set(_MSG "'${CLANG_FORMATTER}'") if(BLACK_FORMATTER) set(_COMMAND ${_COMMAND} COMMAND ${BLACK_FORMATTER} -q ${PROJECT_SOURCE_DIR}) + set(_MSG "${_MSG} and '${BLACK_FORMATTER}'") endif() add_custom_target(${FORMAT_NAME} ${_COMMAND} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMENT "[${PROJECT_NAME}] Running '${CLANG_FORMATTER}'..." + COMMENT "[${PROJECT_NAME}] Running ${_MSG}..." SOURCES ${headers} ${sources} ${examples}) + + unset(_MSG) endif() diff --git a/cmake/Modules/Options.cmake b/cmake/Modules/Options.cmake index ca726c0ad..7151786b9 100644 --- a/cmake/Modules/Options.cmake +++ b/cmake/Modules/Options.cmake @@ -87,8 +87,16 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") set(_BUILD_OPT ON) endif() -if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND - (TIMEMORY_BUILD_TESTING OR TIMEMORY_BUILD_MINIMAL_TESTING OR TIMEMORY_CI)) +if(TIMEMORY_BUILD_TESTING) + set(TIMEMORY_BUILD_EXAMPLES ON) +endif() + +if(TIMEMORY_BUILD_MINIMAL_TESTING) + set(TIMEMORY_BUILD_TESTING ON) + set(TIMEMORY_BUILD_EXAMPLES OFF) +endif() + +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND TIMEMORY_CI) set(_USE_COVERAGE ON) endif() diff --git a/cmake/Modules/ProjectSetup.cmake b/cmake/Modules/ProjectSetup.cmake index 3d0f12e8d..10ed67e32 100644 --- a/cmake/Modules/ProjectSetup.cmake +++ b/cmake/Modules/ProjectSetup.cmake @@ -35,12 +35,8 @@ endif() # override any cache settings if(TIMEMORY_BUILD_TESTING) set(TIMEMORY_BUILD_GOOGLE_TEST ON) - if(NOT TIMEMORY_BUILD_MINIMAL_TESTING) - set(TIMEMORY_BUILD_EXAMPLES ON) - endif() -else() + set(TIMEMORY_BUILD_EXAMPLES ON) if(TIMEMORY_BUILD_MINIMAL_TESTING) - set(TIMEMORY_BUILD_GOOGLE_TEST ON) set(TIMEMORY_BUILD_EXAMPLES OFF) endif() endif() diff --git a/pyctest-runner.py b/pyctest-runner.py index 1a1906dc0..7855637f4 100755 --- a/pyctest-runner.py +++ b/pyctest-runner.py @@ -1186,7 +1186,9 @@ def add_timem_test(name, cmd): }, ) - if len(args.tools) > 0: + if len(args.tools) > 0 and not ( + len(args.tools) == 1 and args.tools[0] == "avail" + ): pyct.test( "timemory-python-timem", [ diff --git a/setup.py b/setup.py index b8cfafe2e..65f3db1a7 100644 --- a/setup.py +++ b/setup.py @@ -21,6 +21,14 @@ parser = argparse.ArgumentParser(add_help=False) parser.add_argument("-h", "--help", help="Print help", action="store_true") +# support CMAKE_ARGS environment variables because +# --install-option for pip is a pain to use +env_cmake_args = os.environ.get("CMAKE_ARGS", None) +if env_cmake_args is not None: + for _arg in env_cmake_args.split(" "): + if "CMAKE_INSTALL_PREFIX" not in _arg: + cmake_args += [_arg] + gotcha_opt = False if platform.system() == "Linux": gotcha_opt = True @@ -293,9 +301,9 @@ def _add_cmake_bool_option(_args): cmake_args += ["-DCMAKE_OSX_DEPLOYMENT_TARGET={}".format(version)] # DO THIS LAST! -# support PYKOKKOS_BASE_SETUP_ARGS environment variables because +# support TIMEMORY_SETUP_ARGS environment variables because # --install-option for pip is a pain to use -# TIMEMORY_SETUP_ARGS should be space-delimited set of cmake arguments, e.g.: +# Env variables should be space-delimited set of cmake arguments, e.g.: # export TIMEMORY_SETUP_ARGS="-DTIMEMORY_USE_MPI=ON -DTIMEMORY_USE_OMPT=OFF" env_cmake_args = os.environ.get("TIMEMORY_SETUP_ARGS", None) if env_cmake_args is not None: diff --git a/source/tests/cache_tests.cpp b/source/tests/cache_tests.cpp index b84ca3678..51cfcf8c2 100644 --- a/source/tests/cache_tests.cpp +++ b/source/tests/cache_tests.cpp @@ -217,6 +217,9 @@ class cache_tests : public ::testing::Test trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); + trait::runtime_enabled::set(false); trait::runtime_enabled::set(false); } diff --git a/source/tests/component_bundle_tests.cpp b/source/tests/component_bundle_tests.cpp index bc2d2cda3..30a468373 100644 --- a/source/tests/component_bundle_tests.cpp +++ b/source/tests/component_bundle_tests.cpp @@ -267,8 +267,8 @@ TEST_F(component_bundle_tests, get) EXPECT_NEAR(std::get<0>(cb), 2.0, 0.1); EXPECT_NEAR(std::get<0>(ab), 2.0, 0.1); - EXPECT_NEAR(std::get<1>(cb) + std::get<2>(cb), 1.0, 0.1); - EXPECT_NEAR(std::get<1>(ab), 1.0, 0.1); + EXPECT_NEAR(std::get<1>(cb) + std::get<2>(cb), 1.0, 0.15); + EXPECT_NEAR(std::get<1>(ab), 1.0, 0.15); } //--------------------------------------------------------------------------------------// diff --git a/source/tests/hybrid_tests.cpp b/source/tests/hybrid_tests.cpp index c6011a144..e11b21359 100644 --- a/source/tests/hybrid_tests.cpp +++ b/source/tests/hybrid_tests.cpp @@ -64,7 +64,7 @@ static const auto memory_unit = std::pair(tim::units::KiB, // acceptable absolute error static const double util_tolerance = 5.0; -static const double timer_tolerance = 0.075; +static const double timer_tolerance = 0.1; // acceptable relative error // static const double util_epsilon = 0.5; @@ -100,7 +100,7 @@ get_test_name() } // this function consumes approximately "n" milliseconds of real time -inline void +TIMEMORY_FLATTEN void do_sleep(long n) { std::this_thread::sleep_for(std::chrono::milliseconds(n)); @@ -114,7 +114,7 @@ fibonacci(long n) } // this function consumes approximately "t" milliseconds of cpu time -inline void +TIMEMORY_FLATTEN void consume(long n) { // a mutex held by one lock @@ -252,8 +252,8 @@ TEST_F(hybrid_tests, hybrid) ASSERT_TRUE(t_util != nullptr) << obj; EXPECT_NEAR(2.0, t_rc->get(), timer_tolerance) << obj; - EXPECT_NEAR(2.5, t_cpu->get(), timer_tolerance) << obj; - EXPECT_NEAR(125.0, t_util->get(), util_tolerance) << obj; + EXPECT_NEAR(2.5, t_cpu->get(), 2.0 * timer_tolerance) << obj; + EXPECT_NEAR(125.0, t_util->get(), 2.0 * util_tolerance) << obj; auto* l_rc = obj.get(); auto* l_cpu = obj.get(); @@ -301,8 +301,8 @@ TEST_F(hybrid_tests, auto_timer) details::print_info(_util, 125.0, "%", cpu_util_convert); ASSERT_NEAR(1.0, _rc.get(), timer_tolerance); - ASSERT_NEAR(1.25, _cpu.get(), timer_tolerance); - ASSERT_NEAR(125.0, _util.get(), util_tolerance); + ASSERT_NEAR(1.25, _cpu.get(), 2.0 * timer_tolerance); + ASSERT_NEAR(125.0, _util.get(), 2.0 * util_tolerance); cpu_clock _cpu_obj = *obj.get(); double _cpu_val = obj.get()->get(); @@ -335,7 +335,7 @@ TEST_F(hybrid_tests, compose) details::print_info(_cpu_obj, 0.75, "sec"); - ASSERT_NEAR(0.75, _cpu_val, timer_tolerance); + ASSERT_NEAR(0.75, _cpu_val, 2.0 * timer_tolerance); ASSERT_NEAR(_cpu_obj.get(), _cpu_val, compose_tolerance); ASSERT_NEAR(_cpu_val, std::get<0>(_cpu_ret) + std::get<1>(_cpu_ret), compose_tolerance); diff --git a/source/timemory/storage/graph.hpp b/source/timemory/storage/graph.hpp index 8df24ee21..ddb083a79 100644 --- a/source/timemory/storage/graph.hpp +++ b/source/timemory/storage/graph.hpp @@ -759,9 +759,12 @@ class graph } private: - AllocatorT m_alloc; inline void m_head_initialize(); inline void m_copy(const graph& other); + +private: + using allocator_traits = std::allocator_traits; + AllocatorT m_alloc{}; }; //======================================================================================// @@ -816,10 +819,10 @@ template graph::~graph() { clear(); - m_alloc.destroy(head); - m_alloc.destroy(feet); - m_alloc.deallocate(head, 1); - m_alloc.deallocate(feet, 1); + allocator_traits::destroy(m_alloc, head); + allocator_traits::destroy(m_alloc, feet); + allocator_traits::deallocate(m_alloc, head, 1); + allocator_traits::deallocate(m_alloc, feet, 1); } //--------------------------------------------------------------------------------------// @@ -828,10 +831,11 @@ template void graph::m_head_initialize() { - head = m_alloc.allocate(1, nullptr); // MSVC does not have default second argument - feet = m_alloc.allocate(1, nullptr); - m_alloc.construct(head, std::move(tgraph_node{})); - m_alloc.construct(feet, std::move(tgraph_node{})); + head = allocator_traits::allocate( + m_alloc, 1, nullptr); // MSVC does not have default second argument + feet = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, head, std::move(tgraph_node{})); + allocator_traits::construct(m_alloc, feet, std::move(tgraph_node{})); head->parent = nullptr; head->first_child = nullptr; @@ -880,7 +884,7 @@ graph::operator=(graph&& x) noexcept template graph::graph(const graph& other) { - // m_alloc.reserve(2 + other.size()); + // allocator_traits::reserve(2 + other.size()); m_head_initialize(); m_copy(other); } @@ -980,8 +984,8 @@ graph::erase(IterT it) cur->next_sibling->prev_sibling = cur->prev_sibling; } - m_alloc.destroy(cur); - m_alloc.deallocate(cur, 1); + allocator_traits::destroy(m_alloc, cur); + allocator_traits::deallocate(m_alloc, cur, 1); it.node = nullptr; return ret; } @@ -1077,8 +1081,8 @@ graph::append_child(IterT position) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::move(tgraph_node{})); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::move(tgraph_node{})); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1108,8 +1112,8 @@ graph::prepend_child(IterT position) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::move(tgraph_node{})); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::move(tgraph_node{})); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1143,8 +1147,8 @@ graph::append_child(IterT position, const T& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1174,10 +1178,8 @@ graph::append_child(IterT position, T&& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // m_alloc.construct(tmp); // Here is where the move semantics kick in - // std::swap(tmp->data, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1208,8 +1210,8 @@ graph::prepend_child(IterT position, const T& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1239,11 +1241,8 @@ graph::prepend_child(IterT position, T&& x) assert(position.node != feet); assert(position.node); - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // std::swap(tmp->data, std::forward(x)); - // auto _x = std::move(x); - // std::swap(tmp->data, _x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1274,7 +1273,7 @@ graph::append_child(IterT position, IterT other) assert(position.node != feet); assert(position.node); - IterT aargh = append_child(position, value_type()); + IterT aargh = append_child(position, value_type{}); return move_ontop(aargh, other); } @@ -1289,7 +1288,7 @@ graph::prepend_child(IterT position, IterT other) assert(position.node != feet); assert(position.node); - IterT aargh = prepend_child(position, value_type()); + IterT aargh = prepend_child(position, value_type{}); return move_ontop(aargh, other); } @@ -1374,8 +1373,8 @@ graph::insert(IterT position, const T& x) } assert(position.node != head); // Cannot insert before head. - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1406,9 +1405,9 @@ graph::insert(IterT position, T&& x) position.node = feet; // Backward compatibility: when calling insert on // a null node, insert before the feet. } - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // std::swap(tmp->data, x); // Move semantics + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); + tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1433,8 +1432,8 @@ template typename graph::sibling_iterator graph::insert(sibling_iterator position, const T& x) { - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1469,8 +1468,8 @@ template IterT graph::insert_after(IterT position, const T& x) { - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, x); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, x); tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1498,9 +1497,9 @@ template IterT graph::insert_after(IterT position, T&& x) { - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, std::forward(x)); - // std::swap(tmp->data, x); // move semantics + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, std::forward(x)); + tmp->first_child = nullptr; tmp->last_child = nullptr; @@ -1529,7 +1528,7 @@ IterT graph::insert_subgraph(IterT position, const iterator_base& _subgraph) { // insert dummy - IterT it = insert(position, value_type()); + IterT it = insert(position, value_type{}); // replace dummy with subgraph return replace(it, _subgraph); } @@ -1556,7 +1555,7 @@ graph::insert_subgraph_after(IterT position, // position, IterT subgraph) // { // // insert dummy -// IterT it(insert(position, value_type())); +// IterT it(insert(position, value_type{})); // // replace dummy with subgraph // return replace(it, subgraph); // } @@ -1568,8 +1567,8 @@ template IterT graph::replace(IterT position, const T& x) { - m_alloc.destroy(position.node); - m_alloc.construct(position.node, x); + allocator_traits::destroy(m_alloc, position.node); + allocator_traits::construct(m_alloc, position.node, x); return position; } @@ -1580,8 +1579,8 @@ template IterT graph::replace(IterT position, T&& x) { - m_alloc.destroy(position.node); - m_alloc.construct(position.node, std::forward(x)); + allocator_traits::destroy(m_alloc, position.node); + allocator_traits::construct(m_alloc, position.node, std::forward(x)); return position; } @@ -1601,8 +1600,8 @@ graph::replace(IterT position, const iterator_base& from) // std::cout << "warning!" << position.node << std::endl; erase_children(position); // std::cout << "no warning!" << std::endl; - graph_node* tmp = m_alloc.allocate(1, nullptr); - m_alloc.construct(tmp, (*from)); + graph_node* tmp = allocator_traits::allocate(m_alloc, 1, nullptr); + allocator_traits::construct(m_alloc, tmp, (*from)); tmp->first_child = nullptr; tmp->last_child = nullptr; if(current_to->prev_sibling == nullptr) @@ -1626,8 +1625,8 @@ graph::replace(IterT position, const iterator_base& from) } tmp->next_sibling = current_to->next_sibling; tmp->parent = current_to->parent; - m_alloc.destroy(current_to); - m_alloc.deallocate(current_to, 1); + allocator_traits::destroy(m_alloc, current_to); + allocator_traits::deallocate(m_alloc, current_to, 1); current_to = tmp; // only at this stage can we fix 'last' diff --git a/source/tools/timemory-timem/CMakeLists.txt b/source/tools/timemory-timem/CMakeLists.txt index b8ef82024..745547011 100644 --- a/source/tools/timemory-timem/CMakeLists.txt +++ b/source/tools/timemory-timem/CMakeLists.txt @@ -70,7 +70,7 @@ if(NOT DEFINED TIMEM_PAPI_TARGET OR NOT TIMEM_PAPI_TARGET) endif() endif() -add_library(timem-md5sum OBJECT md5.cpp md5.hpp) +add_library(timem-md5sum EXCLUDE_FROM_ALL OBJECT md5.cpp md5.hpp) target_link_libraries(timem-md5sum PRIVATE timemory::timemory-compile-options @@ -80,6 +80,8 @@ target_link_libraries(timem-md5sum PRIVATE add_executable(timem ${_EXCLUDE} timem.cpp timem.hpp $) +add_dependencies(timem timem-md5sum) + target_link_libraries(timem PRIVATE timemory::timemory-compile-options timemory::timemory-develop-options @@ -107,6 +109,8 @@ endif() add_executable(timem-mpi ${_EXCLUDE} timem.cpp timem.hpp $) +add_dependencies(timem-mpi timem-md5sum) + target_link_libraries(timem-mpi PRIVATE timemory::timemory-compile-options timemory::timemory-develop-options