boostorg / boostorg/math

GPU compilation failure with pow.hpp from boost::multiprecision

Open
#1,285 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
374
Forks
264
Avg merge
1d 23h
Merged PRs (30d)
17

Description

I have some C++ code that compiled just fine with `nvcc` from CUDA 12.6.1 and Boost 1.84.0. After updating to Boost 1.88.0, which includes the GPU math changes from Boost 1.87.0, I'm now seeing the following error message:

```
/usr/include/boost/multiprecision/detail/functions/pow.hpp(789): error: namespace "boost::math" has no member "rounding_error"
catch(const boost::math::rounding_error&)
^
```

If I'm understanding Boost's macro and include header structure correctly, boost/multiprecision/detail/functions/pow.hpp is inlined with boost/multiprecision/detail/default_ops.hpp. pow.hpp is always included no matter what in default_ops.hpp. `boost::math::rounding_error` is defined in boost/math/policies/error_handling.hpp, which is only included by default_ops.hpp if `BOOST_MP_MATH_AVAILABLE` is defined. This is the same macro that's used for guarding `BOOST_MP_CATCH(const boost::math::rounding_error&) {}` in pow.hpp (the same code not compiling), so all seems good. But, `boost::math::rounding_error` is only defined when `BOOST_MATH_NO_EXCEPTIONS` is NOT defined. And, when compiling with `nvcc`, `BOOST_MATH_NO_EXCEPTIONS` DOES get defined, according to boost/math/tools/config.hpp, because we've got `__CUDACC__` defined by simply using `nvcc`.

Should we be adjusting pow.hpp, and possibly any other cases like this in either `boost::math` or `boost::multiprecision`, to have something like this instead?

```
#if defined(BOOST_MP_MATH_AVAILABLE) && !defined(BOOST_MATH_NO_EXCEPTIONS)
BOOST_MP_CATCH(const boost::math::rounding_error&)
{ /* Fallthrough */
}
#endif
```

That way we only define this catch condition when we have exception support and multiprecision math is available?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.