From 69f2911e04ffb1b19eef1fafb8c040af271f656e Mon Sep 17 00:00:00 2001 From: Tor Aamodt Date: Thu, 15 Jul 2010 18:09:46 -0800 Subject: creating branch for adding support for CUDA 3.x and Fermi [git-p4: depot-paths = "//depot/gpgpu_sim_research/fermi/distribution/": change = 6829] --- benchmarks/CUDA/WP/util.h | 265 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 265 insertions(+) create mode 100644 benchmarks/CUDA/WP/util.h (limited to 'benchmarks/CUDA/WP/util.h') diff --git a/benchmarks/CUDA/WP/util.h b/benchmarks/CUDA/WP/util.h new file mode 100644 index 0000000..56cb493 --- /dev/null +++ b/benchmarks/CUDA/WP/util.h @@ -0,0 +1,265 @@ + class Float4 { + public: + float x, y, z, w; + + __device__ const Float4 + operator+(const Float4& iv) const { + Float4 rv ; + rv.x = x + iv.x ; + rv.y = y + iv.y ; + rv.z = z + iv.z ; + rv.w = w + iv.w ; + return Float4( rv ) ; + } + __device__ const Float4 + operator*(const Float4& iv) const { + Float4 rv ; + rv.x = x * iv.x ; + rv.y = y * iv.y ; + rv.z = z * iv.z ; + rv.w = w * iv.w ; + return Float4( rv ) ; + } + __device__ const Float4 + operator/(const Float4& iv) const { + Float4 rv ; + rv.x = x / iv.x ; + rv.y = y / iv.y ; + rv.z = z / iv.z ; + rv.w = w / iv.w ; + return Float4( rv ) ; + } + __device__ const Float4 + operator-(const Float4& iv) const { + Float4 rv ; + rv.x = x - iv.x ; + rv.y = y - iv.y ; + rv.z = z - iv.z ; + rv.w = w - iv.w ; + return Float4( rv ) ; + } + + __device__ const Float4 + operator+(const float iv) const { + Float4 rv ; + rv.x = x + iv ; + rv.y = y + iv ; + rv.z = z + iv ; + rv.w = w + iv ; + return Float4( rv ) ; + } + __device__ const Float4 + operator*(const float iv) const { + Float4 rv ; + rv.x = x * iv ; + rv.y = y * iv ; + rv.z = z * iv ; + rv.w = w * iv ; + return Float4( rv ) ; + } + __device__ const Float4 + operator/(const float iv) const { + Float4 rv ; + rv.x = x / iv ; + rv.y = y / iv ; + rv.z = z / iv ; + rv.w = w / iv ; + return Float4( rv ) ; + } + __device__ const Float4 + operator-(const float iv) const { + Float4 rv ; + rv.x = x - iv ; + rv.y = y - iv ; + rv.z = z - iv ; + rv.w = w - iv ; + return Float4( rv ) ; + } + __device__ const Float4 + operator-() const { + Float4 rv ; + rv.x = -x ; + rv.y = -y ; + rv.z = -z ; + rv.w = -w ; + return Float4( rv ) ; + } + + __device__ void operator=(const float iv) { + x = iv ; + y = iv ; + z = iv ; + w = iv ; + } + + __device__ void operator+=(const Float4 iv) { + x += iv.x ; + y += iv.y ; + z += iv.z ; + w += iv.w ; + } + __device__ void operator-=(const Float4 iv) { + x -= iv.x ; + y -= iv.y ; + z -= iv.z ; + w -= iv.w ; + } + + }; + + __device__ const Float4 + operator+( const float iv1, const Float4 iv2 ) { + Float4 rv ; + rv.x = iv1 + iv2.x ; + rv.y = iv1 + iv2.y ; + rv.z = iv1 + iv2.z ; + rv.w = iv1 + iv2.w ; + return Float4( rv ) ; + } + __device__ const Float4 + operator*( const float iv1, const Float4 iv2 ) { + Float4 rv ; + rv.x = iv1 * iv2.x ; + rv.y = iv1 * iv2.y ; + rv.z = iv1 * iv2.z ; + rv.w = iv1 * iv2.w ; + return Float4( rv ) ; + } + __device__ const Float4 + operator/( const float iv1, const Float4 iv2 ) { + Float4 rv ; + rv.x = iv1 / iv2.x ; + rv.y = iv1 / iv2.y ; + rv.z = iv1 / iv2.z ; + rv.w = iv1 / iv2.w ; + return Float4( rv ) ; + } + __device__ const Float4 + operator-( const float iv1, const Float4 iv2 ) { + Float4 rv ; + rv.x = iv1 - iv2.x ; + rv.y = iv1 - iv2.y ; + rv.z = iv1 - iv2.z ; + rv.w = iv1 - iv2.w ; + return Float4( rv ) ; + } + +__device__ Float4 max ( const Float4 a , const Float4 b ) +{ + Float4 c ; + c.x = (a.x>b.x)?a.x:b.x; + c.y = (a.y>b.y)?a.y:b.y; + c.z = (a.z>b.z)?a.z:b.z; + c.w = (a.w>b.w)?a.w:b.w; + return(c) ; +} +__device__ Float4 max ( const float a , const Float4 b ) +{ + Float4 c ; + c.x = (a>b.x)?a:b.x; + c.y = (a>b.y)?a:b.y; + c.z = (a>b.z)?a:b.z; + c.w = (a>b.w)?a:b.w; + return(c) ; +} +__device__ Float4 max ( const Float4 a , const float b ) +{ + Float4 c ; + c.x = (a.x>b)?a.x:b; + c.y = (a.y>b)?a.y:b; + c.z = (a.z>b)?a.z:b; + c.w = (a.w>b)?a.w:b; + return(c) ; +} +//__device__ float max ( const float a , const float b ) +//{ +// return(a>b)?a:b) ; +//} + +__device__ Float4 min ( const Float4 a , const Float4 b ) +{ + Float4 c ; + c.x = (a.x