1 #ifndef _REGISTER_TRAITS_H 2 #define _REGISTER_TRAITS_H 12 #include <generics/ldg.h> 41 template<
typename>
struct mapper { };
46 template<>
struct mapper<double2> {
typedef double2
type; };
47 template<>
struct mapper<float2> {
typedef float2
type; };
48 template<>
struct mapper<short2> {
typedef float2
type; };
50 template<>
struct mapper<double4> {
typedef double4
type; };
51 template<>
struct mapper<float4> {
typedef float4
type; };
52 template<>
struct mapper<short4> {
typedef float4
type; };
78 template<
typename,
int N>
struct vector { };
80 template<>
struct vector<
double, 2> {
84 operator type()
const {
return a; }
87 template<>
struct vector<
float, 2> {
90 vector(
const double2 &
a) { this->a.x =
a.x; this->a.y =
a.y; }
91 operator float2()
const {
return a; }
94 template<
typename>
struct scalar { };
95 template<>
struct scalar<double4> {
typedef double type; };
96 template<>
struct scalar<double3> {
typedef double type; };
97 template<>
struct scalar<double2> {
typedef double type; };
99 template<>
struct scalar<float4> {
typedef float type; };
109 template<
typename T >
struct isHalf{
static const bool value =
false; };
110 template<>
struct isHalf<short>{
static const bool value =
true; };
111 template<>
struct isHalf<short2>{
static const bool value =
true; };
112 template<>
struct isHalf<short4>{
static const bool value =
true; };
114 template<
typename T1,
typename T2> __host__ __device__
inline void copy (T1 &
a,
const T2 &
b) {
a =
b; }
116 template<> __host__ __device__
inline void copy(
double &
a,
const int2 &
b) {
118 a = __hiloint2double(
b.y,
b.x);
124 template<> __host__ __device__
inline void copy(double2 &
a,
const int4 &
b) {
126 a.x = __hiloint2double(
b.y,
b.x);
a.y = __hiloint2double(
b.w,
b.z);
133 #define MAX_SHORT_INV 3.051850948e-5 134 static inline __host__ __device__
float s2f(
const short &
a) {
return static_cast<float>(
a) *
MAX_SHORT_INV; }
135 static inline __host__ __device__
double s2d(
const short &
a) {
return static_cast<double>(
a) *
MAX_SHORT_INV; }
138 __device__ __host__
inline int f2i(
float f) {
140 f += 12582912.0f;
return reinterpret_cast<int&
>(
f);
142 return static_cast<int>(
f);
147 __device__ __host__
inline int d2i(
double d) {
149 d += 6755399441055744.0;
return reinterpret_cast<int&
>(
d);
151 return static_cast<int>(
d);
155 template<> __host__ __device__
inline void copy(
float &
a,
const short &
b) {
a =
s2f(
b); }
158 template<> __host__ __device__
inline void copy(float2 &
a,
const short2 &
b) {
162 template<> __host__ __device__
inline void copy(short2 &
a,
const float2 &
b) {
166 template<> __host__ __device__
inline void copy(float4 &
a,
const short4 &
b) {
170 template<> __host__ __device__
inline void copy(short4 &
a,
const float4 &
b) {
178 template <
bool isHalf,
typename T>
180 __device__ __host__
static T
Atan2(
const T &
a,
const T &
b) {
return atan2(
a,
b); }
181 __device__ __host__
static T
Sin(
const T &
a ) {
return sin(
a); }
182 __device__ __host__
static T
Cos(
const T &
a ) {
return cos(
a); }
191 __device__ __host__
static float Atan2(
const float &
a,
const float &
b) {
return atan2f(
a,
b); }
192 __device__ __host__
static float Sin(
const float &
a ) {
199 __device__ __host__
static float Cos(
const float &
a ) {
207 __device__ __host__
static void SinCos(
const float&
a,
float *
s,
float *
c) {
222 __device__ __host__
static float Atan2(
const float &
a,
const float &
b) {
return atan2f(
a,
b)/M_PI; }
223 __device__ __host__
static float Sin(
const float &
a ) {
225 return __sinf(
a*M_PI);
230 __device__ __host__
static float Cos(
const float &
a ) {
232 return __cosf(
a*M_PI);
274 template <
typename VectorType>
277 #if defined(__CUDA_ARCH__) && defined(USE_LDG) 278 return __ldg(reinterpret_cast< VectorType* >(
ptr) +
idx);
284 template <
typename VectorType>
291 #if defined(__CUDA_ARCH__) 300 #if defined(__CUDA_ARCH__) 309 #if defined(__CUDA_ARCH__) 318 #if defined(__CUDA_ARCH__) 327 #if defined(__CUDA_ARCH__) 340 #endif // _REGISTER_TRAITS_H
__device__ static __host__ float Cos(const float &a)
__device__ __host__ int d2i(double d)
__device__ static __host__ T Atan2(const T &a, const T &b)
__device__ static __host__ float Sin(const float &a)
__device__ static __host__ void SinCos(const float &a, float *s, float *c)
__device__ static __host__ T Sin(const T &a)
static __host__ __device__ float s2f(const short &a)
__host__ __device__ void copy(T1 &a, const T2 &b)
__host__ __device__ ValueType sin(ValueType x)
__device__ static __host__ float Sin(const float &a)
float atan2f(float, float)
__device__ __host__ void vector_store(void *ptr, int idx, const VectorType &value)
__host__ __device__ ValueType atan2(ValueType x, ValueType y)
__device__ static __host__ float Atan2(const float &a, const float &b)
__device__ static __host__ void SinCos(const T &a, T *s, T *c)
int int int enum cudaChannelFormatKind f
__device__ void store_streaming_double2(double2 *addr, double x, double y)
__device__ static __host__ T Cos(const T &a)
__device__ void store_streaming_float4(float4 *addr, float x, float y, float z, float w)
static __host__ __device__ double s2d(const short &a)
__device__ static __host__ float Atan2(const float &a, const float &b)
__device__ static __host__ float Cos(const float &a)
__device__ void store_streaming_float2(float2 *addr, float x, float y)
__device__ __host__ VectorType vector_load(void *ptr, int idx)
__host__ __device__ ValueType cos(ValueType x)
__device__ void store_streaming_short2(short2 *addr, short x, short y)
static __inline__ size_t size_t d
__device__ void store_streaming_short4(short4 *addr, short x, short y, short z, short w)
__device__ __host__ int f2i(float f)