[petsc-users] SPRNG package

Barry Smith bsmith at mcs.anl.gov
Sat Dec 12 18:12:15 CST 2015


   Yes, from the manual page: This is only a primative "parallel" random number generator, it should NOT be used for sophisticated parallel Monte Carlo methods since it will very likely not have the correct statistics across processors. You can provide your own parallel generator using PetscRandomRegister();


> On Dec 12, 2015, at 2:22 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
> 
> Thanks for clarifying.  Yes, I’d argue the distinct seeds on the processes is an unsafe way to handle parallel RNG.
>  
> -gideon
> 
>> On Dec 12, 2015, at 3:17 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>> 
>> 
>>> On Dec 12, 2015, at 2:09 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
>>> 
>>> Something about this continues to confuse me.  I’m attaching two simple examples using SPRNG+PETSc, which generate the same results.  Indeed, when run with mpi with more than one process, they generate different sequences of random numbers on reach process, but how is it handling this, if it’s not using SPRNG’s parallel RNG?
>> 
>>  We just put a different seed based on the MPI rank for each process; we do this for all the random number generators we use*.  Note the PETSc code that calls sprng is very short and simple and easily understood /src/sys/classes/random/impls/sprng/sprng.c
>> 
>> Barry
>> 
>> * I am not claiming this is a good idea, it is just what we do.
>>> 
>>> -gideon
>>> 
>>> 
>>>> On Dec 11, 2015, at 5:31 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>>>> 
>>>> 
>>>>  I believe that we compile sprng with MPI but PETSc uses sprng only as a sequential random number generator hence I believe the comment is correct and should be left.
>>>> 
>>>>  Barry
>>>> 
>>>>> On Dec 11, 2015, at 1:51 PM, Gideon Simpson <gideon.simpson at gmail.com> wrote:
>>>>> 
>>>>> It seems confused.  You can compile SPRNG with/without MPI.  However, even if you compile it with MPI support, it can still be run as a serial RNG.
>>>>> 
>>>>> -gideon
>>>>> 
>>>>>> On Dec 11, 2015, at 2:40 PM, Hong <hzhang at mcs.anl.gov> wrote:
>>>>>> 
>>>>>> Barry :
>>>>>>> there is a comment:
>>>>>>> 
>>>>>>>  This is NOT currently using a parallel random number generator. Sprng does have
>>>>>>>  an MPI version we should investigate.
>>>>>> 
>>>>>> Shall we remove this comment? 
>>>>>> Hong
>>>>>> 
>>>>>>>> On Dec 11, 2015, at 11:30 AM, Hong <hzhang at mcs.anl.gov> wrote:
>>>>>>>> 
>>>>>>>> Gideon:
>>>>>>>> I was looking at the source files and noticed in the comments that when petsc is built with sprng, the petsc interface isn’t to the parallel sprng RNG.  But is the package built with MPI, so that I could manually use the parallel RNG?
>>>>>>>> Petsc- sprng-1.0 interface was written many years ago.
>>>>>>>> It is for parallel computation. Students contributed an example at
>>>>>>>> petsc/src/sys/classes/random/examples/tutorials/ex2.c
>>>>>>>> 
>>>>>>>> Very few users have ever used this interface.
>>>>>>>> If you encounter any problem, please report to us.
>>>>>>>> 
>>>>>>>> Hong
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>>> <petsc_sprng1.c><petsc_sprng2.c>
>> 
> 



More information about the petsc-users mailing list