GHOST  1.1.2
General, Hybrid, and Optimized Sparse Toolkit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Enumerations | Functions
rand.h File Reference

Functions for handling random number generation states. More...

#include "error.h"
Include dependency graph for rand.h:
This graph shows which files directly or indirectly include this file:

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...
 

Detailed Description

Functions for handling random number generation states.

Author
Moritz Kreutzer morit.nosp@m.z.kr.nosp@m.eutze.nosp@m.r@fa.nosp@m.u.de

Macro Definition Documentation

#define GHOST_RAND_SEED_ALL   (GHOST_RAND_SEED_PU|GHOST_RAND_SEED_RANK|GHOST_RAND_SEED_TIME)

Enumeration Type Documentation

Enumerator
GHOST_RAND_SEED_NONE 
GHOST_RAND_SEED_PU 
GHOST_RAND_SEED_RANK 
GHOST_RAND_SEED_TIME 

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: