diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2006-02-25 17:26:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2006-02-25 17:26:00 +0000 |
commit | 7aea996581324bd60f8349779625a26082b45a85 (patch) | |
tree | 82b12f93518ca5599675ee5a9dcf2e98ce582316 /Carpet/CarpetLib/src/dist.hh | |
parent | 63c13016173d70762f6f23c624f597484c906096 (diff) |
CarpetLib: Cache the results of MPI_Comm_rank and MPI_Comm_size
darcs-hash:20060225172648-dae7b-93b93c97212a7fa33c8770200b8f8b1494ad9776.gz
Diffstat (limited to 'Carpet/CarpetLib/src/dist.hh')
-rw-r--r-- | Carpet/CarpetLib/src/dist.hh | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Carpet/CarpetLib/src/dist.hh b/Carpet/CarpetLib/src/dist.hh index 86fcbf61b..d68c733ee 100644 --- a/Carpet/CarpetLib/src/dist.hh +++ b/Carpet/CarpetLib/src/dist.hh @@ -60,16 +60,16 @@ namespace dist { // Rank in the communicator (this processor's number, 0 .. size-1) inline int rank () { - int rank_; - MPI_Comm_rank (comm(), &rank_); + static int rank_ = -1; + if (rank_ == -1) MPI_Comm_rank (comm(), &rank_); return rank_; } // Size of the communicator inline int size () { - int size_; - MPI_Comm_size (comm(), &size_); + static int size_ = -1; + if (size_ == -1) MPI_Comm_size (comm(), &size_); return size_; } |