gcc/libgfortran/intrinsics
Janne Blomqvist 0eaee4abb1 Improve PRNG jumping when using threads
Currently, when a new thread needs to use the RANDOM_NUMBER intrinsic,
the per-thread PRNG state is initialized by copying the master state
and then jumping forwards N*2**128 entries in the stream so that the
PRNG streams for different threads don't alias each other, where N is
the number of threads that have so far initialized the PRNG.

With this patch the master state itself is jumped forwards once each
time a new thread initializes the PRNG, thus obviating the need to
jump through all the N-1 previous streams. Effectively turning an O(N)
algorithm into an O(1) one.

Regtested on x86_64-pc-linux-gnu.

libgfortran/ChangeLog:

2019-09-05  Janne Blomqvist  <jb@gcc.gnu.org>

	* intrinsics/random.c (master_init): Replace with
	master_state.init.
	(njumps): Remove variable.
	(master_state): Make instance of struct prng_state.
	(init_rand_state): When jumping, update the master_state once
	instead of keeping track of how many jumps need to be done.
	(SZU64): Modify to handle new master_state.
	(SZ): Likewise.
	(random_seed_i4): Likewise.
	(random_seed_i8): Likewise.

From-SVN: r275397
2019-09-05 09:59:55 +03:00
..
abort.c Update copyright years. 2019-01-01 13:31:55 +01:00
access.c Update copyright years. 2019-01-01 13:31:55 +01:00
args.c Update copyright years. 2019-01-01 13:31:55 +01:00
associated.c Update copyright years. 2019-01-01 13:31:55 +01:00
c99_functions.c Update copyright years. 2019-01-01 13:31:55 +01:00
chdir.c Update copyright years. 2019-01-01 13:31:55 +01:00
chmod.c Update copyright years. 2019-01-01 13:31:55 +01:00
clock.c Update copyright years. 2019-01-01 13:31:55 +01:00
cpu_time.c Update copyright years. 2019-01-01 13:31:55 +01:00
cshift0.c Update copyright years. 2019-01-01 13:31:55 +01:00
ctime.c Update copyright years. 2019-01-01 13:31:55 +01:00
date_and_time.c Update copyright years. 2019-01-01 13:31:55 +01:00
dprod_r8.f90 Update copyright years. 2019-01-01 13:31:55 +01:00
dtime.c Update copyright years. 2019-01-01 13:31:55 +01:00
env.c Update copyright years. 2019-01-01 13:31:55 +01:00
eoshift0.c Update copyright years. 2019-01-01 13:31:55 +01:00
eoshift2.c Update copyright years. 2019-01-01 13:31:55 +01:00
erfc_scaled.c Update copyright years. 2019-01-01 13:31:55 +01:00
erfc_scaled_inc.c Update copyright years. 2019-01-01 13:31:55 +01:00
etime.c Update copyright years. 2019-01-01 13:31:55 +01:00
execute_command_line.c libfortran/90038 Reap dead children when wait=.false. 2019-05-19 22:38:11 +03:00
exit.c Update copyright years. 2019-01-01 13:31:55 +01:00
extends_type_of.c Update copyright years. 2019-01-01 13:31:55 +01:00
f2c_specifics.F90 Update copyright years. 2019-01-01 13:31:55 +01:00
fnum.c Update copyright years. 2019-01-01 13:31:55 +01:00
gerror.c Update copyright years. 2019-01-01 13:31:55 +01:00
getXid.c Update copyright years. 2019-01-01 13:31:55 +01:00
getcwd.c Update copyright years. 2019-01-01 13:31:55 +01:00
getlog.c Update copyright years. 2019-01-01 13:31:55 +01:00
hostnm.c Update copyright years. 2019-01-01 13:31:55 +01:00
ierrno.c Update copyright years. 2019-01-01 13:31:55 +01:00
is_contiguous.c re PR fortran/45424 ([F08] Add IS_CONTIGUOUS intrinsic) 2019-01-07 19:30:28 +00:00
ishftc.c Update copyright years. 2019-01-01 13:31:55 +01:00
kill.c Update copyright years. 2019-01-01 13:31:55 +01:00
link.c Update copyright years. 2019-01-01 13:31:55 +01:00
move_alloc.c Update copyright years. 2019-01-01 13:31:55 +01:00
mvbits.c Update copyright years. 2019-01-01 13:31:55 +01:00
pack_generic.c Update copyright years. 2019-01-01 13:31:55 +01:00
perror.c Update copyright years. 2019-01-01 13:31:55 +01:00
rand.c Update copyright years. 2019-01-01 13:31:55 +01:00
random.c Improve PRNG jumping when using threads 2019-09-05 09:59:55 +03:00
random_init.f90 Update copyright years. 2019-01-01 13:31:55 +01:00
rename.c Update copyright years. 2019-01-01 13:31:55 +01:00
reshape_generic.c Update copyright years. 2019-01-01 13:31:55 +01:00
reshape_packed.c Update copyright years. 2019-01-01 13:31:55 +01:00
selected_char_kind.c Update copyright years. 2019-01-01 13:31:55 +01:00
selected_int_kind.f90 Update copyright years. 2019-01-01 13:31:55 +01:00
selected_real_kind.f90 Update copyright years. 2019-01-01 13:31:55 +01:00
signal.c Update copyright years. 2019-01-01 13:31:55 +01:00
size.c Update copyright years. 2019-01-01 13:31:55 +01:00
sleep.c Update copyright years. 2019-01-01 13:31:55 +01:00
spread_generic.c Update copyright years. 2019-01-01 13:31:55 +01:00
stat.c Update copyright years. 2019-01-01 13:31:55 +01:00
string_intrinsics.c Update copyright years. 2019-01-01 13:31:55 +01:00
string_intrinsics_inc.c Update copyright years. 2019-01-01 13:31:55 +01:00
symlnk.c Update copyright years. 2019-01-01 13:31:55 +01:00
system.c Update copyright years. 2019-01-01 13:31:55 +01:00
system_clock.c Update copyright years. 2019-01-01 13:31:55 +01:00
time.c Update copyright years. 2019-01-01 13:31:55 +01:00
time_1.h Update copyright years. 2019-01-01 13:31:55 +01:00
umask.c Update copyright years. 2019-01-01 13:31:55 +01:00
unlink.c Update copyright years. 2019-01-01 13:31:55 +01:00
unpack_generic.c Update copyright years. 2019-01-01 13:31:55 +01:00