Astaroth  3.1
Scalable Multi-GPU Stencil Computations
Loading...
Searching...
No Matches
random.cuh
Go to the documentation of this file.
1#pragma once
2
3/*
4 * Random number generation
5 */
6
7#include <cstdint>
8
9#if AC_CPU_BUILD
10#include <random>
11
12#include <stdlib.h>
13#else
14#if AC_USE_HIP
15#include <hip/hip_fp16.h> // Workaround: required by hiprand
16#include <hiprand/hiprand.h> // Random numbers
17#include <hiprand/hiprand_kernel.h> // Random numbers (device)
18#else
19#include <curand.h> // Random numbers
20#include <curand_kernel.h> // Random numbers (device)
21#endif
22#endif
23
24// clang-format off
25#include "host_datatypes.h"
26// clang-format on
27
29#include "errchk.h"
30#include "func_define.h"
31
33
34AcResult acRandInitAlt(const uint64_t, const size_t, const size_t);
35void acRandQuit(void);
36
37#if AC_CPU_BUILD
38
39__device__ __forceinline__ AcReal rand_uniform();
40
41#else
42
44
45extern __device__ __constant__ acRandState* rand_states;
46
47#if AC_DOUBLE_PRECISION
48#define rand_uniform() curand_uniform_double(&rand_states[local_compdomain_idx])
49#else
50#define rand_uniform() curand_uniform(&rand_states[local_compdomain_idx])
51#endif /* AC_DOUBLE_PRECISION */
52
53#endif /* AC_CPU_BUILD */
54
float AcReal
Definition acreal.h:11
Brief info.
#define AC_BEGIN_C_DECLARATIONS
Definition func_define.h:14
#define AC_END_C_DECLARATIONS
Definition func_define.h:15
#define curandStateXORWOW_t
Definition hip.h:100
AcResult
Definition host_datatypes.h:10
void acRandQuit(void)
#define rand_uniform()
Definition random.cuh:50
__device__ __constant__ acRandState * rand_states
AcResult acRandInitAlt(const uint64_t, const size_t, const size_t)
curandStateXORWOW_t acRandState
Definition random.cuh:43