1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-09-20 17:25:37 +01:00
Grid/lib/simd/Grid_empty.h
2015-06-09 15:46:21 +09:00

290 lines
6.0 KiB
C++

//----------------------------------------------------------------------
/*! @file Grid_sse4.h
@brief Empty Optimization libraries for debugging
Using intrinsics
*/
// Time-stamp: <2015-06-09 14:28:02 neo>
//----------------------------------------------------------------------
namespace Optimization {
template<class vtype>
union uconv {
float f;
vtype v;
};
union u128f {
float v;
float f[4];
};
union u128d {
double v;
double f[2];
};
struct Vsplat{
//Complex float
inline float operator()(float a, float b){
return 0;
}
// Real float
inline float operator()(float a){
return 0;
}
//Complex double
inline double operator()(double a, double b){
return 0;
}
//Real double
inline double operator()(double a){
return 0;
}
//Integer
inline int operator()(Integer a){
return 0;
}
};
struct Vstore{
//Float
inline void operator()(float a, float* F){
}
//Double
inline void operator()(double a, double* D){
}
//Integer
inline void operator()(int a, Integer* I){
}
};
struct Vstream{
//Float
inline void operator()(float * a, float b){
}
//Double
inline void operator()(double * a, double b){
}
};
struct Vset{
// Complex float
inline float operator()(Grid::ComplexF *a){
return 0;
}
// Complex double
inline double operator()(Grid::ComplexD *a){
return 0;
}
// Real float
inline float operator()(float *a){
return 0;
}
// Real double
inline double operator()(double *a){
return 0;
}
// Integer
inline int operator()(Integer *a){
return 0;
}
};
template <typename Out_type, typename In_type>
struct Reduce{
//Need templated class to overload output type
//General form must generate error if compiled
inline Out_type operator()(In_type in){
printf("Error, using wrong Reduce function\n");
exit(1);
return 0;
}
};
/////////////////////////////////////////////////////
// Arithmetic operations
/////////////////////////////////////////////////////
struct Sum{
//Complex/Real float
inline float operator()(float a, float b){
return 0;
}
//Complex/Real double
inline double operator()(double a, double b){
return 0;
}
//Integer
inline int operator()(int a, int b){
return 0;
}
};
struct Sub{
//Complex/Real float
inline float operator()(float a, float b){
return 0;
}
//Complex/Real double
inline double operator()(double a, double b){
return 0;
}
//Integer
inline int operator()(int a, int b){
return 0;
}
};
struct MultComplex{
// Complex float
inline float operator()(float a, float b){
return 0;
}
// Complex double
inline double operator()(double a, double b){
return 0;
}
};
struct Mult{
// Real float
inline float operator()(float a, float b){
return 0;
}
// Real double
inline double operator()(double a, double b){
return 0;
}
// Integer
inline int operator()(int a, int b){
return 0;
}
};
struct Conj{
// Complex single
inline float operator()(float in){
return 0;
}
// Complex double
inline double operator()(double in){
return 0;
}
// do not define for integer input
};
struct TimesMinusI{
//Complex single
inline float operator()(float in, float ret){
return 0;
}
//Complex double
inline double operator()(double in, double ret){
return 0;
}
};
struct TimesI{
//Complex single
inline float operator()(float in, float ret){
return 0;
}
//Complex double
inline double operator()(double in, double ret){
return 0;
}
};
//////////////////////////////////////////////
// Some Template specialization
template < typename vtype >
void permute(vtype &a, vtype b, int perm) {
};
//Complex float Reduce
template<>
inline Grid::ComplexF Reduce<Grid::ComplexF, float>::operator()(float in){
return 0;
}
//Real float Reduce
template<>
inline Grid::RealF Reduce<Grid::RealF, float>::operator()(float in){
return 0;
}
//Complex double Reduce
template<>
inline Grid::ComplexD Reduce<Grid::ComplexD, double>::operator()(double in){
return 0;
}
//Real double Reduce
template<>
inline Grid::RealD Reduce<Grid::RealD, double>::operator()(double in){
return 0;
}
//Integer Reduce
template<>
inline Integer Reduce<Integer, int>::operator()(int in){
// FIXME unimplemented
printf("Reduce : Missing integer implementation -> FIX\n");
assert(0);
}
}
//////////////////////////////////////////////////////////////////////////////////////
// Here assign types
namespace Grid {
typedef float SIMD_Ftype; // Single precision type
typedef double SIMD_Dtype; // Double precision type
typedef int SIMD_Itype; // Integer type
// prefetch utilities
inline void v_prefetch0(int size, const char *ptr){};
inline void prefetch_HINT_T0(const char *ptr){};
// Gpermute function
template < typename VectorSIMD >
inline void Gpermute(VectorSIMD &y,const VectorSIMD &b, int perm ) {
Optimization::permute(y.v,b.v,perm);
}
// Function name aliases
typedef Optimization::Vsplat VsplatSIMD;
typedef Optimization::Vstore VstoreSIMD;
typedef Optimization::Vset VsetSIMD;
typedef Optimization::Vstream VstreamSIMD;
template <typename S, typename T> using ReduceSIMD = Optimization::Reduce<S,T>;
// Arithmetic operations
typedef Optimization::Sum SumSIMD;
typedef Optimization::Sub SubSIMD;
typedef Optimization::Mult MultSIMD;
typedef Optimization::MultComplex MultComplexSIMD;
typedef Optimization::Conj ConjSIMD;
typedef Optimization::TimesMinusI TimesMinusISIMD;
typedef Optimization::TimesI TimesISIMD;
}