CPP   111

rng.h

Guest on 28th June 2022 10:12:24 AM

  1. /*
  2.  * Copyright  NVIDIA Corporation.  All rights reserved.
  3.  *
  4.  * Please refer to the NVIDIA end user license agreement (EULA) associated
  5.  * with this source code for terms and conditions that govern your use of
  6.  * this software. Any use, reproduction, disclosure, or distribution of
  7.  * this software and related documentation outside the terms of the EULA
  8.  * is strictly prohibited.
  9.  *
  10.  */
  11.  
  12. /*
  13. * Copyright  NVIDIA Corporation.  All rights reserved.
  14. *
  15. * NVIDIA Corporation and its licensors retain all intellectual property and
  16. * proprietary rights in and to this software and related documentation.
  17. * Any use, reproduction, disclosure, or distribution of this software
  18. * and related documentation without an express license agreement from
  19. * NVIDIA Corporation is strictly prohibited.
  20. *
  21. * Please refer to the applicable NVIDIA end user license agreement (EULA)
  22. * associated with this source code for terms and conditions that govern
  23. * your use of this NVIDIA software.
  24. *
  25. */
  26.  
  27. #include <curand.h>
  28. #include <string>
  29.  
  30. // RNGs
  31. class RNG
  32. {
  33.     public:
  34.         enum RngType {Pseudo, Quasi, ScrambledQuasi};
  35.         RNG(unsigned long prngSeed, unsigned int qrngDimensions, unsigned int nSamples);
  36.         virtual ~RNG();
  37.  
  38.         float getNextU01(void);
  39.         void getInfoString(std::string &msg);
  40.         void selectRng(RngType type);
  41.         void resetSeed(void);
  42.         void resetDimensions(void);
  43.         void incrementDimensions(void);
  44.  
  45.     private:
  46.         // Generators
  47.         curandGenerator_t *m_pCurrent;
  48.         curandGenerator_t m_prng;
  49.         curandGenerator_t m_qrng;
  50.         curandGenerator_t m_sqrng;
  51.  
  52.         // Parameters
  53.         unsigned long m_prngSeed;
  54.         unsigned int  m_qrngDimensions;
  55.  
  56.         // Batches
  57.         const unsigned int m_nSamplesBatchTarget;
  58.         unsigned int       m_nSamplesBatchActual;
  59.         unsigned int       m_nSamplesRemaining;
  60.         void generateBatch(void);
  61.  
  62.         // Helpers
  63.         void updateDimensions(void);
  64.         void setBatchSize(void);
  65.  
  66.         // Buffers
  67.         float *m_h_samples;
  68.         float *m_d_samples;
  69.  
  70.         static const unsigned int s_maxQrngDimensions;
  71. };

Raw Paste


Login or Register to edit or fork this paste. It's free.