10#ifndef TEUCHOS_DEFAULT_COMM_HPP
11#define TEUCHOS_DEFAULT_COMM_HPP
14#include "Teuchos_DefaultSerialComm.hpp"
24template<
class OrdinalType>
26mpiFreeDefaultComm (MPI_Comm,
int,
void*,
void*);
28template<
class OrdinalType>
30mpiFreeDefaultSerialComm (MPI_Comm,
int,
void*,
void*);
61template<
typename OrdinalType>
102 Details::mpiFreeDefaultComm (
MPI_Comm,
int,
void*,
void*);
107 Details::mpiFreeDefaultSerialComm (
MPI_Comm,
int,
void*,
void*);
111 static void freeDefaultComm () {
119 static void freeDefaultSerialComm () {
120 if (defaultSerialComm_ !=
NULL) {
121 delete defaultSerialComm_;
122 defaultSerialComm_ =
NULL;
130template<
class OrdinalType>
139 std::cerr <<
"Teuchos::DefaultComm: Failed to free default Comm! We can't "
140 "throw an exception here because this is a singleton destructor that "
141 "should only be called at MPI_Finalize or (if not building with MPI) at "
142 "exit from main()." << std::endl;
147 return (MPI_SUCCESS == 0) ? -1 : 0;
152template<
class OrdinalType>
154mpiFreeDefaultSerialComm (MPI_Comm,
int,
void*,
void*)
161 std::cerr <<
"Teuchos::DefaultComm: Failed to free default serial Comm! "
162 "We can't throw an exception here because this is a singleton destructor "
163 "that should only be called at MPI_Finalize or (if not building with MPI)"
164 " at exit from main()." << std::endl;
169 return (MPI_SUCCESS == 0) ? -1 : 0;
178template<
typename OrdinalType>
197 Details::mpiFreeDefaultComm<OrdinalType>,
206 "Teuchos::DefaultComm::getComm: MPI_Comm_create_keyval failed!");
226 "Teuchos::DefaultComm::getComm: MPI_Comm_set_attr failed!");
259# error "Sorry, you need an MPI implementation that supports at least MPI 2.0 in order to build this code. MPI 2.0 came out in 1997. I wrote this comment in 2017. If you really _really_ want MPI 1.x support, please file a GitHub issue for this feature request at github.com/trilinos/trilinos/issues with an expression of its priority and we will get to it as soon as we can."
283 "Teuchos::DefaultComm::getComm: atexit failed!");
289 (comm_ ==
NULL, std::logic_error,
"Teuchos::DefaultComm::getComm: "
290 "comm_ == NULL before return. This should never happen. "
291 "Please report this bug to the Teuchos developers.");
296 return rcp (comm_,
false);
299template<
typename OrdinalType>
307 if (defaultSerialComm_ ==
NULL) {
319 Details::mpiFreeDefaultSerialComm<OrdinalType>,
323 if (defaultSerialComm_ !=
NULL) {
324 delete defaultSerialComm_;
325 defaultSerialComm_ =
NULL;
328 true, std::runtime_error,
"Teuchos::DefaultComm::getDefaultSerialComm"
329 ": MPI_Comm_create_keyval failed!");
338 if (defaultSerialComm_ !=
NULL) {
339 delete defaultSerialComm_;
340 defaultSerialComm_ =
NULL;
343 true, std::runtime_error,
"Teuchos::DefaultComm::getDefaultSerialComm"
344 ": MPI_Comm_set_attr failed!");
353# error "Sorry, you need an MPI implementation that supports at least MPI 2.0 in order to build this code. MPI 2.0 came out in 1997. I wrote this comment in 2017. If you really _really_ want MPI 1.x support, please file a GitHub issue for this feature request at github.com/trilinos/trilinos/issues with an expression of its priority and we will get to it as soon as we can."
372 if (defaultSerialComm_ !=
NULL) {
373 delete defaultSerialComm_;
374 defaultSerialComm_ =
NULL;
377 "Teuchos::DefaultComm::getDefaultSerialComm: atexit failed!");
383 (defaultSerialComm_ ==
NULL, std::logic_error,
"Teuchos::DefaultComm::"
384 "getDefaultSerialComm: defaultSerialComm_ == NULL before return. This sh"
385 "ould never happen. Please report this bug to the Teuchos developers.");
390 return rcp (defaultSerialComm_,
false);
394template<
typename OrdinalType>
398template<
typename OrdinalType>
Implementation of Teuchos wrappers for MPI.
Reference-counted pointer class and non-member templated function implementations.
Return a default global communicator appropriate for the build.
static Teuchos::RCP< const Comm< OrdinalType > > getDefaultSerialComm(const Teuchos::RCP< const Comm< OrdinalType > > &comm)
Return a serial Comm if the input Comm is null.
static Teuchos::RCP< const Comm< OrdinalType > > getComm()
Return the default global communicator.
Smart reference counting pointer class for automatic garbage collection.
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object.
bool is_null() const
Returns true if the underlying pointer is null.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Namespace of implementation details.
The Teuchos namespace contains all of the classes, structs and enums used by Teuchos,...