Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002 scarrier_test.cc : CPU tests of scarrier.h CUDA code using mocking 
0003 ================================================================
0004 
0005 Standalone compile and run with::
0006 
0007    ~/o/sysrap/tests/scarrier_test.sh 
0008 
0009 **/
0010 #include <numeric>
0011 #include <vector>
0012 
0013 #include "srngcpu.h"
0014 using RNG = srngcpu ; 
0015 
0016 #include "scuda.h"
0017 #include "squad.h"
0018 
0019 #include "sphoton.h"
0020 #include "scarrier.h"
0021 #include "SEvent.hh"
0022 #include "NP.hh"
0023 
0024 
0025 
0026 NP* make_carrier_photon( const NP* gs, const NP* se )
0027 {
0028     const quad6* gg = (quad6*)gs->bytes() ;  
0029     const int*   seed = (int*)se->bytes() ;  
0030 
0031     RNG rng ; 
0032 
0033     int tot_photon = se->shape[0] ; 
0034     NP* ph = NP::Make<float>( tot_photon, 4, 4); 
0035     sphoton* pp = (sphoton*)ph->bytes() ; 
0036 
0037     for(int i=0 ; i < tot_photon ; i++ )
0038     {
0039         unsigned photon_id = i ; 
0040         unsigned genstep_id = seed[photon_id] ; 
0041         const quad6& g = gg[genstep_id] ;  
0042 
0043         sphoton& p = pp[photon_id] ; 
0044  
0045         scarrier::generate(p, rng, g, photon_id, genstep_id ); 
0046 
0047         std::cout << p.desc() << std::endl;  
0048     }
0049     return ph ; 
0050 }
0051 
0052 void test_generate()
0053 {
0054     NP* gs = SEvent::MakeCarrierGenstep(); 
0055     NP* se = SEvent::MakeSeed(gs) ; 
0056     NP* ph = make_carrier_photon(gs, se); 
0057 
0058     gs->save("$FOLD/gs.npy"); 
0059     se->save("$FOLD/se.npy"); 
0060     ph->save("$FOLD/ph.npy"); 
0061 }
0062 
0063 int main(int argc, char** argv)
0064 {
0065     test_generate(); 
0066     return 0 ; 
0067 }
0068