diff --git a/bindings/python/tv.cc b/bindings/python/tv.cc index 44e3635373..3558fa631c 100644 --- a/bindings/python/tv.cc +++ b/bindings/python/tv.cc @@ -86,23 +86,22 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const assert(input_json_per_rank_list.size() == num_ranks && "Must have the same number of json files as ranks"); + // Initialize the info object, that will hold data for all ranks for all phases + std::unique_ptr info = std::make_unique(); + #ifdef VT_TV_N_THREADS const int threads = VT_TV_N_THREADS; #else const int threads = 2; #endif #ifdef VT_TV_OPENMP_ENABLED + #if VT_TV_OPENMP_ENABLED omp_set_num_threads(threads); // print number of threads fmt::print("vt-tv: Using {} threads\n", threads); - #endif - - // Initialize the info object, that will hold data for all ranks for all phases - std::unique_ptr info = std::make_unique(); - - #ifdef VT_TV_OPENMP_ENABLED # pragma omp parallel for #endif + #endif for (int64_t rank_id = 0; rank_id < num_ranks; rank_id++) { fmt::print("Reading file for rank {}\n", rank_id); std::string rank_json_str = input_json_per_rank_list[rank_id]; @@ -110,8 +109,10 @@ void tvFromJson(const std::vector& input_json_per_rank_list, const reader.readString(rank_json_str); auto tmpInfo = reader.parse(); #ifdef VT_TV_OPENMP_ENABLED + #if VT_TV_OPENMP_ENABLED #pragma omp critical #endif + #endif { info->addInfo(tmpInfo->getObjectInfo(), tmpInfo->getRank(rank_id)); } diff --git a/bindings/python/tv.h b/bindings/python/tv.h index ccecae302d..65c3a31312 100644 --- a/bindings/python/tv.h +++ b/bindings/python/tv.h @@ -66,8 +66,10 @@ #include #ifdef VT_TV_OPENMP_ENABLED +#if VT_TV_OPENMP_ENABLED #include #endif +#endif namespace vt::tv::bindings::python { diff --git a/src/vt-tv/utility/parse_render.cc b/src/vt-tv/utility/parse_render.cc index 41cbe28401..9d8e145865 100644 --- a/src/vt-tv/utility/parse_render.cc +++ b/src/vt-tv/utility/parse_render.cc @@ -86,9 +86,11 @@ void ParseRender::parseAndRender(PhaseType phase_id, std::unique_ptr info) const int threads = 2; #endif #ifdef VT_TV_OPENMP_ENABLED + #if VT_TV_OPENMP_ENABLED omp_set_num_threads(threads); fmt::print("vt-tv: Using {} threads\n", threads); # pragma omp parallel for + #endif #endif // VT_TV_OPENMP_ENABLED for (int64_t rank = 0; rank < n_ranks; rank++) { fmt::print("Reading file for rank {}\n", rank); @@ -96,8 +98,10 @@ void ParseRender::parseAndRender(PhaseType phase_id, std::unique_ptr info) reader.readFile(input_dir + "data." + std::to_string(rank) + ".json"); auto tmpInfo = reader.parse(); #ifdef VT_TV_OPENMP_ENABLED + #if VT_TV_OPENMP_ENABLED #pragma omp critical #endif + #endif { info->addInfo(tmpInfo->getObjectInfo(), tmpInfo->getRank(rank)); } diff --git a/src/vt-tv/utility/parse_render.h b/src/vt-tv/utility/parse_render.h index 2d2b58aad2..e25ae66814 100644 --- a/src/vt-tv/utility/parse_render.h +++ b/src/vt-tv/utility/parse_render.h @@ -52,8 +52,10 @@ #include #ifdef VT_TV_OPENMP_ENABLED +#if VT_TV_OPENMP_ENABLED #include #endif +#endif namespace vt::tv::utility { /**