Next: , Previous: , Up: Run-time library functions   [Contents][Index]


6.3.7 Random-task functions

Randomness appears in various forms in the coNCePTuaL language, such as when assigning a task to A RANDOM PROCESSOR (see Reordering task IDs) or when let-binding A RANDOM TASK or A RANDOM TASK OTHER THAN a given task ID to a variable (see Binding variables). The following functions are used to select tasks at random. coNCePTuaL currently uses the Mersenne Twister as its random-number generator. Hence, given the same seed, a coNCePTuaL program will see the same random-number sequence on every platform.

Function: int ncptl_seed_random_task (int seed, ncptl_int procID)

Initialize the random-number generator needed by ncptl_random_task(). If seed is zero, ncptl_seed_random_task() selects an arbitrary seed value. ncptl_seed_random_task() returns the seed that was used. procID specifies the (physical) processor ID of the calling task and is needed to seed the task-local random-number generators used by some of the functions in Language-visible functions.

Function: ncptl_int ncptl_random_task (ncptl_int lower_bound, ncptl_int upper_bound, ncptl_int excluded)

Return a randomly selected task number from lower_bound to upper_bound (both inclusive). If excluded is nonnegative then that task number will never be selected, even if it’s within range.

Scott Pakin, pakin@lanl.gov