mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Merge branch 'master' of github.com:paboyle/Grid
Merge done Conflicts: lib/serialisation/XmlIO.h tests/Test_stencil.cc
This commit is contained in:
commit
ca42fe6d32
1
.gitignore
vendored
1
.gitignore
vendored
@ -43,6 +43,7 @@
|
||||
########################################
|
||||
Makefile.in
|
||||
Makefile
|
||||
Config.h
|
||||
config.log
|
||||
config.status
|
||||
.deps
|
||||
|
172
lib/Config.h
172
lib/Config.h
@ -1,172 +0,0 @@
|
||||
/* lib/Config.h. Generated from Config.h.in by configure. */
|
||||
/* lib/Config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* AVX Intrinsics */
|
||||
/* #undef AVX1 */
|
||||
|
||||
/* AVX2 Intrinsics */
|
||||
/* #undef AVX2 */
|
||||
|
||||
/* AVX512 Intrinsics for Knights Corner */
|
||||
/* #undef AVX512 */
|
||||
|
||||
/* EMPTY_SIMD only for DEBUGGING */
|
||||
/* #undef EMPTY_SIMD */
|
||||
|
||||
/* GRID_COMMS_MPI */
|
||||
/* #undef GRID_COMMS_MPI */
|
||||
|
||||
/* GRID_COMMS_NONE */
|
||||
#define GRID_COMMS_NONE 1
|
||||
|
||||
/* GRID_DEFAULT_PRECISION is DOUBLE */
|
||||
/* #undef GRID_DEFAULT_PRECISION_DOUBLE */
|
||||
|
||||
/* GRID_DEFAULT_PRECISION is SINGLE */
|
||||
#define GRID_DEFAULT_PRECISION_SINGLE 1
|
||||
|
||||
/* Support Altivec instructions */
|
||||
/* #undef HAVE_ALTIVEC */
|
||||
|
||||
/* Support AVX (Advanced Vector Extensions) instructions */
|
||||
/* #undef HAVE_AVX */
|
||||
|
||||
/* Support AVX2 (Advanced Vector Extensions 2) instructions */
|
||||
/* #undef HAVE_AVX2 */
|
||||
|
||||
/* Define to 1 if you have the declaration of `be64toh', and to 0 if you
|
||||
don't. */
|
||||
#define HAVE_DECL_BE64TOH 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `ntohll', and to 0 if you don't.
|
||||
*/
|
||||
#define HAVE_DECL_NTOHLL 0
|
||||
|
||||
/* Define to 1 if you have the <endian.h> header file. */
|
||||
#define HAVE_ENDIAN_H 1
|
||||
|
||||
/* Support FMA3 (Fused Multiply-Add) instructions */
|
||||
/* #undef HAVE_FMA */
|
||||
|
||||
/* Define to 1 if you have the `gettimeofday' function. */
|
||||
#define HAVE_GETTIMEOFDAY 1
|
||||
|
||||
/* Define to 1 if you have the <gmp.h> header file. */
|
||||
#define HAVE_GMP_H 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the `gmp' library (-lgmp). */
|
||||
#define HAVE_LIBGMP 1
|
||||
|
||||
/* Define to 1 if you have the `mpfr' library (-lmpfr). */
|
||||
#define HAVE_LIBMPFR 1
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the <malloc/malloc.h> header file. */
|
||||
/* #undef HAVE_MALLOC_MALLOC_H */
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Support mmx instructions */
|
||||
#define HAVE_MMX /**/
|
||||
|
||||
/* Define to 1 if you have the <mm_malloc.h> header file. */
|
||||
#define HAVE_MM_MALLOC_H 1
|
||||
|
||||
/* Support SSE (Streaming SIMD Extensions) instructions */
|
||||
#define HAVE_SSE /**/
|
||||
|
||||
/* Support SSE2 (Streaming SIMD Extensions 2) instructions */
|
||||
#define HAVE_SSE2 /**/
|
||||
|
||||
/* Support SSE3 (Streaming SIMD Extensions 3) instructions */
|
||||
#define HAVE_SSE3 /**/
|
||||
|
||||
/* Support SSSE4.1 (Streaming SIMD Extensions 4.1) instructions */
|
||||
#define HAVE_SSE4_1 /**/
|
||||
|
||||
/* Support SSSE4.2 (Streaming SIMD Extensions 4.2) instructions */
|
||||
#define HAVE_SSE4_2 /**/
|
||||
|
||||
/* Support SSSE3 (Supplemental Streaming SIMD Extensions 3) instructions */
|
||||
#define HAVE_SSSE3 /**/
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* NEON ARMv8 Experimental support */
|
||||
/* #undef NEONv8 */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "grid"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "paboyle@ph.ed.ac.uk"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "Grid"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "Grid 1.0"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "grid"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "1.0"
|
||||
|
||||
/* SSE4 Intrinsics */
|
||||
#define SSE4 1
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "1.0"
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT32_T */
|
||||
|
||||
/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
|
||||
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
|
||||
#define below would cause a syntax error. */
|
||||
/* #undef _UINT64_T */
|
||||
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 32 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint32_t */
|
||||
|
||||
/* Define to the type of an unsigned integer type of width exactly 64 bits if
|
||||
such a type exists and the standard includes do not define it. */
|
||||
/* #undef uint64_t */
|
@ -17,7 +17,6 @@
|
||||
|
||||
#define __X86_64
|
||||
|
||||
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace Grid {
|
||||
|
||||
GridStopWatch GridLogger::StopWatch;
|
||||
std::ostream GridLogger::devnull(0);
|
||||
GridStopWatch Logger::StopWatch;
|
||||
std::ostream Logger::devnull(0);
|
||||
|
||||
GridLogger GridLogError (1,"Error");
|
||||
GridLogger GridLogWarning (1,"Warning");
|
||||
|
54
lib/Log.h
54
lib/Log.h
@ -6,31 +6,39 @@ namespace Grid {
|
||||
|
||||
std::ostream& operator<< (std::ostream& stream, const GridTime& time);
|
||||
|
||||
class GridLogger {
|
||||
int active;
|
||||
std::string name;
|
||||
class Logger {
|
||||
protected:
|
||||
int active;
|
||||
std::string name, topName;
|
||||
public:
|
||||
|
||||
static GridStopWatch StopWatch;
|
||||
static std::ostream devnull;
|
||||
|
||||
GridLogger(int on, std::string nm): active(on), name(nm) {
|
||||
};
|
||||
|
||||
void Active(int on) {active = on;};
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& stream, const GridLogger& log){
|
||||
if ( log.active ) {
|
||||
StopWatch.Stop();
|
||||
GridTime now = StopWatch.Elapsed();
|
||||
StopWatch.Start();
|
||||
stream << "Grid : "<<log.name << " : " << now << " : ";
|
||||
return stream;
|
||||
} else {
|
||||
return devnull;
|
||||
static GridStopWatch StopWatch;
|
||||
static std::ostream devnull;
|
||||
|
||||
Logger(std::string topNm, int on, std::string nm)
|
||||
: active(on), name(nm), topName(topNm) {};
|
||||
|
||||
void Active(int on) {active = on;};
|
||||
int isActive(void) {return active;};
|
||||
|
||||
friend std::ostream& operator<< (std::ostream& stream, const Logger& log){
|
||||
if ( log.active ) {
|
||||
StopWatch.Stop();
|
||||
GridTime now = StopWatch.Elapsed();
|
||||
StopWatch.Start();
|
||||
stream << std::setw(8) << std::left << log.topName << " : ";
|
||||
stream << std::setw(12) << std::left << log.name << " : ";
|
||||
stream << now << " : ";
|
||||
return stream;
|
||||
} else {
|
||||
return devnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
class GridLogger: public Logger {
|
||||
public:
|
||||
GridLogger(int on, std::string nm): Logger("Grid", on, nm){};
|
||||
};
|
||||
|
||||
void GridLogConfigure(std::vector<std::string> &logstreams);
|
||||
|
@ -1,4 +1,4 @@
|
||||
|
||||
HFILES=./algorithms/approx/bigfloat.h ./algorithms/approx/bigfloat_double.h ./algorithms/approx/Chebyshev.h ./algorithms/approx/MultiShiftFunction.h ./algorithms/approx/Remez.h ./algorithms/approx/Zolotarev.h ./algorithms/CoarsenedMatrix.h ./algorithms/iterative/AdefGeneric.h ./algorithms/iterative/ConjugateGradient.h ./algorithms/iterative/ConjugateGradientMultiShift.h ./algorithms/iterative/ConjugateResidual.h ./algorithms/iterative/ImplicitlyRestartedLanczos.h ./algorithms/iterative/MatrixUtils.h ./algorithms/iterative/NormalEquations.h ./algorithms/iterative/PrecConjugateResidual.h ./algorithms/iterative/PrecGeneralisedConjugateResidual.h ./algorithms/iterative/SchurRedBlack.h ./algorithms/LinearOperator.h ./algorithms/Preconditioner.h ./algorithms/SparseMatrix.h ./Algorithms.h ./AlignedAllocator.h ./cartesian/Cartesian_base.h ./cartesian/Cartesian_full.h ./cartesian/Cartesian_red_black.h ./Cartesian.h ./communicator/Communicator_base.h ./Communicator.h ./Config.h ./cshift/Cshift_common.h ./cshift/Cshift_mpi.h ./cshift/Cshift_none.h ./Cshift.h ./Grid.h ./Init.h ./lattice/Lattice_arith.h ./lattice/Lattice_base.h ./lattice/Lattice_comparison.h ./lattice/Lattice_comparison_utils.h ./lattice/Lattice_conformable.h ./lattice/Lattice_coordinate.h ./lattice/Lattice_ET.h ./lattice/Lattice_local.h ./lattice/Lattice_overload.h ./lattice/Lattice_peekpoke.h ./lattice/Lattice_reality.h ./lattice/Lattice_reduction.h ./lattice/Lattice_rng.h ./lattice/Lattice_trace.h ./lattice/Lattice_transfer.h ./lattice/Lattice_transpose.h ./lattice/Lattice_unary.h ./lattice/Lattice_where.h ./Lattice.h ./Log.h ./Old/Tensor_peek.h ./Old/Tensor_poke.h ./parallelIO/BinaryIO.h ./parallelIO/NerscIO.h ./pugixml/pugixml.h ./qcd/action/ActionBase.h ./qcd/action/ActionParams.h ./qcd/action/Actions.h ./qcd/action/fermion/CayleyFermion5D.h ./qcd/action/fermion/ContinuedFractionFermion5D.h ./qcd/action/fermion/DomainWallFermion.h ./qcd/action/fermion/FermionOperator.h ./qcd/action/fermion/FermionOperatorImpl.h ./qcd/action/fermion/g5HermitianLinop.h ./qcd/action/fermion/MobiusFermion.h ./qcd/action/fermion/MobiusZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonCayleyTanhFermion.h ./qcd/action/fermion/OverlapWilsonCayleyZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonContfracTanhFermion.h ./qcd/action/fermion/OverlapWilsonContfracZolotarevFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionTanhFermion.h ./qcd/action/fermion/OverlapWilsonPartialFractionZolotarevFermion.h ./qcd/action/fermion/PartialFractionFermion5D.h ./qcd/action/fermion/ScaledShamirFermion.h ./qcd/action/fermion/ShamirZolotarevFermion.h ./qcd/action/fermion/WilsonCompressor.h ./qcd/action/fermion/WilsonFermion.h ./qcd/action/fermion/WilsonFermion5D.h ./qcd/action/fermion/WilsonKernels.h ./qcd/action/gauge/WilsonGaugeAction.h ./qcd/action/pseudofermion/EvenOddSchurDifferentiable.h ./qcd/action/pseudofermion/OneFlavourEvenOddRational.h ./qcd/action/pseudofermion/OneFlavourEvenOddRationalRatio.h ./qcd/action/pseudofermion/OneFlavourRational.h ./qcd/action/pseudofermion/OneFlavourRationalRatio.h ./qcd/action/pseudofermion/TwoFlavour.h ./qcd/action/pseudofermion/TwoFlavourEvenOdd.h ./qcd/action/pseudofermion/TwoFlavourEvenOddRatio.h ./qcd/action/pseudofermion/TwoFlavourRatio.h ./qcd/hmc/HMC.h ./qcd/hmc/integrators/Integrator.h ./qcd/hmc/integrators/Integrator_algorithm.h ./qcd/QCD.h ./qcd/spin/Dirac.h ./qcd/spin/TwoSpinor.h ./qcd/utils/CovariantCshift.h ./qcd/utils/LinalgUtils.h ./qcd/utils/SpaceTimeGrid.h ./qcd/utils/SUn.h ./qcd/utils/WilsonLoops.h ./serialisation/BaseIO.h ./serialisation/BinaryIO.h ./serialisation/MacroMagic.h ./serialisation/Serialisation.h ./serialisation/TextIO.h ./serialisation/XmlIO.h ./simd/Grid_avx.h ./simd/Grid_avx512.h ./simd/Grid_empty.h ./simd/Grid_imci.h ./simd/Grid_neon.h ./simd/Grid_qpx.h ./simd/Grid_sse4.h ./simd/Grid_vector_types.h ./simd/Grid_vector_unops.h ./Simd.h ./stencil/Lebesgue.h ./Stencil.h ./tensors/Tensor_arith.h ./tensors/Tensor_arith_add.h ./tensors/Tensor_arith_mac.h ./tensors/Tensor_arith_mul.h ./tensors/Tensor_arith_scalar.h ./tensors/Tensor_arith_sub.h ./tensors/Tensor_class.h ./tensors/Tensor_determinant.h ./tensors/Tensor_exp.h ./tensors/Tensor_extract_merge.h ./tensors/Tensor_index.h ./tensors/Tensor_inner.h ./tensors/Tensor_logical.h ./tensors/Tensor_outer.h ./tensors/Tensor_reality.h ./tensors/Tensor_Ta.h ./tensors/Tensor_trace.h ./tensors/Tensor_traits.h ./tensors/Tensor_transpose.h ./tensors/Tensor_unary.h ./Tensors.h ./Threads.h ./Timer.h
|
||||
|
||||
CCFILES=./algorithms/approx/MultiShiftFunction.cc ./algorithms/approx/Remez.cc ./algorithms/approx/Zolotarev.cc ./Init.cc ./Log.cc ./pugixml/pugixml.cc ./qcd/action/fermion/CayleyFermion5D.cc ./qcd/action/fermion/ContinuedFractionFermion5D.cc ./qcd/action/fermion/PartialFractionFermion5D.cc ./qcd/action/fermion/WilsonFermion.cc ./qcd/action/fermion/WilsonFermion5D.cc ./qcd/action/fermion/WilsonKernels.cc ./qcd/action/fermion/WilsonKernelsHand.cc ./qcd/hmc/HMC.cc ./qcd/spin/Dirac.cc ./qcd/utils/SpaceTimeGrid.cc ./stencil/Lebesgue.cc ./stencil/Stencil_common.cc
|
||||
CCFILES=./algorithms/approx/MultiShiftFunction.cc ./algorithms/approx/Remez.cc ./algorithms/approx/Zolotarev.cc ./Init.cc ./Log.cc ./pugixml/pugixml.cc ./qcd/action/fermion/CayleyFermion5D.cc ./qcd/action/fermion/ContinuedFractionFermion5D.cc ./qcd/action/fermion/PartialFractionFermion5D.cc ./qcd/action/fermion/WilsonFermion.cc ./qcd/action/fermion/WilsonFermion5D.cc ./qcd/action/fermion/WilsonKernels.cc ./qcd/action/fermion/WilsonKernelsHand.cc ./qcd/hmc/HMC.cc ./qcd/spin/Dirac.cc ./qcd/utils/SpaceTimeGrid.cc ./serialisation/BinaryIO.cc ./serialisation/TextIO.cc ./serialisation/XmlIO.cc ./stencil/Lebesgue.cc ./stencil/Stencil_common.cc
|
||||
|
@ -5,22 +5,27 @@
|
||||
#include <ctime>
|
||||
#include <chrono>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <syscall.h>
|
||||
#include <linux/perf_event.h>
|
||||
|
||||
#endif
|
||||
namespace Grid {
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
|
||||
int cpu, int group_fd, unsigned long flags)
|
||||
{
|
||||
int ret;
|
||||
int ret=0;
|
||||
|
||||
ret = syscall(__NR_perf_event_open, hw_event, pid, cpu,
|
||||
group_fd, flags);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
class PerformanceCounter {
|
||||
@ -63,7 +68,6 @@ public:
|
||||
|
||||
int PCT;
|
||||
|
||||
struct perf_event_attr pe;
|
||||
long long count;
|
||||
int fd;
|
||||
uint64_t elapsed;
|
||||
@ -74,15 +78,19 @@ public:
|
||||
}
|
||||
|
||||
PerformanceCounter(int _pct) {
|
||||
#ifdef __linux__
|
||||
assert(_pct>=0);
|
||||
assert(_pct<PERFORMANCE_COUNTER_NUM_TYPES);
|
||||
fd=-1;
|
||||
count=0;
|
||||
PCT =_pct;
|
||||
Open();
|
||||
#endif
|
||||
}
|
||||
void Open(void)
|
||||
{
|
||||
#ifdef __linux__
|
||||
struct perf_event_attr pe;
|
||||
memset(&pe, 0, sizeof(struct perf_event_attr));
|
||||
pe.size = sizeof(struct perf_event_attr);
|
||||
|
||||
@ -99,32 +107,48 @@ public:
|
||||
fprintf(stderr, "Error opening leader %llx for event %s\n", pe.config,name);
|
||||
perror("Error is");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Start(void)
|
||||
{
|
||||
#ifdef __linux__
|
||||
if ( fd!= -1) {
|
||||
ioctl(fd, PERF_EVENT_IOC_RESET, 0);
|
||||
ioctl(fd, PERF_EVENT_IOC_ENABLE, 0);
|
||||
}
|
||||
begin =__rdtsc();
|
||||
#else
|
||||
begin = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Stop(void) {
|
||||
count=0;
|
||||
#ifdef __linux__
|
||||
if ( fd!= -1) {
|
||||
ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
|
||||
::read(fd, &count, sizeof(long long));
|
||||
}
|
||||
elapsed = __rdtsc() - begin;
|
||||
#else
|
||||
elapsed = 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
void Report(void) {
|
||||
#ifdef __linux__
|
||||
printf("%llu cycles %s = %20llu\n", elapsed , PerformanceCounterConfigs[PCT].name, count);
|
||||
#else
|
||||
printf("%llu cycles \n", elapsed );
|
||||
#endif
|
||||
}
|
||||
|
||||
~PerformanceCounter()
|
||||
{
|
||||
#ifdef __linux__
|
||||
close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,4 +1,3 @@
|
||||
#if 0
|
||||
#ifndef GRID_IRL_H
|
||||
#define GRID_IRL_H
|
||||
|
||||
@ -18,8 +17,9 @@ template<class Field>
|
||||
const RealD small = 1.0e-16;
|
||||
public:
|
||||
int lock;
|
||||
int converged;
|
||||
int get;
|
||||
int Niter;
|
||||
int converged;
|
||||
|
||||
int Nk; // Number of converged sought
|
||||
int Np; // Np -- Number of spare vecs in kryloc space
|
||||
@ -59,6 +59,7 @@ public:
|
||||
// Sanity checked this routine (step) against Saad.
|
||||
/////////////////////////
|
||||
void RitzMatrix(DenseVector<Field>& evec,int k){
|
||||
|
||||
if(1) return;
|
||||
|
||||
GridBase *grid = evec[0]._grid;
|
||||
@ -451,8 +452,9 @@ until convergence
|
||||
std::cout << " -- Nconv = "<< Nconv << "\n";
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Adapted from Rudy's lanczos factor routine
|
||||
/////////////////////////////////////////////////
|
||||
int Lanczos_Factor(int start, int end, int cont,
|
||||
DenseVector<Field> & bq,
|
||||
Field &bf,
|
||||
@ -546,10 +548,16 @@ until convergence
|
||||
std::cout << "alpha = " << alpha << " fnorm = " << fnorm << '\n';
|
||||
|
||||
///Iterative refinement of orthogonality V = [ bq[0] bq[1] ... bq[M] ]
|
||||
#if 0
|
||||
int re = 0;
|
||||
// FIXME undefined params; how set in Rudy's code
|
||||
int ref =0;
|
||||
Real rho = 1.0e-8;
|
||||
|
||||
while( re == ref || (sqbt < rho * bck && re < 5) ){
|
||||
|
||||
Field tmp2(grid);
|
||||
Field tmp1(grid);
|
||||
|
||||
//bex = V^dag bf
|
||||
DenseVector<ComplexD> bex(j+1);
|
||||
for(int k=0;k<j+1;k++){
|
||||
@ -566,14 +574,14 @@ until convergence
|
||||
|
||||
//bf = bf - V V^dag bf. Subtracting off any component in span { V[j] }
|
||||
RealD btc = axpy_norm(bf,-1.0,tmp2,bf);
|
||||
alpha = alpha + bex[j]; sqbt = sqrt(real(btc));
|
||||
alpha = alpha + real(bex[j]); sqbt = sqrt(real(btc));
|
||||
// FIXME is alpha real in RUDY's code?
|
||||
RealD nmbex = 0;for(int k=0;k<j+1;k++){nmbex = nmbex + real( conjugate(bex[k])*bex[k] );}
|
||||
bck = sqrt( nmbex );
|
||||
re++;
|
||||
}
|
||||
std::cout << "Iteratively refined orthogonality, changes alpha\n";
|
||||
if(re > 1) std::cout << "orthagonality refined " << re << " times" <<std::endl;
|
||||
#endif
|
||||
H[j][j]=alpha;
|
||||
}
|
||||
|
||||
@ -702,7 +710,6 @@ until convergence
|
||||
RealD beta;
|
||||
|
||||
Householder_vector<RealD>(ck, 0, 2, v, beta);
|
||||
|
||||
Householder_mult<RealD>(H,v,beta,0,lock_num+0,lock_num+2,0);
|
||||
Householder_mult<RealD>(H,v,beta,0,lock_num+0,lock_num+2,1);
|
||||
///Accumulate eigenvector
|
||||
@ -787,51 +794,26 @@ until convergence
|
||||
}
|
||||
std::cout << "Got " << converged << " so far " <<std::endl;
|
||||
}
|
||||
#if 0
|
||||
///Check
|
||||
void Check(void) {
|
||||
|
||||
DenseVector<RealD> goodval(get);
|
||||
///Check
|
||||
void Check(DenseVector<RealD> &evals,
|
||||
DenseVector<DenseVector<RealD> > &evecs) {
|
||||
|
||||
DenseVector<RealD> goodval(this->get);
|
||||
|
||||
EigenSort(evals,evecs);
|
||||
|
||||
int NM = Nm;
|
||||
int Nget = this->get;
|
||||
S **V;
|
||||
V = new S* [NM];
|
||||
|
||||
RealD *QZ;
|
||||
QZ = new RealD [NM*NM];
|
||||
DenseVector< DenseVector<RealD> > V; Size(V,NM);
|
||||
DenseVector<RealD> QZ(NM*NM);
|
||||
|
||||
for(int i = 0; i < NM; i++){
|
||||
for(int j = 0; j < NM; j++){
|
||||
|
||||
QZ[i*NM+j] = this->evecs[i][j];
|
||||
|
||||
int f_size_cb = 24*dop.cbLs*dop.node_cbvol;
|
||||
|
||||
for(int cb = this->prec; cb < 2; cb++){
|
||||
for(int i = 0; i < NM; i++){
|
||||
V[i] = (S*)(this->bq[i][cb]);
|
||||
|
||||
const int m0 = 4 * 4; // this is new code
|
||||
assert(m0 % 16 == 0); // see the reason in VtimesQ.C
|
||||
|
||||
const int row_per_thread = f_size_cb / (bfmarg::threads);
|
||||
{
|
||||
|
||||
{
|
||||
DenseVector<RealD> vrow_tmp0(m0*NM);
|
||||
DenseVector<RealD> vrow_tmp1(m0*NM);
|
||||
RealD *row_tmp0 = vrow_tmp0.data();
|
||||
RealD *row_tmp1 = vrow_tmp1.data();
|
||||
VtimesQ(QZ, NM, V, row_tmp0, row_tmp1, id * row_per_thread, m0, (id + 1) * row_per_thread);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// evecs[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
@ -1020,4 +1002,4 @@ static void Lock(DenseMatrix<T> &H, ///Hess mtx
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -1,49 +1,211 @@
|
||||
#ifndef GRID_SERIALISATION_ABSTRACT_READER_H
|
||||
#define GRID_SERIALISATION_ABSTRACT_READER_H
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace Grid {
|
||||
class Writer {
|
||||
public:
|
||||
|
||||
virtual ~Writer() {};
|
||||
|
||||
virtual void push(const std::string &s) = 0;
|
||||
virtual void pop(void) =0;
|
||||
virtual void write( const std::string& s,const std::string &output ) =0;
|
||||
virtual void write( const std::string& s,const int16_t output ) =0;
|
||||
virtual void write( const std::string& s,const uint16_t output ) =0;
|
||||
virtual void write( const std::string& s,const int32_t output ) =0;
|
||||
virtual void write( const std::string& s,const uint32_t output ) =0;
|
||||
virtual void write( const std::string& s,const int64_t output ) =0;
|
||||
virtual void write( const std::string& s,const uint64_t output ) =0;
|
||||
virtual void write( const std::string& s,const float output ) =0;
|
||||
virtual void write( const std::string& s,const double output ) =0;
|
||||
virtual void write( const std::string& s,const bool output ) =0;
|
||||
|
||||
};
|
||||
|
||||
class Reader {
|
||||
public:
|
||||
|
||||
|
||||
|
||||
virtual ~Reader() {};
|
||||
|
||||
virtual void read( const std::string& s,std::string &output ) =0;
|
||||
virtual void push(const std::string &s) =0;
|
||||
virtual void pop(void) = 0;
|
||||
|
||||
virtual void read( const std::string& s, int16_t &output ) =0;
|
||||
virtual void read( const std::string& s, uint16_t &output ) =0;
|
||||
virtual void read( const std::string& s, int32_t &output ) =0;
|
||||
virtual void read( const std::string& s, uint32_t &output ) =0;
|
||||
virtual void read( const std::string& s, int64_t &output ) =0;
|
||||
virtual void read( const std::string& s, uint64_t &output ) =0;
|
||||
virtual void read( const std::string& s, float &output ) =0;
|
||||
virtual void read( const std::string& s, double &output ) =0;
|
||||
virtual void read( const std::string& s, bool &output ) =0;
|
||||
class Serializable {};
|
||||
|
||||
// static polymorphism implemented using CRTP idiom
|
||||
|
||||
// Static abstract writer
|
||||
template <typename T>
|
||||
class Writer
|
||||
{
|
||||
public:
|
||||
Writer(void);
|
||||
virtual ~Writer(void) = default;
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
typename std::enable_if<std::is_base_of<Serializable, U>::value, void>::type
|
||||
write(const std::string& s, const U &output);
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
write(const std::string& s, const U &output);
|
||||
private:
|
||||
T *upcast;
|
||||
};
|
||||
|
||||
// Static abstract reader
|
||||
template <typename T>
|
||||
class Reader
|
||||
{
|
||||
public:
|
||||
Reader(void);
|
||||
virtual ~Reader(void) = default;
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
typename std::enable_if<std::is_base_of<Serializable, U>::value, void>::type
|
||||
read(const std::string& s, U &output);
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
read(const std::string& s, U &output);
|
||||
protected:
|
||||
template <typename U>
|
||||
void fromString(U &output, const std::string &s);
|
||||
private:
|
||||
T *upcast;
|
||||
};
|
||||
|
||||
// Generic writer interface
|
||||
template <typename T>
|
||||
inline void push(Writer<T> &w, const std::string &s)
|
||||
{
|
||||
w.push(s);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void push(Writer<T> &w, const char *s)
|
||||
{
|
||||
w.push(std::string(s));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void pop(Writer<T> &w)
|
||||
{
|
||||
w.pop();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline void write(Writer<T> &w, const std::string& s, const U &output)
|
||||
{
|
||||
w.write(s, output);
|
||||
}
|
||||
|
||||
// Generic reader interface
|
||||
template <typename T>
|
||||
inline void push(Reader<T> &r, const std::string &s)
|
||||
{
|
||||
r.push(s);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void push(Reader<T> &r, const char *s)
|
||||
{
|
||||
r.push(std::string(s));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void pop(Reader<T> &r)
|
||||
{
|
||||
r.pop();
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline void read(Reader<T> &r, const std::string &s, U &output)
|
||||
{
|
||||
r.read(s, output);
|
||||
}
|
||||
|
||||
template < class T >
|
||||
inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v)
|
||||
{
|
||||
os << "[";
|
||||
for (auto &x: v)
|
||||
{
|
||||
os << x << " ";
|
||||
}
|
||||
if (v.size() > 0)
|
||||
{
|
||||
os << "\b";
|
||||
}
|
||||
os << "]";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
// Writer template implementation ////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Writer<T>::Writer(void)
|
||||
{
|
||||
upcast = static_cast<T *>(this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Writer<T>::push(const std::string &s)
|
||||
{
|
||||
upcast->push(s);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Writer<T>::pop(void)
|
||||
{
|
||||
upcast->pop();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<std::is_base_of<Serializable, U>::value, void>::type
|
||||
Writer<T>::write(const std::string &s, const U &output)
|
||||
{
|
||||
U::write(*this, s, output);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
Writer<T>::write(const std::string &s, const U &output)
|
||||
{
|
||||
upcast->writeDefault(s, output);
|
||||
}
|
||||
|
||||
// Reader template implementation ////////////////////////////////////////////
|
||||
template <typename T>
|
||||
Reader<T>::Reader(void)
|
||||
{
|
||||
upcast = static_cast<T *>(this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Reader<T>::push(const std::string &s)
|
||||
{
|
||||
upcast->push(s);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void Reader<T>::pop(void)
|
||||
{
|
||||
upcast->pop();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<std::is_base_of<Serializable, U>::value, void>::type
|
||||
Reader<T>::read(const std::string &s, U &output)
|
||||
{
|
||||
U::read(*this, s, output);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
typename std::enable_if<!std::is_base_of<Serializable, U>::value, void>::type
|
||||
Reader<T>::read(const std::string &s, U &output)
|
||||
{
|
||||
upcast->readDefault(s, output);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename U>
|
||||
void Reader<T>::fromString(U &output, const std::string &s)
|
||||
{
|
||||
std::istringstream is(s);
|
||||
|
||||
is.exceptions(std::ios::failbit);
|
||||
try
|
||||
{
|
||||
is >> std::boolalpha >> output;
|
||||
}
|
||||
catch(std::istringstream::failure &e)
|
||||
{
|
||||
std::cerr << "numerical conversion failure on '" << s << "' ";
|
||||
std::cerr << "(typeid: " << typeid(U).name() << ")" << std::endl;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
36
lib/serialisation/BinaryIO.cc
Normal file
36
lib/serialisation/BinaryIO.cc
Normal file
@ -0,0 +1,36 @@
|
||||
#include <Grid.h>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace std;
|
||||
|
||||
// Writer implementation ///////////////////////////////////////////////////////
|
||||
BinaryWriter::BinaryWriter(const string &fileName)
|
||||
: file_(fileName, ios::binary|ios::out)
|
||||
{}
|
||||
|
||||
template <>
|
||||
void BinaryWriter::writeDefault(const string &s, const string &output)
|
||||
{
|
||||
uint64_t sz = output.size();
|
||||
|
||||
write("", sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
write("", output[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reader implementation ///////////////////////////////////////////////////////
|
||||
BinaryReader::BinaryReader(const string &fileName)
|
||||
: file_(fileName, ios::binary|ios::in)
|
||||
{}
|
||||
|
||||
template <>
|
||||
void BinaryReader::readDefault(const string &s, string &output)
|
||||
{
|
||||
uint64_t sz;
|
||||
|
||||
read("", sz);
|
||||
output.reserve(sz);
|
||||
file_.read((char *)output.data(), sz);
|
||||
}
|
@ -9,101 +9,76 @@
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
namespace Grid {
|
||||
|
||||
class BinaryWriter : public Writer {
|
||||
private:
|
||||
|
||||
std::ofstream file;
|
||||
|
||||
public:
|
||||
|
||||
BinaryWriter(const std::string &_file) : file(_file,std::ios::binary|std::ios::out) {}
|
||||
|
||||
~BinaryWriter() {}
|
||||
|
||||
// Binary is scopeless
|
||||
void push(const std::string &s) {}
|
||||
void pop(void) {}
|
||||
|
||||
void write(const std::string& s,const std::string &output) {
|
||||
uint32_t sz = output.size();
|
||||
write(s,sz);
|
||||
const char * cstr = output.c_str();
|
||||
for(int c=0;c<output.size();c++){
|
||||
write(s,cstr[c]);
|
||||
}
|
||||
class BinaryWriter: public Writer<BinaryWriter>
|
||||
{
|
||||
public:
|
||||
BinaryWriter(const std::string &fileName);
|
||||
virtual ~BinaryWriter(void) = default;
|
||||
void push(const std::string &s) {};
|
||||
void pop(void) {};
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const U &x);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const std::vector<U> &x);
|
||||
private:
|
||||
std::ofstream file_;
|
||||
};
|
||||
void write( const std::string& s,const char output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int16_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint16_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int32_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint32_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int64_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint64_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const float output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const double output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const bool output ) { writeInternal(s,output); };
|
||||
|
||||
private:
|
||||
template<class T> void writeInternal( const std::string& s,const T output ){
|
||||
// FIXME --- htons, htonl, htno64 etc..
|
||||
file.write((char *)&output,sizeof(T));
|
||||
|
||||
class BinaryReader: public Reader<BinaryReader>
|
||||
{
|
||||
public:
|
||||
BinaryReader(const std::string &fileName);
|
||||
virtual ~BinaryReader(void) = default;
|
||||
void push(const std::string &s) {};
|
||||
void pop(void) {};
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, U &output);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, std::vector<U> &output);
|
||||
private:
|
||||
std::ifstream file_;
|
||||
};
|
||||
|
||||
// Writer template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void BinaryWriter::writeDefault(const std::string &s, const U &x)
|
||||
{
|
||||
file_.write((char *)&x, sizeof(U));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class BinaryReader : public Reader{
|
||||
private:
|
||||
|
||||
std::ifstream file;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
BinaryReader(const std::string &_file) : file(_file,std::ios::binary|std::ios::in) {}
|
||||
|
||||
~BinaryReader() {}
|
||||
|
||||
// Binary is scopeless
|
||||
void push(const std::string &s) { }
|
||||
void pop(void) { }
|
||||
|
||||
void read( const std::string& s,std::string &output ) {
|
||||
|
||||
output.clear();
|
||||
|
||||
uint32_t sz;
|
||||
file.read((char *)&sz,sizeof(sz));
|
||||
|
||||
for(int c=0;c<sz;c++){
|
||||
char ch;
|
||||
file.read(&ch,sizeof(ch));
|
||||
output.push_back(ch);
|
||||
template <typename U>
|
||||
void BinaryWriter::writeDefault(const std::string &s, const std::vector<U> &x)
|
||||
{
|
||||
uint64_t sz = x.size();
|
||||
|
||||
write("", sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
write("", x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Reader template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void BinaryReader::readDefault(const std::string &s, U &output)
|
||||
{
|
||||
file_.read((char *)&output, sizeof(U));
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
void BinaryReader::readDefault(const std::string &s, std::vector<U> &output)
|
||||
{
|
||||
uint64_t sz;
|
||||
|
||||
read("", sz);
|
||||
output.resize(sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
read("", output[i]);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void read( const std::string& s, int16_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint16_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, int32_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint32_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, int64_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint64_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, float &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, double &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, bool &output ) { readInternal(s,output); };
|
||||
|
||||
|
||||
private:
|
||||
|
||||
template<class T> void readInternal( const std::string& path, T &output ){
|
||||
file.read((char *)&output,sizeof(output)); // byte order??
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -111,8 +111,8 @@ THE SOFTWARE.
|
||||
#define GRID_MACRO_MEMBER(A,B) A B;
|
||||
|
||||
#define GRID_MACRO_OS_WRITE_MEMBER(A,B) os<< #A <<" "#B <<" = "<< obj. B <<" ; " <<std::endl;
|
||||
#define GRID_MACRO_READ_MEMBER(A,B) read(RD,#B,obj. B);
|
||||
#define GRID_MACRO_WRITE_MEMBER(A,B) write(WR,#B,obj. B);
|
||||
#define GRID_MACRO_READ_MEMBER(A,B) Grid::read(RD,#B,obj. B);
|
||||
#define GRID_MACRO_WRITE_MEMBER(A,B) Grid::write(WR,#B,obj. B);
|
||||
|
||||
#define GRID_DECL_CLASS_MEMBERS(cname,...) \
|
||||
\
|
||||
@ -120,14 +120,16 @@ THE SOFTWARE.
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_MEMBER,__VA_ARGS__)) \
|
||||
\
|
||||
\
|
||||
friend void write(Writer &WR,const std::string &s, const cname &obj){ \
|
||||
template <typename T>\
|
||||
static void write(Writer<T> &WR,const std::string &s, const cname &obj){ \
|
||||
push(WR,s);\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_WRITE_MEMBER,__VA_ARGS__)) \
|
||||
pop(WR);\
|
||||
} \
|
||||
\
|
||||
\
|
||||
friend void read(Reader &RD,const std::string &s, cname &obj){ \
|
||||
template <typename T>\
|
||||
static void read(Reader<T> &RD,const std::string &s, cname &obj){ \
|
||||
push(RD,s);\
|
||||
GRID_MACRO_EVAL(GRID_MACRO_MAP(GRID_MACRO_READ_MEMBER,__VA_ARGS__)) \
|
||||
pop(RD);\
|
||||
|
@ -5,85 +5,6 @@
|
||||
#include <serialisation/BaseIO.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
|
||||
// Generic reader writer interface
|
||||
inline void push(Writer & WR,const std::string &s) { WR.push(s);}
|
||||
inline void push(Writer & WR,const char *s) { WR.push(std::string(s));}
|
||||
inline void pop (Writer & WR) { WR.pop();}
|
||||
|
||||
// inline void write(Writer& wr, const std::string& s,const char * output ) { wr.write(s,std::string(output)); };
|
||||
inline void write(Writer& wr, const std::string& s,const std::string &output) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const int16_t output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const uint16_t output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const int32_t output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const uint32_t output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const int64_t output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const uint64_t output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const float output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const double output ) { wr.write(s,output); };
|
||||
inline void write(Writer& wr, const std::string& s,const bool output ) { wr.write(s,output); };
|
||||
|
||||
inline void push(Reader & WR,const std::string &s) { WR.push(s);}
|
||||
inline void push(Reader & WR,const char *s) { WR.push(std::string(s));}
|
||||
inline void pop (Reader & WR) { WR.pop();}
|
||||
|
||||
inline void read(Reader& rd, const std::string& s,std::string &output) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, int16_t &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, uint16_t &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, int32_t &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, uint32_t &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, int64_t &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, uint64_t &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, float &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, double &output ) { rd.read(s,output); };
|
||||
inline void read(Reader& rd, const std::string& s, bool &output ) { rd.read(s,output); };
|
||||
|
||||
|
||||
template<class T> void write(Writer& wr, const std::string& s,const std::vector<T> output ) {
|
||||
push(wr,s);
|
||||
uint64_t sz =output.size();
|
||||
write(wr,"N",sz);
|
||||
for(int i=0;i<output.size();i++){
|
||||
std::ostringstream oss; oss << "elem" << i;
|
||||
write(wr,oss.str(),output[i]);
|
||||
}
|
||||
pop(wr);
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
void read(Reader& rd, const std::string& s,std::vector<T> &output ) {
|
||||
|
||||
push(rd,s);
|
||||
|
||||
uint64_t sz; read(rd,"N",sz);
|
||||
// skip the vector length
|
||||
T tmp;
|
||||
output.resize(0);
|
||||
for(int i=0;i<sz;i++){
|
||||
std::ostringstream oss; oss << "elem" << i;
|
||||
read(rd,oss.str(),tmp);
|
||||
output.push_back(tmp);
|
||||
}
|
||||
pop(rd);
|
||||
};
|
||||
|
||||
template < class T >
|
||||
inline std::ostream& operator << (std::ostream& os, const std::vector<T>& v)
|
||||
{
|
||||
os << "[";
|
||||
for (typename std::vector<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
|
||||
{
|
||||
os << " " << *ii;
|
||||
}
|
||||
os << " ]";
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
// Todo:
|
||||
//////////////////////////////////////////
|
||||
@ -97,7 +18,7 @@ namespace Grid {
|
||||
// Select the default serialiser use ifdef's
|
||||
//////////////////////////////////////////
|
||||
namespace Grid {
|
||||
typedef XMLReader DefaultReader;
|
||||
typedef XMLWriter DefaultWriter;
|
||||
typedef XmlReader DefaultReader;
|
||||
typedef XmlWriter DefaultWriter;
|
||||
}
|
||||
#endif
|
||||
|
66
lib/serialisation/TextIO.cc
Normal file
66
lib/serialisation/TextIO.cc
Normal file
@ -0,0 +1,66 @@
|
||||
#include <Grid.h>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace std;
|
||||
|
||||
// Writer implementation ///////////////////////////////////////////////////////
|
||||
TextWriter::TextWriter(const string &fileName)
|
||||
: file_(fileName, ios::out)
|
||||
{}
|
||||
|
||||
void TextWriter::push(const string &s)
|
||||
{
|
||||
level_++;
|
||||
};
|
||||
|
||||
void TextWriter::pop(void)
|
||||
{
|
||||
level_--;
|
||||
};
|
||||
|
||||
void TextWriter::indent(void)
|
||||
{
|
||||
for (int i = 0; i < level_; ++i)
|
||||
{
|
||||
file_ << '\t';
|
||||
}
|
||||
};
|
||||
|
||||
// Reader implementation ///////////////////////////////////////////////////////
|
||||
TextReader::TextReader(const string &fileName)
|
||||
: file_(fileName, ios::in)
|
||||
{}
|
||||
|
||||
void TextReader::push(const string &s)
|
||||
{
|
||||
level_++;
|
||||
};
|
||||
|
||||
void TextReader::pop(void)
|
||||
{
|
||||
level_--;
|
||||
};
|
||||
|
||||
void TextReader::checkIndent(void)
|
||||
{
|
||||
char c;
|
||||
|
||||
for (int i = 0; i < level_; ++i)
|
||||
{
|
||||
file_.get(c);
|
||||
if (c != '\t')
|
||||
{
|
||||
cerr << "mismatch on tab " << c << " level " << level_;
|
||||
cerr << " i "<< i <<endl;
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void TextReader::readDefault(const string &s, string &output)
|
||||
{
|
||||
checkIndent();
|
||||
output.clear();
|
||||
getline(file_, output);
|
||||
}
|
@ -9,140 +9,88 @@
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
class TextWriter : public Writer {
|
||||
private:
|
||||
|
||||
std::ofstream file;
|
||||
int level;
|
||||
void indent(void) {
|
||||
for(int i=0;i<level;i++){
|
||||
file <<"\t";
|
||||
}
|
||||
}
|
||||
public:
|
||||
|
||||
TextWriter(const std::string &_file) : file(_file,std::ios::out) {
|
||||
level=0;
|
||||
}
|
||||
|
||||
~TextWriter() { }
|
||||
|
||||
void push(const std::string &s)
|
||||
namespace Grid
|
||||
{
|
||||
|
||||
class TextWriter: public Writer<TextWriter>
|
||||
{
|
||||
// std::string tmp = s;
|
||||
// write(s,tmp);
|
||||
level++;
|
||||
}
|
||||
void pop(void) {
|
||||
level--;
|
||||
}
|
||||
|
||||
void write( const std::string& s,const std::string &output ) {
|
||||
indent();
|
||||
file<<output<<std::endl;
|
||||
public:
|
||||
TextWriter(const std::string &fileName);
|
||||
virtual ~TextWriter(void) = default;
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const U &output);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const std::vector<U> &output);
|
||||
private:
|
||||
void indent(void);
|
||||
private:
|
||||
std::ofstream file_;
|
||||
int level_{0};
|
||||
};
|
||||
void write( const std::string& s,const int16_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint16_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int32_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint32_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int64_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint64_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const float output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const double output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const bool output ) { writeInternal(s,output); };
|
||||
|
||||
private:
|
||||
|
||||
template<class T> void writeInternal( const std::string& s,const T output ){
|
||||
|
||||
class TextReader: public Reader<TextReader>
|
||||
{
|
||||
public:
|
||||
TextReader(const std::string &fileName);
|
||||
virtual ~TextReader(void) = default;
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, U &output);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, std::vector<U> &output);
|
||||
private:
|
||||
void checkIndent(void);
|
||||
private:
|
||||
std::ifstream file_;
|
||||
int level_{0};
|
||||
};
|
||||
|
||||
// Writer template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void TextWriter::writeDefault(const std::string &s, const U &output)
|
||||
{
|
||||
indent();
|
||||
file << std::boolalpha << output<<std::endl;
|
||||
file_ << std::boolalpha << output << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class TextReader : public Reader {
|
||||
private:
|
||||
|
||||
std::ifstream file;
|
||||
int level;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
TextReader(const std::string &_file) : file(_file,std::ios::in) { level = 0;};
|
||||
|
||||
~TextReader() { }
|
||||
|
||||
void read( const std::string& s,std::string &output ) {
|
||||
char c='a';
|
||||
for(int i=0;i<level;i++){
|
||||
file.get(c);
|
||||
if ( c != '\t' )
|
||||
std::cout << "mismatch on tab "<<c<<" level "<< level<< " i "<< i<<std::endl;
|
||||
}
|
||||
output.clear();
|
||||
std::getline(file,output);
|
||||
};
|
||||
void push(const std::string &s) {
|
||||
// std::string tmp; read(s,tmp);
|
||||
level++;
|
||||
}
|
||||
void pop(void) { level--; }
|
||||
|
||||
template<class T>
|
||||
void read( const std::string& s, std::vector<T> &output ) {
|
||||
template <typename U>
|
||||
void TextWriter::writeDefault(const std::string &s, const std::vector<U> &output)
|
||||
{
|
||||
uint64_t sz = output.size();
|
||||
|
||||
push(s);
|
||||
|
||||
uint64_t n; read("N",n);
|
||||
|
||||
// skip the vector length
|
||||
T tmp;
|
||||
output.resize(0);
|
||||
for(int i=0;i<n;i++){
|
||||
std::ostringstream oss; oss << "elem" << i;
|
||||
read(*this,oss.str(),tmp);
|
||||
output.push_back(tmp);
|
||||
write(s, sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
write(s, output[i]);
|
||||
}
|
||||
|
||||
pop();
|
||||
|
||||
};
|
||||
|
||||
void read( const std::string& s, int16_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint16_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, int32_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint32_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, int64_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint64_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, float &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, double &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, bool &output ) { readInternal(s,output); };
|
||||
|
||||
|
||||
private:
|
||||
|
||||
template<class T> void readInternal( const std::string& path, T &output ){
|
||||
std::string asString;
|
||||
read(path,asString);
|
||||
convert(asString,output);
|
||||
}
|
||||
|
||||
template<class T> void convert(const std::string &asString,T &output)
|
||||
{
|
||||
std::istringstream is(asString); is.exceptions(std::ios::failbit);
|
||||
try {
|
||||
is >> std::boolalpha >> output;
|
||||
} catch(std::istringstream::failure e) {
|
||||
std::cerr << "XML read failure on "<<" "<<asString<<" "<<typeid(T).name()<<std::endl;
|
||||
}
|
||||
assert( is.tellg()==-1);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Reader template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void TextReader::readDefault(const std::string &s, U &output)
|
||||
{
|
||||
std::string buf;
|
||||
|
||||
readDefault(s, buf);
|
||||
fromString(output, buf);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
void TextReader::readDefault(const std::string &s, std::vector<U> &output)
|
||||
{
|
||||
uint64_t sz;
|
||||
|
||||
read("", sz);
|
||||
output.resize(sz);
|
||||
for (uint64_t i = 0; i < sz; ++i)
|
||||
{
|
||||
read("", output[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
59
lib/serialisation/XmlIO.cc
Normal file
59
lib/serialisation/XmlIO.cc
Normal file
@ -0,0 +1,59 @@
|
||||
#include <Grid.h>
|
||||
|
||||
using namespace Grid;
|
||||
using namespace std;
|
||||
|
||||
// Writer implementation ///////////////////////////////////////////////////////
|
||||
XmlWriter::XmlWriter(const string &fileName)
|
||||
: fileName_(fileName)
|
||||
{
|
||||
node_ = doc_.append_child();
|
||||
node_.set_name("grid");
|
||||
}
|
||||
|
||||
XmlWriter::~XmlWriter(void)
|
||||
{
|
||||
doc_.save_file(fileName_.c_str(), " ");
|
||||
}
|
||||
|
||||
void XmlWriter::push(const string &s)
|
||||
{
|
||||
node_ = node_.append_child(s.c_str());
|
||||
}
|
||||
|
||||
void XmlWriter::pop(void)
|
||||
{
|
||||
node_ = node_.parent();
|
||||
}
|
||||
|
||||
// Reader implementation ///////////////////////////////////////////////////////
|
||||
XmlReader::XmlReader(const string &fileName)
|
||||
: fileName_(fileName)
|
||||
{
|
||||
pugi::xml_parse_result result = doc_.load_file(fileName_.c_str());
|
||||
|
||||
if ( !result )
|
||||
{
|
||||
cerr << "XML error description: " << result.description() << "\n";
|
||||
cerr << "XML error offset : " << result.offset << "\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
node_ = doc_.child("grid");
|
||||
}
|
||||
|
||||
void XmlReader::push(const string &s)
|
||||
{
|
||||
node_ = node_.child(s.c_str());
|
||||
}
|
||||
|
||||
void XmlReader::pop(void)
|
||||
{
|
||||
node_ = node_.parent();
|
||||
}
|
||||
|
||||
template <>
|
||||
void XmlReader::readDefault(const string &s, string &output)
|
||||
{
|
||||
output = node_.child(s.c_str()).first_child().value();
|
||||
}
|
@ -11,136 +11,94 @@
|
||||
|
||||
#include "pugixml/pugixml.h"
|
||||
|
||||
|
||||
namespace Grid {
|
||||
|
||||
class XMLWriter : public Writer {
|
||||
private:
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_node node;
|
||||
std::string file;
|
||||
|
||||
public:
|
||||
|
||||
XMLWriter(const std::string &_file) : file(_file)
|
||||
namespace Grid
|
||||
{
|
||||
|
||||
class XmlWriter: public Writer<XmlWriter>
|
||||
{
|
||||
node=doc.append_child();
|
||||
node.set_name("document");
|
||||
}
|
||||
|
||||
~XMLWriter()
|
||||
{
|
||||
// simple_walker walker;
|
||||
// doc.traverse(walker);
|
||||
|
||||
doc.save_file(file.c_str()," ");
|
||||
}
|
||||
|
||||
void push(const std::string &s)
|
||||
{
|
||||
node = node.append_child(s.c_str());
|
||||
}
|
||||
void pop(void) {
|
||||
node = node.parent();
|
||||
}
|
||||
|
||||
void write( const std::string& s,const std::string &output ) {
|
||||
pugi::xml_node leaf=node.append_child(s.c_str());
|
||||
leaf.append_child(pugi::node_pcdata).set_value(output.c_str());
|
||||
|
||||
public:
|
||||
XmlWriter(const std::string &fileName);
|
||||
virtual ~XmlWriter(void);
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const U &x);
|
||||
template <typename U>
|
||||
void writeDefault(const std::string &s, const std::vector<U> &x);
|
||||
private:
|
||||
pugi::xml_document doc_;
|
||||
pugi::xml_node node_;
|
||||
std::string fileName_;
|
||||
};
|
||||
|
||||
void write( const std::string& s,const int16_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint16_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int32_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint32_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const int64_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const uint64_t output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const float output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const double output ) { writeInternal(s,output); };
|
||||
void write( const std::string& s,const bool output ) { writeInternal(s,output); };
|
||||
|
||||
private:
|
||||
|
||||
template<class T> void writeInternal( const std::string& s,const T output ){
|
||||
|
||||
class XmlReader: public Reader<XmlReader>
|
||||
{
|
||||
public:
|
||||
XmlReader(const std::string &fileName);
|
||||
virtual ~XmlReader(void) = default;
|
||||
void push(const std::string &s);
|
||||
void pop(void);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, U &output);
|
||||
template <typename U>
|
||||
void readDefault(const std::string &s, std::vector<U> &output);
|
||||
private:
|
||||
pugi::xml_document doc_;
|
||||
pugi::xml_node node_;
|
||||
std::string fileName_;
|
||||
};
|
||||
|
||||
// Writer template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void XmlWriter::writeDefault(const std::string &s, const U &x)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << std::boolalpha << output;
|
||||
write(s,os.str());
|
||||
|
||||
os << std::boolalpha << x;
|
||||
pugi::xml_node leaf = node_.append_child(s.c_str());
|
||||
leaf.append_child(pugi::node_pcdata).set_value(os.str().c_str());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
class XMLReader : public Reader {
|
||||
private:
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_node node;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
XMLReader(const std::string &_file)
|
||||
template <typename U>
|
||||
void XmlWriter::writeDefault(const std::string &s, const std::vector<U> &x)
|
||||
{
|
||||
pugi::xml_parse_result result = doc.load_file(_file.c_str());
|
||||
|
||||
if ( !result ) {
|
||||
std::cout << "XML error description: " << result.description() << "\n";
|
||||
std::cout << "XML error offset: " << result.offset << "\n";
|
||||
push(s);
|
||||
for (auto &x_i: x)
|
||||
{
|
||||
write("elem", x_i);
|
||||
}
|
||||
|
||||
assert(result);
|
||||
|
||||
// simple_walker walker;
|
||||
// doc.traverse(walker);
|
||||
|
||||
node= doc.child("document");
|
||||
pop();
|
||||
}
|
||||
|
||||
~XMLReader() { }
|
||||
|
||||
void read( const std::string& s,std::string &output ) {
|
||||
output=node.child(s.c_str()).first_child().value();
|
||||
};
|
||||
void push(const std::string &s)
|
||||
|
||||
// Reader template implementation ////////////////////////////////////////////
|
||||
template <typename U>
|
||||
void XmlReader::readDefault(const std::string &s, U &output)
|
||||
{
|
||||
node = node.child(s.c_str());
|
||||
std::string buf;
|
||||
|
||||
readDefault(s, buf);
|
||||
fromString(output, buf);
|
||||
}
|
||||
void pop(void) {
|
||||
node = node.parent();
|
||||
}
|
||||
|
||||
void read( const std::string& s, int16_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint16_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, int32_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint32_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, int64_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, uint64_t &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, float &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, double &output ) { readInternal(s,output); };
|
||||
void read( const std::string& s, bool &output ) { readInternal(s,output); };
|
||||
|
||||
|
||||
private:
|
||||
|
||||
template<class T> void readInternal( const std::string& path, T &output ){
|
||||
std::string asString;
|
||||
read(path,asString);
|
||||
convert(asString,output);
|
||||
}
|
||||
|
||||
template<class T> void convert(const std::string &asString,T &output)
|
||||
|
||||
template <typename U>
|
||||
void XmlReader::readDefault(const std::string &s, std::vector<U> &output)
|
||||
{
|
||||
std::istringstream is(asString); is.exceptions(std::ios::failbit);
|
||||
try {
|
||||
is >> std::boolalpha >> output;
|
||||
} catch(std::istringstream::failure e) {
|
||||
std::cerr << "XML read failure on "<<" "<<asString<<" "<<typeid(T).name()<<std::endl;
|
||||
pugi::xml_node nodeCpy;
|
||||
std::string buf;
|
||||
unsigned int i = 0;
|
||||
|
||||
push(s);
|
||||
while (node_.child("elem"))
|
||||
{
|
||||
output.resize(i + 1);
|
||||
read("elem", output[i]);
|
||||
node_.child("elem").set_name("elem-done");
|
||||
i++;
|
||||
}
|
||||
// assert( is.tellg()==-1);
|
||||
pop();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -59,7 +59,7 @@ clang-avx2)
|
||||
CXX=clang++ ../../configure --enable-simd=AVX2 CXXFLAGS="-mavx2 -mfma -O3 -std=c++11" LIBS="-lgmp -lmpfr" --enable-comms=none
|
||||
;;
|
||||
clang-avx-openmp)
|
||||
CXX=clang-omp++ ../../configure --enable-simd=AVX CXXFLAGS="-mavx -fopenmp -O3 -std=c++11" LDFLAGS="-fopenmp" LIBS="-lgmp -lmpfr" --enable-comms=none
|
||||
CXX=clang-omp++ ../../configure --enable-precision=double --enable-simd=AVX CXXFLAGS="-mavx -fopenmp -O3 -std=c++11" LDFLAGS="-fopenmp" LIBS="-lgmp -lmpfr" --enable-comms=none
|
||||
;;
|
||||
clang-xc30)
|
||||
CXX=$HOME/Clang/install/bin/clang++ ../../configure --enable-simd=AVX CXXFLAGS="-mavx -O3 -std=c++11 -I/opt/gcc/4.9.2/snos/include/g++/x86_64-suse-linux/ -I/opt/gcc/4.9.2/snos/include/g++/ " LDFLAGS="" LIBS="-lgmp -lmpfr" --enable-comms=none
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
bin_PROGRAMS = Test_GaugeAction Test_cayley_cg Test_cayley_coarsen_support Test_cayley_even_odd Test_cayley_ldop_cr Test_cf_coarsen_support Test_cf_cr_unprec Test_cheby Test_contfrac_cg Test_contfrac_even_odd Test_contfrac_force Test_cshift Test_cshift_red_black Test_dwf_cg_prec Test_dwf_cg_schur Test_dwf_cg_unprec Test_dwf_cr_unprec Test_dwf_even_odd Test_dwf_force Test_dwf_fpgcr Test_dwf_hdcr Test_gamma Test_hmc_EODWFRatio Test_hmc_EOWilsonFermionGauge Test_hmc_EOWilsonRatio Test_hmc_WilsonFermionGauge Test_hmc_WilsonGauge Test_hmc_WilsonRatio Test_lie_generators Test_main Test_multishift_sqrt Test_nersc_io Test_partfrac_force Test_quenched_update Test_remez Test_rhmc_EOWilson1p1 Test_rhmc_EOWilsonRatio Test_rhmc_Wilson1p1 Test_rhmc_WilsonRatio Test_rng Test_rng_fixed Test_serialisation Test_simd Test_stencil Test_wilson_cg_prec Test_wilson_cg_schur Test_wilson_cg_unprec Test_wilson_cr_unprec Test_wilson_even_odd Test_wilson_force Test_wilson_force_phiMdagMphi Test_wilson_force_phiMphi
|
||||
bin_PROGRAMS = Test_GaugeAction Test_cayley_cg Test_cayley_coarsen_support Test_cayley_even_odd Test_cayley_ldop_cr Test_cf_coarsen_support Test_cf_cr_unprec Test_cheby Test_contfrac_cg Test_contfrac_even_odd Test_contfrac_force Test_cshift Test_cshift_red_black Test_dwf_cg_prec Test_dwf_cg_schur Test_dwf_cg_unprec Test_dwf_cr_unprec Test_dwf_even_odd Test_dwf_force Test_dwf_fpgcr Test_dwf_hdcr Test_gamma Test_hmc_EODWFRatio Test_hmc_EOWilsonFermionGauge Test_hmc_EOWilsonRatio Test_hmc_WilsonFermionGauge Test_hmc_WilsonGauge Test_hmc_WilsonRatio Test_lie_generators Test_main Test_multishift_sqrt Test_nersc_io Test_partfrac_force Test_quenched_update Test_remez Test_rhmc_EOWilson1p1 Test_rhmc_EOWilsonRatio Test_rhmc_Wilson1p1 Test_rhmc_WilsonRatio Test_rng Test_rng_fixed Test_serialisation Test_simd Test_stencil Test_wilson_cg_prec Test_wilson_cg_schur Test_wilson_cg_unprec Test_wilson_cr_unprec Test_wilson_even_odd Test_wilson_force Test_wilson_force_phiMdagMphi Test_wilson_force_phiMphi Test_synthetic_lanczos
|
||||
|
||||
|
||||
Test_GaugeAction_SOURCES=Test_GaugeAction.cc
|
||||
@ -98,8 +98,8 @@ Test_gparity_SOURCES=Test_gparity.cc
|
||||
Test_gparity_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_gpwilson_even_odd_SOURCES=Test_gpwilson_even_odd.cc
|
||||
Test_gpwilson_even_odd_LDADD=-lGrid
|
||||
#Test_gpwilson_even_odd_SOURCES=Test_gpwilson_even_odd.cc
|
||||
#Test_gpwilson_even_odd_LDADD=-lGrid
|
||||
|
||||
|
||||
Test_hmc_EODWFRatio_SOURCES=Test_hmc_EODWFRatio.cc
|
||||
|
@ -57,5 +57,21 @@ int main (int argc, char ** argv)
|
||||
ChebyStep.csv(of);
|
||||
}
|
||||
|
||||
lo=-8;
|
||||
hi=8;
|
||||
Chebyshev<LatticeFermion> ChebyIndefInv(lo,hi,40,InverseApproximation);
|
||||
{
|
||||
std::ofstream of("chebyindefinv");
|
||||
ChebyIndefInv.csv(of);
|
||||
}
|
||||
|
||||
lo=0;
|
||||
hi=64;
|
||||
Chebyshev<LatticeFermion> ChebyNE(lo,hi,40,InverseApproximation);
|
||||
{
|
||||
std::ofstream of("chebyNE");
|
||||
ChebyNE.csv(of);
|
||||
}
|
||||
|
||||
Grid_finalize();
|
||||
}
|
||||
|
@ -1,36 +1,35 @@
|
||||
#include <Grid.h>
|
||||
|
||||
namespace Grid {
|
||||
|
||||
class myclass {
|
||||
public:
|
||||
|
||||
GRID_DECL_CLASS_MEMBERS(myclass,
|
||||
int, x,
|
||||
double, y,
|
||||
bool , b,
|
||||
std::string, name,
|
||||
std::vector<double>, array,
|
||||
std::vector<std::vector<double> >, twodimarray,
|
||||
);
|
||||
|
||||
myclass(){}
|
||||
myclass(int i) : array(4,5.1), twodimarray(3,std::vector<double>(2,1.23456)) {
|
||||
x=i;
|
||||
y=2*i;
|
||||
b=true;
|
||||
name="bother said pooh";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class myclass: Serializable {
|
||||
public:
|
||||
|
||||
GRID_DECL_CLASS_MEMBERS(myclass,
|
||||
int, x,
|
||||
double, y,
|
||||
bool , b,
|
||||
std::string, name,
|
||||
std::vector<double>, array,
|
||||
std::vector<std::vector<double>>, twodimarray,
|
||||
);
|
||||
|
||||
myclass() {}
|
||||
myclass(int i)
|
||||
: array(4,5.1), twodimarray(3,std::vector<double>(2,1.23456))
|
||||
{
|
||||
x=i;
|
||||
y=2*i;
|
||||
b=true;
|
||||
name="bother said pooh";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int16_t i16 = 1;
|
||||
int16_t i16 = 1;
|
||||
uint16_t u16 = 2;
|
||||
int32_t i32 = 3;
|
||||
int32_t i32 = 3;
|
||||
uint32_t u32 = 4;
|
||||
int64_t i64 = 5;
|
||||
int64_t i64 = 5;
|
||||
uint64_t u64 = 6;
|
||||
float f = M_PI;
|
||||
double d = 2*M_PI;
|
||||
@ -41,8 +40,9 @@ using namespace Grid;
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
{
|
||||
XMLWriter WR("bother.xml");
|
||||
|
||||
XmlWriter WR("bother.xml");
|
||||
|
||||
// test basic type writing
|
||||
push(WR,"BasicTypes");
|
||||
write(WR,std::string("i16"),i16);
|
||||
write(WR,"u16",u16);
|
||||
@ -54,40 +54,54 @@ int main(int argc,char **argv)
|
||||
write(WR,"d",d);
|
||||
write(WR,"b",b);
|
||||
pop(WR);
|
||||
|
||||
|
||||
// test serializable class writing
|
||||
myclass obj(1234); // non-trivial constructor
|
||||
write(WR,"obj",obj);
|
||||
|
||||
WR.write("obj2", obj);
|
||||
|
||||
std::vector<myclass> vec;
|
||||
vec.push_back(myclass(1234));
|
||||
vec.push_back(myclass(5678));
|
||||
vec.push_back(myclass(3838));
|
||||
write(WR, "objvec", vec);
|
||||
};
|
||||
|
||||
XMLReader RD("bother.xml");
|
||||
|
||||
myclass copy1;
|
||||
myclass copy2;
|
||||
myclass copy3;
|
||||
|
||||
read(RD,"obj",copy1);
|
||||
std::cout << "Loaded " << copy1<<std::endl;
|
||||
|
||||
|
||||
// read tests
|
||||
myclass copy1, copy2, copy3;
|
||||
std::vector<myclass> veccopy1, veccopy2, veccopy3;
|
||||
//// XML
|
||||
{
|
||||
XmlReader RD("bother.xml");
|
||||
read(RD,"obj",copy1);
|
||||
read(RD,"objvec", veccopy1);
|
||||
std::cout << "Loaded (XML) -----------------" << std::endl;
|
||||
std::cout << copy1 << std::endl << veccopy1 << std::endl;
|
||||
}
|
||||
//// binary
|
||||
{
|
||||
BinaryWriter BWR("bother.bin");
|
||||
write(BWR,"discard",copy1 );
|
||||
write(BWR,"discard",veccopy1 );
|
||||
}
|
||||
{
|
||||
{
|
||||
BinaryReader BRD("bother.bin");
|
||||
read (BRD,"discard",copy2 );
|
||||
std::cout<<copy2<<std::endl;
|
||||
read (BRD,"discard",veccopy2 );
|
||||
std::cout << "Loaded (bin) -----------------" << std::endl;
|
||||
std::cout << copy2 << std::endl << veccopy2 << std::endl;
|
||||
}
|
||||
|
||||
|
||||
//// text
|
||||
{
|
||||
TextWriter TWR("bother.txt");
|
||||
write(TWR,"discard",copy1 );
|
||||
write(TWR,"discard",veccopy1 );
|
||||
}
|
||||
{
|
||||
{
|
||||
TextReader TRD("bother.txt");
|
||||
read (TRD,"discard",copy3 );
|
||||
std::cout<<copy3<<std::endl;
|
||||
read (TRD,"discard",veccopy3 );
|
||||
std::cout << "Loaded (txt) -----------------" << std::endl;
|
||||
std::cout << copy3 << std::endl << veccopy3 << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ int main (int argc, char ** argv)
|
||||
}
|
||||
*/
|
||||
|
||||
typedef CartesianStencil<vobj,vobj,SimpleCompressor<vobj> > Stencil;
|
||||
for(int dir=0;dir<4;dir++){
|
||||
for(int disp=0;disp<Fine._fdimensions[dir];disp++){
|
||||
|
||||
@ -61,7 +62,11 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> directions(npoint,dir);
|
||||
std::vector<int> displacements(npoint,disp);
|
||||
|
||||
<<<<<<< HEAD
|
||||
CartesianStencil<vobj,vobj,SimpleCompressor<vobj> > myStencil(&Fine,npoint,0,directions,displacements);
|
||||
=======
|
||||
Stencil myStencil(&Fine,npoint,0,directions,displacements);
|
||||
>>>>>>> bc4b2528835e646fab1b186506b4740d97b02243
|
||||
|
||||
std::vector<int> ocoor(4);
|
||||
for(int o=0;o<Fine.oSites();o++){
|
||||
@ -142,8 +147,8 @@ int main (int argc, char ** argv)
|
||||
std::vector<int> directions(npoint,dir);
|
||||
std::vector<int> displacements(npoint,disp);
|
||||
|
||||
CartesianStencil<vobj,vobj,SimpleCompressor<vobj> > EStencil(&rbFine,npoint,Even,directions,displacements);
|
||||
CartesianStencil<vobj,vobj,SimpleCompressor<vobj> > OStencil(&rbFine,npoint,Odd,directions,displacements);
|
||||
Stencil EStencil(&rbFine,npoint,Even,directions,displacements);
|
||||
Stencil OStencil(&rbFine,npoint,Odd,directions,displacements);
|
||||
|
||||
std::vector<int> ocoor(4);
|
||||
for(int o=0;o<Fine.oSites();o++){
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
|
||||
random(pRNG,scale);
|
||||
|
||||
scale = exp(-real(scale)*6.0);
|
||||
scale = exp(-real(scale)*3.0);
|
||||
std::cout << " True matrix \n"<< scale <<std::endl;
|
||||
}
|
||||
|
||||
@ -88,8 +88,7 @@ int main (int argc, char ** argv)
|
||||
RealD mu = 0.0;
|
||||
int order = 11;
|
||||
ChebyshevLanczos<LatticeComplex> Cheby(alpha,beta,mu,order);
|
||||
|
||||
std::ofstream file("pooh.dat");
|
||||
std::ofstream file("cheby.dat");
|
||||
Cheby.csv(file);
|
||||
|
||||
HermOpOperatorFunction<LatticeComplex> X;
|
||||
@ -114,9 +113,9 @@ int main (int argc, char ** argv)
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<RealD> eval(Nm);
|
||||
std::vector<LatticeComplex> evec(Nm,grid);
|
||||
ChebyIRL.calc(eval,evec,src, Nconv);
|
||||
// std::vector<RealD> eval(Nm);
|
||||
// std::vector<LatticeComplex> evec(Nm,grid);
|
||||
// ChebyIRL.calc(eval,evec,src, Nconv);
|
||||
}
|
||||
|
||||
Grid_finalize();
|
||||
|
Loading…
Reference in New Issue
Block a user