summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorgreen349 <[email protected]>2018-04-11 16:15:31 -0400
committerRoland Green <[email protected]>2018-04-11 18:28:52 -0400
commitf25a04e6a3db604f52d655fa98b99ad8f5343015 (patch)
treef08ab8ff85d78c9fb47b34113547c24dbbe59853 /src/cuda-sim
parent755a3cfa1b2b1711f395702d32a927dc53bee212 (diff)
Add support for isnan to compile with GCC-4.8.2
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-math.h4
-rw-r--r--src/cuda-sim/instructions.cc9
2 files changed, 8 insertions, 5 deletions
diff --git a/src/cuda-sim/cuda-math.h b/src/cuda-sim/cuda-math.h
index 4721e8a..f88c526 100644
--- a/src/cuda-sim/cuda-math.h
+++ b/src/cuda-sim/cuda-math.h
@@ -67,6 +67,8 @@
#ifndef CUDA_MATH
#define CUDA_MATH
+#include <cmath>
+
// cuda math implementations
#undef max
#undef min
@@ -321,7 +323,7 @@ float __internal_accurate_fdividef(float a, float b)
float __saturatef(float a)
{
float b;
- if (isnan(a)) b = 0.0f;
+ if (std::isnan(a)) b = 0.0f;
else if (a >= 1.0f) b = 1.0f;
else if (a <= 0.0f) b = 0.0f;
else b = a;
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index 011c285..e3b8970 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -33,6 +33,7 @@
#include "ptx.tab.h"
#include <stdlib.h>
#include <math.h>
+#include <cmath>
#include <fenv.h>
#include "cuda-math.h"
#include "../abstract_hardware_model.h"
@@ -1961,7 +1962,7 @@ ptx_reg_t d2d( ptx_reg_t x, unsigned from_width, unsigned to_width, int to_sign,
y.f64 = x.f64;
break;
}
- if (isnan(y.f64)) {
+ if (std::isnan(y.f64)) {
y.u64 = 0xfff8000000000000ull;
} else if (saturation_mode) {
y.f64 = cuda_math::__saturatef(y.f64);
@@ -2086,7 +2087,7 @@ void ptx_round(ptx_reg_t& data, int rounding_mode, int type)
}
}
if ((type == F64_TYPE)||(type == FF64_TYPE)) {
- if (isnan(data.f64)) {
+ if (std::isnan(data.f64)) {
data.u64 = 0xfff8000000000000ull;
}
}
@@ -2648,12 +2649,12 @@ void mad_def( const ptx_instruction *pI, ptx_thread_info *thread, bool use_carry
bool isNaN(float x)
{
- return isnan(x);
+ return std::isnan(x);
}
bool isNaN(double x)
{
- return isnan(x);
+ return std::isnan(x);
}
void max_impl( const ptx_instruction *pI, ptx_thread_info *thread )