#include #include #include #include using namespace std; int main(int argc, char **argv) { int pid, nprocs; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &pid); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); chrono::time_point start, end; int n = atoi(argv[1]); // la taille du tableau global int root = atoi(argv[2]); // le processus root double *vecteur; double *vecres; if (pid == root) { vecteur = new double[n]; vecres = new double[n]; random_device rd; mt19937 gen(rd()); uniform_real_distribution<> dis(0, 10.0); for (int i = 0; i < n; i++) vecteur[i] = dis(gen); cout << "le tableau initial est "; for (int i = 0; i < n; i++) cout << vecteur[i] << " "; cout << endl; } if (pid==root) { start = chrono::system_clock::now(); } int nlocal = n / nprocs; int reste = n%nprocs; int* sendcounts; int* displs; if (pid==root) { sendcounts = new int[nprocs]; displs = new int[nprocs]; int ptr = 0; for (int i=0; i elapsed_seconds = end-start; cout << "tps=" << elapsed_seconds.count() << endl; for (int i=0; i