Replies: 3 comments 11 replies
-
I just ran into a compile time issue building with both |
Beta Was this translation helpful? Give feedback.
-
Any ideas whether the |
Beta Was this translation helpful? Give feedback.
-
I gave
There is probably also a desire for explicit functions from
There was also some small by-catch: in-advert conversions from |
Beta Was this translation helpful? Give feedback.
-
Support for floating point types other than
double
is going to be introduced in MFEM v4.7 with PR #3922.Summary
This is a summary of the main changes in PR #3922:
double
is replaced throughout most of the library with a new type,real_t
, which by default is just a typedef todouble
.float
type) precision only. Other types may be added in the future.real_t
is a typedef tofloat
.MFEM_PRECISION
with one of the strings:single
/Single
/SINGLE
/double
/Double
/DOUBLE
.config/_config.hpp
,MFEM_PRECISION
is represented by defining exactly one of the macros:MFEM_USE_DOUBLE
, orMFEM_USE_SINGLE
.config.mk
andMFEMConfig.cmake
, the option is represented by the variablesMFEM_USE_DOUBLE
andMFEM_USE_SINGLE
defined asYES
/NO
(make) orON
/OFF
(cmake).real_t operator""_r()
for integer and floating-point arguments.real_t
constants as1_r
,0.25_r
, etc.real_t
type is to use c-style casting, e.g.real_t(1)
,real_t(0.25)
,real_t(M_PI*M_PI)
,reat_t(alpha(beta))
, wherealpha
has the signaturedouble alpha(double)
, etc.ex33
/ex33p
, were updated and support single precision, on both CPUs and GPUs.--enable-single
when usingMFEM_PRECISION=single
.--with-precision=single
when usingMFEM_PRECISION=single
.Discussion
Replacing
double
withreal_t
in user code is NOT necessary, as long as MFEM is built with double precision -- in this casereal_t
is just an alias ofdouble
, i.e. they are the same type, just different names.The only reason to convert
double
toreal_t
in user code is to add support for single precision to the user code -- and that will be just the first step. Depending on the application, adding support for single precision may require changes like: convertingdouble
constants toreal_t
constants to prevent undesirable computations in higher precision; or increasing tolerances (whenMFEM_USE_SINGLE
is defined) in iterative methods to ensure convergence is possible in the lower precision, see e.g. this code in the updated ex10:mfem/examples/ex10.cpp
Lines 462 to 472 in 6f37514
Beta Was this translation helpful? Give feedback.
All reactions