Skip to content

Commit a0ccbb3

Browse files
committed
Merge branch 'develop' of https://github.com/paboyle/Grid into develop
2 parents 5eeabaa + 00d0d6d commit a0ccbb3

6 files changed

Lines changed: 113 additions & 13 deletions

File tree

Grid/lattice/Lattice_ET.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ GridUnopClass(UnaryTimesI, timesI(a));
350350
GridUnopClass(UnaryTimesMinusI, timesMinusI(a));
351351
GridUnopClass(UnaryAbs, abs(a));
352352
GridUnopClass(UnarySqrt, sqrt(a));
353-
GridUnopClass(UnaryRsqrt, rsqrt(a));
354353
GridUnopClass(UnarySin, sin(a));
355354
GridUnopClass(UnaryCos, cos(a));
356355
GridUnopClass(UnaryAsin, asin(a));
@@ -463,7 +462,6 @@ GRID_DEF_UNOP(timesMinusI, UnaryTimesMinusI);
463462
GRID_DEF_UNOP(abs, UnaryAbs); // abs overloaded in cmath C++98; DON'T do the
464463
// abs-fabs-dabs-labs thing
465464
GRID_DEF_UNOP(sqrt, UnarySqrt);
466-
GRID_DEF_UNOP(rsqrt, UnaryRsqrt);
467465
GRID_DEF_UNOP(sin, UnarySin);
468466
GRID_DEF_UNOP(cos, UnaryCos);
469467
GRID_DEF_UNOP(asin, UnaryAsin);

Grid/simd/Grid_vector_unops.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ accelerator_inline Grid_simd<S, V> sqrt(const Grid_simd<S, V> &r) {
125125
return SimdApply(SqrtRealFunctor<S>(), r);
126126
}
127127
template <class S, class V>
128-
accelerator_inline Grid_simd<S, V> rsqrt(const Grid_simd<S, V> &r) {
129-
return SimdApply(RSqrtRealFunctor<S>(), r);
130-
}
131-
template <class Scalar>
132-
accelerator_inline Scalar rsqrt(const Scalar &r) {
133-
return (RSqrtRealFunctor<Scalar>(), r);
134-
}
135-
template <class S, class V>
136128
accelerator_inline Grid_simd<S, V> cos(const Grid_simd<S, V> &r) {
137129
return SimdApply(CosRealFunctor<S>(), r);
138130
}

Grid/tensors/Tensor_Ta.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,22 @@ accelerator_inline iMatrix<vtype,N> ProjectOnGroup(const iMatrix<vtype,N> &arg)
9292
{
9393
// need a check for the group type?
9494
iMatrix<vtype,N> ret(arg);
95+
vtype rnrm;
9596
vtype nrm;
9697
vtype inner;
9798
for(int c1=0;c1<N;c1++){
99+
100+
// Normalises row c1
98101
zeroit(inner);
99102
for(int c2=0;c2<N;c2++)
100103
inner += innerProduct(ret._internal[c1][c2],ret._internal[c1][c2]);
101104

102-
nrm = rsqrt(inner);
105+
nrm = sqrt(inner);
106+
nrm = 1.0/nrm;
103107
for(int c2=0;c2<N;c2++)
104108
ret._internal[c1][c2]*= nrm;
105109

110+
// Remove c1 from rows c1+1...N-1
106111
for (int b=c1+1; b<N; ++b){
107112
decltype(ret._internal[b][b]*ret._internal[b][b]) pr;
108113
zeroit(pr);

Grid/tensors/Tensor_unary.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ NAMESPACE_BEGIN(Grid);
8484
}
8585

8686
UNARY(sqrt);
87-
UNARY(rsqrt);
8887
UNARY(sin);
8988
UNARY(cos);
9089
UNARY(asin);

Grid/threads/Accelerator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ inline void *acceleratorAllocDevice(size_t bytes)
328328
return ptr;
329329
};
330330

331-
inline void acceleratorFreeShared(void *ptr){ free(ptr);};
331+
inline void acceleratorFreeShared(void *ptr){ hipFree(ptr);};
332332
inline void acceleratorFreeDevice(void *ptr){ hipFree(ptr);};
333333
inline void acceleratorCopyToDevice(void *from,void *to,size_t bytes) { hipMemcpy(to,from,bytes, hipMemcpyHostToDevice);}
334334
inline void acceleratorCopyFromDevice(void *from,void *to,size_t bytes){ hipMemcpy(to,from,bytes, hipMemcpyDeviceToHost);}

tests/core/Test_unary.cc

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*************************************************************************************
2+
3+
Grid physics library, www.github.com/paboyle/Grid
4+
5+
Source file: ./tests/Test_quenched_update.cc
6+
7+
Copyright (C) 2015
8+
9+
Author: Azusa Yamaguchi <ayamaguc@staffmail.ed.ac.uk>
10+
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
11+
12+
This program is free software; you can redistribute it and/or modify
13+
it under the terms of the GNU General Public License as published by
14+
the Free Software Foundation; either version 2 of the License, or
15+
(at your option) any later version.
16+
17+
This program is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU General Public License for more details.
21+
22+
You should have received a copy of the GNU General Public License along
23+
with this program; if not, write to the Free Software Foundation, Inc.,
24+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25+
26+
See the full license in the file "LICENSE" in the top level distribution directory
27+
*************************************************************************************/
28+
/* END LEGAL */
29+
#include <Grid/Grid.h>
30+
31+
using namespace std;
32+
using namespace Grid;
33+
;
34+
35+
int main (int argc, char ** argv)
36+
{
37+
Grid_init(&argc,&argv);
38+
39+
std::vector<int> latt({8,8,8,8});
40+
GridCartesian * grid = SpaceTimeGrid::makeFourDimGrid(latt,
41+
GridDefaultSimd(Nd,vComplexD::Nsimd()),
42+
GridDefaultMpi());
43+
44+
GridCartesian * gridF = SpaceTimeGrid::makeFourDimGrid(latt,
45+
GridDefaultSimd(Nd,vComplexF::Nsimd()),
46+
GridDefaultMpi());
47+
48+
49+
///////////////////////////////
50+
// Configuration of known size
51+
///////////////////////////////
52+
LatticeColourMatrixD ident(grid);
53+
LatticeColourMatrixD U(grid);
54+
LatticeColourMatrixD tmp(grid);
55+
LatticeColourMatrixD org(grid);
56+
LatticeColourMatrixF UF(gridF);
57+
58+
LatticeGaugeField Umu(grid);
59+
60+
ident =1.0;
61+
62+
// RNG set up for test
63+
std::vector<int> pseeds({1,2,3,4,5}); // once I caught a fish alive
64+
std::vector<int> sseeds({6,7,8,9,10});// then i let it go again
65+
GridParallelRNG pRNG(grid); pRNG.SeedFixedIntegers(pseeds);
66+
GridSerialRNG sRNG; sRNG.SeedFixedIntegers(sseeds);
67+
68+
SU<Nc>::HotConfiguration(pRNG,Umu);
69+
70+
U = PeekIndex<LorentzIndex>(Umu,0);
71+
org=U;
72+
73+
74+
tmp= U*adj(U) - ident ;
75+
RealD Def1 = norm2( tmp );
76+
std::cout << " Defect1 "<<Def1<<std::endl;
77+
78+
tmp = U - org;
79+
std::cout << "Diff1 "<<norm2(tmp)<<std::endl;
80+
precisionChange(UF,U);
81+
precisionChange(U,UF);
82+
83+
tmp= U*adj(U) - ident ;
84+
RealD Def2 = norm2( tmp );
85+
std::cout << " Defect2 "<<Def2<<std::endl;
86+
87+
tmp = U - org;
88+
std::cout << "Diff2 "<<norm2(tmp)<<std::endl;
89+
90+
U = ProjectOnGroup(U);
91+
92+
tmp= U*adj(U) - ident ;
93+
RealD Def3 = norm2( tmp);
94+
std::cout << " Defect3 "<<Def3<<std::endl;
95+
96+
97+
tmp = U - org;
98+
std::cout << "Diff3 "<<norm2(tmp)<<std::endl;
99+
100+
101+
Grid_finalize();
102+
}
103+
104+
105+
106+

0 commit comments

Comments
 (0)