The programme program rand10 real*10 x call random_number (x) end program rand10 fails during linking with $ ~/gcc/bin/gfortran -o rand10 rand10.f90 /usr/bin/ld: Undefined symbols: __gfortran_random_r10 collect2: ld returned 1 exit status $ ~/gcc/bin/gfortran --version GNU Fortran 95 (GCC) 4.2.0 20060624 (experimental)
I'll take a look at this. See http://gcc.gnu.org/ml/fortran/2006-07/msg00311.html and follow-ups for the discussion of this bug.
While I work on this, I might as well tackle some other issues. Before I start work, some timings with a vanilla tree as of today. The timing isn't terrible (within a factor of two with Intel 8.1), but of course, I don't know Intel's quality of RNG. $ cat random-single.f90 program main real, dimension(10**7) :: a call random_number(a) end program main $ gfortran random-single.f90 $ ./a.out && time ./a.out real 0m0.765s user 0m0.730s sys 0m0.036s $ ifort random-single.f90 $ ./a.out && time ./a.out real 0m0.362s user 0m0.313s sys 0m0.049s $ cat random-double.f90 program main real(kind=8), dimension(10**7) :: a call random_number(a) end program main $ gfortran random-double.f90 $ ./a.out && time ./a.out real 0m0.886s user 0m0.804s sys 0m0.077s $ ifort random-double.f90 $ ./a.out && time ./a.out real 0m0.402s user 0m0.328s sys 0m0.074s
Created attachment 11926 [details] patch This implements random for KIND=10 and KIND=16 REALs. It is regression-tested on i686-pc-linux-gnu, but not on a system with KIND=16 REALs. It also speeds up the random numbers for the real case: $ gfortran random-single.f90 $ ./a.out && time ./a.out real 0m0.300s user 0m0.266s sys 0m0.034s (same program as before).
Thomas, Don't you need a HAVE_GFC_REAL_16 section or is random_r10 used for random_r16? Also, I noticed that you've eliminated the normalize_* calls. I think may actually be able to remove these functions and the file that contains them.
(In reply to comment #4) > Don't you need a HAVE_GFC_REAL_16 section or is random_r10 used > for random_r16? Oops, I uploaded the wrong patch. Sorry 'bout that. However, I still need to think a bit about what constant to multiply with. What I currently have could also return 1. > > Also, I noticed that you've eliminated the normalize_* calls. > I think may actually be able to remove these functions and > the file that contains them. Correct. I would also have to remove the call to normalize_* from rand.c. Looks like a bit more work to be done.
Created attachment 11929 [details] current status of patch This is the current status of the patch. As I wrote, this isn't yet complete. Thomas
Created attachment 11951 [details] Current status of patch Here's the current patch. It regtests fine, and seems to do the Right Thing. I haven't been able to test it on a system with REAL(16), nor on an S/360 where FLT_RADIX == 16.
Subject: Bug 28452 Author: tkoenig Date: Tue Aug 1 17:29:50 2006 New Revision: 115859 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115859 Log: 2006-08-01 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/28452 * libgfortran/ChangeLog: Correct PR number. * gcc/testsuite/ChangeLog: Likewise. Modified: trunk/gcc/testsuite/ChangeLog trunk/libgfortran/ChangeLog
Subject: Bug 28452 Author: tkoenig Date: Sat Aug 26 19:17:35 2006 New Revision: 116476 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116476 Log: 2006-08-26 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/28542 * Makefile.am: Remove normalize.c. * aclocal.m4: Regenerate. * Makefile.in: Regenerate. * libgfortran.h: #include <float.h>. Define GFC_REAL_*_DIGITS and GFC_REAL_*_RADIX. Remove prototypes for normalize_r4_i4 and normalize_r8_i8. * intrinsics/random.c (top level): Add prototypes for random_r10, arandom_r10, random_r16 and arandom_r16. (rnumber_4): New static function. (rnumber_8): New static function. (rnumber_10): New static function. (rnumber_16): New static function. (top level): Set to kiss_size to 12 if we have REAL(KIND=16), to 8 otherwise. Define KISS_DEFAULT_SEED_1, KISS_DEFAULT_SEED_2 and KISS_DEFAULT_SEED_3. (kiss_random_kernel): Take argument to differentiate between different random number generators. (random_r4): Add argument to call to kiss_random_kernel, use rnumber_*. (random_r8): Likewise. (random_r10): New function. (random_r16): New function. (arandom_r4): Add argument to call to kiss_random_kernel, use_rnumber_*. (arandom_r8): Likewise. (arandom_r10): New function. (arandom_r16): New function. * intrinsics/rand.c (rand): Use shift and mask. * runtime/normalize.c: Remove. 2006-08-28 Thomas Koenig <Thomas.Koenig@online.de> PR libfortran/28452 * gfortran.dg/random_3.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/random_3.f90 Removed: branches/gcc-4_1-branch/libgfortran/runtime/normalize.c Modified: branches/gcc-4_1-branch/gcc/testsuite/ChangeLog branches/gcc-4_1-branch/libgfortran/ChangeLog branches/gcc-4_1-branch/libgfortran/Makefile.am branches/gcc-4_1-branch/libgfortran/Makefile.in branches/gcc-4_1-branch/libgfortran/intrinsics/rand.c branches/gcc-4_1-branch/libgfortran/intrinsics/random.c branches/gcc-4_1-branch/libgfortran/libgfortran.h
Fixed on 4.1 as well. Closing.