From 271654030828ff8799cb2828803c39b6beb22723 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 2 Nov 2023 14:37:17 -0400 Subject: [PATCH 1/2] `ThreadPool::default_nthread` is public and static --- src/madness/world/thread.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/madness/world/thread.h b/src/madness/world/thread.h index 836f20562db..eb15cb4b825 100644 --- a/src/madness/world/thread.h +++ b/src/madness/world/thread.h @@ -1122,7 +1122,12 @@ namespace madness { void operator=(const ThreadPool&) = delete; void operator=(ThreadPool&&) = delete; - private: + /// Get the number of threads from the environment. + + /// \return The number of threads. + static int default_nthread(); + + private: friend class WorldTaskQueue; // Thread pool data @@ -1147,11 +1152,6 @@ namespace madness { /// \param[in] nthread Description needed. ThreadPool(int nthread=-1); - /// Get the number of threads from the environment. - - /// \return The number of threads. - int default_nthread(); - /// Run the next task. /// \todo Verify and complete this documentation. From 41375b2b9f4a877ee4c33c67f9162c9c2efe1629 Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Thu, 2 Nov 2023 16:18:08 -0400 Subject: [PATCH 2/2] free `ParsecRuntime::madness_comm_thread_es` even if MADWorld did not create the context --- src/madness/world/parsec.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/madness/world/parsec.cc b/src/madness/world/parsec.cc index 555c822c586..2e4c7f94f4e 100644 --- a/src/madness/world/parsec.cc +++ b/src/madness/world/parsec.cc @@ -226,13 +226,13 @@ namespace madness { if (*made_new_ctx) { parsec_context_wait(ctx); parsec_fini(&ctx); - if (nullptr != madness_comm_thread_es) { + ctx = nullptr; + } + if (nullptr != madness_comm_thread_es) { /* madness_comm_thread_es is just a copy of ES[0]. Resources (including es->profiling_es) are * actually freed during parsec_fini. Just need to free memory allocated to store it. */ free(madness_comm_thread_es); madness_comm_thread_es = nullptr; - } - ctx = nullptr; } }