lanl / singularity-eos

Performance portable equations of state and mixed cell closures
https://lanl.github.io/singularity-eos/
BSD 3-Clause "New" or "Revised" License
25 stars 8 forks source link

Switch asserts to runtime errors in constructors #345

Open jhp-lanl opened 7 months ago

jhp-lanl commented 7 months ago

Our spack host codes don't always propagate the build type to their spack dependencies. As a result, telling the host code to build with debug won't link to a debug version of singularity-eos. Host codes also don't want to propagate the build type either for performance reasons or to minimize the size of the spack buildout.

However, this makes our assert statements almost completely useless since it's probably rare that somebody will manually change the spack spec to build singularity in debug mode.

I would propose that all constructors should use the ports-of-call portable error machinery instead and ensure that errors are raised even outside debug builds. Checks at lookup time can still use asserts since we want those to be performant, but there's no reason to sacrifice debugging for performance during initialization.

Yurlungur commented 7 months ago

We have a tool for this now in the portable_errors header. PORTABLE_ALWAYS_THROW seems like the thing.

jhp-lanl commented 7 months ago

We have a tool for this now in the portable_errors header. PORTABLE_ALWAYS_THROW seems like the thing.

I would propose that all constructors should use the ports-of-call portable error machinery instead and ensure that errors are raised even outside debug builds

😉

Yurlungur commented 7 months ago

Whoops clearly I have excellent reading comprehension. My bad.