From 7e7e98eda7ab893ee12b307a97ab5eaf23f63af9 Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Thu, 15 Jul 2010 23:11:12 -0800 Subject: compiles with CUDA 3.1 (but, nothing tested) [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6832] --- libcuda/cuda_runtime_api.cc | 19 ++++++++++++++++++- src/cuda-sim/cuda-math.h | 17 +++++++++++++++++ src/cuda-sim/instructions.cc | 32 ++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/libcuda/cuda_runtime_api.cc b/libcuda/cuda_runtime_api.cc index e056f1a..d17383d 100644 --- a/libcuda/cuda_runtime_api.cc +++ b/libcuda/cuda_runtime_api.cc @@ -906,9 +906,12 @@ timer_event_t *g_timer_events = NULL; __host__ cudaError_t CUDARTAPI cudaEventCreate(cudaEvent_t *event) { timer_event_t *t = (timer_event_t*) calloc(1,sizeof(timer_event_t)); - t->m_uid = ++g_next_event_uid; +#if CUDART_VERSION >= 3000 + cuda_not_implemented(__my_func__,__LINE__); +#else *event = t->m_uid; +#endif t->m_next = g_timer_events; g_timer_events = t; @@ -919,6 +922,9 @@ __host__ cudaError_t CUDARTAPI cudaEventCreate(cudaEvent_t *event) __host__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t stream) { +#if CUDART_VERSION >= 3000 + cuda_not_implemented(__my_func__,__LINE__); +#else timer_event_t *t = g_timer_events; while( t && t->m_uid != event ) t = t->m_next; @@ -928,6 +934,7 @@ __host__ cudaError_t CUDARTAPI cudaEventRecord(cudaEvent_t event, cudaStream_t s t->m_updates++; t->m_gpu_tot_sim_cycle = gpu_tot_sim_cycle; t->m_wallclock = time((time_t *)NULL); +#endif return g_last_cudaError = cudaSuccess; } @@ -945,6 +952,10 @@ __host__ cudaError_t CUDARTAPI cudaEventSynchronize(cudaEvent_t event) __host__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event) { +#if CUDART_VERSION >= 3000 + cuda_not_implemented(__my_func__,__LINE__); + return g_last_cudaError = cudaErrorUnknown; +#else timer_event_t *l = NULL; timer_event_t *t = g_timer_events; while( t && t->m_uid != event ) { @@ -964,11 +975,16 @@ __host__ cudaError_t CUDARTAPI cudaEventDestroy(cudaEvent_t event) free(l); return g_last_cudaError = cudaSuccess; } +#endif } __host__ cudaError_t CUDARTAPI cudaEventElapsedTime(float *ms, cudaEvent_t start, cudaEvent_t end) { +#if CUDART_VERSION >= 3000 + cuda_not_implemented(__my_func__,__LINE__); + return g_last_cudaError = cudaErrorUnknown; +#else time_t elapsed_time; timer_event_t *s, *e; s = e = g_timer_events; @@ -980,6 +996,7 @@ __host__ cudaError_t CUDARTAPI cudaEventElapsedTime(float *ms, cudaEvent_t start elapsed_time = e->m_wallclock - s->m_wallclock; *ms = 1000*elapsed_time; return g_last_cudaError = cudaSuccess; +#endif } 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 #define __CUDA_INTERNAL_COMPILATION__ +#if CUDART_VERSION >= 3000 +#define __CUDACC__ +#include +#else #include +#endif #undef __CUDA_INTERNAL_COMPILATION__ #undef __attribute__ + +#if CUDART_VERSION >= 3000 +#define __internal_float2int float2int +#define __internal_float2uint float2uint +#include +#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; } } -- cgit v1.3