Grid 0.7.0
Lattice_crc.h
Go to the documentation of this file.
1/*************************************************************************************
2
3 Grid physics library, www.github.com/paboyle/Grid
4
5 Source file: ./lib/lattice/Lattice_crc.h
6
7 Copyright (C) 2021
8
9Author: Peter Boyle <paboyle@ph.ed.ac.uk>
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License along
22 with this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25 See the full license in the file "LICENSE" in the top level distribution directory
26*************************************************************************************/
27/* END LEGAL */
28#pragma once
29
31
32template<class vobj> void DumpSliceNorm(std::string s,const Lattice<vobj> &f,int mu=-1)
33{
34 auto ff = localNorm2(f);
35 if ( mu==-1 ) mu = f.Grid()->Nd()-1;
36 typedef typename vobj::tensor_reduced normtype;
37 typedef typename normtype::scalar_object scalar;
38 std::vector<scalar> sff;
39 sliceSum(ff,sff,mu);
40 for(int t=0;t<sff.size();t++){
41 std::cout << s<<" "<<t<<" "<<sff[t]<<std::endl;
42 }
43}
44
45template<class vobj> uint32_t crc(const Lattice<vobj> & buf)
46{
47 autoView( buf_v , buf, CpuRead);
48 return ::crc32(0L,(unsigned char *)&buf_v[0],(size_t)sizeof(vobj)*buf.oSites());
49}
50
51#define CRC(U) std::cerr << "FingerPrint "<<__FILE__ <<" "<< __LINE__ <<" "<< #U <<" "<<crc(U)<<std::endl;
52
54
55
void DumpSliceNorm(std::string s, const Lattice< vobj > &f, int mu=-1)
Definition Lattice_crc.h:32
uint32_t crc(const Lattice< vobj > &buf)
Definition Lattice_crc.h:45
auto localNorm2(const Lattice< vobj > &rhs) -> Lattice< typename vobj::tensor_reduced >
void sliceSum(const Lattice< vobj > &Data, std::vector< typename vobj::scalar_object > &result, int orthogdim)
#define autoView(l_v, l, mode)
@ CpuRead
#define NAMESPACE_BEGIN(A)
Definition Namespace.h:35
#define NAMESPACE_END(A)
Definition Namespace.h:36
int Nd(void) const
accelerator_inline uint64_t oSites(void) const
GridBase * Grid(void) const