diff --git a/include/host_queue.h b/include/host_queue.h index aff3e7066..dd95bf5a4 100644 --- a/include/host_queue.h +++ b/include/host_queue.h @@ -114,7 +114,7 @@ namespace detail { host_queue() { // TODO what is a good thread count for the non-collective thread pool? - threads.emplace(std::piecewise_construct, std::tuple{0}, std::tuple{MPI_COMM_NULL, 4}); + threads.emplace(std::piecewise_construct, std::tuple{0}, std::tuple{MPI_COMM_NULL, 4, id++}); } void require_collective_group(collective_group_id cgid) { @@ -122,7 +122,7 @@ namespace detail { assert(cgid != 0); MPI_Comm comm; MPI_Comm_dup(MPI_COMM_WORLD, &comm); - threads.emplace(std::piecewise_construct, std::tuple{cgid}, std::tuple{comm, 1}); + threads.emplace(std::piecewise_construct, std::tuple{cgid}, std::tuple{comm, 1, id++}); } template @@ -160,15 +160,16 @@ namespace detail { MPI_Comm comm; ctpl::thread_pool thread; - comm_thread(MPI_Comm comm, size_t n_threads) : comm(comm), thread(n_threads) { + comm_thread(MPI_Comm comm, size_t n_threads, size_t id) : comm(comm), thread(n_threads) { for(size_t i = 0; i < n_threads; ++i) { auto& worker = thread.get_thread(i); - set_thread_name(worker.native_handle(), "worker" + std::to_string(i)); + set_thread_name(worker.native_handle(), fmt::format("cy-worker-{}.{}", id, i)); } } }; std::unordered_map threads; + size_t id = 0; }; } // namespace detail diff --git a/src/executor.cc b/src/executor.cc index 6392d16bf..2ecbec0ed 100644 --- a/src/executor.cc +++ b/src/executor.cc @@ -33,7 +33,7 @@ namespace detail { void executor::startup() { exec_thrd = std::thread(&executor::run, this); - set_thread_name(exec_thrd.native_handle(), "executor"); + set_thread_name(exec_thrd.native_handle(), "cy-executor"); } void executor::shutdown() { diff --git a/src/runtime.cc b/src/runtime.cc index 8ac94379e..dc7c8cc42 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -171,7 +171,7 @@ namespace detail { is_active = true; if(is_master_node()) { schdlr->startup(); } exec->startup(); - set_thread_name(get_current_thread_handle(), "main"); + set_thread_name(get_current_thread_handle(), "cy-main"); } void runtime::shutdown() noexcept { diff --git a/src/scheduler.cc b/src/scheduler.cc index 7b480e9ea..8d3c20145 100644 --- a/src/scheduler.cc +++ b/src/scheduler.cc @@ -12,7 +12,7 @@ namespace detail { void scheduler::startup() { worker_thread = std::thread(&scheduler::schedule, this); - set_thread_name(worker_thread.native_handle(), "scheduler"); + set_thread_name(worker_thread.native_handle(), "cy-scheduler"); } void scheduler::shutdown() { diff --git a/test/runtime_tests.cc b/test/runtime_tests.cc index 7414c22ff..7cc86b3b5 100644 --- a/test/runtime_tests.cc +++ b/test/runtime_tests.cc @@ -993,18 +993,18 @@ namespace detail { if(rt.is_master_node()) { const auto scheduler_thread_name = get_thread_name(scheduler_testspy::get_worker_thread(schdlr).native_handle()); - CHECK(scheduler_thread_name == "scheduler"); + CHECK(scheduler_thread_name == "cy-scheduler"); } const auto executor_thread_name = get_thread_name(executor_testspy::get_exec_thrd(exec).native_handle()); - CHECK(executor_thread_name == "executor"); + CHECK(executor_thread_name == "cy-executor"); const auto main_thread_name = get_thread_name(get_current_thread_handle()); - CHECK(main_thread_name == "main"); + CHECK(main_thread_name == "cy-main"); q.submit([](handler& cgh) { cgh.host_task(experimental::collective, [&](experimental::collective_partition) { - const auto base_name = std::string("worker"); + const auto base_name = std::string("cy-worker-"); const auto worker_thread_name = get_thread_name(get_current_thread_handle()); CHECK_THAT(worker_thread_name, Catch::Matchers::StartsWith(base_name)); });