/* ************************************************************************* C-DAC Tech Workshop : hyPACK-2013 October 15-18, 2013 Example 2.4 : mpicpp-vv-mult-blkstp-unf.C Objective : MPI program to compute dot product of two vectors using block-striped partitioning with uniform data distribution Input : Process with rank 0 reads a real vectors of size n. Output : Process with rank 0 prints the final dot product of two vectors. Created : August-2013 E-mail : hpcfte@cdac.in ************************************************************************** */ #include #include #include #include #include"mpi.h" using namespace std; int main(int argc,char *argv[]) { int root = 0,myrank,numprocs,index; int no_interval; int vsize = 100; int scatsize; int *vector_a,*vector_b,*buffer_a,*buffer_b; int sum = 0,finalvalue = 0,i; MPI::Init(argc,argv); numprocs = MPI::COMM_WORLD.Get_size(); myrank = MPI::COMM_WORLD.Get_rank(); if(myrank == root) { vector_a = new int[vsize]; vector_b = new int[vsize]; for(i = 0;i < vsize;i++) { vector_a[i] = i+1; vector_b[i] = vsize+(i+1); } } MPI::COMM_WORLD.Bcast(&vsize,1,MPI::INT,0); if(vsize < numprocs) { if(myrank == 0) cout<<"\nVector size is less than No. of Procs.."<" <