mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-04 19:25:56 +01:00
Removed some assertions in Test_simd and removed exit() in Reduce
This commit is contained in:
parent
05edf803bd
commit
b7c76ede29
@ -691,7 +691,7 @@ struct Reduce{
|
|||||||
//General form must generate error if compiled
|
//General form must generate error if compiled
|
||||||
inline Out_type operator()(In_type in){
|
inline Out_type operator()(In_type in){
|
||||||
printf("Error, using wrong Reduce function\n");
|
printf("Error, using wrong Reduce function\n");
|
||||||
exit(1);
|
//exit(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -101,14 +101,14 @@ public:
|
|||||||
// FIXME still to test:
|
// FIXME still to test:
|
||||||
//
|
//
|
||||||
// innerProduct,
|
// innerProduct,
|
||||||
// norm2,
|
// norm2,
|
||||||
// Reduce,
|
// Reduce,
|
||||||
//
|
//
|
||||||
// mac,mult,sub,add, vone,vzero,vcomplex_i, =Zero(),
|
// mac,mult,sub,add, vone,vzero,vcomplex_i, =Zero(),
|
||||||
// vset,vsplat,vstore,vstream,vload, scalar*vec, vec*scalar
|
// vset,vsplat,vstore,vstream,vload, scalar*vec, vec*scalar
|
||||||
// unary -,
|
// unary -,
|
||||||
// *= , -=, +=
|
// *= , -=, +=
|
||||||
// outerproduct,
|
// outerproduct,
|
||||||
// zeroit
|
// zeroit
|
||||||
// permute
|
// permute
|
||||||
class funcReduce {
|
class funcReduce {
|
||||||
@ -119,12 +119,12 @@ template<class reduce,class scal> void sfunc(reduce &rr,scal &i1,scal &i2) con
|
|||||||
std::string name(void) const { return std::string("Reduce"); }
|
std::string name(void) const { return std::string("Reduce"); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class scal, class vec,class functor >
|
template<class scal, class vec,class functor >
|
||||||
void Tester(const functor &func)
|
void Tester(const functor &func)
|
||||||
{
|
{
|
||||||
GridSerialRNG sRNG;
|
GridSerialRNG sRNG;
|
||||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
ExtractBuffer<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
@ -172,8 +172,10 @@ void Tester(const functor &func)
|
|||||||
}
|
}
|
||||||
if ( ok==0 ) {
|
if ( ok==0 ) {
|
||||||
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout<<GridLogMessage << " wrong!" <<std::endl;
|
||||||
}
|
}
|
||||||
assert(ok==0);
|
//assert(ok==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class functor>
|
template<class functor>
|
||||||
@ -229,17 +231,19 @@ void IntTester(const functor &func)
|
|||||||
}
|
}
|
||||||
if ( ok==0 ) {
|
if ( ok==0 ) {
|
||||||
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout<<GridLogMessage << " wrong!" <<std::endl;
|
||||||
}
|
}
|
||||||
assert(ok==0);
|
//assert(ok==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class reduced,class scal, class vec,class functor >
|
template<class reduced,class scal, class vec,class functor >
|
||||||
void ReductionTester(const functor &func)
|
void ReductionTester(const functor &func)
|
||||||
{
|
{
|
||||||
GridSerialRNG sRNG;
|
GridSerialRNG sRNG;
|
||||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
ExtractBuffer<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
@ -278,12 +282,14 @@ void ReductionTester(const functor &func)
|
|||||||
}
|
}
|
||||||
if ( ok==0 ) {
|
if ( ok==0 ) {
|
||||||
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout<<GridLogMessage << " wrong!" <<std::endl;
|
||||||
}
|
}
|
||||||
assert(ok==0);
|
//assert(ok==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class reduced,class scal, class vec,class functor >
|
template<class reduced,class scal, class vec,class functor >
|
||||||
void IntReductionTester(const functor &func)
|
void IntReductionTester(const functor &func)
|
||||||
{
|
{
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
@ -323,8 +329,10 @@ void IntReductionTester(const functor &func)
|
|||||||
}
|
}
|
||||||
if ( ok==0 ) {
|
if ( ok==0 ) {
|
||||||
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout<<GridLogMessage << " wrong!" <<std::endl;
|
||||||
}
|
}
|
||||||
assert(ok==0);
|
//assert(ok==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +341,7 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
funcPermute(int _n) { n=_n;};
|
funcPermute(int _n) { n=_n;};
|
||||||
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { permute(rr,i1,n);}
|
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { permute(rr,i1,n);}
|
||||||
template<class scal> void apply(ExtractBuffer<scal> &rr,ExtractBuffer<scal> &in) const {
|
template<class scal> void apply(ExtractBuffer<scal> &rr,ExtractBuffer<scal> &in) const {
|
||||||
int sz=in.size();
|
int sz=in.size();
|
||||||
int msk = sz>>(n+1);
|
int msk = sz>>(n+1);
|
||||||
for(int i=0;i<sz;i++){
|
for(int i=0;i<sz;i++){
|
||||||
@ -351,8 +359,8 @@ public:
|
|||||||
template<class scal> void apply(ExtractBuffer<scal> &r1,
|
template<class scal> void apply(ExtractBuffer<scal> &r1,
|
||||||
ExtractBuffer<scal> &r2,
|
ExtractBuffer<scal> &r2,
|
||||||
ExtractBuffer<scal> &in1,
|
ExtractBuffer<scal> &in1,
|
||||||
ExtractBuffer<scal> &in2) const
|
ExtractBuffer<scal> &in2) const
|
||||||
{
|
{
|
||||||
int sz=in1.size();
|
int sz=in1.size();
|
||||||
int msk = sz>>(n+1);
|
int msk = sz>>(n+1);
|
||||||
|
|
||||||
@ -364,7 +372,7 @@ public:
|
|||||||
|
|
||||||
if ( (i&msk) == 0 ) { r2[i]=in1[j2];}
|
if ( (i&msk) == 0 ) { r2[i]=in1[j2];}
|
||||||
else { r2[i]=in2[j2];}
|
else { r2[i]=in2[j2];}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string name(void) const { return std::string("Exchange"); }
|
std::string name(void) const { return std::string("Exchange"); }
|
||||||
};
|
};
|
||||||
@ -374,7 +382,7 @@ public:
|
|||||||
int n;
|
int n;
|
||||||
funcRotate(int _n) { n=_n;};
|
funcRotate(int _n) { n=_n;};
|
||||||
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { rr=rotate(i1,n);}
|
template<class vec> void operator()(vec &rr,vec &i1,vec &i2) const { rr=rotate(i1,n);}
|
||||||
template<class scal> void apply(ExtractBuffer<scal> &rr,ExtractBuffer<scal> &in) const {
|
template<class scal> void apply(ExtractBuffer<scal> &rr,ExtractBuffer<scal> &in) const {
|
||||||
int sz = in.size();
|
int sz = in.size();
|
||||||
for(int i=0;i<sz;i++){
|
for(int i=0;i<sz;i++){
|
||||||
rr[i] = in[(i+n)%sz];
|
rr[i] = in[(i+n)%sz];
|
||||||
@ -384,12 +392,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template<class scal, class vec,class functor >
|
template<class scal, class vec,class functor >
|
||||||
void PermTester(const functor &func)
|
void PermTester(const functor &func)
|
||||||
{
|
{
|
||||||
GridSerialRNG sRNG;
|
GridSerialRNG sRNG;
|
||||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
ExtractBuffer<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
@ -425,37 +433,39 @@ void PermTester(const functor &func)
|
|||||||
for(int i=0;i<Nsimd;i++){
|
for(int i=0;i<Nsimd;i++){
|
||||||
std::cout<< input1[i]<<" ";
|
std::cout<< input1[i]<<" ";
|
||||||
}
|
}
|
||||||
std::cout <<std::endl;
|
std::cout <<std::endl;
|
||||||
for(int i=0;i<Nsimd;i++){
|
for(int i=0;i<Nsimd;i++){
|
||||||
std::cout<< result[i]<<" ";
|
std::cout<< result[i]<<" ";
|
||||||
}
|
}
|
||||||
std::cout <<std::endl;
|
std::cout <<std::endl;
|
||||||
for(int i=0;i<Nsimd;i++){
|
for(int i=0;i<Nsimd;i++){
|
||||||
std::cout<< reference[i]<<" ";
|
std::cout<< reference[i]<<" ";
|
||||||
}
|
}
|
||||||
std::cout <<std::endl;
|
std::cout <<std::endl;
|
||||||
std::cout<<GridLogMessage<< "*****" << std::endl;
|
std::cout<<GridLogMessage<< "*****" << std::endl;
|
||||||
}
|
}
|
||||||
for(int i=0;i<Nsimd;i++){
|
for(int i=0;i<Nsimd;i++){
|
||||||
if ( abs(reference[i]-result[i])>1.0e-7){
|
if ( abs(reference[i]-result[i])>1.0e-7){
|
||||||
std::cout<<GridLogMessage<< "*****" << std::endl;
|
std::cout<<GridLogMessage<< "*****" << std::endl;
|
||||||
std::cout<<GridLogMessage<< "["<<i<<"] "<< abs(reference[i]-result[i]) << " " <<reference[i]<< " " << result[i]<<std::endl;
|
std::cout<<GridLogMessage<< "["<<i<<"] "<< abs(reference[i]-result[i]) << " " <<reference[i]<< " " << result[i]<<std::endl;
|
||||||
ok++;
|
ok++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ok==0 ) {
|
if ( ok==0 ) {
|
||||||
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
std::cout<<GridLogMessage << " OK!" <<std::endl;
|
||||||
|
} else {
|
||||||
|
std::cout<<GridLogMessage << " wrong!" <<std::endl;
|
||||||
}
|
}
|
||||||
assert(ok==0);
|
//assert(ok==0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class scal, class vec,class functor >
|
template<class scal, class vec,class functor >
|
||||||
void ExchangeTester(const functor &func)
|
void ExchangeTester(const functor &func)
|
||||||
{
|
{
|
||||||
GridSerialRNG sRNG;
|
GridSerialRNG sRNG;
|
||||||
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
sRNG.SeedFixedIntegers(std::vector<int>({45,12,81,9}));
|
||||||
|
|
||||||
int Nsimd = vec::Nsimd();
|
int Nsimd = vec::Nsimd();
|
||||||
|
|
||||||
ExtractBuffer<scal> input1(Nsimd);
|
ExtractBuffer<scal> input1(Nsimd);
|
||||||
@ -566,7 +576,7 @@ int main (int argc, char ** argv)
|
|||||||
std::cout << " Test {1,2,3,4} " << Test <<std::endl;
|
std::cout << " Test {1,2,3,4} " << Test <<std::endl;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
GridCartesian Grid(latt_size,simd_layout,mpi_layout);
|
||||||
std::vector<int> seeds({1,2,3,4});
|
std::vector<int> seeds({1,2,3,4});
|
||||||
|
|
||||||
@ -742,7 +752,7 @@ int main (int argc, char ** argv)
|
|||||||
for(int r=0;r<vComplexD::Nsimd();r++){
|
for(int r=0;r<vComplexD::Nsimd();r++){
|
||||||
PermTester<ComplexD,vComplexD>(funcRotate(r));
|
PermTester<ComplexD,vComplexD>(funcRotate(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout<<GridLogMessage << "==================================="<< std::endl;
|
std::cout<<GridLogMessage << "==================================="<< std::endl;
|
||||||
std::cout<<GridLogMessage << "Testing vInteger "<< std::endl;
|
std::cout<<GridLogMessage << "Testing vInteger "<< std::endl;
|
||||||
std::cout<<GridLogMessage << "==================================="<< std::endl;
|
std::cout<<GridLogMessage << "==================================="<< std::endl;
|
||||||
@ -773,13 +783,13 @@ int main (int argc, char ** argv)
|
|||||||
precisionChange(&DD[0],&F[0],Ndp);
|
precisionChange(&DD[0],&F[0],Ndp);
|
||||||
std::cout << GridLogMessage<<"Double to single";
|
std::cout << GridLogMessage<<"Double to single";
|
||||||
for(int i=0;i<Ndp;i++){
|
for(int i=0;i<Ndp;i++){
|
||||||
// std::cout << "DD["<<i<<"] = "<< DD[i]<<" "<<D[i]<<" "<<DD[i]-D[i] <<std::endl;
|
// std::cout << "DD["<<i<<"] = "<< DD[i]<<" "<<D[i]<<" "<<DD[i]-D[i] <<std::endl;
|
||||||
DD[i] = DD[i] - D[i];
|
DD[i] = DD[i] - D[i];
|
||||||
decltype(innerProduct(DD[0],DD[0])) nrm;
|
decltype(innerProduct(DD[0],DD[0])) nrm;
|
||||||
nrm = innerProduct(DD[i],DD[i]);
|
nrm = innerProduct(DD[i],DD[i]);
|
||||||
auto tmp = Reduce(nrm);
|
auto tmp = Reduce(nrm);
|
||||||
// std::cout << tmp << std::endl;
|
// std::cout << tmp << std::endl;
|
||||||
assert( tmp < 1.0e-14 );
|
assert( tmp < 1.0e-14 );
|
||||||
}
|
}
|
||||||
std::cout <<" OK ! "<<std::endl;
|
std::cout <<" OK ! "<<std::endl;
|
||||||
|
|
||||||
@ -788,13 +798,13 @@ int main (int argc, char ** argv)
|
|||||||
precisionChange(&H[0],&D[0],Ndp);
|
precisionChange(&H[0],&D[0],Ndp);
|
||||||
precisionChange(&DD[0],&H[0],Ndp);
|
precisionChange(&DD[0],&H[0],Ndp);
|
||||||
for(int i=0;i<Ndp;i++){
|
for(int i=0;i<Ndp;i++){
|
||||||
// std::cout << "DD["<<i<<"] = "<< DD[i]<<" "<<D[i]<<" "<<DD[i]-D[i]<<std::endl;
|
// std::cout << "DD["<<i<<"] = "<< DD[i]<<" "<<D[i]<<" "<<DD[i]-D[i]<<std::endl;
|
||||||
DD[i] = DD[i] - D[i];
|
DD[i] = DD[i] - D[i];
|
||||||
decltype(innerProduct(DD[0],DD[0])) nrm;
|
decltype(innerProduct(DD[0],DD[0])) nrm;
|
||||||
nrm = innerProduct(DD[i],DD[i]);
|
nrm = innerProduct(DD[i],DD[i]);
|
||||||
auto tmp = Reduce(nrm);
|
auto tmp = Reduce(nrm);
|
||||||
// std::cout << tmp << std::endl;
|
// std::cout << tmp << std::endl;
|
||||||
assert( tmp < 1.0e-3 );
|
assert( tmp < 1.0e-3 );
|
||||||
}
|
}
|
||||||
std::cout <<" OK ! "<<std::endl;
|
std::cout <<" OK ! "<<std::endl;
|
||||||
|
|
||||||
@ -803,13 +813,13 @@ int main (int argc, char ** argv)
|
|||||||
precisionChange(&H[0] ,&F[0],Nsp);
|
precisionChange(&H[0] ,&F[0],Nsp);
|
||||||
precisionChange(&FF[0],&H[0],Nsp);
|
precisionChange(&FF[0],&H[0],Nsp);
|
||||||
for(int i=0;i<Nsp;i++){
|
for(int i=0;i<Nsp;i++){
|
||||||
// std::cout << "FF["<<i<<"] = "<< FF[i]<<" "<<F[i]<<" "<<FF[i]-F[i]<<std::endl;
|
// std::cout << "FF["<<i<<"] = "<< FF[i]<<" "<<F[i]<<" "<<FF[i]-F[i]<<std::endl;
|
||||||
FF[i] = FF[i] - F[i];
|
FF[i] = FF[i] - F[i];
|
||||||
decltype(innerProduct(FF[0],FF[0])) nrm;
|
decltype(innerProduct(FF[0],FF[0])) nrm;
|
||||||
nrm = innerProduct(FF[i],FF[i]);
|
nrm = innerProduct(FF[i],FF[i]);
|
||||||
auto tmp = Reduce(nrm);
|
auto tmp = Reduce(nrm);
|
||||||
// std::cout << tmp << std::endl;
|
// std::cout << tmp << std::endl;
|
||||||
assert( tmp < 1.0e-3 );
|
assert( tmp < 1.0e-3 );
|
||||||
}
|
}
|
||||||
std::cout <<" OK ! "<<std::endl;
|
std::cout <<" OK ! "<<std::endl;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user