My program it is with MPI and OpenMP, and is a sample program take
much memory, I don't know the memory RAM consume for a mpi program and
I want to know if mpi consume a lot of memory when if used together
openmp or I doing something wrong, for take memory Ram of mi program I
used a file /proc/id_proc/stat, where id_proc if the id of my process.
This is my example program:

#include <stdio.h>
#include "mpi.h"
#include <omp.h>
#include <vector>
#include <algorithm>

int main(int argc, char** argv){

        int  my_rank; /* rank of process */
         int  p;       /* number of processes */

         MPI_Init_thread(&argc, &argv, MPI::THREAD_MULTIPLE,&argc);

         /* find out process rank */
        MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);

        /* find out number of processes */
        MPI_Comm_size(MPI_COMM_WORLD, &p);

         char cad[4];
         MPI_Status status;

omp_set_num_threads(2);
#pragma omp parallel
{
                         int h =  omp_get_thread_num();

                         if(h==0){
                                MPI_Send(&cad, 1, MPI::CHAR, my_rank, 
11,MPI_COMM_WORLD);
                         }
                         else{
                                std::vector<bool> all(2,0);
                                MPI_Recv(&cad, 2, MPI::CHAR, MPI::ANY_SOURCE,
MPI::ANY_TAG,MPI_COMM_WORLD, &status);
                        }
        }

        /* shut down MPI */
        MPI_Finalize();

        return 0;
}

Compile:
mpic++ -fopenmp -fno-threadsafe-statics -o sample_program sample_program.c

Run
mpirun  sample_program

and the memory consume: 190MB

Please I need help is very important to me get a low memory consume

Reply via email to