Commit af58973f by LAMBERT Jean-charles

### add OpenMP and MPI exercices

parent d87aaf4e
 #define NMAX 1000000 int main(int argc, char **argv) { int a[NMAX],i; #pragma omp parallel for for (i = 0; i < NMAX; i++) { a[i] = 2 * i ; } return 0; }
 #include // PROVIDES THE BASIC MPI DEFINITION AND TYPES #include #include #define NMAX 24 #define MIN(a,b) ((a) < (b) ? (a) : (b)) int main(int argc, char **argv) { int i, my_rank, partner, size,a[NMAX],chunk,istart,istop; MPI_Status stat; MPI_Init(&argc, &argv); // START MPI MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); // DETERMINE RANK OF THIS PROCESSOR MPI_Comm_size(MPI_COMM_WORLD, &size); // DETERMINE TOTAL NUMBER OF PROCESSORS chunk=NMAX/size; // #chunks per processors istart=(chunk*my_rank); // first index of my rank if (my_rank
 #include // PROVIDES THE BASIC MPI DEFINITION AND TYPES #include #include #define NMAX 24 #define MIN(a,b) ((a) < (b) ? (a) : (b)) int main(int argc, char **argv) { int i, my_rank, partner, size,a[NMAX],chunk,istart,istop; MPI_Status stat; MPI_Init(&argc, &argv); // START MPI MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); // DETERMINE RANK OF THIS PROCESSOR MPI_Comm_size(MPI_COMM_WORLD, &size); // DETERMINE TOTAL NUMBER OF PROCESSORS chunk=NMAX/size; // #chunks per processors istart=(chunk*my_rank); // first index of my rank istop=MIN(istart+chunk,NMAX); // last index of my rank for (i=istart; i
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!