[Mpi-forum] about MPI_Scan

Likun Tan likunt at andrew.cmu.edu
Fri Sep 2 14:30:31 CDT 2011


Hello,

I have a rectangular matrix B with size M*N (where N>>M), i use the
following command to create and compute the matrix by column:

PetscSplitOwnership(PETSC_COMM_WORLD, &n, &N);
MPI_Scan(&n, &cstart, 1, MPI_INT, MPI_SUM, PETSC_COMM_WORLD);
cstart -= n;
MatCreateSeqDense(PETSC_COMM_SELF, M, n, PETSC_NULL, &B);

for(j=0; j<n; j++)
{
   for(i=0; i<M; i++)
   {
      MatSetValues(B, 1, &i, 1, &j, &value, INSERT_VALUES);
   }
}

MatAssemblyBegin(B, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(B, MAT_FINAL_ASSEMBLY);

where n is the number of columns in each processor.
Any problem with this?

Thanks,
Likun








More information about the mpi-forum mailing list