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:
2025-10-22 15:08:49 -04:00
parent b20d3467fa
commit 0581f69c48
6 changed files with 41 additions and 47 deletions

View File

@@ -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);
}
}