From 6b6628cbd360e5b281a2af00f3cee46570882f68 Mon Sep 17 00:00:00 2001 From: Landon Owen Date: Mon, 19 Aug 2024 11:42:10 -0700 Subject: [PATCH] Fixed inconsistency in Communicator for non-MPI builds and added pointer function to get null pointer for adiak --- src/Distributed/Communicator.hh | 10 +++++++--- src/PYB11/Utilities/Utilities_PYB11.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Distributed/Communicator.hh b/src/Distributed/Communicator.hh index 11a03fb13..19437d56d 100644 --- a/src/Distributed/Communicator.hh +++ b/src/Distributed/Communicator.hh @@ -9,6 +9,8 @@ #ifdef USE_MPI #include +#else +typedef int MPI_Comm; #endif namespace Spheral { @@ -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. diff --git a/src/PYB11/Utilities/Utilities_PYB11.py b/src/PYB11/Utilities/Utilities_PYB11.py index 3ef35e9ad..c54a4e894 100644 --- a/src/PYB11/Utilities/Utilities_PYB11.py +++ b/src/PYB11/Utilities/Utilities_PYB11.py @@ -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();