![]() |
|
|||
File indexing completed on 2025-09-17 08:54:09
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file corecel/sys/ScopedMpiInit.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Macros.hh" 0010 0011 namespace celeritas 0012 { 0013 //---------------------------------------------------------------------------// 0014 /*! 0015 * RAII class for initializing and finalizing MPI. 0016 * 0017 * \note Unlike the MpiCommunicator and MpiOperations class, it is not 0018 * necessary to link against MPI to use this class. 0019 */ 0020 class ScopedMpiInit 0021 { 0022 public: 0023 //! Status of initialization 0024 enum class Status 0025 { 0026 disabled = -1, //!< Not compiled *or* disabled via environment 0027 uninitialized = 0, //!< MPI_Init has not been called anywhere 0028 initialized = 1 //!< MPI_Init has been called somewhere 0029 }; 0030 0031 // Whether MPI has been initialized 0032 static Status status(); 0033 0034 public: 0035 // Construct with argc/argv references 0036 ScopedMpiInit(int* argc, char*** argv); 0037 0038 //! Construct with null argc/argv when those are unavailable 0039 ScopedMpiInit() : ScopedMpiInit(nullptr, nullptr) {} 0040 0041 // Call MPI finalize on destruction 0042 ~ScopedMpiInit(); 0043 0044 //!@{ 0045 //! Prevent copying and moving for RAII class 0046 CELER_DELETE_COPY_MOVE(ScopedMpiInit); 0047 //!@} 0048 0049 // Shortcut for comm_world().size() > 1 0050 bool is_world_multiprocess() const; 0051 0052 private: 0053 bool do_finalize_{false}; 0054 static Status status_; 0055 }; 0056 0057 //---------------------------------------------------------------------------// 0058 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |