m0n0lithic

mpi04.c :: Escritura en Paralelo "no-contigua" usando PVFS2

May 13th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.59 KB | None | 0 0
  1. * example of parallel MPI write into a single file */
  2. #include "mpi.h"
  3. #include <stdio.h>
  4. #define BUFSIZE 100
  5. int main(int argc, char *argv[])
  6. {
  7. /*    int j = 0;
  8.     char hostname[256];
  9.     gethostname(hostname, sizeof(hostname));
  10.     printf("PID %d on %s ready for attach\n", getpid(), hostname);
  11.     fflush(stdout);
  12.     while (0 == j)
  13.         sleep(5);
  14. */
  15.         int ret, resultlen;
  16.         int i, myrank, buf[BUFSIZE];
  17.         char msg[MPI_MAX_ERROR_STRING];
  18.         MPI_File thefile;
  19.         MPI_Init(&argc, &argv);
  20.         MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
  21.         for (i=0; i<BUFSIZE; i++)
  22.                 buf[i] = myrank * BUFSIZE + i;
  23.         ret = MPI_File_open(MPI_COMM_WORLD, "pvfs2:/mnt/pvfs2/mpio/testfile",
  24.                 MPI_MODE_CREATE | MPI_MODE_WRONLY,
  25.                 MPI_INFO_NULL, &thefile);
  26.         if (ret != MPI_SUCCESS)
  27.         {
  28.                 MPI_Error_string(ret, msg, &resultlen);
  29.                 fprintf(stderr, "MPI_File_open(): %s\n", msg);
  30.                 return(-1);
  31.         } else {
  32.                 MPI_File_set_view(thefile, myrank * BUFSIZE * sizeof(int),
  33.                         MPI_INT, MPI_INT, "native", MPI_INFO_NULL);
  34.                 MPI_File_write(thefile, buf, BUFSIZE, MPI_INT,
  35.                         MPI_STATUS_IGNORE);
  36.                 MPI_File_close(&thefile);
  37.                 MPI_Finalize();
  38.                 return 0;
  39.         }
  40. }
  41.  
  42. /* Flags de Compilacion de OpenMPI-1.8.1:
  43. ./configure --prefix=/home/wilderman/openmpi --with-pvfs2=/usr/local --with-pvfs2-libs=/usr/local
  44.  
  45. OrangeFS-2.8.8 (PVFS 1.8.2)
  46. CFLAGS="-fPIC" ./configure
Advertisement
Add Comment
Please, Sign In to add comment