1 #ifndef _REGISTER_TRAITS_H
2 #define _REGISTER_TRAITS_H
94 template<
typename>
struct mapper { };
95 template<>
struct mapper<double> {
typedef double type; };
217 template<
typename,
int N>
struct vector { };
223 operator type()
const {
return a; }
229 vector(
const double2 &a) { this->a.x = a.x; this->a.y = a.y; }
230 operator type()
const {
return a; }
236 vector(
const int2 &a) { this->a.x = a.x; this->a.y = a.y; }
237 operator type()
const {
return a; }
319 template <>
struct scalar<doubledouble4> {
328 template<
typename T >
struct isHalf{
static const bool value =
false; };
329 template<>
struct isHalf<short>{
static const bool value =
true; };
330 template<>
struct isHalf<short2>{
static const bool value =
true; };
331 template<>
struct isHalf<short4>{
static const bool value =
true; };
348 template<
typename T >
struct isFixed{
static const bool value =
false; };
367 template <
bool isFixed,
typename T>
369 __device__ __host__
static T
Atan2(
const T &a,
const T &b) {
return atan2(a,b); }
370 __device__ __host__
static T
Sin(
const T &a ) {
return sin(a); }
371 __device__ __host__
static T
Cos(
const T &a ) {
return cos(a); }
372 __device__ __host__
static void SinCos(
const T &a, T *s, T *c) { sincos(a, s, c); }
380 __device__ __host__
static float Atan2(
const float &a,
const float &b) {
return atan2f(a,b); }
381 __device__ __host__
static float Sin(
const float &a)
389 __device__ __host__
static float Cos(
const float &a)
398 __device__ __host__
static void SinCos(
const float &a,
float *s,
float *c)
413 __device__ __host__
static float Atan2(
const float &a,
const float &b) {
return atan2f(a,b)/M_PI; }
414 __device__ __host__
static float Sin(
const float &a)
417 return __sinf(a *
static_cast<float>(M_PI));
419 return sinf(a *
static_cast<float>(M_PI));
422 __device__ __host__
static float Cos(
const float &a)
425 return __cosf(a *
static_cast<float>(M_PI));
427 return cosf(a *
static_cast<float>(M_PI));
431 __device__ __host__
static void SinCos(
const float &a,
float *s,
float *c)
434 __sincosf(a *
static_cast<float>(M_PI), s, c);
436 sincosf(a *
static_cast<float>(M_PI), s, c);
496 #if (__CUDA_ARCH__ >= 320 && __CUDA_ARCH__ < 520)
499 return reinterpret_cast<const VectorType *
>(ptr)[idx];
505 float4
tmp = vector_load<float4>(ptr, idx);
507 memcpy(&recast, &
tmp,
sizeof(float4));
511 template <> __device__ __host__
inline char8
vector_load(
const void *ptr,
int idx)
513 float2
tmp = vector_load<float2>(ptr, idx);
515 memcpy(&recast, &
tmp,
sizeof(float2));
519 template <
typename VectorType>
521 reinterpret_cast< VectorType*
>(ptr)[idx] = value;
525 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const double2 &value) {
526 #if defined(__CUDA_ARCH__)
529 reinterpret_cast<double2*
>(ptr)[idx] = value;
534 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const float4 &value) {
535 #if defined(__CUDA_ARCH__)
538 reinterpret_cast<float4*
>(ptr)[idx] = value;
543 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const float2 &value) {
544 #if defined(__CUDA_ARCH__)
547 reinterpret_cast<float2*
>(ptr)[idx] = value;
552 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const short4 &value) {
553 #if defined(__CUDA_ARCH__)
556 reinterpret_cast<short4*
>(ptr)[idx] = value;
561 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const short2 &value) {
562 #if defined(__CUDA_ARCH__)
565 reinterpret_cast<short2*
>(ptr)[idx] = value;
571 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const char4 &value) {
572 #if defined(__CUDA_ARCH__)
573 store_streaming_short2(
reinterpret_cast<short2*
>(ptr)+idx,
reinterpret_cast<const short2*
>(&value)->x,
reinterpret_cast<const short2*
>(&value)->y);
575 reinterpret_cast<char4*
>(ptr)[idx] = value;
580 __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const char2 &value) {
581 #if defined(__CUDA_ARCH__)
582 vector_store(ptr, idx, *
reinterpret_cast<const short*
>(&value));
584 reinterpret_cast<char2*
>(ptr)[idx] = value;
590 #if defined(__CUDA_ARCH__)
591 vector_store(ptr, idx, *
reinterpret_cast<const float4 *
>(&value));
593 reinterpret_cast<short8 *
>(ptr)[idx] = value;
597 template <> __device__ __host__
inline void vector_store(
void *ptr,
int idx,
const char8 &value)
599 #if defined(__CUDA_ARCH__)
600 vector_store(ptr, idx, *
reinterpret_cast<const float2 *
>(&value));
602 reinterpret_cast<char8 *
>(ptr)[idx] = value;
cudaColorSpinorField * tmp
__device__ __forceinline__ T __ldg(const T *ptr)
__device__ void store_streaming_float2(float2 *addr, float x, float y)
__host__ __device__ ValueType cos(ValueType x)
__host__ __device__ ValueType atan2(ValueType x, ValueType y)
__device__ void store_streaming_float4(float4 *addr, float x, float y, float z, float w)
__device__ void store_streaming_double2(double2 *addr, double x, double y)
__host__ __device__ ValueType sin(ValueType x)
std::complex< double > Complex
__device__ void store_streaming_short4(short4 *addr, short x, short y, short z, short w)
__device__ void store_streaming_short2(short2 *addr, short x, short y)
__device__ __host__ void vector_store(void *ptr, int idx, const VectorType &value)
__device__ __host__ VectorType vector_load(const void *ptr, int idx)
__device__ static __host__ float Cos(const float &a)
__device__ static __host__ void SinCos(const float &a, float *s, float *c)
__device__ static __host__ float Atan2(const float &a, const float &b)
__device__ static __host__ float Sin(const float &a)
__device__ static __host__ float Cos(const float &a)
__device__ static __host__ float Atan2(const float &a, const float &b)
__device__ static __host__ void SinCos(const float &a, float *s, float *c)
__device__ static __host__ float Sin(const float &a)
__device__ static __host__ T Sin(const T &a)
__device__ static __host__ void SinCos(const T &a, T *s, T *c)
__device__ static __host__ T Cos(const T &a)
__device__ static __host__ T Atan2(const T &a, const T &b)