Skip to content

Commit

Permalink
Remove get_instance_number related to runtime and affinity_data
Browse files Browse the repository at this point in the history
  • Loading branch information
aurianer committed Apr 12, 2024
1 parent 963c180 commit b7e1671
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 29 deletions.
1 change: 0 additions & 1 deletion libs/pika/affinity/include/pika/affinity/affinity_data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ namespace pika::detail {
no_affinity_; ///< mask of processing units which have no affinity
bool use_process_mask_; ///< use the process CPU mask to limit available PUs
std::size_t num_pus_needed_;
static std::atomic<int> instance_number_counter_; ///< counter for instance numbers
};
} // namespace pika::detail

Expand Down
3 changes: 1 addition & 2 deletions libs/pika/affinity/src/affinity_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace pika::detail {
threads::detail::resize(no_affinity_, threads::detail::hardware_concurrency());
}

affinity_data::~affinity_data() { --instance_number_counter_; }
affinity_data::~affinity_data() {}

// NOLINTBEGIN(bugprone-easily-swappable-parameters)
void affinity_data::init(std::size_t num_threads, std::size_t max_cores, std::size_t pu_offset,
Expand Down Expand Up @@ -285,5 +285,4 @@ namespace pika::detail {
return (num_pu + offset) % hardware_concurrency;
}

std::atomic<int> affinity_data::instance_number_counter_(-1);
} // namespace pika::detail
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void print_system_characteristics()
// -------------------------------------- //

//! -------------------------------------- runtime
std::cout << "[Runtime], instance number " << rt->get_instance_number() << "\n"
std::cout << "[Runtime] instance "
<< "called by thread named " << pika::detail::get_thread_name() << "\n\n";

//! -------------------------------------- thread_manager
Expand Down
9 changes: 2 additions & 7 deletions libs/pika/runtime/include/pika/runtime/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ namespace pika::detail {

pika::util::runtime_configuration const& get_config() const;

std::size_t get_instance_number() const;

/// \brief Return the system uptime measure on the thread executing this call
static std::uint64_t get_system_uptime();

Expand Down Expand Up @@ -290,8 +288,8 @@ namespace pika::detail {
/// \returns This function will return whether the requested operation
/// succeeded or not.
///
virtual bool register_thread(char const* name, std::size_t num = 0,
error_code& ec = throws);
virtual bool register_thread(
char const* name, std::size_t num = 0, error_code& ec = throws);

/// \brief Unregister an external OS-thread with pika
///
Expand Down Expand Up @@ -344,9 +342,6 @@ namespace pika::detail {

pika::util::runtime_configuration rtcfg_;

long instance_number_;
static std::atomic<int> instance_number_counter_;

// topology and affinity data
pika::threads::detail::topology& topology_;

Expand Down
21 changes: 3 additions & 18 deletions libs/pika/runtime/src/runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ namespace pika::detail {
///////////////////////////////////////////////////////////////////////////
runtime::runtime(pika::util::runtime_configuration& rtcfg, bool initialize)
: rtcfg_(rtcfg)
, instance_number_(++instance_number_counter_)
, topology_(resource::get_partitioner().get_topology())
, state_(pika::runtime_state::invalid)
, on_start_func_(global_on_start_func)
Expand All @@ -273,7 +272,6 @@ namespace pika::detail {
// this constructor is called by the distributed runtime only
runtime::runtime(pika::util::runtime_configuration& rtcfg)
: rtcfg_(rtcfg)
, instance_number_(++instance_number_counter_)
, topology_(resource::get_partitioner().get_topology())
, state_(pika::runtime_state::invalid)
, on_start_func_(global_on_start_func)
Expand Down Expand Up @@ -355,9 +353,6 @@ namespace pika::detail {

LPROGRESS_;

// allow to reuse instance number if this was the only instance
if (0 == instance_number_counter_) --instance_number_counter_;

resource::detail::delete_partitioner();

#if defined(PIKA_HAVE_GPU_SUPPORT)
Expand Down Expand Up @@ -389,11 +384,6 @@ namespace pika::detail {

pika::util::runtime_configuration const& runtime::get_config() const { return rtcfg_; }

std::size_t runtime::get_instance_number() const
{
return static_cast<std::size_t>(instance_number_);
}

pika::runtime_state runtime::get_state() const { return state_.load(); }

pika::threads::detail::topology const& runtime::get_topology() const { return topology_; }
Expand All @@ -404,9 +394,6 @@ namespace pika::detail {
state_.store(s);
}

///////////////////////////////////////////////////////////////////////////
std::atomic<int> runtime::instance_number_counter_(-1);

///////////////////////////////////////////////////////////////////////////
namespace {
std::chrono::time_point<std::chrono::high_resolution_clock>& runtime_uptime()
Expand Down Expand Up @@ -1396,8 +1383,8 @@ namespace pika::detail {

notification_policy_type notifier;

notifier.add_on_start_thread_callback(pika::util::detail::bind(
&runtime::init_tss_helper, this, prefix, _1, _2, _3, _4));
notifier.add_on_start_thread_callback(
pika::util::detail::bind(&runtime::init_tss_helper, this, prefix, _1, _2, _3, _4));
notifier.add_on_stop_thread_callback(
pika::util::detail::bind(&runtime::deinit_tss_helper, this, prefix, _1));
notifier.set_on_error_callback(pika::util::detail::bind(
Expand Down Expand Up @@ -1455,7 +1442,6 @@ namespace pika::detail {
{
on_start_func_(local_thread_num, global_thread_num, pool_name, context);
}

}

void runtime::deinit_tss_helper(char const* context, std::size_t global_thread_num)
Expand Down Expand Up @@ -1494,8 +1480,7 @@ namespace pika::detail {
}

/// Register an external OS-thread with pika
bool runtime::register_thread(
char const* name, std::size_t global_thread_num, error_code& ec)
bool runtime::register_thread(char const* name, std::size_t global_thread_num, error_code& ec)
{
std::string thread_name(name);
thread_name += "-thread";
Expand Down

0 comments on commit b7e1671

Please sign in to comment.