mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-25 21:25:56 +01:00
Seems we've not been keeping the test up-to-date
This commit is contained in:
parent
a97b814f0c
commit
606698511c
@ -30,11 +30,22 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <Hadrons/Application.hpp>
|
#include <Hadrons/Application.hpp>
|
||||||
#include <Hadrons/Modules.hpp>
|
#include <Hadrons/Modules.hpp>
|
||||||
#include <Grid/util/EigenUtil.h>
|
|
||||||
|
|
||||||
using namespace Grid;
|
using namespace Grid;
|
||||||
using namespace Hadrons;
|
using namespace Hadrons;
|
||||||
|
|
||||||
|
// Very simple iterators for Eigen tensors
|
||||||
|
// The only way I could get these iterators to work is to put the begin() and end() functions in the Eigen namespace
|
||||||
|
// So if Eigen ever defines these, we'll have a conflict and have to change this
|
||||||
|
namespace Eigen {
|
||||||
|
template <typename ET>
|
||||||
|
inline typename std::enable_if<EigenIO::is_tensor<ET>::value, typename EigenIO::Traits<ET>::scalar_type *>::type
|
||||||
|
begin( ET & et ) { return reinterpret_cast<typename Grid::EigenIO::Traits<ET>::scalar_type *>(et.data()); }
|
||||||
|
template <typename ET>
|
||||||
|
inline typename std::enable_if<EigenIO::is_tensor<ET>::value, typename EigenIO::Traits<ET>::scalar_type *>::type
|
||||||
|
end( ET & et ) { return begin(et) + et.size() * EigenIO::Traits<ET>::count; }
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// Test creation of laplacian eigenvectors
|
// Test creation of laplacian eigenvectors
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
@ -115,6 +126,7 @@ void test_Perambulators(Application &application)
|
|||||||
// PerambLight parameters
|
// PerambLight parameters
|
||||||
MDistil::PerambLight::Par PerambPar;
|
MDistil::PerambLight::Par PerambPar;
|
||||||
PerambPar.eigenPack="LapEvec";
|
PerambPar.eigenPack="LapEvec";
|
||||||
|
PerambPar.noise="Peramb_noise";
|
||||||
PerambPar.PerambFileName="peramb.bin";
|
PerambPar.PerambFileName="peramb.bin";
|
||||||
PerambPar.UniqueIdentifier="full_dilution";
|
PerambPar.UniqueIdentifier="full_dilution";
|
||||||
PerambPar.solver="CG_s";
|
PerambPar.solver="CG_s";
|
||||||
@ -227,16 +239,32 @@ void test_MultiPerambulators(Application &application)
|
|||||||
A2AMesonFieldPar.output="MesonSinksPhi5";
|
A2AMesonFieldPar.output="MesonSinksPhi5";
|
||||||
application.createModule<MContraction::A2AMesonField>("DistilMesonFieldPhi5",A2AMesonFieldPar);
|
application.createModule<MContraction::A2AMesonField>("DistilMesonFieldPhi5",A2AMesonFieldPar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_Noises(Application &application) {
|
||||||
|
// DistilVectors parameters
|
||||||
|
MDistil::NoisesPar NoisePar;
|
||||||
|
NoisePar.UniqueIdentifier = "full_dilution";
|
||||||
|
NoisePar.nvec = 5;
|
||||||
|
NoisePar.Distil.LI = 5;
|
||||||
|
NoisePar.Distil.nnoise = 1;
|
||||||
|
NoisePar.Distil.Ns = 4;
|
||||||
|
NoisePar.Distil.Nt = 8;
|
||||||
|
NoisePar.Distil.Nt = 1;
|
||||||
|
application.createModule<MDistil::Noises>("Peramb_noise",NoisePar);
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
// DistilVectors
|
// DistilVectors
|
||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void test_DistilVectors(Application &application)
|
void test_DistilVectors(Application &application)
|
||||||
{
|
{
|
||||||
|
test_Noises(application);
|
||||||
// DistilVectors parameters
|
// DistilVectors parameters
|
||||||
MDistil::DistilVectors::Par DistilVecPar;
|
MDistil::DistilVectors::Par DistilVecPar;
|
||||||
DistilVecPar.noise="Peramb_noise";
|
DistilVecPar.noise="Peramb_noise";
|
||||||
DistilVecPar.perambulator="Peramb_perambulator_light";
|
//DistilVecPar.perambulator="Peramb_perambulator_light";
|
||||||
|
DistilVecPar.perambulator="Peramb";
|
||||||
DistilVecPar.eigenPack="LapEvec";
|
DistilVecPar.eigenPack="LapEvec";
|
||||||
DistilVecPar.tsrc = 0;
|
DistilVecPar.tsrc = 0;
|
||||||
DistilVecPar.nnoise = 1;
|
DistilVecPar.nnoise = 1;
|
||||||
@ -390,8 +418,10 @@ void test_MesonFieldRhoAll(Application &application)
|
|||||||
{
|
{
|
||||||
// DistilVectors parameters
|
// DistilVectors parameters
|
||||||
MContraction::A2AMesonField::Par A2AMesonFieldPar;
|
MContraction::A2AMesonField::Par A2AMesonFieldPar;
|
||||||
A2AMesonFieldPar.left="DistilVecs_rho_all_tsrc";
|
//A2AMesonFieldPar.left="DistilVecs_rho_all_tsrc";
|
||||||
A2AMesonFieldPar.right="DistilVecs_rho_all_tsrc";
|
//A2AMesonFieldPar.right="DistilVecs_rho_all_tsrc";
|
||||||
|
A2AMesonFieldPar.left="DistilVecs_rho";
|
||||||
|
A2AMesonFieldPar.right="DistilVecs_rho";
|
||||||
A2AMesonFieldPar.output="MesonSinksRhoAll";
|
A2AMesonFieldPar.output="MesonSinksRhoAll";
|
||||||
A2AMesonFieldPar.gammas="all";
|
A2AMesonFieldPar.gammas="all";
|
||||||
A2AMesonFieldPar.mom={"0 0 0"};
|
A2AMesonFieldPar.mom={"0 0 0"};
|
||||||
@ -797,6 +827,15 @@ public:
|
|||||||
inline value_type * end(void) { return m_p + N; }
|
inline value_type * end(void) { return m_p + N; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename ET> typename std::enable_if<EigenIO::is_tensor<ET>::value>::type
|
||||||
|
dump_tensor(const ET & et, const char * psz = nullptr) {
|
||||||
|
if( psz )
|
||||||
|
std::cout << psz << ": ";
|
||||||
|
else
|
||||||
|
std::cout << "Unnamed tensor: ";
|
||||||
|
Serializable::WriteMember( std::cout, et );
|
||||||
|
}
|
||||||
|
|
||||||
template <int Options>
|
template <int Options>
|
||||||
void EigenSliceExample()
|
void EigenSliceExample()
|
||||||
{
|
{
|
||||||
@ -824,17 +863,21 @@ void EigenSliceExample2()
|
|||||||
T3 a(2,3,4);
|
T3 a(2,3,4);
|
||||||
|
|
||||||
std::cout << "Initialising a:";
|
std::cout << "Initialising a:";
|
||||||
SequentialInit( a );
|
TestScalar f{ 0 };
|
||||||
|
const TestScalar Inc{ 1, -1 };
|
||||||
|
for( auto &c : a ) {
|
||||||
|
c = f;
|
||||||
|
f += Inc;
|
||||||
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
//std::cout << "Validating a:";
|
std::cout << "Validating a (Eigen::" << ( ( Options & Eigen::RowMajor ) ? "Row" : "Col" ) << "Major):" << std::endl;
|
||||||
float z = 0;
|
f = 0;
|
||||||
for( int i = 0 ; i < a.dimension(0) ; i++ )
|
for( int i = 0 ; i < a.dimension(0) ; i++ )
|
||||||
for( int j = 0 ; j < a.dimension(1) ; j++ )
|
for( int j = 0 ; j < a.dimension(1) ; j++ )
|
||||||
for( int k = 0 ; k < a.dimension(2) ; k++ ) {
|
for( int k = 0 ; k < a.dimension(2) ; k++ ) {
|
||||||
TestScalar w{z, -z};
|
std::cout << " a(" << i << "," << j << "," << k << ")=" << a(i,j,k) << std::endl;
|
||||||
//std::cout << " a(" << i << "," << j << "," << k << ")=" << w;
|
assert( ( Options & Eigen::RowMajor ) == 0 || a(i,j,k) == f );
|
||||||
assert( a(i,j,k) == w );
|
f += Inc;
|
||||||
z++;
|
|
||||||
}
|
}
|
||||||
//std::cout << std::endl;
|
//std::cout << std::endl;
|
||||||
//std::cout << "a initialised to:\n" << a << std::endl;
|
//std::cout << "a initialised to:\n" << a << std::endl;
|
||||||
@ -933,8 +976,8 @@ int main(int argc, char *argv[])
|
|||||||
<< ", sizeof(hsize_t) = " << sizeof(hsize_t)
|
<< ", sizeof(hsize_t) = " << sizeof(hsize_t)
|
||||||
<< ", sizeof(unsigned long long) = " << sizeof(unsigned long long)
|
<< ", sizeof(unsigned long long) = " << sizeof(unsigned long long)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
if( DebugEigenTest() ) return 0;
|
//if( DebugEigenTest() ) return 0;
|
||||||
if(DebugGridTensorTest()) return 0;
|
//if(DebugGridTensorTest()) return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Decode command-line parameters. 1st one is which test to run
|
// Decode command-line parameters. 1st one is which test to run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user