MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / myrand

Function myrand

cpp/5_Domain_Specific/fluidsGL/fluidsGL.cpp:229–246  ·  view source on GitHub ↗

very simple von neumann middle-square prng. can't use rand() in -qatest mode because its implementation varies across platforms which makes testing for consistency in the important parts of this program difficult.

Source from the content-addressed store, hash-verified

227// mode because its implementation varies across platforms which makes testing
228// for consistency in the important parts of this program difficult.
229float myrand(void)
230{
231 static int seed = 72191;
232 char sq[22];
233
234 if (ref_file) {
235 seed *= seed;
236 sprintf(sq, "%010d", seed);
237 // pull the middle 5 digits out of sq
238 sq[8] = 0;
239 seed = atoi(&sq[3]);
240
241 return seed / 99999.f;
242 }
243 else {
244 return rand() / (float)RAND_MAX;
245 }
246}
247
248void initParticles(cData *p, int dx, int dy)
249{

Callers 1

initParticlesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected