![]() |
GHOST
1.1.2
General, Hybrid, and Optimized Sparse Toolkit
|
Functions for handling random number generation states. More...
#include "error.h"
Go to the source code of this file.
Macros | |
#define | GHOST_RAND_SEED_ALL (GHOST_RAND_SEED_PU|GHOST_RAND_SEED_RANK|GHOST_RAND_SEED_TIME) |
Enumerations | |
enum | ghost_rand_seed_type { GHOST_RAND_SEED_NONE = 0, GHOST_RAND_SEED_PU = 1, GHOST_RAND_SEED_RANK = 2, GHOST_RAND_SEED_TIME = 4 } |
Functions | |
ghost_error | ghost_rand_get (unsigned int **s) |
Get a random state for the calling thread. More... | |
ghost_error | ghost_rand_create () |
Create a random seed for each PU of the machine. More... | |
void | ghost_rand_destroy () |
Destroy the random states. More... | |
ghost_error | ghost_rand_seed (ghost_rand_seed_type which, unsigned int seed) |
Set the random number seed. More... | |
int | ghost_rand_cu_seed_get () |
Get the CUDA random seed. More... | |
bool | ghost_rand_customseed () |
Check whether a custom seed has been set. More... | |
Functions for handling random number generation states.
#define GHOST_RAND_SEED_ALL (GHOST_RAND_SEED_PU|GHOST_RAND_SEED_RANK|GHOST_RAND_SEED_TIME) |
enum ghost_rand_seed_type |
ghost_error ghost_rand_create | ( | ) |
Create a random seed for each PU of the machine.
This assumes that there at most as many OpenMP threads as there are PUs.
int ghost_rand_cu_seed_get | ( | ) |
Get the CUDA random seed.
bool ghost_rand_customseed | ( | ) |
Check whether a custom seed has been set.
void ghost_rand_destroy | ( | ) |
Destroy the random states.
ghost_error ghost_rand_get | ( | unsigned int ** | s | ) |
Get a random state for the calling thread.
s | Where to store the state. |
The random state is determined from the calling OpenMP thread index. OpenMP do not have to be pinned in order to return correct random seeds. This function is used for thread-safe random number generation.
ghost_error ghost_rand_seed | ( | ghost_rand_seed_type | which, |
unsigned int | seed | ||
) |
Set the random number seed.
which | Which components of the seed should be set. Components can be combined with OR. |
seed | The value to which the component should be set. |
The random number seed used by GHOST is a combination of the time, the rank and the PU. Each of those components can be set individually with this function. This assumes that there at most as many OpenMP threads as there are PUs. It is not possible to set the PU seed on CUDA devices.