Commercial Compilers and Parallel Random Numbers

Scott Robert Ladd coyote@coyotegulch.com
Sun Apr 25 18:24:00 GMT 2004


Hello

In the past, I'd done a bit a reasearch about parallel random number 
generators, and I've coallesced some of that here in light of recent 
discussions.

IBM's XL Fortran for the Power3 has a run-time parameter that sets the 
number of threads for the random number generator. IBM implemented this 
model in response to user requests; from the sound of it, they use a 
system similar to the one I suggested, maintaining per-thread seed data. 
NERSC has a paper on this at:

     http://www.nersc.gov/~ragerber/reports/random_number.pdf

Documentation for DEC Fortran 90 v5.2, from December 1998, states that 
it's RANDOM_NUMBER "executes in parallel for mapped data."

I can't find anything in Intel's or Lahey's documentation that says 
anything about whether or not their RANDOM_NUMBER routines are thread-safe.

I experimented with a simple program:

   program randpar

   integer, parameter :: LOOPS = 1024
   integer, parameter :: N = 1000000
   real, dimension(N) :: data1
   integer :: i

   !omp parallel do
   do i = 1, LOOPS
     call random_number(data1)
   end do

   end program randpar

Intel ifort 8.0 performs poorly on the code above, with erratic run 
times on an HT-enabled Pentium 4, and a consistent segmentation fault on 
a dual Pentium 3 system.

Lahey lf95 6.1 (yes, I know a somewhat antiquated version) does not 
crash on the dual P3, but it gains almost no benefit (about 2%) from 
parallelization. My guess is that Lahey wraps their RANDOM_NUMBER as a 
critical section so it is only accessed by one thread at a time. I did 
not try Lahey on the P4, as it is not installed there at the moment.

GCC, of course, lacks OpenMP support, so I can't perform the above 
experiment using tree-ssa.

Just some food for thought.

-- 
Scott Robert Ladd
Coyote Gulch Productions (http://www.coyotegulch.com)
Software Invention for High-Performance Computing



More information about the Fortran mailing list