Curand Library
Total Page:16
File Type:pdf, Size:1020Kb
cuRAND Library Programming Guide PG-05328-050_v11.4 | September 2021 Table of Contents Introduction.........................................................................................................................viii Chapter 1. Compatibility and Versioning..............................................................................1 Chapter 2. Host API Overview...............................................................................................2 2.1. Generator Types........................................................................................................................ 3 2.2. Generator Options..................................................................................................................... 3 2.2.1. Seed..................................................................................................................................... 3 2.2.2. Offset....................................................................................................................................3 2.2.3. Order....................................................................................................................................4 2.3. Return Values............................................................................................................................ 6 2.4. Generation Functions................................................................................................................ 7 2.5. Host API Example......................................................................................................................8 2.6. Static Library support............................................................................................................... 9 2.7. Performance Notes................................................................................................................. 10 Chapter 3. Device API Overview..........................................................................................11 3.1. Pseudorandom Sequences..................................................................................................... 11 3.1.1. Bit Generation with XORWOW and MRG32k3a generators.............................................11 3.1.2. Bit Generation with the MTGP32 generator....................................................................12 3.1.3. Bit Generation with Philox_4x32_10 generator...............................................................14 3.1.4. Distributions...................................................................................................................... 15 3.2. Quasirandom Sequences........................................................................................................ 16 3.3. Skip-Ahead...............................................................................................................................17 3.4. Device API for discrete distributions......................................................................................18 3.5. Performance Notes................................................................................................................. 18 3.6. Device API Examples...............................................................................................................19 3.7. Thrust and cuRAND Example.................................................................................................30 3.8. Poisson API Example.............................................................................................................. 31 Chapter 4. Testing............................................................................................................... 38 Chapter 5. Modules............................................................................................................. 45 5.1. Host API................................................................................................................................... 45 curandCreateGenerator (curandGenerator_t, curandRngType_t)........................................... 47 curandCreateGeneratorHost (curandGenerator_t, curandRngType_t)....................................50 curandCreatePoissonDistribution (double, curandDiscreteDistribution_t).............................52 curandDestroyDistribution (curandDiscreteDistribution_t)......................................................53 curandDestroyGenerator (curandGenerator_t).........................................................................53 cuRAND Library PG-05328-050 _vRelease Version | ii curandGenerate (curandGenerator_t, unsigned int, size_t).....................................................54 curandGenerateLogNormal (curandGenerator_t, float, size_t, float, float)............................ 55 curandGenerateLogNormalDouble (curandGenerator_t, double, size_t, double, double)......56 curandGenerateLongLong (curandGenerator_t, unsigned long long, size_t)......................... 57 curandGenerateNormal (curandGenerator_t, float, size_t, float, float).................................. 58 curandGenerateNormalDouble (curandGenerator_t, double, size_t, double, double)............59 curandGeneratePoisson (curandGenerator_t, unsigned int, size_t, double)...........................61 curandGenerateSeeds (curandGenerator_t)............................................................................. 62 curandGenerateUniform (curandGenerator_t, float, size_t).................................................... 62 curandGenerateUniformDouble (curandGenerator_t, double, size_t).....................................63 curandGetDirectionVectors32 (curandDirectionVectors32_t, curandDirectionVectorSet_t)................................................................................................. 64 curandGetDirectionVectors64 (curandDirectionVectors64_t, curandDirectionVectorSet_t)................................................................................................. 65 curandGetProperty (libraryPropertyType, int)...........................................................................65 curandGetScrambleConstants32 (unsigned int)....................................................................... 66 curandGetScrambleConstants64 (unsigned long long)............................................................67 curandGetVersion (int)................................................................................................................67 curandSetGeneratorOffset (curandGenerator_t, unsigned long long).....................................68 curandSetGeneratorOrdering (curandGenerator_t, curandOrdering_t).................................. 68 curandSetPseudoRandomGeneratorSeed (curandGenerator_t, unsigned long long)............ 69 curandSetQuasiRandomGeneratorDimensions (curandGenerator_t, unsigned int)...............70 curandSetStream (curandGenerator_t, cudaStream_t)........................................................... 70 5.2. Device API................................................................................................................................ 71 curand (curandStateMtgp32_t).................................................................................................. 71 curand (curandStateScrambledSobol64_t)............................................................................... 71 curand (curandStateSobol64_t)................................................................................................. 72 curand (curandStateScrambledSobol32_t)............................................................................... 72 curand (curandStateSobol32_t)................................................................................................. 73 curand (curandStateMRG32k3a_t).............................................................................................73 curand (curandStatePhilox4_32_10_t).......................................................................................74 curand (curandStateXORWOW_t)...............................................................................................74 curand4 (curandStatePhilox4_32_10_t).....................................................................................75 curand_init (curandDirectionVectors64_t, unsigned long long, unsigned long long, curandStateScrambledSobol64_t)........................................................................................ 75 curand_init (curandDirectionVectors64_t, unsigned long long, curandStateSobol64_t).........76 curand_init (curandDirectionVectors32_t, unsigned int, unsigned int, curandStateScrambledSobol32_t)........................................................................................ 76 curand_init (curandDirectionVectors32_t, unsigned int, curandStateSobol32_t)....................77 cuRAND Library PG-05328-050 _vRelease Version | iii curand_init (unsigned long long, unsigned long long, unsigned long long, curandStateMRG32k3a_t)......................................................................................................77 curand_init (unsigned long long, unsigned long long, unsigned long long, curandStatePhilox4_32_10_t)................................................................................................78 curand_init (unsigned long long, unsigned long long, unsigned long long, curandStateXORWOW_t)........................................................................................................79 curand_log_normal (curandStateScrambledSobol64_t, float, float)......................................