ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
ISF
ISF_FastCaloSim
ISF_FastCaloGpu
src
CaloGpuGeneral.cxx
Go to the documentation of this file.
1
#include "
ISF_FastCaloGpu/CaloGpuGeneral.h
"
2
#include "
ISF_FastCaloGpu/CaloGpuGeneral_cu.h
"
3
4
#include "
ISF_FastCaloGpu/Rand4Hits.h
"
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
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
41
void
CaloGpuGeneral::Rand4Hits_finish
(
void
* rd4h ) {
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
}
MAXHITCT
#define MAXHITCT
Definition
Args.h:13
CaloGpuGeneral.h
CaloGpuGeneral_cu.h
t0
static Double_t t0
Definition
LArPhysWaveHECTool.cxx:38
Rand4Hits.h
Rand4Hits
Definition
Rand4Hits.h:13
Rand4Hits::add_a_hits
void add_a_hits(int nhits)
Definition
Rand4Hits.h:49
Rand4Hits::get_cells_energy
float * get_cells_energy()
Definition
Rand4Hits.h:38
Rand4Hits::create_gen
void create_gen(unsigned long long seed, size_t numhits, bool useCPU=false)
Rand4Hits::get_ct
int * get_ct()
Definition
Rand4Hits.h:42
Rand4Hits::set_c_hits
void set_c_hits(int nhits)
Definition
Rand4Hits.h:30
Rand4Hits::allocate_simulation
void allocate_simulation(long long maxhits, unsigned short maxbins, unsigned short maxhitct, unsigned long n_cells)
Rand4Hits::rand_ptr
float * rand_ptr(int nhits)
Definition
Rand4Hits.h:18
Rand4Hits::set_t_a_hits
void set_t_a_hits(int nhits)
Definition
Rand4Hits.h:29
Rand4Hits::get_cell_e_h
Cell_E * get_cell_e_h()
Definition
Rand4Hits.h:40
Rand4Hits::get_cell_e
Cell_E * get_cell_e()
Definition
Rand4Hits.h:39
r
int r
Definition
globals.cxx:22
CaloGpuGeneral_cu::simulate_hits
void simulate_hits(float, int, Chain0_Args &, bool)
CaloGpuGeneral::simulate_hits
void simulate_hits(float, int, Chain0_Args &, bool)
Definition
CaloGpuGeneral.cxx:45
CaloGpuGeneral::Rand4Hits_finish
void Rand4Hits_finish(void *)
Definition
CaloGpuGeneral.cxx:41
CaloGpuGeneral::Rand4Hits_init
void * Rand4Hits_init(long long, unsigned short, unsigned long long, bool)
Definition
CaloGpuGeneral.cxx:8
Chain0_Args
Definition
Args.h:17
Generated on
for ATLAS Offline Software by
1.17.0