mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-13 20:26:03 +08:00
Avoid using std::raise() for divide by zero
This commit is contained in:
parent
62de593c40
commit
37de432907
@ -177,10 +177,6 @@ using std::ptrdiff_t;
|
||||
#include "src/Core/arch/Default/TypeCasting.h"
|
||||
#include "src/Core/arch/Default/GenericPacketMathFunctionsFwd.h"
|
||||
|
||||
#ifndef EIGEN_GPU_COMPILE_PHASE
|
||||
#include <csignal>
|
||||
#endif
|
||||
|
||||
#if defined EIGEN_VECTORIZE_AVX512
|
||||
#if defined EIGEN_VECTORIZE_AVX512FP16
|
||||
#include "src/Core/arch/AVX512/PacketMathFP16.h"
|
||||
|
@ -388,7 +388,11 @@ template <typename Packet>
|
||||
struct maybe_raise_div_by_zero<Packet, true> {
|
||||
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Packet x) {
|
||||
if (EIGEN_PREDICT_FALSE(predux_any(pcmp_eq(x, pzero(x))))) {
|
||||
std::raise(SIGFPE);
|
||||
// Use volatile variables to force a division by zero, which will
|
||||
// result in the default platform behaviour (usually SIGFPE).
|
||||
volatile typename unpacket_traits<Packet>::type zero = 0;
|
||||
volatile typename unpacket_traits<Packet>::type val = 1;
|
||||
val = val / zero;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user