MPI Parallelization


After the development of a serial code one can parallelize the code by MPI or OpenMP or by both of them.



  1. Compile the code wth the option

    -D_MPI_PARALLEL

  2. Start your main function as follows:

    int my_rank;

    MPI_Init(&argc,&argv);

    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

  3. Use the a grid constructor as follows:

    Grid grid(...,MPI_COMM_WORLD);

  4. End the code with

    MPI_Finalize();



  1. A special construction is required for the Print function. Open the data file only for the processor with rank 0 as follows:



    if(my_rank==0) DATEI.open("u.dx",std::ios :: out);

    u.Print_Dx(&DATEI);

    if(my_rank==0) DATEI.close();



  1. Be carefull with using the if condition. Do not write something like:

    if(my_rank==0) cout << L_infty(u);


Handbook

Last modified: Wed Jun 6 10:15:36 PDT 2001