Skip to content
MpiEnvironment.hpp 754 B
Newer Older
#include <limits>

#include <mpi.h>

class MpiEnvironment { // wrapper for creating and destroying the environment
	std::size_t _worldRank{std::numeric_limits<std::size_t>::max()};
	std::size_t _worldSize{0};
	std::size_t worldRank() const { return _worldRank; }
	std::size_t worldSize() const { return _worldSize; }
	bool isMaster() const { return _isMaster; }

	void swap(MpiEnvironment& first, MpiEnvironment& second) noexcept;
	MpiEnvironment(int& argc, char* argv[]);
	~MpiEnvironment();
	MpiEnvironment(MpiEnvironment&) = delete;
	MpiEnvironment& operator=(MpiEnvironment&) = delete;
	MpiEnvironment(MpiEnvironment&& other) noexcept;
	MpiEnvironment& operator=(MpiEnvironment&& other) noexcept;