summaryrefslogtreecommitdiff
path: root/src/cuda-sim
diff options
context:
space:
mode:
authorTor Aamodt <[email protected]>2010-07-15 23:11:12 -0800
committerTor Aamodt <[email protected]>2010-07-15 23:11:12 -0800
commit7e7e98eda7ab893ee12b307a97ab5eaf23f63af9 (patch)
tree0331f32478d93d3437fcc222f94b180381748e5f /src/cuda-sim
parent69f2911e04ffb1b19eef1fafb8c040af271f656e (diff)
compiles with CUDA 3.1 (but, nothing tested)
[git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6832]
Diffstat (limited to 'src/cuda-sim')
-rw-r--r--src/cuda-sim/cuda-math.h17
-rw-r--r--src/cuda-sim/instructions.cc32
2 files changed, 45 insertions, 4 deletions
diff --git a/src/cuda-sim/cuda-math.h b/src/cuda-sim/cuda-math.h
index d495461..ea7f5fd 100644
--- a/src/cuda-sim/cuda-math.h
+++ b/src/cuda-sim/cuda-math.h
@@ -47,6 +47,7 @@ namespace cuda_math {
#define __attribute__(a) // to remove warnings inside math_functions.h
#undef INT_MAX
+#if CUDART_VERSION < 3000
// DEVICE_BUILTIN
struct int4 {
int x, y, z, w;
@@ -69,13 +70,29 @@ namespace cuda_math {
typedef struct float2 float2;
extern float rsqrtf(float); // CUDA 2.3 beta
+#else
+#define UINT_MAX ((unsigned int)-1)
+#endif
#define CUDA_FLOAT_MATH_FUNCTIONS
#include <device_types.h>
#define __CUDA_INTERNAL_COMPILATION__
+#if CUDART_VERSION >= 3000
+#define __CUDACC__
+#include <device_functions.h>
+#else
#include <math_functions.h>
+#endif
#undef __CUDA_INTERNAL_COMPILATION__
#undef __attribute__
+
+#if CUDART_VERSION >= 3000
+#define __internal_float2int float2int
+#define __internal_float2uint float2uint
+#include <math.h>
+#define __internal_accurate_fdividef fdividef
+#endif
+
}
#endif
diff --git a/src/cuda-sim/instructions.cc b/src/cuda-sim/instructions.cc
index a7a4df6..4479cbe 100644
--- a/src/cuda-sim/instructions.cc
+++ b/src/cuda-sim/instructions.cc
@@ -1042,7 +1042,11 @@ ptx_reg_t f2f( ptx_reg_t x, unsigned from_width, unsigned to_width, int to_sign,
y.f32 = truncf(x.f32);
break;
case RNI_OPTION:
+#if CUDART_VERSION >= 3000
+ y.f32 = nearbyintf(x.f32);
+#else
y.f32 = cuda_math::__internal_nearbyintf(x.f32);
+#endif
break;
case RMI_OPTION:
if ((x.u32 & 0x7f800000) == 0) {
@@ -1066,7 +1070,12 @@ ptx_reg_t f2f( ptx_reg_t x, unsigned from_width, unsigned to_width, int to_sign,
}
break;
}
- if (cuda_math::__cuda___isnanf(y.f32)) {
+#if CUDART_VERSION >= 3000
+ if (isnanf(y.f32))
+#else
+ if (cuda_math::__cuda___isnanf(y.f32))
+#endif
+ {
y.u32 = 0x7fffffff;
} else if (saturation_mode) {
y.f32 = cuda_math::__saturatef(y.f32);
@@ -1083,7 +1092,11 @@ ptx_reg_t d2d( ptx_reg_t x, unsigned from_width, unsigned to_width, int to_sign,
y.f64 = trunc(x.f64);
break;
case RNI_OPTION:
- y.f64 = cuda_math::__internal_nearbyintf(x.f64);
+#if CUDART_VERSION >= 3000
+ y.f64 = nearbyint(x.f32);
+#else
+ y.f64 = cuda_math::__internal_nearbyint(x.f64);
+#endif
break;
case RMI_OPTION:
y.f64 = floor(x.f64);
@@ -1184,7 +1197,13 @@ void ptx_round(ptx_reg_t& data, int rounding_mode, int type)
case U64_TYPE:
printf("Trying to round an integer??\n"); assert(0); break;
case F16_TYPE: assert(0); break;
- case F32_TYPE: data.f32 = cuda_math::__cuda_nearbyintf(data.f32); break;
+ case F32_TYPE:
+#if CUDART_VERSION >= 3000
+ data.f32 = nearbyintf(data.f32);
+#else
+ data.f32 = cuda_math::__cuda_nearbyintf(data.f32);
+#endif
+ break;
case F64_TYPE: data.f64 = round(data.f64); break;
default: assert(0); break;
}
@@ -1229,7 +1248,12 @@ void ptx_round(ptx_reg_t& data, int rounding_mode, int type)
}
if (type == F32_TYPE) {
- if (cuda_math::__cuda___isnanf(data.f32)) {
+#if CUDART_VERSION >= 3000
+ if (isnanf(data.f32))
+#else
+ if (cuda_math::__cuda___isnanf(data.f32))
+#endif
+ {
data.u32 = 0x7fffffff;
}
}