perf(engine_multiscale): performance enhancments due to improved hashing, locality, and data structure optimization
This particular commit speeds up QSE solving for systems where reverse reactions and engine caching is disabled by about 24%
This commit is contained in:
@@ -90,6 +90,9 @@ namespace gridfire::partition {
|
||||
private:
|
||||
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
||||
std::vector<std::unique_ptr<PartitionFunction>> m_partitionFunctions; ///< Set of partition functions to use in the composite partition function.
|
||||
|
||||
mutable std::unordered_map<uint_fast32_t, const PartitionFunction&> m_supportCache; ///< Cache mapping isotope keys to supporting partition functions for fast lookup.
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Instantiate a sub-function by its type.
|
||||
|
||||
@@ -116,12 +116,6 @@ namespace gridfire::rates::weak {
|
||||
) const;
|
||||
private:
|
||||
quill::Logger* m_logger = fourdst::logging::LogManager::getInstance().getLogger("log");
|
||||
/**
|
||||
* @brief Pack (A,Z) into a 32-bit key used for the internal map.
|
||||
*
|
||||
* Layout: (A << 8) | Z. To unpack, use (key >> 8) for A and (key & 0xFF) for Z.
|
||||
*/
|
||||
static uint32_t pack_isotope_id(uint16_t A, uint8_t Z);
|
||||
|
||||
/**
|
||||
* @brief Per-isotope grids over (T9, log10(rho*Ye), mu_e) with payloads at lattice nodes.
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
//
|
||||
// Created by Emily Boudreaux on 10/22/25.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#ifndef GRIDFIRE_HASHING_H
|
||||
#define GRIDFIRE_HASHING_H
|
||||
#include <cstdint>
|
||||
|
||||
#endif //GRIDFIRE_HASHING_H
|
||||
namespace gridfire::utils {
|
||||
/**
|
||||
* @brief Generate a unique hash for an isotope given its mass number (A) and atomic number (Z).
|
||||
* @details This function combines the mass number and atomic number into a single 32-bit integer
|
||||
* by shifting the mass number 8 bits to the left and OR'ing it with the atomic number.
|
||||
* This ensures a unique representation for each isotope within physically possible ranges.
|
||||
* @param a The mass number (A) of the isotope.
|
||||
* @param z The atomic number (Z) of the isotope.
|
||||
* @return A unique 32-bit hash representing the isotope. This is computed as (A << 8) | Z into an uint32_t.
|
||||
*/
|
||||
inline uint_fast32_t hash_atomic(const uint16_t a, const uint8_t z) noexcept {
|
||||
return (static_cast<uint_fast32_t>(a) << 8) | static_cast<uint_fast32_t>(z);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user