You are on page 1of 3

EMAIL NOTE: It will be necessary to experiment around using code to determine exactly how the various

random number generators on ClearSpeed work. Hopefully the attached comments will also help.

If everyone will take a close look at the random number generators, hopefully solutions will be found to
all problems regarding their use for this project. If so, then perhaps following a class discussion of this,
problems with the random number generators will be eliminated.

ClearSpeed was heavily used to compute many mathematical calculations, which it could usually do
much faster than the server host that housed it. Also, they went to the trouble to fully implement the
full IEEE standards for use of floating point numbers. As a result, I assume that the random number
generators included have been tested out extensively, both initially and by heavy use of numerous
purchasers of ClearSpeed Accelerators.

CLEARSPEED PSEUDO-RANDOM NUMBER GENERATORS

The information on the pseudo-random generators provided by ClearSpeed is in the Cn Standard


Libraries Reference Manual, on pages 44, 45, 67, 68, 69. Additionally, Chapter 6 is titled "The
ClearSpeed Random Number Generator Library" and contains additional information. There may be
random number generators for the assembly language for ClearSpeed, but these would be less easy to
use.

A few basic facts about pseudo-random generators follow. They require the use of a "seed" to generate
a sequence of random values. If the same seed is always used, the same sequence of random values will
be generated each time. This is the reason the sequence is called a pseudo-random number generator,
as its values are predictable. A different sequence is generated if the seed is changed. Typically, if r(n) is
the random value generated at stage n, it is used as the seed to produce the r(n+1) random value. The
fact that the same sequence is produced is not a problem, as quality random algorithms pass
"randomness tests" like the numbers in the sequence being generated are uniformly distributed. In fact,
the same sequence being produced when the same seed is used is often an advantage, as it makes
debugging easier since the same random sequence is used on each successive run.

Since we don't want aircraft locations, velocity directions and speeds, etc. to be identical for aircraft in
different PEs, we need to use different random value sequences for different PEs. This can be handled by
assigning a different seed to each PE. If the random value r(n) lies in the range of [0,1], we can use this
value to add this fraction of a nautical mile to the present x-coordinate location. The next r(n+1) random
variable can be used to add a fraction of a nautical mile to the y-coordinate. While the same random
value could be used to adjust both the x and y coordinate location, this is less realistic, as a wind stream
against aircraft would probably effect the x and y coordinates differently. Of course, this adjustment will
change aircraft's velocity somewhat - both in terms of direction and in terms of speed.

When a random number generator produces a sequence that is “uniformly distributed, it means that if
the range of values being produced is partitioned evenly into k subintervals, that the number of values
produced by the random generator tends to place approximately 1/k of these values into each
subinterval. This would tend to become more the case as the number of sequence values generated
increases. If one wants to generate sequence values that meet some other test other than being “a
uniformly distributed” sequence, then probably the best way to do this is to search for a random
number generator that meets your needs and then implement it on ClearSpeed. Random number
generators normally only involve a small amount of code and are fairly straight-forward , so they can
usually be easily re-implemented on other sequential or parallel systems. The specification that the
average of height of the planes (or their speed) not be the median of the values being randomly
generated eliminates the use of a uniformly distributed random number processor. While desirable, this
is more of an “extra credit” specification rather than a core requirement for this project.

The random values being used to produce radar (corresponding to variations in the velocity of aircraft
during each 0.5 seconds), the random values produced for this purpose needs to be different for each
aircraft. Moreover, since this is occurring each ½ second, it would dramatically slow down the execution
rate if these random values were produced by the server or the control unit for the accelerator. In other
words, these need to be produced by parallel random sequence generation, where each sequence is
different (due to having a different seed).

If the random numbers being generated are integers between 0 and some MAX_VALUE, then random
numbers in the range [0,1] can be produced by dividing each random number by MAX_VALUE. Of
course, another method is to switch to a random number generator that produces values in the [0,1]
range.

Some comments about material in the ClearSpeed C n Standard Libraries Reference Manual follow. This
can be found at the ClearSpeed document site that I created and posted on our class webpage. It can
also be found on the ClearSpeed files on the documentation for the CSX600 on the simd server (when
this server is up and running).

RANDOM NUMBER GENERATOR - ClearSpeed Cn Standard Libraries Reference Manual

 Pseudo-Random Number Generator “rand” is discussed on page 44. The random seed is set
using “srand”
o It returns a number between 0 and RAND_MAX. If you want a value between 0 and 1,
then the random value has to be divided by RAND_MAX.
o If the seed is the same at the start of the generation of a sequence of random numbers,
the same sequence will be generated.
 A family of pseudo-random number generators for different data types is described on pg 45.
The Pseudo-Random Number Generator “rand48” returns values of type double that lie in the
interval [0.0, 1.0) – (i.e., that is greater than or equal to 0 and strictly less than 1).
 Poly versions of the rand48 family of generators are discussed on page 67. These can be used to
generate a sequence of random numbers for each active processor. For example, drand48p
return values of type double with a value in the interval [0.0, 1.0]
 The poly version, randp, of rand is discussed on page 69. It returns a number in the range of [0,
RAND_MAX], so you would have to divide it by RAND_MAX or 1+RAND_MAX to get a value in
[0,1] or [0,1), respectively.
 The algorithm used requires a random seed, and with a given random seed value, the same
sequence of pseudo-random numbers is always produced. To produce unpredictable values,
different (perhaps time-varying seeds must be used. To get different values in each PE, a
different seed must be used on each PE.
 Further information is covered in Chapter 6, “The ClearSpeed Random Number Generator
Library”, on pages 571-590.

You might also like