boostorg / boostorg/math

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

オープン
#1,285 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
374
フォーク
264
平均マージ
1日 23時間
マージ済み PR(30日)
17

説明

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?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。