ATLAS Offline Software
CaloGpuGeneral.cxx
Go to the documentation of this file.
3 
5 #include <chrono>
6 #include <iostream>
7 
8 void* CaloGpuGeneral::Rand4Hits_init( long long maxhits, unsigned short maxbin, unsigned long long seed,
9  bool /*hitspy*/ ) {
10 
12  Rand4Hits* rd4h = new Rand4Hits;
14 
15  // By default, generate random numbers on GPU, unless macro RNDGEN_CPU is set
16  // This is controlled by cmake parameter -DRNDGEN_CPU
17  constexpr bool genOnCPU{false};
18 
20  // use CPU rand num gen to be able to compare GPU implementations
21  rd4h->create_gen( seed, 3 * maxhits, genOnCPU );
23  rd4h->set_t_a_hits( maxhits );
24  rd4h->set_c_hits( 0 );
26 
27  rd4h->allocate_simulation( maxhits, maxbin, 2000, 200000 );
29 
30  std::chrono::duration<double> diff1 = t1 - t0;
31  std::chrono::duration<double> diff2 = t2 - t1;
32  std::chrono::duration<double> diff3 = t3 - t2;
33  std::chrono::duration<double> diff4 = t4 - t3;
34  std::chrono::duration<double> diff5 = t5 - t4;
35  std::cout << "Time of R4hit: " << diff1.count() << "," << diff2.count() << "," << diff3.count() << ","
36  << diff4.count() << "," << diff5.count() << " s" << std::endl;
37 
38  return (void*)rd4h;
39 }
40 
42  if ( (Rand4Hits*)rd4h ) delete (Rand4Hits*)rd4h;
43 }
44 
45 void CaloGpuGeneral::simulate_hits( float E, int nhits, Chain0_Args& args , bool reweight) {
46 
47  Rand4Hits* rd4h = (Rand4Hits*)args.rd4h;
48 
49  float* r = rd4h->rand_ptr( nhits );
50 
51  rd4h->add_a_hits( nhits );
52  args.rand = r;
53 
54  args.maxhitct = MAXHITCT;
55 
56  args.cells_energy = rd4h->get_cells_energy(); // Hit cell energy map , size of ncells(~200k float)
57  args.hitcells_E = rd4h->get_cell_e(); // Hit cell energy map, moved together
58  args.hitcells_E_h = rd4h->get_cell_e_h(); // Host array
59 
60  args.hitcells_ct = rd4h->get_ct(); // single value, number of uniq hit cells
61 
62  CaloGpuGeneral_cu::simulate_hits( E, nhits, args , reweight);
63 }
beamspotman.r
def r
Definition: beamspotman.py:676
Rand4Hits::get_cell_e_h
Cell_E * get_cell_e_h()
Definition: Rand4Hits.h:40
Rand4Hits::get_cells_energy
float * get_cells_energy()
Definition: Rand4Hits.h:38
LUCID_EventTPCnv_Dict::t3
std::vector< LUCID_RawData_p1 > t3
Definition: LUCID_EventTPCnvDict.h:28
Rand4Hits.h
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
ALFA_EventTPCnv_Dict::t1
std::vector< ALFA_RawDataCollection_p1 > t1
Definition: ALFA_EventTPCnvDict.h:43
Rand4Hits::set_c_hits
void set_c_hits(int nhits)
Definition: Rand4Hits.h:30
CaloGpuGeneral_cu::simulate_hits
void simulate_hits(float, int, Chain0_Args &, bool)
CaloGpuGeneral::Rand4Hits_init
void * Rand4Hits_init(long long, unsigned short, unsigned long long, bool)
Definition: CaloGpuGeneral.cxx:8
Rand4Hits::allocate_simulation
void allocate_simulation(long long maxhits, unsigned short maxbins, unsigned short maxhitct, unsigned long n_cells)
Rand4Hits::get_ct
int * get_ct()
Definition: Rand4Hits.h:42
CaloGpuGeneral.h
Rand4Hits::create_gen
void create_gen(unsigned long long seed, size_t numhits, bool useCPU=false)
CaloGpuGeneral::simulate_hits
void simulate_hits(float, int, Chain0_Args &, bool)
Definition: CaloGpuGeneral.cxx:45
python.handimod.now
now
Definition: handimod.py:675
MAXHITCT
#define MAXHITCT
Definition: Args.h:13
Chain0_Args
Definition: Args.h:17
LUCID_EventTPCnv_Dict::t4
std::vector< LUCID_RawDataContainer_p1 > t4
Definition: LUCID_EventTPCnvDict.h:29
Rand4Hits
Definition: Rand4Hits.h:13
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
Rand4Hits::rand_ptr
float * rand_ptr(int nhits)
Definition: Rand4Hits.h:18
Rand4Hits::add_a_hits
void add_a_hits(int nhits)
Definition: Rand4Hits.h:49
Rand4Hits::get_cell_e
Cell_E * get_cell_e()
Definition: Rand4Hits.h:39
CaloGpuGeneral_cu.h
LUCID_EventTPCnv_Dict::t5
std::vector< LUCID_Digit_p2 > t5
Definition: LUCID_EventTPCnvDict.h:31
ALFA_EventTPCnv_Dict::t2
std::vector< ALFA_RawDataContainer_p1 > t2
Definition: ALFA_EventTPCnvDict.h:44
CaloGpuGeneral::Rand4Hits_finish
void Rand4Hits_finish(void *)
Definition: CaloGpuGeneral.cxx:41
Rand4Hits::set_t_a_hits
void set_t_a_hits(int nhits)
Definition: Rand4Hits.h:29
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80