// mpic++ -std=c++11 -Wall -Wextra -lboost_mpi -lboost_serialization -o laplacien_mpi.out laplacien_mpi.cpp // mpirun -n 50 --hostfile mpi_file ./laplacien_mpi.out #include "image.hpp" #include namespace mpi = boost::mpi; #include int main(int argc, char ** argv) { mpi::environment env(argc, argv); mpi::communicator world; int rank = world.rank(); int size = world.size(); int Nj = size; if (rank == 0) // master node { // read image image_t data0; int width, height; std::string readError = readPgm("backloop.pgm", width, height, data0); if (readError != "") { std::cout << readError << std::endl; exit(-1); } int heightN = (height+Nj-1) / Nj; int height2 = heightN * Nj; int sizeN = heightN * width; // copy data0 in data1 // ensure the height of data1 is a multiple of Nj image_t data1(width*height2); std::copy_n(data0.begin(), width*height, std::inserter(data1, data1.begin())); // some data for MPI transfers image_t data(sizeN); std::vector allData(Nj, data); std::vector allResults(Nj, data); // decompose image for (int j=0; j