All pastes #181988 Raw Edit

mpi sample

public c v1 · immutable
#181988 ·published 2006-09-25 16:15 UTC
rendered paste body
#include <stdio.h>#include "mpi.h"int main( argc, argv )int  argc;char **argv;{    int rank, size;    int a[8];    int b[8];    int c[8];    for (int i=0;i<8;i++)    {     b[i]=i;     c[i]=i+4;    }        int ista,iend;        MPI_Init( &argc, &argv );    MPI_Comm_size( MPI_COMM_WORLD, &size );    MPI_Comm_rank( MPI_COMM_WORLD, &rank );        ista = (8/size)*rank;    iend = ista+(N/size);    for (int i=ista;i<=iend;i++)     {     a[i] = b[i] + c[i];     printf( "%d + %d = %d on processor %d of %d\n",b[i],c[i],a[i],rank,size);    }        MPI_Finalize();    return 0;}