19 using namespace colorspinor;
21 template<
typename real,
int Ns,
int Nc, QudaFieldOrder order>
31 template<
typename real,
typename Arg>
33 real phi = 2.0*M_PI*Random<real>(localState);
34 real radius = Random<real>(localState);
35 radius =
sqrt(-1.0 *
log(radius));
36 arg.
v(parity, x_cb, s, c) = complex<real>(radius*
cos(phi),radius*
sin(phi));
39 template<
typename real,
typename Arg>
41 real x = Random<real>(localState);
42 real y = Random<real>(localState);
43 arg.
v(parity, x_cb, s, c) = complex<real>(x, y);
51 for (
int x_cb = 0; x_cb < arg.
volumeCB; x_cb++) {
52 for (
int s = 0;
s < Ns;
s++) {
53 for (
int c = 0; c < Nc; c++) {
56 genGauss<real>(
arg, localState,
parity, x_cb,
s, c);
58 genUniform<real>(
arg, localState,
parity, x_cb,
s, c);
59 arg.rng.State()[parity * arg.volumeCB + x_cb] = localState;
67 template <
typename real,
int Ns,
int Nc, QudaNoiseType type,
typename Arg>
70 int x_cb = blockIdx.x * blockDim.x + threadIdx.x;
73 int parity = blockIdx.y * blockDim.y + threadIdx.y;
74 if (parity >= arg.
nParity)
return;
77 for (
int s=0;
s<Ns;
s++) {
78 for (
int c=0; c<Nc; c++) {
86 template <
typename real,
int Ns,
int Nc, QudaNoiseType type,
typename Arg>
115 long long flops()
const {
return 0; }
121 template <
typename real,
int Ns,
int Nc, QudaFieldOrder order>
138 errorQuda(
"Noise type %d not implemented", type);
143 template <
typename real,
int Ns,
int Nc>
147 spinorNoise<real,Ns,Nc,QUDA_FLOAT2_FIELD_ORDER>(
in, rngstate, type);
149 spinorNoise<real,Ns,Nc,QUDA_FLOAT4_FIELD_ORDER>(
in, rngstate, type);
155 template <
typename real,
int Ns>
159 spinorNoise<real,Ns,3>(src, randstates, type);
160 }
else if (src.
Ncolor() == 6) {
161 spinorNoise<real,Ns,6>(src, randstates, type);
162 }
else if (src.
Ncolor() == 24) {
163 spinorNoise<real,Ns,24>(src, randstates, type);
164 }
else if (src.
Ncolor() == 32) {
165 spinorNoise<real,Ns,32>(src, randstates, type);
171 template <
typename real>
174 if (src.
Nspin() == 4) {
175 spinorNoise<real,4>(src, randstates, type);
176 }
else if (src.
Nspin() == 2) {
177 spinorNoise<real,2>(src, randstates, type);
178 }
else if (src.
Nspin() == 1) {
179 spinorNoise<real,1>(src, randstates, type);
201 default:
errorQuda(
"Precision %d not implemented", src->Precision());
212 RNG *randstates =
new RNG(src, seed);
void Init()
Initialize CURAND RNG states.
void setPrecision(QudaPrecision precision, QudaPrecision ghost_precision=QUDA_INVALID_PRECISION, bool force_native=false)
struct curandStateMRG32k3a cuRNGState
enum QudaPrecision_s QudaPrecision
const char * AuxString() const
void apply(const cudaStream_t &stream)
enum QudaNoiseType_s QudaNoiseType
QudaVerbosity getVerbosity()
__host__ __device__ ValueType sqrt(ValueType x)
Arg(ColorSpinorField &v, RNG &rng)
static ColorSpinorField * Create(const ColorSpinorParam ¶m)
void backup()
Backup CURAND array states initialization.
const char * VolString() const
SpinorNoise(Arg &arg, const ColorSpinorField &meta)
__device__ __host__ void genUniform(Arg &arg, cuRNGState &localState, int parity, int x_cb, int s, int c)
void genGauss(GaugeField &U, RNG &rngstate, double sigma)
QudaFieldLocation location
__host__ __device__ ValueType sin(ValueType x)
void Release()
Release Device memory for CURAND RNG states.
void restore()
Restore CURAND array states initialization.
Class declaration to initialize and hold CURAND RNG states.
TuneParam & tuneLaunch(Tunable &tunable, QudaTune enabled, QudaVerbosity verbosity)
void SpinorNoiseCPU(Arg &arg)
unsigned int sharedBytesPerThread() const
QudaFieldLocation Location() const
__host__ __device__ ValueType log(ValueType x)
const ColorSpinorField & meta
unsigned int sharedBytesPerBlock(const TuneParam ¶m) const
__global__ void SpinorNoiseGPU(Arg arg)
bool advanceTuneParam(TuneParam ¶m) const
__host__ __device__ ValueType arg(const complex< ValueType > &z)
Returns the phase angle of z.
colorspinor::FieldOrderCB< real, Ns, Nc, 1, order > V
__host__ __device__ __inline__ cuRNGState * State()
__host__ __device__ ValueType cos(ValueType x)
QudaTune getTuning()
Query whether autotuning is enabled or not. Default is enabled but can be overridden by setting QUDA_...
QudaPrecision Precision() const
unsigned int minThreads() const
QudaFieldOrder FieldOrder() const
void spinorNoise(ColorSpinorField &src, RNG &randstates, QudaNoiseType type)
Generate a random noise spinor. This variant allows the user to manage the RNG state.
virtual bool advanceTuneParam(TuneParam ¶m) const