26 #ifndef G4FastPathHadronicCrossSection_hh
27 #define G4FastPathHadronicCrossSection_hh
34 #include <unordered_map>
47 namespace G4FastPathHadronicCrossSection {
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;
196 static inline void logTiming( cycleCountEntry* , fastPathEntry* , timing& );
203 namespace G4FastPathHadronicCrossSection {
207 if ( cl !=
nullptr ) ++(cl->invocationCountTriedOneLineCache);
210 if ( cl !=
nullptr ) ++(cl->invocationCountOneLineCache);
212 inline void logHit(cycleCountEntry* cl) {
213 if ( cl !=
nullptr ) ++(cl->cacheHitCount);
217 if ( cl !=
nullptr ) ++(cl->invocationCountFastPath);
221 if ( cl !=
nullptr ) ++(cl->invocationCountSlowPath);
226 if ( cl !=
nullptr ) cl->initCyclesFastPath = tm.rdtsc_stop - tm.rdtsc_start;
230 if ( cl!=
nullptr ) cl->totalCyclesFastPath = tm.rdtsc_stop - tm.rdtsc_start;
234 if ( cl!=
nullptr ) cl->totalCyclesSlowPath = tm.rdtsc_stop - tm.rdtsc_start;
236 inline void logTiming( cycleCountEntry* entry , fastPathEntry* fast_entry, timing& timing)
238 if (fast_entry !=
nullptr ) {
239 if ( entry->invocationCountFastPath == 0 ) {
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";
310 #endif //G4FastPathHadronicCrossSection_hh
static void logTotalCyclesSlowPath(cycleCountEntry *, timing &)
bool operator()(const fastPathRequestConfig_t &lhs, const fastPathRequestConfig_t &rhs) const
fastPathEntry(const G4ParticleDefinition *par, const G4Material *mat, G4double min_cutoff)
void Initialize(G4CrossSectionDataStore *)
static void logTiming(cycleCountEntry *, fastPathEntry *, timing &)
size_t operator()(const G4CrossSectionDataStore_Key &x) const
const G4String & particle
std::hash< uint64_t > hash_uint64_t
const G4String & GetName() const
const G4ParticleDefinition *const particle
G4bool prevCalcUsedFastPath
G4double GetCrossSection(G4double ene) const
const G4double min_cutoff
static void logInvocationCountFastPath(cycleCountEntry *)
const G4Material *const material
const G4Material *const material
const G4String & GetParticleName() const
std::set< fastPathRequestConfig_t, fastPathRequestConfig_Less > G4CrossSectionDataStore_Requests
std::unordered_map< G4CrossSectionDataStore_Key, cycleCountEntry *, G4CrossSectionDataStore_Key_Hash, G4CrossSectionDataStore_Key_EqualTo > G4CrossSectionDataStore_Cache
static void logInvocationCountSlowPAth(cycleCountEntry *)
static void logInitCyclesFastPath(cycleCountEntry *, timing &)
void logStartCountCycles(timing &)
std::pair< const G4ParticleDefinition *, const G4Material * > G4CrossSectionDataStore_Key
G4bool useFastPathIfAvailable
static void logInvocationOneLine(cycleCountEntry *)
static void logHit(cycleCountEntry *)
cycleCountEntry(const G4String &pname, const G4Material *mat)
static constexpr double MeV
G4double Value(G4double theEnergy, size_t &lastidx) const
std::less< G4CrossSectionDataStore_Key > less
G4CrossSectionDataStore_Key part_mat
unsigned long long rdtsc_start
bool operator()(const G4CrossSectionDataStore_Key &lhs, const G4CrossSectionDataStore_Key &rhs) const
static void logTotalCyclesFastPath(cycleCountEntry *, timing &)
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
static constexpr double MeV
static void logInvocationTriedOneLine(cycleCountEntry *)
G4bool initializationPhase
unsigned long long rdtsc_stop
void logStopCountCycles(timing &)