I have the following function inside a .cpp file which #include
s "IonizationTables.h", the .h file where the vector ionizationEnergy[100*101/2]
is implemented (as a look-up table) with 5050 (double) entries:, and also #include
s "Ionization.h", where eV_to_au
is defined and which is then implemented in Ionization.cpp, as a double value (double eV_to_au = 1.0 / 27.2116;
).
double continuity_tool(double Potential, unsigned int atomic_number_, unsigned int Z) {
double Potential_in_eV = Potential / eV_to_au; // a division
double Potential_in_eVV = IonizationTables::ionizationEnergy[atomic_number_*(atomic_number_-1)/2 + Z]; // equivalent to above. which is more efficient?
}
I have to call this function for more than 100.000 times in a simulation, possibly millions.
The simulation is done on a HPC cluster, with many many nodes and cores.
How shall I calculate Potential in eV? Using first instruction or using 2nd instruction? And why?
Thank you!
question from:
https://stackoverflow.com/questions/65830095/what-instruction-is-more-efficient 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…