On Wed, Jul 14, 2010 at 5:08 AM, Axel Arnold
<address@hidden> wrote:
On Tuesday 13 July 2010 21:22:50 Owen Hickey wrote:
> You need to sed the random number generator as while the numbers appear to
> be random they are in fact deterministic so for one processor:
> t_random seed [expr abs([clock clicks]%100000)]
Another good choice is
t_random seed [pid]
which has the advantage, that if you for example batch-submit your jobs and 4
start at the same time, with modern systems the chance are actually quite good
that several start in the same second, which means you get again the same
seed. The process id pid however is always different.
Finally, the tcl built-in RNG is always initialized from some "true" random
source, so that also works:
t_random seed [expr int(rand(()*32768)]
>
> or for 128 processors:
> set Seeds [list {}]
> set _ran [pid]
> for {set i 0} {$i<128} {incr i} {
> lappend Seeds {0}
> }
> for {set i 0} {$i<128} {incr i} {
> set _ran [expr ($_ran * 9301 + 49297) % 233280]
> set seed [expr int(1000000000 * ($_ran / double(233280)))]
> lset Seeds $i $seed
> }
>
> puts $Seeds
> t_random seed [lindex $Seeds 0] [lindex $Seeds 1] [lindex $Seeds 2] [lindex
....
> [lindex $Seeds 125] [lindex $Seeds 126] [lindex $Seeds 127]
That can be done much easier:
set seed [pid]
for {set i 0} {$i< [setmd n_nodes]} {incr i} {
lappend Seeds [expr $seed + $i]
}
eval t_random seed $Seeds
This has the advantage that it works for any number of CPUs, and using a
simple linear sequence for the seeds works as good as using a pseudo-random
series.
Finally, you should always save the seed somewhere. In case something really
unusual happens in your simulation that you want to investigate further, you
need exactly the same seed again to reproduce the simulation.
Cheers,
Axel
--
JP Dr. Axel Arnold Tel: +49 711 685 67609
ICP, Universität Stuttgart Email: address@hidden
Pfaffenwaldring 27
70569 Stuttgart, Germany