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