1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-06-13 12:47:05 +01:00

Merge branch 'master' into feature/scalar_adjointFT

This commit is contained in:
2017-05-12 10:41:39 +01:00
65 changed files with 637 additions and 149 deletions

9
lib/Grid_Eigen_Dense.h Normal file
View File

@ -0,0 +1,9 @@
#pragma once
#if defined __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <Grid/Eigen/Dense>
#if defined __GNUC__
#pragma GCC diagnostic pop
#endif

View File

@ -135,8 +135,6 @@ class ConjugateGradient : public OperatorFunction<Field> {
Linop.HermOpAndNorm(psi, mmp, d, qq);
p = mmp - src;
RealD mmpnorm = sqrt(norm2(mmp));
RealD psinorm = sqrt(norm2(psi));
RealD srcnorm = sqrt(norm2(src));
RealD resnorm = sqrt(norm2(p));
RealD true_residual = resnorm / srcnorm;

View File

@ -28,7 +28,7 @@ SOFTWARE.
#ifndef NLOHMANN_JSON_HPP
#define NLOHMANN_JSON_HPP
#include <Grid/DisableWarnings.h>
#include <algorithm> // all_of, for_each, transform
#include <array> // array
#include <cassert> // assert

View File

@ -22,7 +22,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
#ifndef GRID_LATTICE_REDUCTION_H
#define GRID_LATTICE_REDUCTION_H
#include <Grid/Eigen/Dense>
#include <Grid/Grid_Eigen_Dense.h>
namespace Grid {
#ifdef GRID_WARN_SUBOPTIMAL

View File

@ -158,7 +158,7 @@ namespace Grid {
#ifdef RNG_SITMO
typedef sitmo::prng_engine RngEngine;
typedef uint64_t RngStateType;
static const int RngStateCount = 4;
static const int RngStateCount = 13;
#endif
std::vector<RngEngine> _generators;

View File

@ -30,6 +30,7 @@ directory
*************************************************************************************/
/* END LEGAL */
#include <Grid/GridCore.h>
#include <Grid/util/CompilerCompatible.h>
#include <cxxabi.h>
#include <memory>

View File

@ -205,13 +205,14 @@ public:
void Stop(void) {
count=0;
cycles=0;
size_t ign;
#ifdef __linux__
ssize_t ign;
if ( fd!= -1) {
::ioctl(fd, PERF_EVENT_IOC_DISABLE, 0);
::ioctl(cyclefd, PERF_EVENT_IOC_DISABLE, 0);
ign=::read(fd, &count, sizeof(long long));
ign=::read(cyclefd, &cycles, sizeof(long long));
ign+=::read(cyclefd, &cycles, sizeof(long long));
assert(ign=2*sizeof(long long));
}
elapsed = cyclecount() - begin;
#else

View File

@ -29,7 +29,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
*************************************************************************************/
/* END LEGAL */
#include <Grid/Eigen/Dense>
#include <Grid/Grid_Eigen_Dense.h>
#include <Grid/qcd/action/fermion/FermionCore.h>
#include <Grid/qcd/action/fermion/CayleyFermion5D.h>

View File

@ -29,7 +29,7 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
*************************************************************************************/
/* END LEGAL */
#include <Grid/Eigen/Dense>
#include <Grid/Grid_Eigen_Dense.h>
#include <Grid/qcd/action/fermion/FermionCore.h>
#include <Grid/qcd/action/fermion/CayleyFermion5D.h>

View File

@ -220,20 +220,32 @@ namespace QCD {
inline void DoubleStore(GridBase *GaugeGrid,
DoubledGaugeField &Uds,
const GaugeField &Umu) {
const GaugeField &Umu)
{
typedef typename Simd::scalar_type scalar_type;
conformable(Uds._grid, GaugeGrid);
conformable(Umu._grid, GaugeGrid);
GaugeLinkField U(GaugeGrid);
GaugeLinkField tmp(GaugeGrid);
Lattice<iScalar<vInteger> > coor(GaugeGrid);
for (int mu = 0; mu < Nd; mu++) {
LatticeCoordinate(coor, mu);
auto pha = Params.boundary_phases[mu];
scalar_type phase( real(pha),imag(pha) );
int Lmu = GaugeGrid->GlobalDimensions()[mu] - 1;
LatticeCoordinate(coor, mu);
U = PeekIndex<LorentzIndex>(Umu, mu);
tmp = where(coor == Lmu, Params.boundary_phases[mu] * U, U);
tmp = where(coor == Lmu, phase * U, U);
PokeIndex<LorentzIndex>(Uds, tmp, mu);
U = adj(Cshift(U, mu, -1));
U = where(coor == 0, Params.boundary_phases[mu] * U, U);
U = where(coor == 0, conjugate(phase) * U, U);
PokeIndex<LorentzIndex>(Uds, U, mu + 4);
}
}
@ -251,11 +263,11 @@ namespace QCD {
tmp = zero;
parallel_for(int sss=0;sss<tmp._grid->oSites();sss++){
int sU=sss;
for(int s=0;s<Ls;s++){
int sF = s+Ls*sU;
tmp[sU] = tmp[sU]+ traceIndex<SpinIndex>(outerProduct(Btilde[sF],Atilde[sF])); // ordering here
}
int sU=sss;
for(int s=0;s<Ls;s++){
int sF = s+Ls*sU;
tmp[sU] = tmp[sU]+ traceIndex<SpinIndex>(outerProduct(Btilde[sF],Atilde[sF])); // ordering here
}
}
PokeIndex<LorentzIndex>(mat,tmp,mu);
@ -587,7 +599,7 @@ class GparityWilsonImpl : public ConjugateGaugeImpl<GaugeImplTypes<S, Nrepresent
// use lorentz for flavour as hack.
auto tmp = TraceIndex<SpinIndex>(outerProduct(Btilde, A));
parallel_for(auto ss = tmp.begin(); ss < tmp.end(); ss++) {
link[ss]() = tmp[ss](0, 0) - conjugate(tmp[ss](1, 1));
link[ss]() = tmp[ss](0, 0) + conjugate(tmp[ss](1, 1));
}
PokeIndex<LorentzIndex>(mat, link, mu);
return;

View File

@ -40,7 +40,6 @@ JSONWriter::~JSONWriter(void)
delete_comma();
ss_ << "}";
cout << ss_.str() << endl;
// write prettified JSON to file
std::ofstream os(fileName_);
os << std::setw(2) << json::parse(ss_.str()) << std::endl;
@ -95,7 +94,7 @@ JSONReader::JSONReader(const string &fileName)
// test
// serialize to standard output
std::cout << "JSONReader::JSONReader : " << jobject_ << endl;
//std::cout << "JSONReader::JSONReader : " << jobject_ << endl;
jcur_ = jobject_;
}
@ -113,7 +112,7 @@ bool JSONReader::push(const string &s)
std::cout << "out of range: " << e.what() << '\n';
return false;
}
cout << "JSONReader::push : " << s << " : "<< jcur_ << endl;
//cout << "JSONReader::push : " << s << " : "<< jcur_ << endl;
}
else
{
@ -134,7 +133,7 @@ void JSONReader::pop(void)
else
do_pop.pop_back();
cout << "JSONReader::pop : " << jcur_ << endl;
//cout << "JSONReader::pop : " << jcur_ << endl;
}
bool JSONReader::nextElement(const std::string &s)
@ -157,14 +156,14 @@ bool JSONReader::nextElement(const std::string &s)
template <>
void JSONReader::readDefault(const string &s, string &output)
{
cout << "JSONReader::readDefault(string) : " << s<< " " << jcur_ << endl;
//cout << "JSONReader::readDefault(string) : " << s<< " " << jcur_ << endl;
if (s.size()){
std::cout << "String: "<< jcur_[s] << std::endl;
//std::cout << "String: "<< jcur_[s] << std::endl;
output = jcur_[s];
}
else
{
std::cout << "String: "<< jcur_ << std::endl;
//std::cout << "String: "<< jcur_ << std::endl;
output = jcur_;
}
}

View File

@ -1,6 +1,6 @@
/*************************************************************************************
Grid physics library, www.github.com/paboyle/Grid
Grid physics library, www.github.com/paboyle/Grid
Source file: ./lib/serialisation/JSON_IO.h
@ -43,10 +43,10 @@ using json = nlohmann::json;
namespace Grid
{
class JSONWriter: public Writer<JSONWriter>
{
public:
JSONWriter(const std::string &fileName);
virtual ~JSONWriter(void);
@ -55,6 +55,8 @@ namespace Grid
template <typename U>
void writeDefault(const std::string &s, const U &x);
template <typename U>
void writeDefault(const std::string &s, const std::complex<U> &x);
template <typename U>
void writeDefault(const std::string &s, const std::vector<U> &x);
template<std::size_t N>
@ -65,7 +67,7 @@ namespace Grid
std::string fileName_;
std::ostringstream ss_;
};
class JSONReader: public Reader<JSONReader>
{
public:
@ -77,6 +79,8 @@ namespace Grid
template <typename U>
void readDefault(const std::string &s, U &output);
template <typename U>
void readDefault(const std::string &s, std::complex<U> &output);
template <typename U>
void readDefault(const std::string &s, std::vector<U> &output);
private:
json jobject_; // main object
@ -97,11 +101,12 @@ namespace Grid
struct isWriter< JSONWriter > {
static const bool value = true;
};
// Writer template implementation ////////////////////////////////////////////
template <typename U>
void JSONWriter::writeDefault(const std::string &s, const U &x)
{
//std::cout << "JSONReader::writeDefault(U) : " << s << std::endl;
std::ostringstream os;
os << std::boolalpha << x;
if (s.size())
@ -110,9 +115,23 @@ namespace Grid
ss_ << os.str() << " ," ;
}
template <typename U>
void JSONWriter::writeDefault(const std::string &s, const std::complex<U> &x)
{
//std::cout << "JSONReader::writeDefault(complex) : " << s << std::endl;
std::ostringstream os;
os << "["<< std::boolalpha << x.real() << ", " << x.imag() << "]";
if (s.size())
ss_ << "\""<< s << "\" : " << os.str() << " ," ;
else
ss_ << os.str() << " ," ;
}
template <typename U>
void JSONWriter::writeDefault(const std::string &s, const std::vector<U> &x)
{
//std::cout << "JSONReader::writeDefault(vec U) : " << s << std::endl;
if (s.size())
ss_ << " \""<<s<<"\" : [";
else
@ -124,59 +143,77 @@ namespace Grid
delete_comma();
ss_<< "],";
}
template<std::size_t N>
void JSONWriter::writeDefault(const std::string &s, const char(&x)[N]){
//std::cout << "JSONReader::writeDefault(char U) : " << s << std::endl;
if (s.size())
ss_ << "\""<< s << "\" : \"" << x << "\" ," ;
else
ss_ << "\"" << x << "\" ," ;
ss_ << "\"" << x << "\" ," ;
}
// Reader template implementation ////////////////////////////////////////////
template <typename U>
void JSONReader::readDefault(const std::string &s, U &output)
{
std::cout << "JSONReader::readDefault(U) : " << s << " : "<< jcur_ << std::endl;
//std::cout << "JSONReader::readDefault(U) : " << s << " : "<< jcur_ << std::endl;
if (s.size()){
std::cout << "String: "<< jcur_[s] << std::endl;
//std::cout << "String: "<< jcur_[s] << std::endl;
output = jcur_[s];
}
else
{
std::cout << "String: "<< jcur_ << std::endl;
output = jcur_;
//std::cout << "String: "<< jcur_ << std::endl;
output = jcur_;
}
}
template <typename U>
void JSONReader::readDefault(const std::string &s, std::complex<U> &output)
{
U tmp1, tmp2;
//std::cout << "JSONReader::readDefault( complex U) : " << s << " : "<< jcur_ << std::endl;
json j = jcur_;
json::iterator it = j.begin();
jcur_ = *it;
read("", tmp1);
it++;
jcur_ = *it;
read("", tmp2);
output = std::complex<U>(tmp1,tmp2);
}
template <>
void JSONReader::readDefault(const std::string &s, std::string &output);
template <typename U>
void JSONReader::readDefault(const std::string &s, std::vector<U> &output)
{
std::string buf;
unsigned int i = 0;
std::cout << "JSONReader::readDefault(vec) : " << jcur_ << std::endl;
//std::cout << "JSONReader::readDefault(vec) : " << jcur_ << std::endl;
if (s.size())
push(s);
json j = jcur_;
for (json::iterator it = j.begin(); it != j.end(); ++it) {
jcur_ = *it;
std::cout << "Value: " << it.value() << "\n";
//std::cout << "Value: " << it.value() << "\n";
output.resize(i + 1);
read("", output[i++]);
}
jcur_ = j;
if (s.size())
pop();
}
}
#endif

View File

@ -327,6 +327,10 @@ class Grid_simd {
// provides support
///////////////////////////////////////
#if (__GNUC__ == 5 ) || ( ( __GNUC__ == 6 ) && __GNUC_MINOR__ < 3 )
#pragma GCC push_options
#pragma GCC optimize ("O0")
#endif
template <class functor>
friend inline Grid_simd SimdApply(const functor &func, const Grid_simd &v) {
Grid_simd ret;
@ -355,7 +359,9 @@ class Grid_simd {
ret.v = cx.v;
return ret;
}
#if (__GNUC__ == 5 ) || ( ( __GNUC__ == 6 ) && __GNUC_MINOR__ < 3 )
#pragma GCC pop_options
#endif
///////////////////////
// Exchange
// Al Ah , Bl Bh -> Al Bl Ah,Bh

2
lib/sitmo_rng/README Normal file
View File

@ -0,0 +1,2 @@
downloaded file from : http://www.sitmo.com/wp-content/uploads/2016/03/prng_engine.hpp
Unmodified beyond filename

View File

@ -106,7 +106,6 @@ class CartesianStencil { // Stencil runs along coordinate axes only; NO diagonal
public:
typedef CartesianCommunicator::CommsRequest_t CommsRequest_t;
typedef uint32_t StencilInteger;
typedef typename cobj::vector_type vector_type;
typedef typename cobj::scalar_type scalar_type;
typedef typename cobj::scalar_object scalar_object;

View File

@ -0,0 +1,56 @@
#pragma once
#if defined(__clang__)
#if __clang_major__ < 3
#error "This clang++ version is known to not work with Grid due to compiler bugs"
#endif
#if __clang_major__ == 3
#if __clang_minor__ < 5
#error "This clang++ version is known to not work with Grid due to compiler bugs"
#endif
#endif
// Intel compiler *ALSO* has __GNUC__ defined so must if/else GCC checks
#elif defined(__INTEL_COMPILER)
#if __INTEL_COMPILER < 1603
#error "This icpc version is known to not work with Grid due to compiler bugs"
#endif
#else
// This macro is annoying many other compilers just define __GNUC__ and claim GCC compat
// but this defeats the use of __GNUC__ to really detect G++
#if defined(__GNUC__)
#if __GNUC__ < 4
#error "g++ prior to version 4 is known to not work with Grid due to compiler bugs"
#endif
#if __GNUC__ == 4
#if __GNUC_MINOR__ != 9
#error "g++ 4.9 is the only gcc-4.x version known to work with Grid due to compiler bugs"
#endif
#endif
#if __GNUC__ == 5
#warning "g++ version 5 is known to not work with Grid due to compiler bugs under -O3 : ensure you run make check"
#endif
#if __GNUC__ == 6
#if __GNUC_MINOR__ < 3
#warning "This g++6.3 is the first recent g++ version known to work with Grid: ensure you run make check"
#endif
#endif
#else
#warning "Unknown compiler detected: cannot guarantee compatability since Grid tends to break compilers"
#warning "Ensure to run : make check"
#endif
#endif

View File

@ -48,6 +48,8 @@ Author: paboyle <paboyle@ph.ed.ac.uk>
#include <Grid/Grid.h>
#include <Grid/util/CompilerCompatible.h>
#include <fenv.h>
#ifdef __APPLE__
@ -229,10 +231,12 @@ void Grid_init(int *argc,char ***argv)
if( !GridCmdOptionExists(*argv,*argv+*argc,"--debug-stdout") ){
Grid_quiesce_nodes();
} else {
FILE *fp;
std::ostringstream fname;
fname<<"Grid.stdout.";
fname<<CartesianCommunicator::RankWorld();
freopen(fname.str().c_str(),"w",stdout);
fp=freopen(fname.str().c_str(),"w",stdout);
assert(fp!=(FILE *)NULL);
}
////////////////////////////////////