[petsc-users] prefix (i.e. cumulative) sum

Gideon Simpson gideon.simpson at gmail.com
Tue Feb 14 15:01:47 CST 2017


I gather I’d use something like this?

VecGetArray(x, &xarray);
VecGetArray(y, &yarray);

MPI_Scan(array, array, nglobal, MPIU_SCALAR, MPI_SUM, PETSC_COMM_WORLD);

VecRestoreArray(x, &xarray);
VecRestoreArray(y, &yarray);


-gideon

> On Feb 14, 2017, at 3:48 PM, Matthew Knepley <knepley at gmail.com> wrote:
> 
> On Tue, Feb 14, 2017 at 2:46 PM, Gideon Simpson <gideon.simpson at gmail.com <mailto:gideon.simpson at gmail.com>> wrote:
> Is there a clever way to handle a prefix (cumulative) sum in petsc?  I think I can see how to do with using some underlying MPI, but I was wondering if there were some built in routines that could be useful.
> 
> It is one MPI call (MPI_Scan), but you could do it by assigning sizes to a PetscLayout (which is how I have done it several places).
> 
>   Thanks,
> 
>     Matt
>  
> -gideon
> 
> 
> 
> 
> -- 
> What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
> -- Norbert Wiener

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170214/cbc7e3f3/attachment.html>


More information about the petsc-users mailing list