ATLAS Offline Software
Loading...
Searching...
No Matches
CaloGpuGeneral.cxx
Go to the documentation of this file.
3
5#include <chrono>
6#include <iostream>
7
8void* CaloGpuGeneral::Rand4Hits_init( long long maxhits, unsigned short maxbin, unsigned long long seed,
9 bool /*hitspy*/ ) {
10
11 auto t0 = std::chrono::system_clock::now();
12 Rand4Hits* rd4h = new Rand4Hits;
13 auto t1 = std::chrono::system_clock::now();
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
19 auto t2 = std::chrono::system_clock::now();
20 // use CPU rand num gen to be able to compare GPU implementations
21 rd4h->create_gen( seed, 3 * maxhits, genOnCPU );
22 auto t3 = std::chrono::system_clock::now();
23 rd4h->set_t_a_hits( maxhits );
24 rd4h->set_c_hits( 0 );
25 auto t4 = std::chrono::system_clock::now();
26
27 rd4h->allocate_simulation( maxhits, maxbin, 2000, 200000 );
28 auto t5 = std::chrono::system_clock::now();
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
45void 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}
#define MAXHITCT
Definition Args.h:13
static Double_t t0
void add_a_hits(int nhits)
Definition Rand4Hits.h:49
float * get_cells_energy()
Definition Rand4Hits.h:38
void create_gen(unsigned long long seed, size_t numhits, bool useCPU=false)
int * get_ct()
Definition Rand4Hits.h:42
void set_c_hits(int nhits)
Definition Rand4Hits.h:30
void allocate_simulation(long long maxhits, unsigned short maxbins, unsigned short maxhitct, unsigned long n_cells)
float * rand_ptr(int nhits)
Definition Rand4Hits.h:18
void set_t_a_hits(int nhits)
Definition Rand4Hits.h:29
Cell_E * get_cell_e_h()
Definition Rand4Hits.h:40
Cell_E * get_cell_e()
Definition Rand4Hits.h:39
int r
Definition globals.cxx:22
void simulate_hits(float, int, Chain0_Args &, bool)
void simulate_hits(float, int, Chain0_Args &, bool)
void Rand4Hits_finish(void *)
void * Rand4Hits_init(long long, unsigned short, unsigned long long, bool)