Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:10

0001 #pragma once
0002 
0003 /**
0004 QRng
0005 ====
0006 
0007 Canonical instanciation within QSim::UploadComponents
0008 
0009 Small *skipahead_event_offsets* are for functionality testing, 
0010 typically the offset should be greater than the maximum number of 
0011 randoms to simulate an item(photon). 
0012 
0013 
0014 
0015 TODO : implement sanity check for use after loading::
0016 
0017     bool QRng::IsAllZero( RNG* states, unsigned num_states ) //  static
0018 
0019 **/
0020 
0021 #include <string>
0022 #include "QUDARAP_API_EXPORT.hh"
0023 #include "plog/Severity.h"
0024 #include "curand_kernel.h"   
0025 #include "qrng.h"
0026 
0027 //#define OLD_MONOLITHIC_CURANDSTATE 1
0028 
0029 #ifdef OLD_MONOLITHIC_CURANDSTATE
0030 #else
0031 #include "SCurandState.h"
0032 #endif
0033 
0034 
0035 
0036 struct QUDARAP_API QRng 
0037 {
0038     typedef unsigned long long ULL ; 
0039     static constexpr const char* init_VERBOSE = "QRng__init_VERBOSE" ; 
0040     static constexpr const ULL M = 1000000 ;  
0041     static const plog::Severity LEVEL ; 
0042     static const QRng* INSTANCE ; 
0043     static const QRng* Get(); 
0044     static std::string Desc();
0045 
0046     static const char* Load_FAIL_NOTES ; 
0047 
0048 
0049 
0050 #ifdef OLD_MONOLITHIC_CURANDSTATE
0051     static constexpr const char* IMPL = "OLD_MONOLITHIC_CURANDSTATE" ; 
0052     static XORWOW* LoadAndUpload(ULL& rngmax, const char* path); 
0053     static XORWOW* Load(ULL& rngmax, const char* path); 
0054     static XORWOW* UploadAndFree(RNG* h_states, ULL num_states ); 
0055 #else
0056     static constexpr const char* IMPL = "CHUNKED_CURANDSTATE" ; 
0057     static XORWOW* LoadAndUpload(ULL rngmax, const SCurandState& cs); 
0058 #endif
0059     static void Save( XORWOW* states, unsigned num_states, const char* path ); 
0060 
0061 
0062     const char* RNGNAME ; 
0063     bool  UPLOAD_RNG_STATES ; 
0064     ULL            skipahead_event_offset ; 
0065     ULL            seed ;
0066     ULL            offset ; 
0067     const char*    SEED_OFFSET ;
0068     int            parse_rc ; 
0069     qrng<RNG>*     qr ;  
0070     qrng<RNG>*     d_qr ;  
0071     ULL            rngmax ;
0072 
0073 #ifndef OLD_MONOLITHIC_CURANDSTATE
0074     SCurandState   cs ; 
0075 #endif
0076 
0077 
0078     QRng(unsigned skipahead_event_offset=1) ;  
0079     void init(); 
0080 
0081     template<typename R> void initStates();
0082 
0083     void initMeta(); 
0084 
0085     virtual ~QRng(); 
0086 
0087     std::string desc() const ; 
0088 
0089 
0090     template <typename T> void generate( T* u, unsigned ni, unsigned nv, unsigned evid ) ; 
0091 
0092     dim3 numBlocks ; 
0093     dim3 threadsPerBlock ; 
0094 
0095 };
0096