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
Name |
Last commit
|
Last update |
---|---|---|
.. | ||
abort.c | Loading commit data... | |
access.c | Loading commit data... | |
args.c | Loading commit data... | |
associated.c | Loading commit data... | |
c99_functions.c | Loading commit data... | |
chdir.c | Loading commit data... | |
chmod.c | Loading commit data... | |
clock.c | Loading commit data... | |
cpu_time.c | Loading commit data... | |
cshift0.c | Loading commit data... | |
ctime.c | Loading commit data... | |
date_and_time.c | Loading commit data... | |
dprod_r8.f90 | Loading commit data... | |
dtime.c | Loading commit data... | |
env.c | Loading commit data... | |
eoshift0.c | Loading commit data... | |
eoshift2.c | Loading commit data... | |
erfc_scaled.c | Loading commit data... | |
erfc_scaled_inc.c | Loading commit data... | |
etime.c | Loading commit data... | |
execute_command_line.c | Loading commit data... | |
exit.c | Loading commit data... | |
extends_type_of.c | Loading commit data... | |
f2c_specifics.F90 | Loading commit data... | |
fnum.c | Loading commit data... | |
gerror.c | Loading commit data... | |
getXid.c | Loading commit data... | |
getcwd.c | Loading commit data... | |
getlog.c | Loading commit data... | |
hostnm.c | Loading commit data... | |
ierrno.c | Loading commit data... | |
is_contiguous.c | Loading commit data... | |
ishftc.c | Loading commit data... | |
kill.c | Loading commit data... | |
link.c | Loading commit data... | |
move_alloc.c | Loading commit data... | |
mvbits.c | Loading commit data... | |
pack_generic.c | Loading commit data... | |
perror.c | Loading commit data... | |
rand.c | Loading commit data... | |
random.c | Loading commit data... | |
random_init.f90 | Loading commit data... | |
rename.c | Loading commit data... | |
reshape_generic.c | Loading commit data... | |
reshape_packed.c | Loading commit data... | |
selected_char_kind.c | Loading commit data... | |
selected_int_kind.f90 | Loading commit data... | |
selected_real_kind.f90 | Loading commit data... | |
signal.c | Loading commit data... | |
size.c | Loading commit data... | |
sleep.c | Loading commit data... | |
spread_generic.c | Loading commit data... | |
stat.c | Loading commit data... | |
string_intrinsics.c | Loading commit data... | |
string_intrinsics_inc.c | Loading commit data... | |
symlnk.c | Loading commit data... | |
system.c | Loading commit data... | |
system_clock.c | Loading commit data... | |
time.c | Loading commit data... | |
time_1.h | Loading commit data... | |
umask.c | Loading commit data... | |
unlink.c | Loading commit data... | |
unpack_generic.c | Loading commit data... |