Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #include <sstream>
0002 #include <limits>
0003 
0004 #include "ssys.h"
0005 
0006 #if defined(MOCK_CURAND) || defined(MOCK_CUDA)
0007 #else
0008 #include "SLOG.hh"
0009 #include "QU.hh"
0010 #endif
0011 
0012 #include "QBase.hh"
0013 #include "qbase.h"
0014 
0015 #if defined(MOCK_CURAND) || defined(MOCK_CUDA)
0016 const plog::Severity QBase::LEVEL = plog::info ;
0017 #else
0018 const plog::Severity QBase::LEVEL = SLOG::EnvLevel("QBase", "DEBUG");
0019 #endif
0020 
0021 const QBase* QBase::INSTANCE = nullptr ;
0022 const QBase* QBase::Get(){ return INSTANCE ; }
0023 
0024 qbase* QBase::MakeInstance() // static
0025 {
0026     qbase* base = new qbase ;
0027     base->pidx = ssys::getenvuint64spec("PIDX", "X40") ;  // X40 sentinel  0xffffffffff  (0x1<<40)-1
0028     return base ;
0029 }
0030 
0031 QBase::QBase()
0032     :
0033     base(MakeInstance()),
0034     d_base(nullptr)
0035 {
0036     init();
0037 }
0038 
0039 /**
0040 QBase::init
0041 ------------
0042 
0043 This appears to take ~0.25s because it is usually the first access to the GPU.
0044 This is with the nvidia-persistenced running, without it the time is ~1.5s
0045 
0046 Tried changing the visible devices but seems to make no difference::
0047 
0048     CUDA_VISIBLE_DEVICES=0
0049     CUDA_VISIBLE_DEVICES=1
0050     CUDA_VISIBLE_DEVICES=0,1
0051 
0052 **/
0053 
0054 void QBase::init()
0055 {
0056     INSTANCE = this ;
0057 
0058 #if defined(MOCK_CURAND) || defined(MOCK_CUDA)
0059     d_base = base ;
0060 #else
0061     LOG(LEVEL) << "[ QU::UploadArray " ;
0062     d_base = QU::UploadArray<qbase>(base,1, "QBase::init/d_base") ;
0063     LOG(LEVEL) << "] QU::UploadArray : takes ~0.25-0.3s : appearing in analog timings as it is first GPU contact " ;
0064 #endif
0065 
0066 
0067 }
0068 
0069 std::string QBase::desc() const
0070 {
0071     std::stringstream ss ;
0072     ss << "QBase::desc"
0073        << " base " << base
0074        << " d_base " << d_base
0075        << " base.desc " << base->desc()
0076        ;
0077     std::string s = ss.str();
0078     return s ;
0079 }
0080 
0081