-
Notifications
You must be signed in to change notification settings - Fork 7
Move choice of floating-point precision to the Python layer #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
ilateur
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Someone (or some-multiple) should test this on linux
DiegoDeGusem
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my linux device the code compiles and the test succeeds 🎉
I also agree with @ilateur's comment about a larger description.
|
A webpage was added in the Tutorials section, explaining how to choose a precision, what errors can occur, and showcasing the effect on the error floor. |
This PR simplifies the process of switching between single and double floating-point precision.
Previously, the precision had to be chosen before compilation, by editing
CMakeLists.txt.Now, mumax+ compiles two binaries: one for single and one for double precision (unless
MUMAXPLUS_FP_PRECISIONis set, see below). The appropriate binary is then loaded during theimport mumaxplusstatement.Two switches control the floating-point precision, as listed below in descending order of priority. Both can take the values
SINGLE/1/32for single precision andDOUBLE/2/64for double precision.--mumaxplus-fp-precisionpassed to thepythoncommand.python some_mumax_script.py --mumaxplus-fp-precision DOUBLE.MUMAXPLUS_FP_PRECISION.--mumaxplus-fp-precisionwill then result in aModuleNotFoundError.The used precision can then be accessed as
mumaxplus.FP_PRECISION.Note
Since the choice of precision must be made before the
import mumaxplusstatement, it is not possible to use single precision in one part of a script and double precision in another: these must be run in separate processes. Reloading mumax+ with a different floating point precision during runtime may lead to a vast wealth of errors.The unit test is based on
examples/errorscaling.py, since the error scaling is highly dependent on the floating point precision.