26#ifndef G4FastPathHadronicCrossSection_hh
27#define G4FastPathHadronicCrossSection_hh
34#include <unordered_map>
90 uint64_t cacheHitCount;
91 uint64_t initCyclesFastPath;
92 uint64_t invocationCountSlowPath;
93 uint64_t totalCyclesSlowPath;
94 uint64_t invocationCountFastPath;
95 uint64_t totalCyclesFastPath;
96 uint64_t invocationCountTriedOneLineCache;
97 uint64_t invocationCountOneLineCache;
114 uint64_t methodCalled;
115 uint64_t hitOneLineCache;
118 uint64_t sampleZandA;
134 return (lhs.first==rhs.first)&&(lhs.second == rhs.second);
147 std::less<G4CrossSectionDataStore_Key>
less;
193 static inline void logInitCyclesFastPath( cycleCountEntry* , timing& );
194 static inline void logTotalCyclesFastPath( cycleCountEntry* , timing& );
195 static inline void logTotalCyclesSlowPath( cycleCountEntry* , timing& );
196 static inline void logTiming( cycleCountEntry* , fastPathEntry* , timing& );
206inline void logInvocationTriedOneLine(cycleCountEntry* cl ) {
207 if ( cl !=
nullptr ) ++(cl->invocationCountTriedOneLineCache);
209inline void logInvocationOneLine( cycleCountEntry* cl ) {
210 if ( cl !=
nullptr ) ++(cl->invocationCountOneLineCache);
212inline void logHit(cycleCountEntry* cl) {
213 if ( cl !=
nullptr ) ++(cl->cacheHitCount);
215inline void logInvocationCountFastPath( cycleCountEntry* cl )
217 if ( cl !=
nullptr ) ++(cl->invocationCountFastPath);
219inline void logInvocationCountSlowPAth( cycleCountEntry* cl)
221 if ( cl !=
nullptr ) ++(cl->invocationCountSlowPath);
224inline void logInitCyclesFastPath(cycleCountEntry* cl,timing& tm)
226 if ( cl !=
nullptr ) cl->initCyclesFastPath =
tm.rdtsc_stop -
tm.rdtsc_start;
228inline void logTotalCyclesFastPath( cycleCountEntry* cl,timing& tm)
230 if ( cl!=
nullptr ) cl->totalCyclesFastPath =
tm.rdtsc_stop -
tm.rdtsc_start;
232inline void logTotalCyclesSlowPath( cycleCountEntry* cl,timing& tm)
234 if ( cl!=
nullptr ) cl->totalCyclesSlowPath =
tm.rdtsc_stop -
tm.rdtsc_start;
236inline void logTiming( cycleCountEntry* entry , fastPathEntry* fast_entry, timing& timing)
238 if (fast_entry !=
nullptr ) {
239 if ( entry->invocationCountFastPath == 0 ) {
241 G4FastPathHadronicCrossSection::logInitCyclesFastPath(entry,timing);
242 G4FastPathHadronicCrossSection::logInvocationCountFastPath(entry);
246 G4FastPathHadronicCrossSection::logTotalCyclesFastPath(entry,timing);
247 G4FastPathHadronicCrossSection::logInvocationCountFastPath(entry);
250 G4FastPathHadronicCrossSection::logInvocationCountSlowPAth(entry);
251 G4FastPathHadronicCrossSection::logTotalCyclesSlowPath(entry,timing);
255inline void logInvocationTriedOneLine(cycleCountEntry*){}
256inline void logInvocationOneLine( cycleCountEntry*){}
257inline void logHit(cycleCountEntry*){}
258inline void logInvocationCountFastPath( cycleCountEntry*){}
259inline void logInvocationCountSlowPAth( cycleCountEntry*){}
260inline void logInitCyclesFastPath( cycleCountEntry* , timing& ){}
261inline void logTotalCyclesFastPath( cycleCountEntry* , timing& ){}
262inline void logTotalCyclesSlowPath( cycleCountEntry* , timing& ){}
263inline void logTiming( cycleCountEntry* , fastPathEntry* , timing& ) {}
301 os<<
"#min_cutoff(MeV): "<<fp.
min_cutoff/MeV<<
"\n";
303 os<<
"#DEBUG COUNTERS: count="<<fp.count<<
" slowpath_sum="<<fp.slowpath_sum<<
" max_delta="<<fp.max_delta;
304 os<<
" min_delta="<<fp.min_delta<<
" sum_delta="<<fp.sum_delta<<
" sum_delta_square="<<fp.sum_delta_square<<
"\n";
std::ostream & operator<<(std::ostream &os, const G4FastPathHadronicCrossSection::fastPathEntry &fp)
const G4String & GetName() const
const G4String & GetParticleName() const
G4double Value(G4double theEnergy, std::size_t &lastidx) const
void logStopCountCycles(timing &)
std::pair< const G4ParticleDefinition *, const G4Material * > G4CrossSectionDataStore_Key
void logStartCountCycles(timing &)
std::set< fastPathRequestConfig_t, fastPathRequestConfig_Less > G4CrossSectionDataStore_Requests
std::unordered_map< G4CrossSectionDataStore_Key, cycleCountEntry *, G4CrossSectionDataStore_Key_Hash, G4CrossSectionDataStore_Key_EqualTo > G4CrossSectionDataStore_Cache
bool operator()(const G4CrossSectionDataStore_Key &lhs, const G4CrossSectionDataStore_Key &rhs) const
size_t operator()(const G4CrossSectionDataStore_Key &x) const
std::hash< uint64_t > hash_uint64_t
G4bool prevCalcUsedFastPath
G4bool useFastPathIfAvailable
G4bool initializationPhase
const G4Material *const material
const G4String & particle
G4double GetCrossSection(G4double ene) const
void Initialize(G4CrossSectionDataStore *)
const G4ParticleDefinition *const particle
const G4Material *const material
const G4double min_cutoff
bool operator()(const fastPathRequestConfig_t &lhs, const fastPathRequestConfig_t &rhs) const
std::less< G4CrossSectionDataStore_Key > less
G4CrossSectionDataStore_Key part_mat
unsigned long long rdtsc_stop
unsigned long long rdtsc_start