Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

performance - What instruction is more efficient?

I have the following function inside a .cpp file which #includes "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 #includes "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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...