File indexing completed on 2026-04-09 07:49:09
0001
0002 #include <sstream>
0003
0004 #include "scuda.h"
0005 #include "squad.h"
0006 #include "NP.hh"
0007
0008 #if defined(MOCK_TEXTURE) || defined(MOCK_CUDA)
0009 #else
0010 #include <cuda_runtime.h>
0011 #include "QUDA_CHECK.h"
0012 #include "QU.hh"
0013 #include "QBuf.hh"
0014 #include "SLOG.hh"
0015 #endif
0016
0017 #include "QOptical.hh"
0018
0019 #if defined(MOCK_TEXTURE) || defined(MOCK_CUDA)
0020 #else
0021 const plog::Severity QOptical::LEVEL = SLOG::EnvLevel("QOptical", "DEBUG");
0022 #endif
0023
0024 const QOptical* QOptical::INSTANCE = nullptr ;
0025 const QOptical* QOptical::Get(){ return INSTANCE ; }
0026
0027 QOptical::QOptical(const NP* optical_)
0028 :
0029 optical(optical_),
0030 buf(nullptr),
0031 d_optical(nullptr)
0032 {
0033 init();
0034 }
0035
0036 void QOptical::init()
0037 {
0038 INSTANCE = this ;
0039
0040 #if defined(MOCK_TEXTURE) || defined(MOCK_CUDA)
0041
0042 NP* a = const_cast<NP*>(optical);
0043 d_optical = a->values<quad>();
0044 assert( d_optical );
0045
0046 #else
0047 buf = QBuf<unsigned>::Upload(optical) ;
0048 d_optical = (quad*)buf->d ;
0049 #endif
0050 }
0051
0052
0053 std::string QOptical::desc() const
0054 {
0055 std::stringstream ss ;
0056 ss << "QOptical"
0057 << " optical " << ( optical ? optical->desc() : "-" )
0058 ;
0059 std::string s = ss.str();
0060 return s ;
0061 }
0062
0063
0064 #if defined(MOCK_TEXTURE) || defined(MOCK_CUDA)
0065 void QOptical::check() const {}
0066 #else
0067
0068
0069 extern "C" void QOptical_check(dim3 numBlocks, dim3 threadsPerBlock, quad* optical, unsigned width, unsigned height );
0070
0071 void QOptical::check() const
0072 {
0073 unsigned height = optical->shape[0] ;
0074 unsigned width = 1 ;
0075
0076 LOG(LEVEL)
0077 << "[" << " height " << height << " width " << width
0078 ;
0079
0080 dim3 numBlocks ;
0081 dim3 threadsPerBlock ;
0082 QU::ConfigureLaunch( numBlocks, threadsPerBlock, width, height );
0083
0084 QOptical_check(numBlocks, threadsPerBlock, d_optical, width, height );
0085
0086 LOG(LEVEL) << "]" ;
0087 }
0088 #endif
0089