diff --git a/CMakeLists.txt b/CMakeLists.txt index 897b2b2fa..f94192d48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -616,12 +616,6 @@ if(PIKA_WITH_SPINLOCK_DEADLOCK_DETECTION) pika_add_config_define(PIKA_HAVE_SPINLOCK_DEADLOCK_DETECTION) endif() -pika_option( - PIKA_WITH_ITTNOTIFY BOOL "Enable Amplifier (ITT) instrumentation support." OFF - CATEGORY "Profiling" - ADVANCED -) - pika_option( PIKA_WITH_MPI BOOL "Enable support for returning futures from MPI asynchronous calls (default: ON)" OFF diff --git a/cmake/FindAmplifier.cmake b/cmake/FindAmplifier.cmake deleted file mode 100644 index 51d204543..000000000 --- a/cmake/FindAmplifier.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2014 Thomas Heller -# Copyright (c) 2012 Hartmut Kaiser -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -if(NOT TARGET pika_internal::amplifier) - find_package(PkgConfig QUIET) - pkg_check_modules(PC_AMPLIFIER QUIET amplifier) - - find_path( - AMPLIFIER_INCLUDE_DIR ittnotify.h - HINTS ${AMPLIFIER_ROOT} ENV AMPLIFIER_ROOT ${PC_AMPLIFIER_INCLUDEDIR} - ${PC_AMPLIFIER_INCLUDE_DIRS} - PATH_SUFFIXES include - ) - - find_library( - AMPLIFIER_LIBRARY - NAMES ittnotify libittnotify - HINTS ${AMPLIFIER_ROOT} ENV AMPLIFIER_ROOT ${PC_AMPLIFIER_LIBDIR} ${PC_AMPLIFIER_LIBRARY_DIRS} - PATH_SUFFIXES lib lib64 - ) - - # Set AMPLIFIER_ROOT in case the other hints are used - if(AMPLIFIER_ROOT) - # The call to file is for compatibility for windows paths - file(TO_CMAKE_PATH ${AMPLIFIER_ROOT} AMPLIFIER_ROOT) - elseif("$ENV{AMPLIFIER_ROOT}") - file(TO_CMAKE_PATH $ENV{AMPLIFIER_ROOT} AMPLIFIER_ROOT) - else() - file(TO_CMAKE_PATH "${AMPLIFIER_INCLUDE_DIR}" AMPLIFIER_INCLUDE_DIR) - string(REPLACE "/include" "" AMPLIFIER_ROOT "${AMPLIFIER_INCLUDE_DIR}") - endif() - - set(AMPLIFIER_LIBRARIES ${AMPLIFIER_LIBRARY}) - set(AMPLIFIER_INCLUDE_DIRS ${AMPLIFIER_INCLUDE_DIR}) - - find_package_handle_standard_args(Amplifier DEFAULT_MSG AMPLIFIER_LIBRARY AMPLIFIER_INCLUDE_DIR) - - get_property( - _type - CACHE AMPLIFIER_ROOT - PROPERTY TYPE - ) - if(_type) - set_property(CACHE AMPLIFIER_ROOT PROPERTY ADVANCED 1) - if("x${_type}" STREQUAL "xUNINITIALIZED") - set_property(CACHE AMPLIFIER_ROOT PROPERTY TYPE PATH) - endif() - endif() - - mark_as_advanced(AMPLIFIER_ROOT AMPLIFIER_LIBRARY AMPLIFIER_INCLUDE_DIR) - - add_library(pika_internal::amplifier INTERFACE IMPORTED) - target_include_directories(pika_internal::amplifier SYSTEM INTERFACE ${AMPLIFIER_INCLUDE_DIR}) - target_link_libraries(pika_internal::amplifier INTERFACE ${AMPLIFIER_LIBRARIES}) -endif() diff --git a/cmake/pika_add_config_test.cmake b/cmake/pika_add_config_test.cmake index 50b10c33a..a7d4f145a 100644 --- a/cmake/pika_add_config_test.cmake +++ b/cmake/pika_add_config_test.cmake @@ -230,15 +230,6 @@ function(pika_check_for_unistd_h) ) endfunction() -# ################################################################################################## -function(pika_check_for_libfun_std_experimental_optional) - pika_add_config_test( - PIKA_WITH_LIBFUN_EXPERIMENTAL_OPTIONAL - SOURCE cmake/tests/libfun_std_experimental_optional.cpp - FILE ${ARGN} - ) -endfunction() - # ################################################################################################## function(pika_check_for_cxx11_std_atomic) # Make sure PIKA_HAVE_LIBATOMIC is removed from the cache if necessary @@ -518,3 +509,12 @@ function(pika_check_for_mpix_continuations) FILE ${ARGN} ) endfunction() + +# ################################################################################################## +function(pika_check_for_pthread_setname_np) + pika_add_config_test( + PIKA_WITH_PTHREAD_SETNAME_NP + SOURCE cmake/tests/pthread_setname_np.cpp + FILE ${ARGN} + ) +endfunction() diff --git a/cmake/pika_perform_cxx_feature_tests.cmake b/cmake/pika_perform_cxx_feature_tests.cmake index 76eaecfe9..1a0b2f6fd 100644 --- a/cmake/pika_perform_cxx_feature_tests.cmake +++ b/cmake/pika_perform_cxx_feature_tests.cmake @@ -61,4 +61,6 @@ function(pika_perform_cxx_feature_tests) ) pika_check_for_stdexec_continues_on(DEFINITIONS PIKA_HAVE_STDEXEC_CONTINUES_ON) + + pika_check_for_pthread_setname_np(DEFINITIONS PIKA_HAVE_PTHREAD_SETNAME_NP) endfunction() diff --git a/cmake/pika_setup_allocator.cmake b/cmake/pika_setup_allocator.cmake index 8c9666964..a9c25ae7c 100644 --- a/cmake/pika_setup_allocator.cmake +++ b/cmake/pika_setup_allocator.cmake @@ -124,20 +124,6 @@ if(NOT TARGET pika_dependencies_allocator) pika_info("Using ${PIKA_WITH_MALLOC} allocator.") - # Setup Intel amplifier - if((NOT PIKA_WITH_APEX) AND PIKA_WITH_ITTNOTIFY) - - find_package(Amplifier) - if(NOT AMPLIFIER_FOUND) - pika_error( - "Intel Amplifier could not be found and PIKA_WITH_ITTNOTIFY=On, please specify AMPLIFIER_ROOT to point to the root of your Amplifier installation" - ) - endif() - - pika_add_config_define(PIKA_HAVE_ITTNOTIFY 1) - pika_add_config_define(PIKA_HAVE_THREAD_DESCRIPTION) - endif() - # convey selected allocator type to the build configuration if(NOT PIKA_FIND_PACKAGE) pika_add_config_define(PIKA_HAVE_MALLOC "\"${PIKA_WITH_MALLOC}\"") diff --git a/cmake/tests/pthread_setname_np.cpp b/cmake/tests/pthread_setname_np.cpp new file mode 100644 index 000000000..4926574e3 --- /dev/null +++ b/cmake/tests/pthread_setname_np.cpp @@ -0,0 +1,11 @@ +//////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2024 ETH Zurich +// +// SPDX-License-Identifier: BSL-1.0 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +//////////////////////////////////////////////////////////////////////////////// + +#include + +int main() { pthread_setname_np(pthread_self(), "test"); } diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index e2f0abf43..345cce651 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -97,7 +97,3 @@ configure_file( if(MSVC AND PIKA_WITH_SWAP_CONTEXT_EMULATION) target_link_options(pika PRIVATE "/EXPORT:switch_to_fiber") endif() - -if(PIKA_WITH_ITTNOTIFY) - target_link_libraries(pika PUBLIC pika_internal::amplifier) -endif() diff --git a/libs/pika/CMakeLists.txt b/libs/pika/CMakeLists.txt index 261e42618..6e89cc5b3 100644 --- a/libs/pika/CMakeLists.txt +++ b/libs/pika/CMakeLists.txt @@ -33,7 +33,6 @@ set(_pika_modules ini init_runtime iterator_support - itt_notify lock_registration logging memory diff --git a/libs/pika/concurrency/CMakeLists.txt b/libs/pika/concurrency/CMakeLists.txt index 2f4fd8c41..9642f08cb 100644 --- a/libs/pika/concurrency/CMakeLists.txt +++ b/libs/pika/concurrency/CMakeLists.txt @@ -36,7 +36,6 @@ pika_add_module( pika_execution_base pika_errors pika_hashing - pika_itt_notify pika_lock_registration pika_thread_support CMAKE_SUBDIRS examples tests diff --git a/libs/pika/concurrency/include/pika/concurrency/spinlock.hpp b/libs/pika/concurrency/include/pika/concurrency/spinlock.hpp index ad4d0d6e6..b2784546b 100644 --- a/libs/pika/concurrency/include/pika/concurrency/spinlock.hpp +++ b/libs/pika/concurrency/include/pika/concurrency/spinlock.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -26,18 +25,15 @@ namespace pika::concurrency::detail { std::atomic v_; public: - spinlock(char const* const desc = "pika::concurrency::detail::spinlock") + spinlock(char const* const = "pika::concurrency::detail::spinlock") : v_(false) { - PIKA_ITT_SYNC_CREATE(this, desc, ""); } - ~spinlock() { PIKA_ITT_SYNC_DESTROY(this); } + ~spinlock() {} void lock() { - PIKA_ITT_SYNC_PREPARE(this); - // Checking for the value in is_locked() ensures that // acquire_lock is only called when is_locked computes // to false. This way we spin only on a load operation @@ -66,34 +62,25 @@ namespace pika::concurrency::detail { "pika::concurrency::detail::spinlock::lock", false); } while (!acquire_lock()); - PIKA_ITT_SYNC_ACQUIRED(this); util::register_lock(this); } bool try_lock() { - PIKA_ITT_SYNC_PREPARE(this); - bool r = acquire_lock(); //-V707 if (r) { - PIKA_ITT_SYNC_ACQUIRED(this); util::register_lock(this); return true; } - PIKA_ITT_SYNC_CANCEL(this); return false; } void unlock() { - PIKA_ITT_SYNC_RELEASING(this); - relinquish_lock(); - - PIKA_ITT_SYNC_RELEASED(this); util::unregister_lock(this); } diff --git a/libs/pika/concurrency/include/pika/concurrency/spinlock_pool.hpp b/libs/pika/concurrency/include/pika/concurrency/spinlock_pool.hpp index 5ab495c09..0cabe3044 100644 --- a/libs/pika/concurrency/include/pika/concurrency/spinlock_pool.hpp +++ b/libs/pika/concurrency/include/pika/concurrency/spinlock_pool.hpp @@ -16,29 +16,16 @@ #include #include #include -#include #include #include namespace pika::concurrency::detail { -#if PIKA_HAVE_ITTNOTIFY != 0 - template - struct itt_spinlock_init - { - itt_spinlock_init(); - ~itt_spinlock_init(); - }; -#endif - template class spinlock_pool { private: static pika::concurrency::detail::cache_aligned_data<::pika::detail::spinlock> pool_[N]; -#if PIKA_HAVE_ITTNOTIFY != 0 - static detail::itt_spinlock_init init_; -#endif public: static ::pika::detail::spinlock& spinlock_for(void const* pv) @@ -51,30 +38,4 @@ namespace pika::concurrency::detail { template pika::concurrency::detail::cache_aligned_data<::pika::detail::spinlock> spinlock_pool::pool_[N]; - -#if PIKA_HAVE_ITTNOTIFY != 0 - template - itt_spinlock_init::itt_spinlock_init() - { - for (int i = 0; i < N; ++i) - { - PIKA_ITT_SYNC_CREATE( - (&spinlock_pool::pool_[i].data_), "pika::concurrency::detail::spinlock", 0); - PIKA_ITT_SYNC_RENAME( - (&spinlock_pool::pool_[i].data_), "pika::concurrency::detail::spinlock"); - } - } - - template - itt_spinlock_init::~itt_spinlock_init() - { - for (int i = 0; i < N; ++i) - { - PIKA_ITT_SYNC_DESTROY((&spinlock_pool::pool_[i].data_)); - } - } - - template - util::detail::itt_spinlock_init spinlock_pool::init_; -#endif } // namespace pika::concurrency::detail diff --git a/libs/pika/executors/CMakeLists.txt b/libs/pika/executors/CMakeLists.txt index 805593dd2..9b95ca5f6 100644 --- a/libs/pika/executors/CMakeLists.txt +++ b/libs/pika/executors/CMakeLists.txt @@ -21,7 +21,6 @@ pika_add_module( pika_async_base pika_config pika_execution - pika_itt_notify pika_properties pika_threading pika_timing diff --git a/libs/pika/functional/CMakeLists.txt b/libs/pika/functional/CMakeLists.txt index e2e6f2242..3a1c2f325 100644 --- a/libs/pika/functional/CMakeLists.txt +++ b/libs/pika/functional/CMakeLists.txt @@ -50,7 +50,6 @@ pika_add_module( pika_datastructures pika_debugging pika_errors - pika_itt_notify pika_tag_invoke pika_type_support CMAKE_SUBDIRS examples tests diff --git a/libs/pika/functional/include/pika/functional/bind.hpp b/libs/pika/functional/include/pika/functional/bind.hpp index 3087cc08f..e34b0a606 100644 --- a/libs/pika/functional/include/pika/functional/bind.hpp +++ b/libs/pika/functional/include/pika/functional/bind.hpp @@ -173,18 +173,6 @@ namespace pika::util::detail { #endif } -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_function_annotation_itt() const - { -# if defined(PIKA_HAVE_THREAD_DESCRIPTION) - return pika::detail::get_function_annotation_itt::call(_f); -# else - static util::itt::string_handle sh("bound"); - return sh; -# endif - } -#endif - private: F _f; util::detail::member_pack_for _args; @@ -229,16 +217,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call(pika::util::detail::bound const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif #endif } // namespace pika::detail diff --git a/libs/pika/functional/include/pika/functional/bind_back.hpp b/libs/pika/functional/include/pika/functional/bind_back.hpp index ac8a4f9a5..d107cf4d2 100644 --- a/libs/pika/functional/include/pika/functional/bind_back.hpp +++ b/libs/pika/functional/include/pika/functional/bind_back.hpp @@ -119,18 +119,6 @@ namespace pika::util::detail { #endif } -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_function_annotation_itt() const - { -# if defined(PIKA_HAVE_THREAD_DESCRIPTION) - return pika::detail::get_function_annotation_itt::call(_f); -# else - static util::itt::string_handle sh("bound_back"); - return sh; -# endif - } -#endif - private: F _f; util::detail::member_pack_for _args; @@ -177,17 +165,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call( - pika::util::detail::bound_back const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif #endif } // namespace pika::detail diff --git a/libs/pika/functional/include/pika/functional/bind_front.hpp b/libs/pika/functional/include/pika/functional/bind_front.hpp index c1ebadf63..3f7030d95 100644 --- a/libs/pika/functional/include/pika/functional/bind_front.hpp +++ b/libs/pika/functional/include/pika/functional/bind_front.hpp @@ -119,18 +119,6 @@ namespace pika::util::detail { #endif } -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_function_annotation_itt() const - { -# if defined(PIKA_HAVE_THREAD_DESCRIPTION) - return pika::detail::get_function_annotation_itt::call(_f); -# else - static util::itt::string_handle sh("bound_front"); - return sh; -# endif - } -#endif - private: F _f; util::detail::member_pack_for _args; @@ -177,17 +165,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call( - pika::util::detail::bound_front const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif #endif } // namespace pika::detail diff --git a/libs/pika/functional/include/pika/functional/deferred_call.hpp b/libs/pika/functional/include/pika/functional/deferred_call.hpp index b3c3d3fcf..bc5609229 100644 --- a/libs/pika/functional/include/pika/functional/deferred_call.hpp +++ b/libs/pika/functional/include/pika/functional/deferred_call.hpp @@ -88,18 +88,6 @@ namespace pika::util::detail { #endif } -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_function_annotation_itt() const - { -# if defined(PIKA_HAVE_THREAD_DESCRIPTION) - return pika::detail::get_function_annotation_itt::call(_f); -# else - static util::itt::string_handle sh("deferred"); - return sh; -# endif - } -#endif - private: F _f; util::detail::member_pack_for _args; @@ -152,17 +140,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call( - pika::util::detail::deferred const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif } // namespace pika::detail #endif diff --git a/libs/pika/functional/include/pika/functional/detail/basic_function.hpp b/libs/pika/functional/include/pika/functional/detail/basic_function.hpp index c21dccb99..0f25f021d 100644 --- a/libs/pika/functional/include/pika/functional/detail/basic_function.hpp +++ b/libs/pika/functional/include/pika/functional/detail/basic_function.hpp @@ -57,7 +57,6 @@ namespace pika::util::detail { std::size_t get_function_address() const; char const* get_function_annotation() const; - util::itt::string_handle get_function_annotation_itt() const; protected: vtable const* vptr; @@ -201,7 +200,6 @@ namespace pika::util::detail { using base_type::get_function_address; using base_type::get_function_annotation; - using base_type::get_function_annotation_itt; private: static constexpr vtable const* get_empty_vtable() noexcept diff --git a/libs/pika/functional/include/pika/functional/detail/vtable/callable_vtable.hpp b/libs/pika/functional/include/pika/functional/detail/vtable/callable_vtable.hpp index 426f24432..2a667a1f4 100644 --- a/libs/pika/functional/include/pika/functional/detail/vtable/callable_vtable.hpp +++ b/libs/pika/functional/include/pika/functional/detail/vtable/callable_vtable.hpp @@ -39,15 +39,6 @@ namespace pika::util::detail { return pika::detail::get_function_annotation::call(vtable::get(f)); } char const* (*get_function_annotation)(void*); - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - PIKA_FORCEINLINE static util::itt::string_handle _get_function_annotation_itt(void* f) - { - return pika::detail::get_function_annotation_itt::call(vtable::get(f)); - } - util::itt::string_handle (*get_function_annotation_itt)(void*); -# endif #endif template @@ -55,10 +46,6 @@ namespace pika::util::detail { #if defined(PIKA_HAVE_THREAD_DESCRIPTION) : get_function_address(&callable_info_vtable::template _get_function_address) , get_function_annotation(&callable_info_vtable::template _get_function_annotation) -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - , get_function_annotation_itt( - &callable_info_vtable::template _get_function_annotation_itt) -# endif #endif { } @@ -67,9 +54,6 @@ namespace pika::util::detail { #if defined(PIKA_HAVE_THREAD_DESCRIPTION) : get_function_address(nullptr) , get_function_annotation(nullptr) -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - , get_function_annotation_itt(nullptr) -# endif #endif { } diff --git a/libs/pika/functional/include/pika/functional/function.hpp b/libs/pika/functional/include/pika/functional/function.hpp index e535a82c1..567f98c3c 100644 --- a/libs/pika/functional/include/pika/functional/function.hpp +++ b/libs/pika/functional/include/pika/functional/function.hpp @@ -83,16 +83,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call(util::detail::function const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif } // namespace pika::detail #endif diff --git a/libs/pika/functional/include/pika/functional/one_shot.hpp b/libs/pika/functional/include/pika/functional/one_shot.hpp index 91deaa9fa..36484b78b 100644 --- a/libs/pika/functional/include/pika/functional/one_shot.hpp +++ b/libs/pika/functional/include/pika/functional/one_shot.hpp @@ -72,18 +72,6 @@ namespace pika::util::detail { #endif } -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_function_annotation_itt() const - { -# if defined(PIKA_HAVE_THREAD_DESCRIPTION) - return pika::detail::get_function_annotation_itt::call(_f); -# else - static util::itt::string_handle sh("one_shot_wrapper"); - return sh; -# endif - } -#endif - public: // exposition-only F _f; #if defined(PIKA_DEBUG) @@ -120,16 +108,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call(util::detail::one_shot_wrapper const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif #endif } // namespace pika::detail diff --git a/libs/pika/functional/include/pika/functional/traits/get_function_annotation.hpp b/libs/pika/functional/include/pika/functional/traits/get_function_annotation.hpp index dff0853dd..ff65a1c10 100644 --- a/libs/pika/functional/include/pika/functional/traits/get_function_annotation.hpp +++ b/libs/pika/functional/include/pika/functional/traits/get_function_annotation.hpp @@ -7,7 +7,6 @@ #pragma once #include -#include #include #include @@ -19,16 +18,4 @@ namespace pika::detail { { static constexpr char const* call(F const& /*f*/) noexcept { return nullptr; } }; - -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt - { - static util::itt::string_handle call(F const& f) - { - static util::itt::string_handle sh(get_function_annotation::call(f)); - return sh; - } - }; -#endif } // namespace pika::detail diff --git a/libs/pika/functional/include/pika/functional/unique_function.hpp b/libs/pika/functional/include/pika/functional/unique_function.hpp index 43d861c17..be81cac39 100644 --- a/libs/pika/functional/include/pika/functional/unique_function.hpp +++ b/libs/pika/functional/include/pika/functional/unique_function.hpp @@ -81,16 +81,5 @@ namespace pika::detail { return f.get_function_annotation(); } }; - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - template - struct get_function_annotation_itt> - { - static util::itt::string_handle call(util::detail::unique_function const& f) noexcept - { - return f.get_function_annotation_itt(); - } - }; -# endif } // namespace pika::detail #endif diff --git a/libs/pika/functional/src/basic_function.cpp b/libs/pika/functional/src/basic_function.cpp index 7ed4f0364..69ca1dd73 100644 --- a/libs/pika/functional/src/basic_function.cpp +++ b/libs/pika/functional/src/basic_function.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include @@ -124,15 +123,6 @@ namespace pika::util::detail { return vptr->get_function_annotation(object); #else return nullptr; -#endif - } - - util::itt::string_handle function_base::get_function_annotation_itt() const - { -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - return vptr->get_function_annotation_itt(object); -#else - return util::itt::string_handle{}; #endif } } // namespace pika::util::detail diff --git a/libs/pika/itt_notify/CMakeLists.txt b/libs/pika/itt_notify/CMakeLists.txt deleted file mode 100644 index 5f482298a..000000000 --- a/libs/pika/itt_notify/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2019-2021 The STE||AR-Group -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - -# Default location is $PIKA_ROOT/libs/itt_notify/include -set(itt_notify_headers pika/modules/itt_notify.hpp pika/itt_notify/thread_name.hpp) - -set(itt_notify_sources itt_notify.cpp thread_name.cpp) - -if(TARGET pika_internal::amplifier) - set(itt_notify_optional_dependencies pika_internal::amplifier) -endif() - -include(pika_add_module) -pika_add_module( - pika itt_notify - GLOBAL_HEADER_GEN OFF - SOURCES ${itt_notify_sources} - HEADERS ${itt_notify_headers} - DEPENDENCIES ${itt_notify_optional_dependencies} - MODULE_DEPENDENCIES pika_config - CMAKE_SUBDIRS examples tests -) diff --git a/libs/pika/itt_notify/README.rst b/libs/pika/itt_notify/README.rst deleted file mode 100644 index edb741de1..000000000 --- a/libs/pika/itt_notify/README.rst +++ /dev/null @@ -1,13 +0,0 @@ - -.. - Copyright (c) 2020 The STE||AR-Group - - SPDX-License-Identifier: BSL-1.0 - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -========== -itt_notify -========== - -This library is part of pika. diff --git a/libs/pika/itt_notify/docs/index.rst b/libs/pika/itt_notify/docs/index.rst deleted file mode 100644 index 47809f922..000000000 --- a/libs/pika/itt_notify/docs/index.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. - Copyright (c) 2020 The STE||AR-Group - - SPDX-License-Identifier: BSL-1.0 - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -.. _modules_itt_notify: - -========== -itt_notify -========== - -This module provides support for profiling with |vtune|_. - -See the :ref:`API reference ` of this module for more -details. - diff --git a/libs/pika/itt_notify/examples/CMakeLists.txt b/libs/pika/itt_notify/examples/CMakeLists.txt deleted file mode 100644 index e361336cc..000000000 --- a/libs/pika/itt_notify/examples/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright (c) 2020 The STE||AR-Group -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -if(PIKA_WITH_EXAMPLES) - pika_add_pseudo_target(examples.modules.itt_notify) - pika_add_pseudo_dependencies(examples.modules examples.modules.itt_notify) - if(PIKA_WITH_TESTS AND PIKA_WITH_TESTS_EXAMPLES) - pika_add_pseudo_target(tests.examples.modules.itt_notify) - pika_add_pseudo_dependencies(tests.examples.modules tests.examples.modules.itt_notify) - endif() -endif() diff --git a/libs/pika/itt_notify/include/pika/itt_notify/thread_name.hpp b/libs/pika/itt_notify/include/pika/itt_notify/thread_name.hpp deleted file mode 100644 index 011ac3a20..000000000 --- a/libs/pika/itt_notify/include/pika/itt_notify/thread_name.hpp +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2019 Mikael Simberg -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#include - -#include - -namespace pika::detail { - /// Helper utility to set and store a name for the current operating system - /// thread. Returns a reference to the name for the current thread. - PIKA_EXPORT std::string& thread_name(); -} // namespace pika::detail diff --git a/libs/pika/itt_notify/include/pika/modules/itt_notify.hpp b/libs/pika/itt_notify/include/pika/modules/itt_notify.hpp deleted file mode 100644 index 4bf5e4e20..000000000 --- a/libs/pika/itt_notify/include/pika/modules/itt_notify.hpp +++ /dev/null @@ -1,693 +0,0 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#include - -#include -#include -#include - -// NOLINTBEGIN(bugprone-reserved-identifier) -struct ___itt_caller; -struct ___itt_string_handle; -struct ___itt_domain; -struct ___itt_id; -using __itt_heap_function = void*; -struct ___itt_counter; -// NOLINTEND(bugprone-reserved-identifier) - -/////////////////////////////////////////////////////////////////////////////// -#define PIKA_ITT_SYNC_CREATE(obj, type, name) itt_sync_create(obj, type, name) -#define PIKA_ITT_SYNC_RENAME(obj, name) itt_sync_rename(obj, name) -#define PIKA_ITT_SYNC_PREPARE(obj) itt_sync_prepare(obj) -#define PIKA_ITT_SYNC_CANCEL(obj) itt_sync_cancel(obj) -#define PIKA_ITT_SYNC_ACQUIRED(obj) itt_sync_acquired(obj) -#define PIKA_ITT_SYNC_RELEASING(obj) itt_sync_releasing(obj) -#define PIKA_ITT_SYNC_RELEASED(obj) itt_sync_released(obj) -#define PIKA_ITT_SYNC_DESTROY(obj) itt_sync_destroy(obj) - -#define PIKA_ITT_STACK_CREATE(ctx) ctx = itt_stack_create() -#define PIKA_ITT_STACK_CALLEE_ENTER(ctx) itt_stack_enter(ctx) -#define PIKA_ITT_STACK_CALLEE_LEAVE(ctx) itt_stack_leave(ctx) -#define PIKA_ITT_STACK_DESTROY(ctx) itt_stack_destroy(ctx) - -#define PIKA_ITT_FRAME_BEGIN(frame, id) itt_frame_begin(frame, id) -#define PIKA_ITT_FRAME_END(frame, id) itt_frame_end(frame, id) - -#define PIKA_ITT_MARK_CREATE(mark, name) mark = itt_mark_create(name) -#define PIKA_ITT_MARK_OFF(mark) itt_mark_off(mark) -#define PIKA_ITT_MARK(mark, parameter) itt_mark(mark, parameter) - -#define PIKA_ITT_THREAD_SET_NAME(name) itt_thread_set_name(name) -#define PIKA_ITT_THREAD_IGNORE() itt_thread_ignore() - -#define PIKA_ITT_TASK_BEGIN(domain, name) itt_task_begin(domain, name) -#define PIKA_ITT_TASK_BEGIN_ID(domain, id, name) itt_task_begin(domain, id, name) -#define PIKA_ITT_TASK_END(domain) itt_task_end(domain) - -#define PIKA_ITT_DOMAIN_CREATE(name) itt_domain_create(name) -#define PIKA_ITT_STRING_HANDLE_CREATE(name) itt_string_handle_create(name) - -#define PIKA_ITT_MAKE_ID(addr, extra) itt_make_id(addr, extra) -#define PIKA_ITT_ID_CREATE(domain, id) itt_id_create(domain, id) -#define PIKA_ITT_ID_DESTROY(id) itt_id_destroy(id) - -#define PIKA_ITT_HEAP_FUNCTION_CREATE(name, domain) itt_heap_function_create(name, domain) /**/ -#define PIKA_ITT_HEAP_ALLOCATE_BEGIN(f, size, initialized) \ - itt_heap_allocate_begin(f, size, initialized) /**/ -#define PIKA_ITT_HEAP_ALLOCATE_END(f, addr, size, initialized) \ - itt_heap_allocate_end(f, addr, size, initialized) /**/ -#define PIKA_ITT_HEAP_FREE_BEGIN(f, addr) itt_heap_free_begin(f, addr) -#define PIKA_ITT_HEAP_FREE_END(f, addr) itt_heap_free_end(f, addr) -#define PIKA_ITT_HEAP_REALLOCATE_BEGIN(f, addr, new_size, initialized) \ - itt_heap_reallocate_begin(f, addr, new_size, initialized) /**/ -#define PIKA_ITT_HEAP_REALLOCATE_END(f, addr, new_addr, new_size, initialized) \ - itt_heap_reallocate_end(f, addr, new_addr, new_size, initialized) /**/ -#define PIKA_ITT_HEAP_INTERNAL_ACCESS_BEGIN() itt_heap_internal_access_begin() -#define PIKA_ITT_HEAP_INTERNAL_ACCESS_END() itt_heap_internal_access_end() - -#define PIKA_ITT_COUNTER_CREATE(name, domain) itt_counter_create(name, domain) /**/ -#define PIKA_ITT_COUNTER_CREATE_TYPED(name, domain, type) \ - itt_counter_create_typed(name, domain, type) /**/ -#define PIKA_ITT_COUNTER_SET_VALUE(id, value_ptr) itt_counter_set_value(id, value_ptr) /**/ -#define PIKA_ITT_COUNTER_DESTROY(id) itt_counter_destroy(id) - -#define PIKA_ITT_METADATA_ADD(domain, id, key, data) itt_metadata_add(domain, id, key, data) /**/ - -/////////////////////////////////////////////////////////////////////////////// -// decide whether to use the ITT notify API if it's available - -#if PIKA_HAVE_ITTNOTIFY != 0 -PIKA_EXPORT extern bool use_ittnotify_api; - -/////////////////////////////////////////////////////////////////////////////// -PIKA_EXPORT void itt_sync_create(void* addr, char const* objtype, char const* objname) noexcept; -PIKA_EXPORT void itt_sync_rename(void* addr, char const* name) noexcept; -PIKA_EXPORT void itt_sync_prepare(void* addr) noexcept; -PIKA_EXPORT void itt_sync_acquired(void* addr) noexcept; -PIKA_EXPORT void itt_sync_cancel(void* addr) noexcept; -PIKA_EXPORT void itt_sync_releasing(void* addr) noexcept; -PIKA_EXPORT void itt_sync_released(void* addr) noexcept; -PIKA_EXPORT void itt_sync_destroy(void* addr) noexcept; - -PIKA_EXPORT ___itt_caller* itt_stack_create() noexcept; -PIKA_EXPORT void itt_stack_enter(___itt_caller* ctx) noexcept; -PIKA_EXPORT void itt_stack_leave(___itt_caller* ctx) noexcept; -PIKA_EXPORT void itt_stack_destroy(___itt_caller* ctx) noexcept; - -PIKA_EXPORT void itt_frame_begin(___itt_domain const* frame, ___itt_id* id) noexcept; -PIKA_EXPORT void itt_frame_end(___itt_domain const* frame, ___itt_id* id) noexcept; - -PIKA_EXPORT int itt_mark_create(char const*) noexcept; -PIKA_EXPORT void itt_mark_off(int mark) noexcept; -PIKA_EXPORT void itt_mark(int mark, char const*) noexcept; - -PIKA_EXPORT void itt_thread_set_name(char const*) noexcept; -PIKA_EXPORT void itt_thread_ignore() noexcept; - -PIKA_EXPORT void itt_task_begin(___itt_domain const*, ___itt_string_handle*) noexcept; -PIKA_EXPORT void itt_task_begin(___itt_domain const*, ___itt_id*, ___itt_string_handle*) noexcept; -PIKA_EXPORT void itt_task_end(___itt_domain const*) noexcept; - -PIKA_EXPORT ___itt_domain* itt_domain_create(char const*) noexcept; -PIKA_EXPORT ___itt_string_handle* itt_string_handle_create(char const*) noexcept; - -PIKA_EXPORT ___itt_id* itt_make_id(void*, std::size_t); -PIKA_EXPORT void itt_id_create(___itt_domain const*, ___itt_id* id) noexcept; -PIKA_EXPORT void itt_id_destroy(___itt_id* id) noexcept; - -PIKA_EXPORT __itt_heap_function itt_heap_function_create(char const*, char const*) noexcept; -PIKA_EXPORT void itt_heap_allocate_begin(__itt_heap_function, std::size_t, int) noexcept; -PIKA_EXPORT void itt_heap_allocate_end(__itt_heap_function, void**, std::size_t, int) noexcept; -PIKA_EXPORT void itt_heap_free_begin(__itt_heap_function, void*) noexcept; -PIKA_EXPORT void itt_heap_free_end(__itt_heap_function, void*) noexcept; -PIKA_EXPORT void itt_heap_reallocate_begin(__itt_heap_function, void*, std::size_t, int) noexcept; -PIKA_EXPORT void itt_heap_reallocate_end( - __itt_heap_function, void*, void**, std::size_t, int) noexcept; -PIKA_EXPORT void itt_heap_internal_access_begin() noexcept; -PIKA_EXPORT void itt_heap_internal_access_end() noexcept; - -PIKA_EXPORT ___itt_counter* itt_counter_create(char const*, char const*) noexcept; -PIKA_EXPORT ___itt_counter* itt_counter_create_typed(char const*, char const*, int) noexcept; -PIKA_EXPORT void itt_counter_destroy(___itt_counter*) noexcept; -PIKA_EXPORT void itt_counter_set_value(___itt_counter*, void*) noexcept; - -PIKA_EXPORT int itt_event_create(char const* name, int namelen) noexcept; -PIKA_EXPORT int itt_event_start(int evnt) noexcept; -PIKA_EXPORT int itt_event_end(int evnt) noexcept; - -PIKA_EXPORT void itt_metadata_add(___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, - std::uint64_t const& data) noexcept; -PIKA_EXPORT void itt_metadata_add( - ___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, double const& data) noexcept; -PIKA_EXPORT void itt_metadata_add( - ___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, char const* data) noexcept; -PIKA_EXPORT void itt_metadata_add( - ___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, void const* data) noexcept; - -/////////////////////////////////////////////////////////////////////////////// -namespace pika::detail { - - struct thread_description; - -} // namespace pika::detail - -namespace pika { namespace util { namespace itt { - - struct stack_context - { - PIKA_EXPORT stack_context(); - PIKA_EXPORT ~stack_context(); - - stack_context(stack_context const& rhs) = delete; - stack_context(stack_context&& rhs) noexcept - : itt_context_(rhs.itt_context_) - { - rhs.itt_context_ = nullptr; - } - - stack_context& operator=(stack_context const& rhs) = delete; - stack_context& operator=(stack_context&& rhs) noexcept - { - if (this != &rhs) - { - itt_context_ = rhs.itt_context_; - rhs.itt_context_ = nullptr; - } - return *this; - } - - struct ___itt_caller* itt_context_ = nullptr; - }; - - struct caller_context - { - PIKA_EXPORT caller_context(stack_context& ctx); - PIKA_EXPORT ~caller_context(); - - stack_context& ctx_; - }; - - ////////////////////////////////////////////////////////////////////////// - struct domain - { - PIKA_NON_COPYABLE(domain); - - domain() = default; - PIKA_EXPORT domain(char const*) noexcept; - - ___itt_domain* domain_ = nullptr; - }; - - struct thread_domain : domain - { - PIKA_NON_COPYABLE(thread_domain); - - PIKA_EXPORT thread_domain() noexcept; - }; - - struct id - { - PIKA_EXPORT id(domain const& domain, void* addr, unsigned long extra = 0) noexcept; - PIKA_EXPORT ~id(); - - id(id const& rhs) = delete; - id(id&& rhs) noexcept - : id_(rhs.id_) - { - rhs.id_ = nullptr; - } - - id& operator=(id const& rhs) = delete; - id& operator=(id&& rhs) noexcept - { - if (this != &rhs) - { - id_ = rhs.id_; - rhs.id_ = nullptr; - } - return *this; - } - - ___itt_id* id_ = nullptr; - }; - - /////////////////////////////////////////////////////////////////////////// - struct frame_context - { - PIKA_EXPORT frame_context(domain const& domain, id* ident = nullptr) noexcept; - PIKA_EXPORT ~frame_context(); - - domain const& domain_; - id* ident_ = nullptr; - }; - - struct undo_frame_context - { - PIKA_EXPORT undo_frame_context(frame_context& frame) noexcept; - PIKA_EXPORT ~undo_frame_context(); - - frame_context& frame_; - }; - - /////////////////////////////////////////////////////////////////////////// - struct mark_context - { - PIKA_EXPORT mark_context(char const* name) noexcept; - PIKA_EXPORT ~mark_context(); - - int itt_mark_; - char const* name_ = nullptr; - }; - - struct undo_mark_context - { - PIKA_EXPORT undo_mark_context(mark_context& mark) noexcept; - PIKA_EXPORT ~undo_mark_context(); - - mark_context& mark_; - }; - - /////////////////////////////////////////////////////////////////////////// - struct string_handle - { - string_handle() noexcept = default; - - PIKA_EXPORT string_handle(char const* s) noexcept; - - string_handle(___itt_string_handle* h) noexcept - : handle_(h) - { - } - - string_handle(string_handle const&) = default; - string_handle(string_handle&& rhs) - : handle_(rhs.handle_) - { - rhs.handle_ = nullptr; - } - - string_handle& operator=(string_handle const&) = default; - string_handle& operator=(string_handle&& rhs) noexcept - { - if (this != &rhs) - { - handle_ = rhs.handle_; - rhs.handle_ = nullptr; - } - return *this; - } - - string_handle& operator=(___itt_string_handle* h) noexcept - { - handle_ = h; - return *this; - } - - explicit constexpr operator bool() const noexcept { return handle_ != nullptr; } - - ___itt_string_handle* handle_ = nullptr; - }; - - /////////////////////////////////////////////////////////////////////////// - struct task - { - PIKA_EXPORT task(domain const&, string_handle const&, std::uint64_t metadata) noexcept; - PIKA_EXPORT task(domain const&, string_handle const&) noexcept; - PIKA_EXPORT ~task(); - - PIKA_EXPORT void add_metadata(string_handle const& name, std::uint64_t val) noexcept; - PIKA_EXPORT void add_metadata(string_handle const& name, double val) noexcept; - PIKA_EXPORT void add_metadata(string_handle const& name, char const* val) noexcept; - PIKA_EXPORT void add_metadata(string_handle const& name, void const* val) noexcept; - - template - void add_metadata(string_handle const& name, T const& val) noexcept - { - add_metadata(name, static_cast(&val)); - } - - domain const& domain_; - ___itt_id* id_ = nullptr; - string_handle sh_; - }; - - /////////////////////////////////////////////////////////////////////////// - struct heap_function - { - PIKA_EXPORT heap_function(char const* name, char const* domain) noexcept; - - __itt_heap_function heap_function_ = nullptr; - }; - - struct heap_internal_access - { - PIKA_EXPORT heap_internal_access() noexcept; - PIKA_EXPORT ~heap_internal_access(); - }; - - struct heap_allocate - { - template - heap_allocate(heap_function& heap_function, T**& addr, std::size_t size, int init) noexcept - : heap_function_(heap_function) - , addr_(reinterpret_cast(addr)) - , size_(size) - , init_(init) - { - if (use_ittnotify_api) - { - PIKA_ITT_HEAP_ALLOCATE_BEGIN(heap_function_.heap_function_, size_, init_); - } - } - - ~heap_allocate() - { - if (use_ittnotify_api) - { - PIKA_ITT_HEAP_ALLOCATE_END(heap_function_.heap_function_, addr_, size_, init_); - } - } - - private: - heap_function& heap_function_; - void**& addr_; - std::size_t size_; - int init_; - }; - - struct heap_free - { - PIKA_EXPORT heap_free(heap_function& heap_function, void* addr) noexcept; - PIKA_EXPORT ~heap_free(); - - private: - heap_function& heap_function_; - void* addr_; - }; - - /////////////////////////////////////////////////////////////////////////// - struct counter - { - PIKA_EXPORT counter(char const* name, char const* domain) noexcept; - PIKA_EXPORT counter(char const* name, char const* domain, int type) noexcept; - PIKA_EXPORT ~counter(); - - template - void set_value(T const& value) noexcept - { - if (use_ittnotify_api && id_) - { - PIKA_ITT_COUNTER_SET_VALUE( - id_, const_cast(static_cast(&value))); - } - } - - counter(counter const& rhs) = delete; - counter(counter&& rhs) noexcept - : id_(rhs.id_) - { - rhs.id_ = nullptr; - } - - counter& operator=(counter const& rhs) = delete; - counter& operator=(counter&& rhs) noexcept - { - if (this != &rhs) - { - id_ = rhs.id_; - rhs.id_ = nullptr; - } - return *this; - } - - private: - ___itt_counter* id_ = nullptr; - }; - - /////////////////////////////////////////////////////////////////////////// - struct event - { - event(char const* name) noexcept - : event_(itt_event_create(name, (int) strnlen(name, 256))) - { - } - - void start() const noexcept { itt_event_start(event_); } - - void end() const noexcept { itt_event_end(event_); } - - private: - int event_ = 0; - }; - - struct mark_event - { - mark_event(event const& e) noexcept - : e_(e) - { - e_.start(); - } - ~mark_event() { e_.end(); } - - private: - event e_; - }; - - inline void event_tick(event const& e) noexcept { e.start(); } -}}} // namespace pika::util::itt - -#else - -inline constexpr void itt_sync_create(void*, char const*, char const*) noexcept {} -inline constexpr void itt_sync_rename(void*, char const*) noexcept {} -inline constexpr void itt_sync_prepare(void*) noexcept {} -inline constexpr void itt_sync_acquired(void*) noexcept {} -inline constexpr void itt_sync_cancel(void*) noexcept {} -inline constexpr void itt_sync_releasing(void*) noexcept {} -inline constexpr void itt_sync_released(void*) noexcept {} -inline constexpr void itt_sync_destroy(void*) noexcept {} - -inline constexpr ___itt_caller* itt_stack_create() noexcept { return nullptr; } -inline constexpr void itt_stack_enter(___itt_caller*) noexcept {} -inline constexpr void itt_stack_leave(___itt_caller*) noexcept {} -inline constexpr void itt_stack_destroy(___itt_caller*) noexcept {} - -inline constexpr void itt_frame_begin(___itt_domain const*, ___itt_id*) noexcept {} -inline constexpr void itt_frame_end(___itt_domain const*, ___itt_id*) noexcept {} - -inline constexpr int itt_mark_create(char const*) noexcept { return 0; } -inline constexpr void itt_mark_off(int) noexcept {} -inline constexpr void itt_mark(int, char const*) noexcept {} - -inline constexpr void itt_thread_set_name(char const*) noexcept {} -inline constexpr void itt_thread_ignore() noexcept {} - -inline constexpr void itt_task_begin(___itt_domain const*, ___itt_string_handle*) noexcept {} -inline constexpr void itt_task_begin( - ___itt_domain const*, ___itt_id*, ___itt_string_handle*) noexcept -{ -} -inline constexpr void itt_task_end(___itt_domain const*) noexcept {} - -inline constexpr ___itt_domain* itt_domain_create(char const*) noexcept { return nullptr; } -inline constexpr ___itt_string_handle* itt_string_handle_create(char const*) noexcept -{ - return nullptr; -} - -inline constexpr ___itt_id* itt_make_id(void*, unsigned long) { return nullptr; } -inline constexpr void itt_id_create(___itt_domain const*, ___itt_id*) noexcept {} -inline constexpr void itt_id_destroy(___itt_id*) noexcept {} - -inline constexpr __itt_heap_function itt_heap_function_create(char const*, char const*) noexcept -{ - return nullptr; -} -inline constexpr void itt_heap_allocate_begin(__itt_heap_function, std::size_t, int) noexcept {} -inline constexpr void itt_heap_allocate_end(__itt_heap_function, void**, std::size_t, int) noexcept -{ -} -inline constexpr void itt_heap_free_begin(__itt_heap_function, void*) noexcept {} -inline constexpr void itt_heap_free_end(__itt_heap_function, void*) noexcept {} -inline constexpr void itt_heap_reallocate_begin( - __itt_heap_function, void*, std::size_t, int) noexcept -{ -} -inline constexpr void itt_heap_reallocate_end( - __itt_heap_function, void*, void**, std::size_t, int) noexcept -{ -} -inline constexpr void itt_heap_internal_access_begin() noexcept {} -inline constexpr void itt_heap_internal_access_end() noexcept {} - -inline constexpr ___itt_counter* itt_counter_create(char const*, char const*) noexcept -{ - return nullptr; -} -inline constexpr ___itt_counter* itt_counter_create_typed(char const*, char const*, int) noexcept -{ - return nullptr; -} -inline constexpr void itt_counter_destroy(___itt_counter*) noexcept {} -inline constexpr void itt_counter_set_value(___itt_counter*, void*) noexcept {} - -inline constexpr int itt_event_create(char const*, int) noexcept { return 0; } -inline constexpr int itt_event_start(int) noexcept { return 0; } -inline constexpr int itt_event_end(int) noexcept { return 0; } - -inline constexpr void itt_metadata_add( - ___itt_domain*, ___itt_id*, ___itt_string_handle*, std::uint64_t const&) noexcept -{ -} -inline constexpr void itt_metadata_add( - ___itt_domain*, ___itt_id*, ___itt_string_handle*, double const&) noexcept -{ -} -inline constexpr void itt_metadata_add( - ___itt_domain*, ___itt_id*, ___itt_string_handle*, char const*) noexcept -{ -} -inline constexpr void itt_metadata_add( - ___itt_domain*, ___itt_id*, ___itt_string_handle*, void const*) noexcept -{ -} - -////////////////////////////////////////////////////////////////////////////// -namespace pika::detail { - - struct thread_description; - -} // namespace pika::detail - -namespace pika::util::itt { - - struct stack_context - { - stack_context() = default; - ~stack_context() = default; - }; - - struct caller_context - { - constexpr caller_context(stack_context&) noexcept {} - ~caller_context() = default; - }; - - ////////////////////////////////////////////////////////////////////////// - struct domain - { - PIKA_NON_COPYABLE(domain); - - constexpr domain(char const*) noexcept {} - domain() = default; - }; - - struct thread_domain : domain - { - PIKA_NON_COPYABLE(thread_domain); - - thread_domain() = default; - }; - - struct id - { - constexpr id(domain const&, void*, unsigned long = 0) noexcept {} - ~id() = default; - }; - - /////////////////////////////////////////////////////////////////////////// - struct frame_context - { - constexpr frame_context(domain const&, id* = nullptr) noexcept {} - ~frame_context() = default; - }; - - struct undo_frame_context - { - constexpr undo_frame_context(frame_context const&) noexcept {} - ~undo_frame_context() = default; - }; - - /////////////////////////////////////////////////////////////////////////// - struct mark_context - { - constexpr mark_context(char const*) noexcept {} - ~mark_context() = default; - }; - - struct undo_mark_context - { - constexpr undo_mark_context(mark_context const&) noexcept {} - ~undo_mark_context() = default; - }; - - /////////////////////////////////////////////////////////////////////////// - struct string_handle - { - constexpr string_handle(char const* = nullptr) noexcept {} - }; - - ////////////////////////////////////////////////////////////////////////// - struct task - { - constexpr task(domain const&, string_handle const&, std::uint64_t) noexcept {} - constexpr task(domain const&, string_handle const&) noexcept {} - - ~task() = default; - }; - - /////////////////////////////////////////////////////////////////////////// - struct heap_function - { - constexpr heap_function(char const*, char const*) noexcept {} - ~heap_function() = default; - }; - - struct heap_allocate - { - template - constexpr heap_allocate(heap_function& /*heap_function*/, T**, std::size_t, int) noexcept - { - } - ~heap_allocate() = default; - }; - - struct heap_free - { - constexpr heap_free(heap_function& /*heap_function*/, void*) noexcept {} - ~heap_free() = default; - }; - - struct heap_internal_access - { - heap_internal_access() = default; - ~heap_internal_access() = default; - }; - - struct counter - { - constexpr counter(char const* /*name*/, char const* /*domain*/) noexcept {} - ~counter() = default; - }; - - struct event - { - constexpr event(char const*) noexcept {} - }; - - struct mark_event - { - constexpr mark_event(event const&) noexcept {} - ~mark_event() = default; - }; - - inline constexpr void event_tick(event const&) noexcept {} -} // namespace pika::util::itt - -#endif // PIKA_HAVE_ITTNOTIFY diff --git a/libs/pika/itt_notify/src/itt_notify.cpp b/libs/pika/itt_notify/src/itt_notify.cpp deleted file mode 100644 index 557b180b5..000000000 --- a/libs/pika/itt_notify/src/itt_notify.cpp +++ /dev/null @@ -1,603 +0,0 @@ -// Copyright (c) 2007-2021 Hartmut Kaiser -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include -#include - -#if PIKA_HAVE_ITTNOTIFY != 0 - -# define INTEL_ITTNOTIFY_API_PRIVATE - -# include -# include - -# include -# include -# include - -/////////////////////////////////////////////////////////////////////////////// -// decide whether to use the ITT notify API if it's available -bool use_ittnotify_api = false; - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_SYNC_CREATE(obj, type, name) \ - if (use_ittnotify_api && __itt_sync_create_ptr) \ - { \ - __itt_sync_create_ptr( \ - const_cast(static_cast(obj)), type, name, __itt_attr_mutex); \ - } \ - /**/ -# define PIKA_INTERNAL_ITT_SYNC(fname, obj) \ - if (use_ittnotify_api && __itt_##fname##_ptr) \ - { \ - __itt_##fname##_ptr(const_cast(static_cast(obj))); \ - } \ - /**/ -# define PIKA_INTERNAL_ITT_SYNC_RENAME(obj, name) \ - if (use_ittnotify_api && __itt_sync_rename_ptr) \ - { \ - __itt_sync_rename_ptr(const_cast(static_cast(obj)), name); \ - } \ - /**/ - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_STACK_CREATE() \ - (use_ittnotify_api && __itt_stack_caller_create_ptr) ? __itt_stack_caller_create_ptr() : \ - (__itt_caller) nullptr /**/ -# define PIKA_INTERNAL_ITT_STACK_ENTER(ctx) \ - if (use_ittnotify_api && __itt_stack_callee_enter_ptr) __itt_stack_callee_enter_ptr(ctx); \ - /**/ -# define PIKA_INTERNAL_ITT_STACK_LEAVE(ctx) \ - if (use_ittnotify_api && __itt_stack_callee_leave_ptr) __itt_stack_callee_leave_ptr(ctx); \ - /**/ -# define PIKA_INTERNAL_ITT_STACK_DESTROY(ctx) \ - if (use_ittnotify_api && __itt_stack_caller_destroy_ptr && ctx != (__itt_caller) nullptr) \ - __itt_stack_caller_destroy_ptr(ctx); \ - /**/ - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_FRAME_BEGIN(domain, id) \ - if (use_ittnotify_api && __itt_frame_begin_v3_ptr) __itt_frame_begin_v3_ptr(domain, id); \ - /**/ -# define PIKA_INTERNAL_ITT_FRAME_END(domain, id) \ - if (use_ittnotify_api && __itt_frame_end_v3_ptr) __itt_frame_end_v3_ptr(domain, id); \ - /**/ - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_MARK_CREATE(name) \ - (use_ittnotify_api && __itt_mark_create_ptr) ? __itt_mark_create_ptr(name) : 0 /**/ -# define PIKA_INTERNAL_ITT_MARK_OFF(mark) \ - if (use_ittnotify_api && __itt_mark_off_ptr) __itt_mark_off_ptr(mark); \ - /**/ -# define PIKA_INTERNAL_ITT_MARK(mark, parameter) \ - if (use_ittnotify_api && __itt_mark_ptr) __itt_mark_ptr(mark, parameter); \ - /**/ - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_THREAD_SET_NAME(name) \ - if (use_ittnotify_api && __itt_thread_set_name_ptr) __itt_thread_set_name_ptr(name); \ - /**/ -# define PIKA_INTERNAL_ITT_THREAD_IGNORE() \ - if (use_ittnotify_api && __itt_thread_ignore_ptr) __itt_thread_ignore_ptr(); \ - /**/ - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_TASK_BEGIN(domain, name) \ - if (use_ittnotify_api && __itt_task_begin_ptr) \ - __itt_task_begin_ptr(domain, __itt_null, __itt_null, name); \ - /**/ -# define PIKA_INTERNAL_ITT_TASK_BEGIN_ID(domain, id, name) \ - if (use_ittnotify_api && __itt_task_begin_ptr) \ - __itt_task_begin_ptr(domain, id, __itt_null, name); \ - /**/ -# define PIKA_INTERNAL_ITT_TASK_END(domain) \ - if (use_ittnotify_api && __itt_task_end_ptr) __itt_task_end_ptr(domain); \ - /**/ - -# define PIKA_INTERNAL_ITT_DOMAIN_CREATE(name) \ - (use_ittnotify_api && __itt_domain_create_ptr) ? __itt_domain_create_ptr(name) : nullptr /**/ - -# define PIKA_INTERNAL_ITT_STRING_HANDLE_CREATE(name) \ - (use_ittnotify_api && __itt_string_handle_create_ptr) ? \ - __itt_string_handle_create_ptr(name) : \ - nullptr /**/ - -# define PIKA_INTERNAL_ITT_MAKE_ID(addr, extra) \ - use_ittnotify_api ? __itt_id_make(addr, extra) : __itt_null /**/ - -# define PIKA_INTERNAL_ITT_ID_CREATE(domain, id) \ - if (use_ittnotify_api && __itt_id_create_ptr) __itt_id_create_ptr(domain, id); \ - /**/ -# define PIKA_INTERNAL_ITT_ID_DESTROY(id) delete id - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_HEAP_FUNCTION_CREATE(name, domain) \ - (use_ittnotify_api && __itt_heap_function_create_ptr) ? \ - __itt_heap_function_create_ptr(name, domain) : \ - nullptr /**/ - -# define PIKA_INTERNAL_HEAP_ALLOCATE_BEGIN(f, size, init) \ - if (use_ittnotify_api && __itt_heap_allocate_begin_ptr) \ - __itt_heap_allocate_begin_ptr(f, size, init); \ - /**/ -# define PIKA_INTERNAL_HEAP_ALLOCATE_END(f, addr, size, init) \ - if (use_ittnotify_api && __itt_heap_allocate_end_ptr) \ - __itt_heap_allocate_end_ptr(f, addr, size, init); \ - /**/ - -# define PIKA_INTERNAL_HEAP_FREE_BEGIN(f, addr) \ - if (use_ittnotify_api && __itt_heap_free_begin_ptr) __itt_heap_free_begin_ptr(f, addr); \ - /**/ -# define PIKA_INTERNAL_HEAP_FREE_END(f, addr) \ - if (use_ittnotify_api && __itt_heap_free_end_ptr) __itt_heap_free_end_ptr(f, addr); \ - /**/ - -# define PIKA_INTERNAL_HEAP_REALLOCATE_BEGIN(f, addr, size, init) \ - if (use_ittnotify_api && __itt_heap_reallocate_begin_ptr) \ - __itt_heap_reallocate_begin_ptr(f, addr, size, init); \ - /**/ -# define PIKA_INTERNAL_HEAP_REALLOCATE_END(f, addr, new_addr, size, init) \ - if (use_ittnotify_api && __itt_heap_reallocate_end_ptr) \ - __itt_heap_reallocate_end_ptr(f, addr, new_addr, size, init); \ - /**/ - -# define PIKA_INTERNAL_INTERNAL_ACCESS_BEGIN() \ - if (use_ittnotify_api && __itt_heap_internal_access_begin_ptr) \ - __itt_heap_internal_access_begin_ptr(); \ - /**/ -# define PIKA_INTERNAL_INTERNAL_ACCESS_END() \ - if (use_ittnotify_api && __itt_heap_internal_access_end_ptr) \ - __itt_heap_internal_access_end_ptr(); \ - /**/ - -/////////////////////////////////////////////////////////////////////////////// -# if defined(__itt_counter_create_typed_ptr) && defined(__itt_counter_set_value_ptr) -# define PIKA_INTERNAL_COUNTER_CREATE(name, domain) \ - (use_ittnotify_api && __itt_counter_create_ptr) ? __itt_counter_create_ptr(name, domain) : \ - (__itt_counter) nullptr /**/ -# define PIKA_INTERNAL_COUNTER_CREATE_TYPED(name, domain, type) \ - (use_ittnotify_api && __itt_counter_create_typed_ptr) ? \ - __itt_counter_create_typed_ptr(name, domain, type) : \ - (__itt_counter) nullptr /**/ -# define PIKA_INTERNAL_COUNTER_SET_VALUE(id, value_ptr) \ - if (use_ittnotify_api && __itt_counter_set_value_ptr) \ - __itt_counter_set_value_ptr(id, value_ptr); \ - /**/ -# define PIKA_INTERNAL_COUNTER_DESTROY(id) \ - if (use_ittnotify_api && __itt_counter_destroy_ptr) __itt_counter_destroy_ptr(id); \ - /**/ -# else -// older itt-notify implementations don't support the typed counter API -# define PIKA_INTERNAL_COUNTER_CREATE(name, domain) (__itt_counter) nullptr /**/ -# define PIKA_INTERNAL_COUNTER_CREATE_TYPED(name, domain, type) (__itt_counter) nullptr /**/ -# define PIKA_INTERNAL_COUNTER_SET_VALUE(id, value_ptr) /**/ -# define PIKA_INTERNAL_COUNTER_DESTROY(id) /**/ -# endif - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_EVENT_CREATE(name, len) \ - (use_ittnotify_api && __itt_event_create_ptr) ? __itt_event_create_ptr(name, len) : 0; \ - /**/ -# define PIKA_INTERNAL_EVENT_START(e) \ - (use_ittnotify_api && __itt_event_start_ptr) ? __itt_event_start_ptr(e) : 0 /**/ -# define PIKA_INTERNAL_EVENT_END(e) \ - (use_ittnotify_api && __itt_event_end_ptr) ? __itt_event_end_ptr(e) : 0 /**/ - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_METADATA_ADD(domain, id, key, type, count, data) \ - if (use_ittnotify_api && __itt_metadata_add_ptr) \ - __itt_metadata_add_ptr(domain, id, key, type, count, data) /**/ -# define PIKA_INTERNAL_METADATA_STR_ADD(domain, id, key, data) \ - if (use_ittnotify_api && __itt_metadata_str_add_ptr) \ - __itt_metadata_str_add_ptr(domain, id, key, data, 0) /**/ - -/////////////////////////////////////////////////////////////////////////////// -# if defined(PIKA_MSVC) || defined(__BORLANDC__) || \ - (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) || \ - (defined(__ICL) && defined(_MSC_EXTENSIONS) && (PIKA_MSVC >= 1200)) - -# pragma comment(lib, "libittnotify.lib") -# endif - -/////////////////////////////////////////////////////////////////////////////// -# define PIKA_INTERNAL_ITT_SYNC_PREPARE(obj) PIKA_INTERNAL_ITT_SYNC(sync_prepare, obj) -# define PIKA_INTERNAL_ITT_SYNC_CANCEL(obj) PIKA_INTERNAL_ITT_SYNC(sync_cancel, obj) -# define PIKA_INTERNAL_ITT_SYNC_ACQUIRED(obj) PIKA_INTERNAL_ITT_SYNC(sync_acquired, obj) -# define PIKA_INTERNAL_ITT_SYNC_RELEASING(obj) PIKA_INTERNAL_ITT_SYNC(sync_releasing, obj) -# define PIKA_INTERNAL_ITT_SYNC_RELEASED(obj) \ - ((void) 0) //PIKA_INTERNAL_ITT_SYNC(sync_released, obj) -# define PIKA_INTERNAL_ITT_SYNC_DESTROY(obj) PIKA_INTERNAL_ITT_SYNC(sync_destroy, obj) - -/////////////////////////////////////////////////////////////////////////////// -namespace pika { namespace util { namespace itt { - - stack_context::stack_context() { PIKA_ITT_STACK_CREATE(itt_context_); } - - stack_context::~stack_context() - { - if (itt_context_) { PIKA_ITT_STACK_DESTROY(itt_context_); } - } - - caller_context::caller_context(stack_context& ctx) - : ctx_(ctx) - { - if (ctx.itt_context_) { PIKA_ITT_STACK_CALLEE_ENTER(ctx_.itt_context_); } - } - - caller_context::~caller_context() - { - if (ctx_.itt_context_) { PIKA_ITT_STACK_CALLEE_LEAVE(ctx_.itt_context_); } - } - - domain::domain(char const* name) noexcept - : domain_(PIKA_ITT_DOMAIN_CREATE(name)) - { - if (domain_ != nullptr) { domain_->flags = 1; } - } - - static thread_local std::unique_ptr<___itt_domain> thread_domain_; - - thread_domain::thread_domain() noexcept - : domain() - { - if (thread_domain_.get() == nullptr) - { - thread_domain_.reset(PIKA_ITT_DOMAIN_CREATE(detail::thread_name().c_str())); - } - - domain_ = thread_domain_.get(); - - if (domain_ != nullptr) { domain_->flags = 1; } - } - - id::id(domain const& domain, void* addr, unsigned long extra) noexcept - { - if (use_ittnotify_api) - { - id_ = PIKA_ITT_MAKE_ID(addr, extra); - PIKA_ITT_ID_CREATE(domain.domain_, id_); - } - } - - id::~id() - { - if (use_ittnotify_api) { PIKA_ITT_ID_DESTROY(id_); } - } - - frame_context::frame_context(domain const& domain, id* ident) noexcept - : domain_(domain) - , ident_(ident) - { - PIKA_ITT_FRAME_BEGIN(domain_.domain_, ident_ ? ident_->id_ : nullptr); - } - - frame_context::~frame_context() - { - PIKA_ITT_FRAME_END(domain_.domain_, ident_ ? ident_->id_ : nullptr); - } - - undo_frame_context::undo_frame_context(frame_context& frame) noexcept - : frame_(frame) - { - PIKA_ITT_FRAME_END(frame_.domain_.domain_, nullptr); - } - - undo_frame_context::~undo_frame_context() - { - PIKA_ITT_FRAME_BEGIN(frame_.domain_.domain_, nullptr); - } - - mark_context::mark_context(char const* name) noexcept - : itt_mark_(0) - , name_(name) - { - PIKA_ITT_MARK_CREATE(itt_mark_, name); - } - - mark_context::~mark_context() { PIKA_ITT_MARK_OFF(itt_mark_); } - - undo_mark_context::undo_mark_context(mark_context& mark) noexcept - : mark_(mark) - { - PIKA_ITT_MARK_OFF(mark_.itt_mark_); - } - undo_mark_context::~undo_mark_context() - { - PIKA_ITT_MARK_CREATE(mark_.itt_mark_, mark_.name_); - } - - string_handle::string_handle(char const* s) noexcept - : handle_(s == nullptr ? nullptr : PIKA_ITT_STRING_HANDLE_CREATE(s)) - { - } - - task::task(domain const& domain, string_handle const& name) noexcept - : domain_(domain) - , sh_(name) - { - if (use_ittnotify_api) - { - id_ = PIKA_ITT_MAKE_ID( - domain_.domain_, reinterpret_cast(sh_.handle_)); - - PIKA_ITT_TASK_BEGIN_ID(domain_.domain_, id_, sh_.handle_); - } - } - - task::task( - domain const& domain, string_handle const& name, std::uint64_t metadata) noexcept - : domain_(domain) - , sh_(name) - { - if (use_ittnotify_api) - { - id_ = PIKA_ITT_MAKE_ID( - domain_.domain_, reinterpret_cast(sh_.handle_)); - - PIKA_ITT_TASK_BEGIN_ID(domain_.domain_, id_, sh_.handle_); - add_metadata(sh_.handle_, metadata); - } - } - - task::~task() - { - if (use_ittnotify_api) - { - PIKA_ITT_TASK_END(domain_.domain_); - delete id_; - } - } - - void task::add_metadata(string_handle const& name, std::uint64_t val) noexcept - { - PIKA_ITT_METADATA_ADD(domain_.domain_, id_, name.handle_, val); - } - - void task::add_metadata(string_handle const& name, double val) noexcept - { - PIKA_ITT_METADATA_ADD(domain_.domain_, id_, name.handle_, val); - } - - void task::add_metadata(string_handle const& name, char const* val) noexcept - { - PIKA_ITT_METADATA_ADD(domain_.domain_, id_, name.handle_, val); - } - - void task::add_metadata(string_handle const& name, void const* val) noexcept - { - PIKA_ITT_METADATA_ADD(domain_.domain_, id_, name.handle_, val); - } - - heap_function::heap_function(char const* name, char const* domain) noexcept - : heap_function_(PIKA_ITT_HEAP_FUNCTION_CREATE(name, domain)) - { - } - - heap_internal_access::heap_internal_access() noexcept - { - PIKA_ITT_HEAP_INTERNAL_ACCESS_BEGIN(); - } - - heap_internal_access::~heap_internal_access() { PIKA_ITT_HEAP_INTERNAL_ACCESS_END(); } - - heap_free::heap_free(heap_function& heap_function, void* addr) noexcept - : heap_function_(heap_function) - , addr_(addr) - { - PIKA_ITT_HEAP_FREE_BEGIN(heap_function_.heap_function_, addr_); - } - - heap_free::~heap_free() - { - PIKA_ITT_HEAP_FREE_END(heap_function_.heap_function_, addr_); - } - - counter::counter(char const* name, char const* domain) noexcept - : id_(PIKA_ITT_COUNTER_CREATE(name, domain)) - { - } - - counter::counter(char const* name, char const* domain, int type) noexcept - : id_(PIKA_ITT_COUNTER_CREATE_TYPED(name, domain, type)) - { - } - - counter::~counter() - { - if (id_) { PIKA_ITT_COUNTER_DESTROY(id_); } - } -}}} // namespace pika::util::itt - -/////////////////////////////////////////////////////////////////////////////// -void itt_sync_create(void* addr, char const* objtype, char const* objname) noexcept -{ - PIKA_INTERNAL_ITT_SYNC_CREATE(addr, objtype, objname); -} - -void itt_sync_rename(void* addr, char const* objname) noexcept -{ - PIKA_INTERNAL_ITT_SYNC_RENAME(addr, objname); -} - -void itt_sync_prepare(void* addr) noexcept { PIKA_INTERNAL_ITT_SYNC_PREPARE(addr); } - -void itt_sync_acquired(void* addr) noexcept { PIKA_INTERNAL_ITT_SYNC_ACQUIRED(addr); } - -void itt_sync_cancel(void* addr) noexcept { PIKA_INTERNAL_ITT_SYNC_CANCEL(addr); } - -void itt_sync_releasing(void* addr) noexcept { PIKA_INTERNAL_ITT_SYNC_RELEASING(addr); } - -void itt_sync_released(void* addr) noexcept { PIKA_INTERNAL_ITT_SYNC_RELEASED(addr); } - -void itt_sync_destroy(void* addr) noexcept { PIKA_INTERNAL_ITT_SYNC_DESTROY(addr); } - -/////////////////////////////////////////////////////////////////////////////// -__itt_caller itt_stack_create() noexcept { return PIKA_INTERNAL_ITT_STACK_CREATE(); } - -void itt_stack_enter(__itt_caller ctx) noexcept { PIKA_INTERNAL_ITT_STACK_ENTER(ctx); } - -void itt_stack_leave(__itt_caller ctx) noexcept { PIKA_INTERNAL_ITT_STACK_LEAVE(ctx); } - -void itt_stack_destroy(__itt_caller ctx) noexcept { PIKA_INTERNAL_ITT_STACK_DESTROY(ctx); } - -/////////////////////////////////////////////////////////////////////////////// -void itt_frame_begin(___itt_domain const* domain, ___itt_id* id) noexcept -{ - PIKA_INTERNAL_ITT_FRAME_BEGIN(domain, id); -} - -void itt_frame_end(___itt_domain const* domain, ___itt_id* id) noexcept -{ - PIKA_INTERNAL_ITT_FRAME_END(domain, id); -} - -/////////////////////////////////////////////////////////////////////////////// -int itt_mark_create(char const* name) noexcept { return PIKA_INTERNAL_ITT_MARK_CREATE(name); } - -void itt_mark_off(int mark) noexcept { PIKA_INTERNAL_ITT_MARK_OFF(mark); } - -void itt_mark(int mark, char const* par) noexcept { PIKA_INTERNAL_ITT_MARK(mark, par); } - -/////////////////////////////////////////////////////////////////////////////// -void itt_thread_set_name(char const* name) noexcept { PIKA_INTERNAL_ITT_THREAD_SET_NAME(name); } - -void itt_thread_ignore() noexcept { PIKA_INTERNAL_ITT_THREAD_IGNORE(); } - -/////////////////////////////////////////////////////////////////////////////// -void itt_task_begin(___itt_domain const* domain, ___itt_string_handle* name) noexcept -{ - PIKA_INTERNAL_ITT_TASK_BEGIN(domain, name); -} - -void itt_task_begin(___itt_domain const* domain, ___itt_id* id, ___itt_string_handle* name) noexcept -{ - PIKA_INTERNAL_ITT_TASK_BEGIN_ID(domain, *id, name); -} - -void itt_task_end(___itt_domain const* domain) noexcept { PIKA_INTERNAL_ITT_TASK_END(domain); } - -___itt_domain* itt_domain_create(char const* name) noexcept -{ - return PIKA_INTERNAL_ITT_DOMAIN_CREATE(name); -} - -___itt_string_handle* itt_string_handle_create(char const* name) noexcept -{ - return PIKA_INTERNAL_ITT_STRING_HANDLE_CREATE(name); -} - -___itt_id* itt_make_id(void* addr, std::size_t extra) -{ - return new ___itt_id(PIKA_INTERNAL_ITT_MAKE_ID(addr, extra)); -} - -void itt_id_create(___itt_domain const* domain, ___itt_id* id) noexcept -{ - PIKA_INTERNAL_ITT_ID_CREATE(domain, *id); -} - -void itt_id_destroy(___itt_id* id) noexcept { PIKA_INTERNAL_ITT_ID_DESTROY(id); } - -/////////////////////////////////////////////////////////////////////////////// -__itt_heap_function itt_heap_function_create(char const* name, char const* domain) noexcept -{ - return PIKA_INTERNAL_ITT_HEAP_FUNCTION_CREATE(name, domain); -} - -void itt_heap_allocate_begin(__itt_heap_function f, std::size_t size, int init) noexcept -{ - PIKA_INTERNAL_HEAP_ALLOCATE_BEGIN(f, size, init); -} - -void itt_heap_allocate_end(__itt_heap_function f, void** addr, std::size_t size, int init) noexcept -{ - PIKA_INTERNAL_HEAP_ALLOCATE_END(f, addr, size, init); -} - -void itt_heap_free_begin(__itt_heap_function f, void* addr) noexcept -{ - PIKA_INTERNAL_HEAP_FREE_BEGIN(f, addr); -} - -void itt_heap_free_end(__itt_heap_function f, void* addr) noexcept -{ - PIKA_INTERNAL_HEAP_FREE_END(f, addr); -} - -void itt_heap_reallocate_begin( - __itt_heap_function f, void* addr, std::size_t new_size, int init) noexcept -{ - PIKA_INTERNAL_HEAP_REALLOCATE_BEGIN(f, addr, new_size, init); -} - -void itt_heap_reallocate_end( - __itt_heap_function f, void* addr, void** new_addr, std::size_t new_size, int init) noexcept -{ - PIKA_INTERNAL_HEAP_REALLOCATE_END(f, addr, new_addr, new_size, init); -} - -void itt_heap_internal_access_begin() noexcept { PIKA_INTERNAL_INTERNAL_ACCESS_BEGIN(); } - -void itt_heap_internal_access_end() noexcept { PIKA_INTERNAL_INTERNAL_ACCESS_END(); } - -/////////////////////////////////////////////////////////////////////////////// -__itt_counter itt_counter_create(char const* name, char const* domain) noexcept -{ - return PIKA_INTERNAL_COUNTER_CREATE(name, domain); -} - -__itt_counter itt_counter_create_typed(char const* name, char const* domain, int type) noexcept -{ - return PIKA_INTERNAL_COUNTER_CREATE_TYPED(name, domain, (__itt_metadata_type) type); -} - -void itt_counter_destroy(__itt_counter id) noexcept { PIKA_INTERNAL_COUNTER_DESTROY(id); } - -void itt_counter_set_value(__itt_counter id, void* value_ptr) noexcept -{ - PIKA_INTERNAL_COUNTER_SET_VALUE(id, value_ptr); -} - -/////////////////////////////////////////////////////////////////////////////// -__itt_event itt_event_create(char const* name, int namelen) noexcept -{ - return PIKA_INTERNAL_EVENT_CREATE(name, namelen); -} - -int itt_event_start(__itt_event evnt) noexcept { return PIKA_INTERNAL_EVENT_START(evnt); } - -int itt_event_end(__itt_event evnt) noexcept { return PIKA_INTERNAL_EVENT_END(evnt); } - -/////////////////////////////////////////////////////////////////////////////// -void itt_metadata_add(___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, - std::uint64_t const& data) noexcept -{ - PIKA_INTERNAL_METADATA_ADD( - domain, *id, key, __itt_metadata_u64, 1, const_cast(&data)); -} - -void itt_metadata_add( - ___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, double const& data) noexcept -{ - PIKA_INTERNAL_METADATA_ADD( - domain, *id, key, __itt_metadata_double, 1, const_cast(&data)); -} - -void itt_metadata_add( - ___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, char const* data) noexcept -{ - PIKA_INTERNAL_METADATA_STR_ADD(domain, *id, key, data); -} - -void itt_metadata_add( - ___itt_domain* domain, ___itt_id* id, ___itt_string_handle* key, void const* data) noexcept -{ - PIKA_INTERNAL_METADATA_ADD( - domain, *id, key, __itt_metadata_unknown, 1, const_cast(data)); -} - -#endif // PIKA_HAVE_ITTNOTIFY diff --git a/libs/pika/itt_notify/src/thread_name.cpp b/libs/pika/itt_notify/src/thread_name.cpp deleted file mode 100644 index 611665ce7..000000000 --- a/libs/pika/itt_notify/src/thread_name.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2019 Mikael Simberg -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#include -#include - -#include - -namespace pika::detail { - std::string& thread_name() - { - static thread_local std::string thread_name_; - return thread_name_; - } -} // namespace pika::detail diff --git a/libs/pika/itt_notify/tests/CMakeLists.txt b/libs/pika/itt_notify/tests/CMakeLists.txt deleted file mode 100644 index 39a4141e8..000000000 --- a/libs/pika/itt_notify/tests/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2020 The STE||AR-Group -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -include(pika_message) -include(pika_option) - -if(PIKA_WITH_TESTS) - if(PIKA_WITH_TESTS_UNIT) - pika_add_pseudo_target(tests.unit.modules.itt_notify) - pika_add_pseudo_dependencies(tests.unit.modules tests.unit.modules.itt_notify) - add_subdirectory(unit) - endif() - - if(PIKA_WITH_TESTS_REGRESSIONS) - pika_add_pseudo_target(tests.regressions.modules.itt_notify) - pika_add_pseudo_dependencies(tests.regressions.modules tests.regressions.modules.itt_notify) - add_subdirectory(regressions) - endif() - - if(PIKA_WITH_TESTS_BENCHMARKS) - pika_add_pseudo_target(tests.performance.modules.itt_notify) - pika_add_pseudo_dependencies(tests.performance.modules tests.performance.modules.itt_notify) - add_subdirectory(performance) - endif() - - if(PIKA_WITH_TESTS_HEADERS) - pika_add_header_tests( - modules.itt_notify - HEADERS ${itt_notify_headers} - HEADER_ROOT ${PROJECT_SOURCE_DIR}/include - NOLIBS - DEPENDENCIES pika_itt_notify - ) - endif() -endif() diff --git a/libs/pika/itt_notify/tests/performance/CMakeLists.txt b/libs/pika/itt_notify/tests/performance/CMakeLists.txt deleted file mode 100644 index 7978545c2..000000000 --- a/libs/pika/itt_notify/tests/performance/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2020 The STE||AR-Group -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/libs/pika/itt_notify/tests/regressions/CMakeLists.txt b/libs/pika/itt_notify/tests/regressions/CMakeLists.txt deleted file mode 100644 index 7978545c2..000000000 --- a/libs/pika/itt_notify/tests/regressions/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2020 The STE||AR-Group -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/libs/pika/itt_notify/tests/unit/CMakeLists.txt b/libs/pika/itt_notify/tests/unit/CMakeLists.txt deleted file mode 100644 index 7978545c2..000000000 --- a/libs/pika/itt_notify/tests/unit/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2020 The STE||AR-Group -# -# SPDX-License-Identifier: BSL-1.0 -# Distributed under the Boost Software License, Version 1.0. (See accompanying -# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/libs/pika/modules.rst b/libs/pika/modules.rst index 386274e41..d1217d936 100644 --- a/libs/pika/modules.rst +++ b/libs/pika/modules.rst @@ -39,7 +39,6 @@ Core modules /libs/core/ini/docs/index.rst /libs/core/init_runtime/docs/index.rst /libs/core/iterator_support/docs/index.rst - /libs/core/itt_notify/docs/index.rst /libs/core/lock_registration/docs/index.rst /libs/core/logging/docs/index.rst /libs/core/memory/docs/index.rst diff --git a/libs/pika/runtime/CMakeLists.txt b/libs/pika/runtime/CMakeLists.txt index 5acdfedbe..8aae90bae 100644 --- a/libs/pika/runtime/CMakeLists.txt +++ b/libs/pika/runtime/CMakeLists.txt @@ -12,7 +12,6 @@ set(runtime_headers pika/runtime/debugging.hpp pika/runtime/detail/runtime_fwd.hpp pika/runtime/get_os_thread_count.hpp - pika/runtime/get_thread_name.hpp pika/runtime/get_worker_thread_num.hpp pika/runtime/report_error.hpp pika/runtime/runtime_handlers.hpp diff --git a/libs/pika/runtime/include/pika/runtime/get_thread_name.hpp b/libs/pika/runtime/include/pika/runtime/get_thread_name.hpp deleted file mode 100644 index 52ba68a1a..000000000 --- a/libs/pika/runtime/include/pika/runtime/get_thread_name.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2007-2014 Hartmut Kaiser -// Copyright (c) 2011 Bryce Lelbach -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -/// \file get_thread_name.hpp - -#pragma once - -#include - -#include - -namespace pika::detail { - /////////////////////////////////////////////////////////////////////////// - /// \brief Return the name of the calling thread. - /// - /// This function returns the name of the calling thread. This name uniquely - /// identifies the thread in the context of pika. If the function is called - /// while no pika runtime system is active, the result will be "". - PIKA_EXPORT std::string get_thread_name(); -} // namespace pika::detail diff --git a/libs/pika/runtime/include/pika/runtime/runtime_fwd.hpp b/libs/pika/runtime/include/pika/runtime/runtime_fwd.hpp index 773ee897e..baacfa202 100644 --- a/libs/pika/runtime/include/pika/runtime/runtime_fwd.hpp +++ b/libs/pika/runtime/include/pika/runtime/runtime_fwd.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/libs/pika/runtime/src/runtime.cpp b/libs/pika/runtime/src/runtime.cpp index a8fa7a851..f357e09a8 100644 --- a/libs/pika/runtime/src/runtime.cpp +++ b/libs/pika/runtime/src/runtime.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -29,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -534,13 +533,6 @@ namespace pika::detail { return runtime_; } - std::string get_thread_name() - { - std::string& thread_name = detail::thread_name(); - if (thread_name.empty()) return ""; - return thread_name; - } - // Register the current kernel thread with pika, this should be done once // for each external OS-thread intended to invoke pika functionality. // Calling this function more than once will silently fail @@ -1133,12 +1125,8 @@ namespace pika::detail { cond.notify_all(); } - // register this thread with any possibly active Intel tool std::string thread_name("main-thread#wait_helper"); - PIKA_ITT_THREAD_SET_NAME(thread_name.c_str()); - - // set thread name as shown in Visual Studio - detail::set_thread_name(thread_name.c_str()); + detail::set_thread_name(thread_name); #if defined(PIKA_HAVE_APEX) // not registering helper threads - for now @@ -1406,23 +1394,18 @@ namespace pika::detail { fullname << "/local:" + std::to_string(local_thread_num); } - PIKA_ASSERT(detail::thread_name().empty()); - detail::thread_name() = PIKA_MOVE(fullname).str(); - - char const* name = detail::thread_name().c_str(); - - // register this thread with any possibly active Intel tool - PIKA_ITT_THREAD_SET_NAME(name); + PIKA_ASSERT(detail::get_thread_name_internal().empty()); + detail::set_thread_name(PIKA_MOVE(fullname).str()); +#if defined(PIKA_HAVE_APEX) || defined(PIKA_HAVE_TRACY) + char const* name = detail::get_thread_name().c_str(); - // set thread name as shown in Visual Studio - detail::set_thread_name(name); - -#if defined(PIKA_HAVE_APEX) +# if defined(PIKA_HAVE_APEX) if (std::strstr(name, "worker") != nullptr) detail::external_timer::register_thread(name); -#endif +# endif -#ifdef PIKA_HAVE_TRACY +# ifdef PIKA_HAVE_TRACY tracy::SetThreadName(name); +# endif #endif // call thread-specific user-supplied on_start handler @@ -1440,7 +1423,7 @@ namespace pika::detail { if (on_stop_func_) { on_stop_func_(global_thread_num, global_thread_num, "", context); } // reset thread local storage - detail::thread_name().clear(); + detail::set_thread_name(""); } void runtime::add_pre_startup_function(startup_function_type f) @@ -1481,7 +1464,7 @@ namespace pika::detail { /// Unregister an external OS-thread with pika bool runtime::unregister_thread() { - deinit_tss_helper(detail::thread_name().c_str(), pika::get_worker_thread_num()); + deinit_tss_helper(detail::get_thread_name().c_str(), pika::get_worker_thread_num()); return true; } diff --git a/libs/pika/runtime_configuration/CMakeLists.txt b/libs/pika/runtime_configuration/CMakeLists.txt index 6d94089a0..02d1bff31 100644 --- a/libs/pika/runtime_configuration/CMakeLists.txt +++ b/libs/pika/runtime_configuration/CMakeLists.txt @@ -24,7 +24,6 @@ pika_add_module( pika_program_options pika_errors pika_filesystem - pika_itt_notify pika_logging pika_ini pika_coroutines diff --git a/libs/pika/runtime_configuration/include/pika/runtime_configuration/runtime_configuration.hpp b/libs/pika/runtime_configuration/include/pika/runtime_configuration/runtime_configuration.hpp index 12c38d4aa..33a3820d7 100644 --- a/libs/pika/runtime_configuration/include/pika/runtime_configuration/runtime_configuration.hpp +++ b/libs/pika/runtime_configuration/include/pika/runtime_configuration/runtime_configuration.hpp @@ -51,9 +51,6 @@ namespace pika::util { // default configuration loaded from pika.ini bool load_application_configuration(char const* filename, error_code& ec = throws); - // Can be set to true if we want to use the ITT notify tools API. - bool get_itt_notify_mode() const; - // Enable lock detection during suspension bool enable_lock_detection() const; diff --git a/libs/pika/runtime_configuration/src/runtime_configuration.cpp b/libs/pika/runtime_configuration/src/runtime_configuration.cpp index 769c865cc..0d4ca2d06 100644 --- a/libs/pika/runtime_configuration/src/runtime_configuration.cpp +++ b/libs/pika/runtime_configuration/src/runtime_configuration.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -231,9 +230,6 @@ namespace pika::util { // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) "master_ini_path_suffixes = /share/pika" PIKA_INI_PATH_DELIMITER "/../share/pika", -#ifdef PIKA_HAVE_ITTNOTIFY - "use_itt_notify = ${PIKA_HAVE_ITTNOTIFY:0}", -#endif "shutdown_check_count = ${PIKA_SHUTDOWN_CHECK_COUNT:10}", #ifdef PIKA_HAVE_VERIFY_LOCKS #if defined(PIKA_DEBUG) @@ -414,9 +410,6 @@ namespace pika::util { pre_initialize_ini(); // set global config options -#if PIKA_HAVE_ITTNOTIFY != 0 - use_ittnotify_api = get_itt_notify_mode(); -#endif PIKA_ASSERT(init_small_stack_size() >= PIKA_SMALL_STACK_SIZE); small_stacksize = init_small_stack_size(); @@ -446,9 +439,6 @@ namespace pika::util { post_initialize_ini(pika_ini_file, cmdline_ini_defs); // set global config options -#if PIKA_HAVE_ITTNOTIFY != 0 - use_ittnotify_api = get_itt_notify_mode(); -#endif PIKA_ASSERT(init_small_stack_size() >= PIKA_SMALL_STACK_SIZE); small_stacksize = init_small_stack_size(); @@ -457,17 +447,6 @@ namespace pika::util { huge_stacksize = init_huge_stack_size(); } - bool runtime_configuration::get_itt_notify_mode() const - { -#if PIKA_HAVE_ITTNOTIFY != 0 - if (pika::detail::section const* sec = get_section("pika"); nullptr != sec) - { - return pika::detail::get_entry_as(*sec, "use_itt_notify", 0) != 0; - } -#endif - return false; - } - // Enable lock detection during suspension bool runtime_configuration::enable_lock_detection() const { diff --git a/libs/pika/synchronization/CMakeLists.txt b/libs/pika/synchronization/CMakeLists.txt index e85fd5665..3e9ca4de1 100644 --- a/libs/pika/synchronization/CMakeLists.txt +++ b/libs/pika/synchronization/CMakeLists.txt @@ -45,7 +45,6 @@ pika_add_module( pika_errors pika_functional pika_hashing - pika_itt_notify pika_memory pika_lock_registration pika_logging diff --git a/libs/pika/synchronization/src/mutex.cpp b/libs/pika/synchronization/src/mutex.cpp index 305150e80..f98427ab2 100644 --- a/libs/pika/synchronization/src/mutex.cpp +++ b/libs/pika/synchronization/src/mutex.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -22,26 +21,22 @@ namespace pika { /////////////////////////////////////////////////////////////////////////// - mutex::mutex(char const* const description) + mutex::mutex(char const* const /* description */) : owner_id_(threads::detail::invalid_thread_id) { - PIKA_ITT_SYNC_CREATE(this, "lcos::local::mutex", description); - PIKA_ITT_SYNC_RENAME(this, "lcos::local::mutex"); } - mutex::~mutex() { PIKA_ITT_SYNC_DESTROY(this); } + mutex::~mutex() {} void mutex::lock(char const* description, error_code& ec) { PIKA_ASSERT(threads::detail::get_self_ptr() != nullptr); - PIKA_ITT_SYNC_PREPARE(this); std::unique_lock l(mtx_); threads::detail::thread_id_type self_id = pika::threads::detail::get_self_id(); if (owner_id_ == self_id) { - PIKA_ITT_SYNC_CANCEL(this); l.unlock(); PIKA_THROWS_IF(ec, pika::error::deadlock, description, "The calling thread already owns the mutex"); @@ -51,15 +46,10 @@ namespace pika { while (owner_id_ != threads::detail::invalid_thread_id) { cond_.wait(l, ec); - if (ec) - { - PIKA_ITT_SYNC_CANCEL(this); - return; - } + if (ec) { return; } } util::register_lock(this); - PIKA_ITT_SYNC_ACQUIRED(this); owner_id_ = self_id; } @@ -67,18 +57,12 @@ namespace pika { { PIKA_ASSERT(threads::detail::get_self_ptr() != nullptr); - PIKA_ITT_SYNC_PREPARE(this); std::unique_lock l(mtx_); - if (owner_id_ != threads::detail::invalid_thread_id) - { - PIKA_ITT_SYNC_CANCEL(this); - return false; - } + if (owner_id_ != threads::detail::invalid_thread_id) { return false; } threads::detail::thread_id_type self_id = pika::threads::detail::get_self_id(); util::register_lock(this); - PIKA_ITT_SYNC_ACQUIRED(this); owner_id_ = self_id; return true; } @@ -87,7 +71,6 @@ namespace pika { { PIKA_ASSERT(threads::detail::get_self_ptr() != nullptr); - PIKA_ITT_SYNC_RELEASING(this); // Unregister lock early as the lock guard below may suspend. util::unregister_lock(this); std::unique_lock l(mtx_); @@ -101,7 +84,6 @@ namespace pika { return; } - PIKA_ITT_SYNC_RELEASED(this); owner_id_ = threads::detail::invalid_thread_id; { @@ -124,7 +106,6 @@ namespace pika { { PIKA_ASSERT(threads::detail::get_self_ptr() != nullptr); - PIKA_ITT_SYNC_PREPARE(this); std::unique_lock l(mtx_); threads::detail::thread_id_type self_id = pika::threads::detail::get_self_id(); @@ -132,27 +113,20 @@ namespace pika { { pika::threads::detail::thread_restart_state const reason = cond_.wait_until(l, abs_time, ec); - if (ec) - { - PIKA_ITT_SYNC_CANCEL(this); - return false; - } + if (ec) { return false; } if (reason == pika::threads::detail::thread_restart_state::timeout) //-V110 { - PIKA_ITT_SYNC_CANCEL(this); return false; } if (owner_id_ != threads::detail::invalid_thread_id) //-V110 { - PIKA_ITT_SYNC_CANCEL(this); return false; } } util::register_lock(this); - PIKA_ITT_SYNC_ACQUIRED(this); owner_id_ = self_id; return true; } diff --git a/libs/pika/thread_pools/CMakeLists.txt b/libs/pika/thread_pools/CMakeLists.txt index 0e0ea8223..da5eb4ff2 100644 --- a/libs/pika/thread_pools/CMakeLists.txt +++ b/libs/pika/thread_pools/CMakeLists.txt @@ -20,13 +20,7 @@ pika_add_module( GLOBAL_HEADER_GEN ON SOURCES ${thread_pools_sources} HEADERS ${thread_pools_headers} - MODULE_DEPENDENCIES - pika_assertion - pika_config - pika_debugging - pika_errors - pika_itt_notify - pika_logging - pika_schedulers + MODULE_DEPENDENCIES pika_assertion pika_config pika_debugging pika_errors pika_logging + pika_schedulers CMAKE_SUBDIRS examples tests ) diff --git a/libs/pika/thread_pools/include/pika/thread_pools/scheduling_loop.hpp b/libs/pika/thread_pools/include/pika/thread_pools/scheduling_loop.hpp index 70d8a0da7..a2deefd31 100644 --- a/libs/pika/thread_pools/include/pika/thread_pools/scheduling_loop.hpp +++ b/libs/pika/thread_pools/include/pika/thread_pools/scheduling_loop.hpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -266,15 +265,6 @@ namespace pika::threads::detail { { std::atomic& this_state = scheduler.get_state(num_thread); -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::stack_context ctx; // helper for itt support - util::itt::thread_domain thread_domain; - util::itt::id threadid(thread_domain, &scheduler); - util::itt::string_handle task_id("task_id"); - util::itt::string_handle task_phase("task_phase"); - // util::itt::frame_context fctx(thread_domain); -#endif - std::int64_t& idle_loop_count = counters.idle_loop_count_; std::int64_t& busy_loop_count = counters.busy_loop_count_; @@ -345,14 +335,7 @@ namespace pika::threads::detail { { is_active_wrapper utilization(counters.is_active_); auto* thrdptr = get_thread_id_data(thrd); -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::caller_context cctx(ctx); - // util::itt::undo_frame_context undoframe(fctx); - util::itt::task task = - thrdptr->get_description().get_task_itt(thread_domain); - task.add_metadata(task_id, thrdptr); - task.add_metadata(task_phase, thrdptr->get_thread_phase()); -#endif + // Record time elapsed in thread changing state // and add to aggregate execution time. exec_time_wrapper exec_time_collector(idle_rate); diff --git a/libs/pika/thread_support/CMakeLists.txt b/libs/pika/thread_support/CMakeLists.txt index 0c9ca0b83..b086f6b4a 100644 --- a/libs/pika/thread_support/CMakeLists.txt +++ b/libs/pika/thread_support/CMakeLists.txt @@ -6,11 +6,11 @@ set(thread_support_headers pika/thread_support/assert_owns_lock.hpp pika/thread_support/atomic_count.hpp - pika/thread_support/set_thread_name.hpp pika/thread_support/spinlock.hpp + pika/thread_support/spinlock.hpp pika/thread_support/thread_name.hpp pika/thread_support/unlock_guard.hpp ) -set(thread_support_sources set_thread_name.cpp spinlock.cpp) +set(thread_support_sources spinlock.cpp thread_name.cpp) include(pika_add_module) pika_add_module( diff --git a/libs/pika/thread_support/include/pika/thread_support/set_thread_name.hpp b/libs/pika/thread_support/include/pika/thread_support/thread_name.hpp similarity index 65% rename from libs/pika/thread_support/include/pika/thread_support/set_thread_name.hpp rename to libs/pika/thread_support/include/pika/thread_support/thread_name.hpp index 2e64e1439..d84efb8bb 100644 --- a/libs/pika/thread_support/include/pika/thread_support/set_thread_name.hpp +++ b/libs/pika/thread_support/include/pika/thread_support/thread_name.hpp @@ -8,17 +8,14 @@ #include +#include + #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) # include +#endif namespace pika::detail { - PIKA_EXPORT void set_thread_name(char const* /*threadName*/, DWORD /*dwThreadID*/ = DWORD(-1)); -} // namespace pika::detail - -#else - -namespace pika::detail { - inline void set_thread_name(char const* /*thread_name*/) {} + PIKA_EXPORT std::string& get_thread_name_internal(); + PIKA_EXPORT std::string get_thread_name(); + PIKA_EXPORT void set_thread_name(std::string_view name); } // namespace pika::detail - -#endif diff --git a/libs/pika/thread_support/src/set_thread_name.cpp b/libs/pika/thread_support/src/set_thread_name.cpp deleted file mode 100644 index 94d7e0a85..000000000 --- a/libs/pika/thread_support/src/set_thread_name.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2007-2013 Hartmut Kaiser -// -// SPDX-License-Identifier: BSL-1.0 -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// -// This code was partially taken from: -// http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx - -#include - -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - -# include - -namespace pika::detail { - DWORD const MS_VC_EXCEPTION = 0x406D'1388; - -# pragma pack(push, 8) - typedef struct tagTHREADNAME_INFO - { - DWORD dwType; // Must be 0x1000. - LPCSTR szName; // Pointer to name (in user addr space). - DWORD dwThreadID; // Thread ID (-1=caller thread). - DWORD dwFlags; // Reserved for future use, must be zero. - } THREADNAME_INFO; -# pragma pack(pop) - - // Set the name of the thread shown in the Visual Studio debugger - void set_thread_name(char const* threadName, DWORD dwThreadID) - { - THREADNAME_INFO info; - info.dwType = 0x1000; - info.szName = threadName; - info.dwThreadID = dwThreadID; - info.dwFlags = 0; - - __try - { - RaiseException( - MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*) &info); - } - __except (EXCEPTION_EXECUTE_HANDLER) - { - } - } -} // namespace pika::detail - -#endif diff --git a/libs/pika/thread_support/src/thread_name.cpp b/libs/pika/thread_support/src/thread_name.cpp new file mode 100644 index 000000000..7b6231b84 --- /dev/null +++ b/libs/pika/thread_support/src/thread_name.cpp @@ -0,0 +1,92 @@ +// Copyright (c) 2007-2013 Hartmut Kaiser +// +// SPDX-License-Identifier: BSL-1.0 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// +// This code was partially taken from: +// http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx + +#include +#include + +#include + +#if defined(PIKA_HAVE_PTHREAD_SETNAME_NP) +# include +#endif + +#include +#include + +namespace pika::detail { + std::string& get_thread_name_internal() + { + static thread_local std::string name{}; + return name; + } + + std::string get_thread_name() + { + std::string const& thread_name = detail::get_thread_name_internal(); + if (thread_name.empty()) return ""; + return thread_name; + } + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) + DWORD const MS_VC_EXCEPTION = 0x406D'1388; + +# pragma pack(push, 8) + typedef struct tagTHREADNAME_INFO + { + DWORD dwType; // Must be 0x1000. + LPCSTR szName; // Pointer to name (in user addr space). + DWORD dwThreadID; // Thread ID (-1=caller thread). + DWORD dwFlags; // Reserved for future use, must be zero. + } THREADNAME_INFO; +# pragma pack(pop) + + // Set the name of the thread shown in the Visual Studio debugger + void set_thread_name(std::string_view thread_name) + { + auto& name = get_thread_name_internal(); + name = thread_name; + + DWORD dwThreadID = -1; + THREADNAME_INFO info; + info.dwType = 0x1000; + info.szName = name.c_str(); + info.dwThreadID = dwThreadID; + info.dwFlags = 0; + + __try + { + RaiseException( + MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*) &info); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + } + } +#else + void set_thread_name(std::string_view thread_name) + { + auto& name = get_thread_name_internal(); + name = thread_name; +# if defined(PIKA_HAVE_PTHREAD_SETNAME_NP) + // https://man7.org/linux/man-pages/man3/pthread_setname_np.3.html: + // The thread name is a meaningful C language string, whose length is restricted to 16 + // characters, including the terminating null byte ('\0'). + std::string pthread_name{thread_name, 0, 15}; + int rc = pthread_setname_np(pthread_self(), pthread_name.c_str()); + if (rc != 0) + { + throw std::runtime_error(fmt::format("pthread_setname_np failed with code {} when " + "attempting to set name \"{}\" for thread {}", + rc, pthread_name, pthread_self())); + } + +# endif + } +#endif +} // namespace pika::detail diff --git a/libs/pika/threading_base/CMakeLists.txt b/libs/pika/threading_base/CMakeLists.txt index 98bb6a98c..bc1e91d09 100644 --- a/libs/pika/threading_base/CMakeLists.txt +++ b/libs/pika/threading_base/CMakeLists.txt @@ -88,7 +88,6 @@ pika_add_module( pika_debugging pika_errors pika_functional - pika_itt_notify pika_lock_registration pika_logging pika_memory diff --git a/libs/pika/threading_base/include/pika/threading_base/annotated_function.hpp b/libs/pika/threading_base/include/pika/threading_base/annotated_function.hpp index 2002ffb76..ede1c51a6 100644 --- a/libs/pika/threading_base/include/pika/threading_base/annotated_function.hpp +++ b/libs/pika/threading_base/include/pika/threading_base/annotated_function.hpp @@ -17,9 +17,7 @@ # include # include -# if PIKA_HAVE_ITTNOTIFY != 0 -# include -# elif defined(PIKA_HAVE_APEX) +# if defined(PIKA_HAVE_APEX) # include # endif #endif diff --git a/libs/pika/threading_base/include/pika/threading_base/scoped_annotation.hpp b/libs/pika/threading_base/include/pika/threading_base/scoped_annotation.hpp index 4406ea657..7cb7e1172 100644 --- a/libs/pika/threading_base/include/pika/threading_base/scoped_annotation.hpp +++ b/libs/pika/threading_base/include/pika/threading_base/scoped_annotation.hpp @@ -12,9 +12,7 @@ # include # include -# if PIKA_HAVE_ITTNOTIFY != 0 -# include -# elif defined(PIKA_HAVE_APEX) +# if defined(PIKA_HAVE_APEX) # include # elif defined(PIKA_HAVE_TRACY) # include @@ -46,26 +44,6 @@ namespace pika { // add empty (but non-trivial) destructor to silence warnings PIKA_HOST_DEVICE ~scoped_annotation() {} }; -# elif PIKA_HAVE_ITTNOTIFY != 0 - struct [[nodiscard]] scoped_annotation - { - PIKA_NON_COPYABLE(scoped_annotation); - - explicit scoped_annotation(char const* name) - : task_(thread_domain_, pika::util::itt::string_handle(name)) - { - } - template - explicit scoped_annotation(F&& f) - : task_( - thread_domain_, pika::detail::get_function_annotation_itt>::call(f)) - { - } - - private: - pika::util::itt::thread_domain thread_domain_; - pika::util::itt::task task_; - }; # elif defined(PIKA_HAVE_TRACY) struct [[nodiscard]] scoped_annotation { diff --git a/libs/pika/threading_base/include/pika/threading_base/thread_description.hpp b/libs/pika/threading_base/include/pika/threading_base/thread_description.hpp index 389c1dcee..9850de6c4 100644 --- a/libs/pika/threading_base/include/pika/threading_base/thread_description.hpp +++ b/libs/pika/threading_base/include/pika/threading_base/thread_description.hpp @@ -12,9 +12,6 @@ #include #include #include -#if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) -# include -#endif #include @@ -45,9 +42,6 @@ namespace pika::detail { data_type type_; data data_; -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle desc_itt_; -# endif PIKA_EXPORT void init_from_alternative_name(char const* altname); @@ -64,15 +58,6 @@ namespace pika::detail { data_.desc_ = desc ? desc : ""; } -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - thread_description(char const* desc, util::itt::string_handle const& sh) noexcept - : type_(data_type_description) - { - data_.desc_ = desc ? desc : ""; - desc_itt_ = sh; - } -# endif - /* The priority of description is name, altname, address */ template >> explicit thread_description(F const& f, char const* altname = nullptr) noexcept @@ -84,9 +69,6 @@ namespace pika::detail { if (name != nullptr) // -V547 { altname = name; -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - desc_itt_ = pika::detail::get_function_annotation_itt::call(f); -# endif } # if defined(PIKA_HAVE_THREAD_DESCRIPTION_FULL) @@ -99,10 +81,6 @@ namespace pika::detail { # else init_from_alternative_name(altname); # endif - -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - if (!desc_itt_) { desc_itt_ = util::itt::string_handle(get_description()); } -# endif } constexpr data_type kind() const noexcept { return type_; } @@ -113,28 +91,6 @@ namespace pika::detail { return data_.desc_; } -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_description_itt() const noexcept - { - PIKA_ASSERT(type_ == data_type_description); - return desc_itt_ ? desc_itt_ : util::itt::string_handle(get_description()); - } - - util::itt::task get_task_itt(util::itt::domain const& domain) const noexcept - { - switch (kind()) - { - case data_type_description: - return util::itt::task(domain, get_description_itt()); - break; - case data_type_address: return util::itt::task(domain, "address", get_address()); break; - default: PIKA_ASSERT(false); break; - } - - return util::itt::task(domain, ""); - } -# endif - std::size_t get_address() const noexcept { PIKA_ASSERT(type_ == data_type_address); @@ -182,28 +138,6 @@ namespace pika::detail { constexpr char const* get_description() const noexcept { return ""; } -# if PIKA_HAVE_ITTNOTIFY != 0 && !defined(PIKA_HAVE_APEX) - util::itt::string_handle get_description_itt() const noexcept - { - PIKA_ASSERT(type_ == data_type_description); - return util::itt::string_handle(get_description()); - } - - util::itt::task get_task_itt(util::itt::domain const& domain) const noexcept - { - switch (kind()) - { - case data_type_description: - return util::itt::task(domain, get_description_itt()); - break; - case data_type_address: return util::itt::task(domain, "address", get_address()); break; - default: PIKA_ASSERT(false); break; - } - - return util::itt::task(domain, ""); - } -# endif - constexpr std::size_t get_address() const noexcept { return 0; } explicit constexpr operator bool() const noexcept { return valid(); }