Skip to content

Commit

Permalink
Fixed inconsistency in Communicator for non-MPI builds and added poin…
Browse files Browse the repository at this point in the history
…ter function to get null pointer for adiak
  • Loading branch information
ldowen committed Aug 19, 2024
1 parent cd3f889 commit 6b6628c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/Distributed/Communicator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#ifdef USE_MPI
#include <mpi.h>
#else
typedef int MPI_Comm;
#endif

namespace Spheral {
Expand All @@ -21,18 +23,20 @@ public:
static Communicator& instance() { static Communicator theInstance; return theInstance; }

// Access the communicator.
#ifdef USE_MPI
static MPI_Comm& communicator() { return instance().mCommunicator; }
static void communicator(MPI_Comm& comm) { instance().mCommunicator = comm; }
#ifdef USE_MPI
static MPI_Comm* comm_ptr() { return &(instance().mCommunicator); }
#else
static int communicator() { return 0; }
static void communicator(int&) {}
static MPI_Comm* comm_ptr() { return nullptr; }
#endif

private:
//------------------------===== Private Interface =====----------------------//
#ifdef USE_MPI
MPI_Comm mCommunicator;
#else
MPI_Comm mCommunicator = 0;
#endif

// No public constructors, destructor, or assignment.
Expand Down
2 changes: 1 addition & 1 deletion src/PYB11/Utilities/Utilities_PYB11.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
namespace Spheral {
inline void spheral_adiak_init() {
adiak::init((void*) Communicator::communicator());
adiak::init(Communicator::instance().comm_ptr());
// Always collect some curated default adiak information
adiak::adiakversion();
adiak::user();
Expand Down

0 comments on commit 6b6628c

Please sign in to comment.