Yes, that’s the kind of thing that I want.

-gideon

> On Feb 14, 2017, at 5:28 PM, Barry Smith <[email protected]> wrote:
> 
> 
>> On Feb 14, 2017, at 3:01 PM, Gideon Simpson <[email protected]> wrote:
>> 
>> 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);
> 
>  This definitely won't work!  What do you want to do take a PETSc vector that 
> lies across process and produce a new PETSc vector that lies across processes 
> in the same way but each entry in the new vector contains the sum of the 
> entries "to the left of that entry, plus the current entry" For example
> 
> [1 3 ]   [8 1]
> 
> becomes
> 
> [1 4] [12 13]?
> 
> Where [] represents the values on each process? and you have two processes in 
> this example.
> 
> Barry
> 
> 
> 
>> 
>> 
>> -gideon
>> 
>>> On Feb 14, 2017, at 3:48 PM, Matthew Knepley <[email protected]> wrote:
>>> 
>>> On Tue, Feb 14, 2017 at 2:46 PM, Gideon Simpson <[email protected]> 
>>> 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
>> 
> 

Reply via email to