[petsc-users] can I still use collectives like MPI_Bcast, MPI_Scatter on Petsc vectors?

Matthew Knepley knepley at gmail.com
Thu Feb 23 12:48:44 CST 2017


On Thu, Feb 23, 2017 at 12:44 PM, Fangbo Wang <fangbowa at buffalo.edu> wrote:

> Assume I need to use Petsc function Matmult,  I need to define a Petsc
> matrix "A" and a Petsc vector "b".
>
> Mat A;
> Vec b;
>
> can I do MPI_bcast on this vector b?
>

1) I assume the Bcast has nothing to do with the MatMult.

2) MPI_Bcast applies only to MPI datatypes. Vec is a pointer to an object
structure.

3) If you want to Bcast the values of a serial vector to all procs, do this:


http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecScatterCreateToAll.html#VecScatterCreateToAll

  Thanks,

     Matt


> Thank you very much!
>
>
> On Thu, Feb 23, 2017 at 1:23 PM, Matthew Knepley <knepley at gmail.com>
> wrote:
>
>> On Thu, Feb 23, 2017 at 12:09 PM, Fangbo Wang <fangbowa at buffalo.edu>
>> wrote:
>>
>>> thank you very much!
>>>
>>
>> I do not know what you mean about "on PETSc Vectors", but yes you can
>> always call MPI functions whenever you want.
>>
>>   Matt
>>
>>
>>> --
>>> Fangbo Wang, PhD student
>>> Stochastic Geomechanics Research Group
>>> Department of Civil, Structural and Environmental Engineering
>>> University at Buffalo
>>> Email: *fangbowa at buffalo.edu <fangbowa at buffalo.edu>*
>>>
>>
>>
>>
>> --
>> 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
>>
>
>
>
> --
> Fangbo Wang, PhD student
> Stochastic Geomechanics Research Group
> Department of Civil, Structural and Environmental Engineering
> University at Buffalo
> Email: *fangbowa at buffalo.edu <fangbowa at buffalo.edu>*
>



-- 
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/20170223/a6339964/attachment.html>


More information about the petsc-users mailing list