From 1d493b9a1e1792eee4697d6d4985770cdb0522f8 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 15 Aug 2013 14:08:20 -0600 Subject: LoopControl: Initialize fine thread communicators ahead of time --- Carpet/LoopControl/src/loopcontrol.cc | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/Carpet/LoopControl/src/loopcontrol.cc b/Carpet/LoopControl/src/loopcontrol.cc index c4a2f6be1..a9b53d948 100644 --- a/Carpet/LoopControl/src/loopcontrol.cc +++ b/Carpet/LoopControl/src/loopcontrol.cc @@ -588,6 +588,7 @@ void lc_descr_init(lc_descr_t **const descr_ptr, all_descrs.push_back(descr); *descr_ptr = descr; + // Determine number of SMT threads if (CCTK_BUILTIN_EXPECT(num_smt_threads==0, false)) { if (CCTK_IsFunctionAliased("GetNumSMTThreads")) { num_smt_threads = GetNumSMTThreads(); @@ -595,6 +596,11 @@ void lc_descr_init(lc_descr_t **const descr_ptr, num_smt_threads = 1; } } + + // Allocate fine thread communicators + if (CCTK_BUILTIN_EXPECT(lc_fine_thread_comm.empty(), false)) { + lc_fine_thread_comm.resize(omp_get_max_threads()); + } } #pragma omp barrier } @@ -822,25 +828,6 @@ void lc_control_init(lc_control_t *restrict const control, } } - // Allocate fine thread communicators - int ftcs, gnct; - if ((ftcs=int(lc_fine_thread_comm.size())) < (gnct=get_num_coarse_threads())) { -#pragma omp barrier - if (not ((int(lc_fine_thread_comm.size()) < get_num_coarse_threads()))) { -#pragma omp critical - cout << "thread: " << omp_get_thread_num() << " " - << "ftcs1=" << ftcs << " " - << "gnct1=" << gnct << " " - << "ftcs2=" << lc_fine_thread_comm.size() << " " - << "gnct2=" << get_num_coarse_threads() << "\n" << flush; - } - assert(int(lc_fine_thread_comm.size()) < get_num_coarse_threads()); -#pragma omp master - lc_fine_thread_comm.resize(get_num_coarse_threads()); -#pragma omp barrier - assert(int(lc_fine_thread_comm.size()) == get_num_coarse_threads()); - } - // Initialize everything with a large, bogus value -- cgit v1.2.3