Hi all,

I'm starting with OpenMPI and actually I'm trying to do a simple example of
combining OpenMP and OpenMPI The thing is that when I trying to run with
"mpirun" it's getting hanged.

I send the number of processors parameter and also I set the OMP_THREADS_NUM

Above is my code:

#include "omp.h"
#include "mpi.h" /* Include MPI header file */

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

  int rnk, sz, n, I, info, i, chunk;

  double *x, *y, *buff;

  n = atoi(argv[1]); /* Get input size */

  /* Initialize threaded MPI environment */
  MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &info);
  MPI_Comm_size(MPI_COMM_WORLD, &sz); /* Find out how many MPI procs */

  chunk = n / sz; /* Assume sz divides n exactly */

  MPI_Scatter(buff,chunk,MPI_DOUBLE,x,chunk,MPI_DOUBLE,0,MPI_COMM_WORLD);

MPI_Scatter(&buff[n],chunk,MPI_DOUBLE,y,chunk,MPI_DOUBLE,0,MPI_COMM_WORLD);

#pragma omp parallel for private(i,chunk) shared(x, y)
  for (i=0; i<chunk; i++)
      x[i] = x[i] + y[i];

  MPI_Gather(x,chunk,MPI_DOUBLE,buff,chunk,MPI_DOUBLE,0,MPI_COMM_WORLD);
  MPI_Finalize();

  return 0;
}


Thanks, I really appreciate your help.
-- 
*Obed Nehemias Muñoz Reynoso*
*B.Sc. in Computer Sciences*

Reply via email to