refactor: use constexpr for host and device code in LBM library
When functions are compiled with constexpr
syntax and cuda code is compiled with --expt-relaxed-constexpr
flag, they can be used on cpu and gpu (see https://www.youtube.com/watch?v=TRQWxkRdPUI)
Advantage:
- function is implicitly
inline
(https://en.cppreference.com/w/cpp/language/constexpr) - no host and device keyword needed
- potential speedups possible (not yet seen)
And biggest advantage: other constexpr functions can be called and used, also for example from the c++ standard library.
So far, std::max
is now used on gpu. std::abs
will be constexpr
from C++23. More and more functions will be constexpr
in the future (see YT video link)