Skip to content
Snippets Groups Projects
Commit 071cbecf authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Add MPI intraface class

Start parallelzationo
parent 3103f6da
No related branches found
No related tags found
No related merge requests found
MPI_Interface::MPI_Interface() : boost::mpi::communicator()
{}
std::array<int, 2> MPI_Interface::get_start_end_from_list(int size, int start)
{
int els_per_rank = size / size();
int remaineder = size % size();
std::array<int, 2> start_end;
start_end[0] = start + els_per_rank * rank() + std::min(rank(), remaineder);
start_end[1] = start + els_per_rank * (rank() + 1) + std::min(rank() + 1, remaineder);
return start_end;
}
#ifndef SISSO_MPI_INTERFACE
#define SISSO_MPI_INTERFACE
#include <boost/mpi.hpp>
#include <array>
extern boost::mpi::environment env;
namespace mpi = boost::mpi;
// Augment the boost mpi communicator class with some other useful data
/**
* @brief Augment the boost MPI communicator class with some other useful data
* @details MPI communicator used to transfer data throughout the cell.
*
*/
class MPI_Interface : public boost::mpi::communicator
{
public:
/**
* @brief Constructor for the MPI_Interface
*/
MPI_Interface();
std::array<int, 2> get_start_end_from_list(int size, int start);
/**
* @brief Unique int tag generator
*
* @param[in] procSend sending process
* @param[in] procRecv receiving process
* @param[in] maxOffest number of different communication processes possible between two processes within the same operation
* @param[in] offest the assigned offset corresponding to a single communication within the same operation
*
* @return A unique tag to send information between two processes
*/
int cantorTagGen(unsigned int procSend, unsigned int procRecv, unsigned int maxOffest, unsigned int offest) { return (int((procSend + procRecv) * (procSend + procSend +1) / 2) + procRecv) * maxOffest + offest; }
};
#endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment