Skip to content

Commit

Permalink
Adapt to std::uncaught_exception() deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
tcojean committed May 5, 2023
1 parent 362ada6 commit 18c5600
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cuda/base/pointer_mode_guard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


#include <ginkgo/core/base/exception_helpers.hpp>
#include <ginkgo/core/base/std_extensions.hpp>


namespace gko {
Expand Down Expand Up @@ -79,7 +80,7 @@ class pointer_mode_guard {
~pointer_mode_guard() noexcept(false)
{
/* Ignore the error during stack unwinding for this call */
if (std::uncaught_exception()) {
if (xstd::uncaught_exception()) {
cublasSetPointerMode(*l_handle, CUBLAS_POINTER_MODE_DEVICE);
} else {
GKO_ASSERT_NO_CUBLAS_ERRORS(
Expand Down Expand Up @@ -126,7 +127,7 @@ class pointer_mode_guard {
~pointer_mode_guard() noexcept(false)
{
/* Ignore the error during stack unwinding for this call */
if (std::uncaught_exception()) {
if (xstd::uncaught_exception()) {
cusparseSetPointerMode(l_handle, CUSPARSE_POINTER_MODE_DEVICE);
} else {
GKO_ASSERT_NO_CUSPARSE_ERRORS(
Expand Down
5 changes: 3 additions & 2 deletions hip/base/pointer_mode_guard.hip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <ginkgo/core/base/exception_helpers.hpp>
#include <ginkgo/core/base/executor.hpp>
#include <ginkgo/core/base/std_extensions.hpp>


namespace gko {
Expand Down Expand Up @@ -81,7 +82,7 @@ class pointer_mode_guard {
~pointer_mode_guard() noexcept(false)
{
/* Ignore the error during stack unwinding for this call */
if (std::uncaught_exception()) {
if (xstd::uncaught_exception()) {
hipblasSetPointerMode(reinterpret_cast<hipblasHandle_t>(l_handle),
HIPBLAS_POINTER_MODE_DEVICE);
} else {
Expand Down Expand Up @@ -131,7 +132,7 @@ class pointer_mode_guard {
~pointer_mode_guard() noexcept(false)
{
/* Ignore the error during stack unwinding for this call */
if (std::uncaught_exception()) {
if (xstd::uncaught_exception()) {
hipsparseSetPointerMode(
reinterpret_cast<hipsparseHandle_t>(l_handle),
HIPSPARSE_POINTER_MODE_DEVICE);
Expand Down
11 changes: 11 additions & 0 deletions include/ginkgo/core/base/std_extensions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define GKO_PUBLIC_CORE_BASE_STD_EXTENSIONS_HPP_


#include <exception>
#include <functional>
#include <memory>
#include <type_traits>
Expand Down Expand Up @@ -69,6 +70,16 @@ template <typename... Ts>
using void_t = typename detail::make_void<Ts...>::type;


// Disable deprecation warnings when using standard > 2014
inline bool uncaught_exception() noexcept {
#if __cplusplus > 201402L
return std::uncaught_exceptions() > 0;
#else
return std::uncaught_exception();
#endif
}


// Kept for backward compatibility.
template <bool B, typename T = void>
using enable_if_t = std::enable_if_t<B, T>;
Expand Down

0 comments on commit 18c5600

Please sign in to comment.