Skip to content

Commit

Permalink
#16: wrap all omp calls in ifdefs in tv.cc
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed May 7, 2024
1 parent 208ccf8 commit 5d82a9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 11 additions & 5 deletions bindings/python/tv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,27 @@ void tvFromJson(const std::vector<std::string>& input_json_per_rank_list, const
#else
const int threads = 2;
#endif
omp_set_num_threads(threads);
// print number of threads
fmt::print("vt-tv: Using {} threads\n", threads);
#ifdef 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> info = std::make_unique<Info>();

# pragma omp parallel for
#ifdef VT_TV_OPENMP_ENABLED
# pragma omp parallel for
#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];
utility::JSONReader reader{static_cast<NodeType>(rank_id)};
reader.readString(rank_json_str);
auto tmpInfo = reader.parse();
#pragma omp critical
#ifdef VT_TV_OPENMP_ENABLED
#pragma omp critical
#endif
{
info->addInfo(tmpInfo->getObjectInfo(), tmpInfo->getRank(rank_id));
}
Expand Down
1 change: 0 additions & 1 deletion src/vt-tv/utility/parse_render.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ void ParseRender::parseAndRender(PhaseType phase_id, std::unique_ptr<Info> info)
const int threads = 2;
#endif
#ifdef VT_TV_OPENMP_ENABLED
fmt::print("openmp enabled\n");
omp_set_num_threads(threads);
# pragma omp parallel for
#endif // VT_TV_OPENMP_ENABLED
Expand Down

0 comments on commit 5d82a9a

Please sign in to comment.