Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Renaming thread functions and some local vars
  • Loading branch information
pshriwise committed Dec 18, 2023
commit bd21f9fe7071ddf4dc87f0fe2dcd820e730b5849
4 changes: 2 additions & 2 deletions include/openmc/openmp_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace openmc {
//==============================================================================
//! Accessor functions related to number of threads and thread number
//==============================================================================
inline int openmc_n_threads()
inline int num_threads()
{
#ifdef _OPENMP
return omp_get_max_threads();
Expand All @@ -19,7 +19,7 @@ inline int openmc_n_threads()
#endif
}

inline int openmc_thread_num()
inline int thread_num()
{
#ifdef _OPENMP
return omp_get_thread_num();
Expand Down
2 changes: 1 addition & 1 deletion src/initialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm)
return err;

#ifdef LIBMESH
const int n_threads = openmc_n_threads();
const int n_threads = num_threads();
// initialize libMesh if it hasn't been initialized already
// (if initialized externally, the libmesh_init object needs to be provided
// also)
Expand Down
5 changes: 2 additions & 3 deletions src/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2714,7 +2714,7 @@ void LibMesh::initialize()
libMesh::ExplicitSystem& eq_sys =
equation_systems_->add_system<libMesh::ExplicitSystem>(eq_system_name_);

for (int i = 0; i < openmc_n_threads(); i++) {
for (int i = 0; i < num_threads(); i++) {
pl_.emplace_back(m_->sub_point_locator());
pl_.back()->set_contains_point_tol(FP_COINCIDENT);
pl_.back()->enable_out_of_mesh_mode();
Expand Down Expand Up @@ -2889,8 +2889,7 @@ int LibMesh::get_bin(Position r) const
return -1;
}

const int thread_num = openmc_thread_num();
const auto& point_locator = pl_.at(thread_num);
const auto& point_locator = pl_.at(thread_num());

const auto elem_ptr = (*point_locator)(p);
return elem_ptr ? get_bin_from_element(elem_ptr) : -1;
Expand Down
6 changes: 3 additions & 3 deletions src/plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ void ProjectionPlot::create_output() const
* Note that a vector of vectors is required rather than a 2-tensor,
* since the stack size varies within each column.
*/
const int n_threads = openmc_n_threads();
const int n_threads = num_threads();
std::vector<std::vector<std::vector<TrackSegment>>> this_line_segments(
n_threads);
for (int t = 0; t < n_threads; ++t) {
Expand All @@ -1231,8 +1231,8 @@ void ProjectionPlot::create_output() const

#pragma omp parallel
{
const int n_threads = openmc_n_threads();
const int tid = openmc_thread_num();
const int n_threads = num_threads();
const int tid = thread_num();

SourceSite s; // Where particle starts from (camera)
s.E = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/volume_calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ vector<VolumeCalculation::Result> VolumeCalculation::execute() const
// At this point, each thread has its own pair of index/hits lists and we
// now need to reduce them. OpenMP is not nearly smart enough to do this
// on its own, so we have to manually reduce them
const int n_threads = openmc_n_threads();
const int n_threads = num_threads();

#pragma omp for ordered schedule(static)
for (int i = 0; i < n_threads; ++i) {
Expand Down