mmc_rand_posix.h
Go to the documentation of this file.
1 /***************************************************************************/
32 /***************************************************************************/
38 #ifndef _MCEXTREME_STDC_RAND_H
39 #define _MCEXTREME_STDC_RAND_H
40 
41 #include <stdlib.h>
42 
43 #define __device__ static inline
44 
45 #define MCX_RNG_NAME "POSIX Multi-threaded RNG"
46 
47 #define RAND_BUF_LEN 3 //register arrays
48 #define RAND_SEED_WORD_LEN 2
49 
50 typedef unsigned int uint;
51 
52 #ifdef _WIN32
53  #include "mmc_rand_drand48.h"
54 #endif
55 
56 typedef unsigned short RandType;
57 
58 // transform into [0,1] random number
59 __device__ float rand_uniform01(RandType t[RAND_BUF_LEN]);
60 __device__ void rng_init(RandType t[RAND_BUF_LEN], RandType tnew[RAND_BUF_LEN], uint* n_seed, int idx);
61 __device__ void rand_need_more(RandType t[RAND_BUF_LEN], RandType tbuf[RAND_BUF_LEN]);
62 // generate [0,1] random number for the next scattering length
63 __device__ float rand_next_scatlen(RandType t[RAND_BUF_LEN]);
64 // generate [0,1] random number for the next arimuthal angle
65 __device__ float rand_next_aangle(RandType t[RAND_BUF_LEN]);
66 // generate random number for the next zenith angle
67 __device__ float rand_next_zangle(RandType t[RAND_BUF_LEN]);
68 __device__ float rand_next_reflect(RandType t[RAND_BUF_LEN]);
69 __device__ float rand_do_roulette(RandType t[RAND_BUF_LEN]);
70 
71 #ifdef MMC_USE_SSE_MATH
72  __device__ void rand_next_aangle_sincos(RandType t[RAND_BUF_LEN], float* si, float* co);
73  __device__ float rand_next_scatlen_ps(RandType t[RAND_BUF_LEN]);
74 #endif
75 
76 #endif
__device__ float rand_next_scatlen(RandType t[RAND_BUF_LEN])
generate [0,1] random number for the next scattering length
Definition: mmc_rand_common.h:46
__device__ float rand_do_roulette(RandType t[RAND_BUF_LEN])
generate random number for the next zenith angle
Definition: mmc_rand_common.h:62
__device__ float rand_next_zangle(RandType t[RAND_BUF_LEN])
generate random number for the next zenith angle
Definition: mmc_rand_common.h:54
__device__ float rand_next_aangle(RandType t[RAND_BUF_LEN])
generate [0,1] random number for the next arimuthal angle
Definition: mmc_rand_common.h:50
Windows 32 port of drand48_r random number generator from libgw2c.
__device__ float rand_next_reflect(RandType t[RAND_BUF_LEN])
generate random number for reflection test
Definition: mmc_rand_common.h:58