mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-09 23:45:36 +00:00
blocked precision promotion infrastructure upgrade
This commit is contained in:
parent
091d5c605e
commit
f1fe444d4f
@ -200,6 +200,7 @@ auto innerProductD (const iScalar<l>& lhs,const iScalar<r>& rhs) -> iScalar<decl
|
|||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
// innerProductD2: precision promotion without inner sum
|
// innerProductD2: precision promotion without inner sum
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
|
|
||||||
accelerator_inline vComplexD2 TensorRemove(const vComplexD2 & x) { return x; };
|
accelerator_inline vComplexD2 TensorRemove(const vComplexD2 & x) { return x; };
|
||||||
accelerator_inline vRealD2 TensorRemove(const vRealD2 & x) { return x; };
|
accelerator_inline vRealD2 TensorRemove(const vRealD2 & x) { return x; };
|
||||||
|
|
||||||
|
@ -38,10 +38,28 @@ NAMESPACE_BEGIN(Grid);
|
|||||||
template<class T, int N> struct isGridTensor<iVector<T, N>> : public std::true_type { static constexpr bool notvalue = false; };
|
template<class T, int N> struct isGridTensor<iVector<T, N>> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
template<class T, int N> struct isGridTensor<iMatrix<T, N>> : public std::true_type { static constexpr bool notvalue = false; };
|
template<class T, int N> struct isGridTensor<iMatrix<T, N>> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
|
||||||
// To store double-precision data in single-precision grids for precision promoted localInnerProductD
|
// Traits to identify scalars
|
||||||
|
template<typename T> struct isGridScalar : public std::false_type { static constexpr bool notvalue = true; };
|
||||||
|
template<class T> struct isGridScalar<iScalar<T>> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
|
||||||
|
// Store double-precision data in single-precision grids for precision promoted localInnerProductD
|
||||||
|
typedef iVector<ComplexD,2> ComplexD2;
|
||||||
typedef iVector<vComplexD,2> vComplexD2;
|
typedef iVector<vComplexD,2> vComplexD2;
|
||||||
|
typedef iVector<RealD,2> RealD2;
|
||||||
typedef iVector<vRealD,2> vRealD2;
|
typedef iVector<vRealD,2> vRealD2;
|
||||||
|
|
||||||
|
// Traits to identify fundamental data types
|
||||||
|
template<typename T> struct isGridFundamental : public std::false_type { static constexpr bool notvalue = true; };
|
||||||
|
template<> struct isGridFundamental<vComplexF> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<vComplexD> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<vRealF> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<vRealD> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<ComplexF> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<ComplexD> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<RealF> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
template<> struct isGridFundamental<RealD> : public std::true_type { static constexpr bool notvalue = false; };
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
// Want to recurse: GridTypeMapper<Matrix<vComplexD> >::scalar_type == ComplexD.
|
// Want to recurse: GridTypeMapper<Matrix<vComplexD> >::scalar_type == ComplexD.
|
||||||
// Use of a helper class like this allows us to template specialise and "dress"
|
// Use of a helper class like this allows us to template specialise and "dress"
|
||||||
@ -86,7 +104,7 @@ NAMESPACE_BEGIN(Grid);
|
|||||||
typedef ComplexF Complexified;
|
typedef ComplexF Complexified;
|
||||||
typedef RealF Realified;
|
typedef RealF Realified;
|
||||||
typedef RealD DoublePrecision;
|
typedef RealD DoublePrecision;
|
||||||
typedef RealD DoublePrecision2;
|
typedef RealD2 DoublePrecision2;
|
||||||
};
|
};
|
||||||
template<> struct GridTypeMapper<RealD> : public GridTypeMapper_Base {
|
template<> struct GridTypeMapper<RealD> : public GridTypeMapper_Base {
|
||||||
typedef RealD scalar_type;
|
typedef RealD scalar_type;
|
||||||
@ -112,7 +130,7 @@ NAMESPACE_BEGIN(Grid);
|
|||||||
typedef ComplexF Complexified;
|
typedef ComplexF Complexified;
|
||||||
typedef RealF Realified;
|
typedef RealF Realified;
|
||||||
typedef ComplexD DoublePrecision;
|
typedef ComplexD DoublePrecision;
|
||||||
typedef ComplexD DoublePrecision2;
|
typedef ComplexD2 DoublePrecision2;
|
||||||
};
|
};
|
||||||
template<> struct GridTypeMapper<ComplexD> : public GridTypeMapper_Base {
|
template<> struct GridTypeMapper<ComplexD> : public GridTypeMapper_Base {
|
||||||
typedef ComplexD scalar_type;
|
typedef ComplexD scalar_type;
|
||||||
|
@ -72,7 +72,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
sw_res.Reset();
|
sw_res.Reset();
|
||||||
sw_res.Start();
|
sw_res.Start();
|
||||||
for(int i = 0; i < nIter; ++i) { innerProduct_norm(ip_d_res, norm2_d_res, x_d, y_d); }
|
for(int i = 0; i < nIter; ++i) { innerProductNorm(ip_d_res, norm2_d_res, x_d, y_d); }
|
||||||
sw_res.Stop();
|
sw_res.Stop();
|
||||||
|
|
||||||
diff_ip_d = ip_d_ref - ip_d_res;
|
diff_ip_d = ip_d_ref - ip_d_res;
|
||||||
@ -104,7 +104,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
sw_res.Reset();
|
sw_res.Reset();
|
||||||
sw_res.Start();
|
sw_res.Start();
|
||||||
for(int i = 0; i < nIter; ++i) { innerProduct_norm(ip_f_res, norm2_f_res, x_f, y_f); }
|
for(int i = 0; i < nIter; ++i) { innerProductNorm(ip_f_res, norm2_f_res, x_f, y_f); }
|
||||||
sw_res.Stop();
|
sw_res.Stop();
|
||||||
|
|
||||||
diff_ip_f = ip_f_ref - ip_f_res;
|
diff_ip_f = ip_f_ref - ip_f_res;
|
||||||
|
Loading…
Reference in New Issue
Block a user