Bug 28452 - __gfortran_random_r10 not found
Summary: __gfortran_random_r10 not found
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Thomas Koenig
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2006-07-21 15:33 UTC by Erik Schnetter
Modified: 2006-08-26 19:18 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.2.0 4.1.2
Last reconfirmed: 2006-07-22 20:23:23


Attachments
patch (1.33 KB, patch)
2006-07-23 21:14 UTC, Thomas Koenig
Details | Diff
current status of patch (2.59 KB, patch)
2006-07-24 20:23 UTC, Thomas Koenig
Details | Diff
Current status of patch (3.67 KB, patch)
2006-07-26 19:49 UTC, Thomas Koenig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Schnetter 2006-07-21 15:33:30 UTC
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)
Comment 1 Thomas Koenig 2006-07-23 17:14:48 UTC
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.
Comment 2 Thomas Koenig 2006-07-23 17:23:09 UTC
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
Comment 3 Thomas Koenig 2006-07-23 21:14:02 UTC
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).
Comment 4 kargls 2006-07-23 23:32:04 UTC
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.
Comment 5 Thomas Koenig 2006-07-24 20:12:59 UTC
(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.

Comment 6 Thomas Koenig 2006-07-24 20:23:27 UTC
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
Comment 7 Thomas Koenig 2006-07-26 19:49:34 UTC
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.
Comment 8 Thomas Koenig 2006-08-01 17:30:12 UTC
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

Comment 9 Thomas Koenig 2006-08-26 19:17:44 UTC
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

Comment 10 Thomas Koenig 2006-08-26 19:18:39 UTC
Fixed on 4.1 as well.

Closing.