GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions | Variables
rand.c File Reference
#include "ghost/config.h"
#include "ghost/types.h"
#include "ghost/util.h"
#include "ghost/timing.h"
#include "ghost/rand.h"
#include "ghost/machine.h"
#include "ghost/omp.h"
#include "ghost/locality.h"
#include "ghost/core.h"
Include dependency graph for rand.c:

Functions

ghost_error ghost_rand_create ()
 Create a random seed for each PU of the machine. More...
 
ghost_error ghost_rand_get (unsigned int **s)
 Get a random state for the calling thread. More...
 
ghost_error ghost_rand_seed (ghost_rand_seed_type which, unsigned int seed)
 Set the random number seed. More...
 
bool ghost_rand_customseed ()
 Check whether a custom seed has been set. More...
 
void ghost_rand_destroy ()
 Destroy the random states. More...
 
int ghost_rand_cu_seed_get ()
 Get the CUDA random seed. More...
 

Variables

static unsigned int * ghost_rand_states =NULL
 
static int nrand = 0
 
static unsigned int cu_seed = 0
 
static bool customseed = false
 

Function Documentation

ghost_error ghost_rand_create ( )

Create a random seed for each PU of the machine.

Returns

This assumes that there at most as many OpenMP threads as there are PUs.

Here is the call graph for this function:

int ghost_rand_cu_seed_get ( )

Get the CUDA random seed.

Returns
The CUDA random seed.
bool ghost_rand_customseed ( )

Check whether a custom seed has been set.

Returns
True if a custom seed has been set, false otherwise.
void ghost_rand_destroy ( )

Destroy the random states.

ghost_error ghost_rand_get ( unsigned int **  s)

Get a random state for the calling thread.

Parameters
sWhere to store the state.
Returns
GHOST_SUCCESS on success or an error indicator.

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.

Here is the call graph for this function:

ghost_error ghost_rand_seed ( ghost_rand_seed_type  which,
unsigned int  seed 
)

Set the random number seed.

Parameters
whichWhich components of the seed should be set. Components can be combined with OR.
seedThe value to which the component should be set.
Returns
GHOST_SUCCESS on success or an error indicator.

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.

Here is the call graph for this function:

Variable Documentation

unsigned int cu_seed = 0
static
bool customseed = false
static
unsigned int* ghost_rand_states =NULL
static
int nrand = 0
static