Floating Point Precision¶
Currently, libCEED supports two options for
CeedScalar : double and single.
The default is to use double precision.
Users wishing to set
CeedScalar to single precision should edit
include/ceed/ceed.h and change
ceed-f32.h instead, then recompile the library.
Tests can be run using
make test FC= because the Fortran tests do not support single precision at this time.
CEED_SCALAR_TYPEwill be defined to match one of the values of the
enum, and can be used for compile-time checking of
CeedScalar’s type; see, e.g.,
Fortran: There is no definition of
CeedScalaravailable in the Fortran header. The user is responsible for ensuring that data used in Fortran code is of the correct type (
real*4) for libCEED’s current configuration.
Julia: After compiling the single precision version of libCEED, instruct LibCEED.jl to use this library with the
set_libceed_path!function and restart the Julia session. LibCEED.jl will configure itself to use the appropriate type for
Python: Make sure to replace the
ceed-f64.hinclusion rather than commenting it out, to guarantee that the Python bindings will pick the correct precision. The
scalar_type()function has been added to the
Ceedclass for convenience. It returns a string corresponding to a numpy datatype matching that of
Scalartype corresponds to
This is work in progress! The ability to use single precision is an initial step in ongoing development of mixed-precision support in libCEED. A current GitHub issue contains discussions related to this development.