do concurrent in parallel? speed-up?

Anton Shterenlikht mexas@bris.ac.uk
Wed Feb 12 08:47:00 GMT 2014


>From: Damian Rouson <rouson@stanford.edu>
>Subject: Re: do concurrent in parallel? speed-up?
>Date: Tue, 11 Feb 2014 11:31:00 -0800
>To: gfortran <fortran@gcc.gnu.org>
>On Tue, 11 Feb 2014 13:15:34 -0500, Tim Prince wrote:
>
>> I've turned my masked do concurrents into DO loops with MERGE for the benefit of gfortran 4.9. ifort 
>> needs VECTOR ALIGNED directives to get full performance of masked DO CONCURRENT, and it's still fully 
>> effective only for single thread vectorization.
>
>Could you provide a simple example and give rough estimates of the resulting speedup with gfortran 4.9 and the CPU employed?
>
>Damian
>

I haven't figured out yet how to do it with gfortran,
but for ifort v 14 on:

CPU0: Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz stepping 07
Total of 16 processors activated (83188.94 BogoMIPS).

with this program:

program pidc

implicit none

integer, parameter :: ik = selected_int_kind(10),     &
                      rk = selected_real_kind(15,3)
integer( kind=ik ), parameter :: dc_limit = 2_ik**27_ik
integer( kind=ik ), parameter ::    limit = 2_ik**31_ik
real( kind=rk ), parameter :: piref = 3.14159265358979323846264338327950288_rk

real( kind=rk) :: pi( dc_limit ), pi_calc = 0.0_rk
integer( kind=ik ) :: i, j, shift, loops

loops = limit / dc_limit

do j = 1, loops
  shift = (j-1)*dc_limit

  do concurrent (i = 1:dc_limit)
    pi(i) = (-1)**(shift+i+1) / real( 2*(shift+i)-1, kind=rk )
  end do
  pi_calc = pi_calc + sum(pi)

end do

pi_calc = pi_calc * 4.0_rk

write (*,"(a,i0)") "**** do concurrent ****, number of outer loops: ", loops
write (*,"(a,i0)") "Series limit: ", limit
write (*,*) "Calculated  pi=", pi_calc
write (*,*) "Reference   pi=", piref
write (*,*) "Absolute error=", pi_calc-piref

end program pidc

I get:

$ ifort -parallel -par-num-threads=1 pi_dc.f90
$ /usr/bin/time -f%E ./a.out
**** do concurrent ****, number of outer loops: 16
Series limit: 2147483648
 Calculated  pi=   3.14159265312117     
 Reference   pi=   3.14159265358979     
 Absolute error= -4.686184773561308E-010
0:16.17
$ ifort -parallel -par-num-threads=16 pi_dc.f90
$ /usr/bin/time -f%E ./a.out
**** do concurrent ****, number of outer loops: 16
Series limit: 2147483648
 Calculated  pi=   3.14159265312117     
 Reference   pi=   3.14159265358979     
 Absolute error= -4.686184773561308E-010
0:02.80
$ ifort -parallel -par-num-threads=8 pi_dc.f90
$ /usr/bin/time -f%E ./a.out
**** do concurrent ****, number of outer loops: 16
Series limit: 2147483648
 Calculated  pi=   3.14159265312117     
 Reference   pi=   3.14159265358979     
 Absolute error= -4.686184773561308E-010
0:03.80
$ ifort -parallel -par-num-threads=32 pi_dc.f90
$ /usr/bin/time -f%E ./a.out
**** do concurrent ****, number of outer loops: 16
Series limit: 2147483648
 Calculated  pi=   3.14159265312117     
 Reference   pi=   3.14159265358979     
 Absolute error= -4.686184773561308E-010
0:03.20
$ 

So a speed up of about 5-6 going from 1 to 16 cores,
i.e. efficiency of about 0.3-0.4.

I know this has nothing to do with gfortran,
just a data point.

Anton



More information about the Fortran mailing list