mirror of
https://github.com/paboyle/Grid.git
synced 2026-08-25 03:49:35 +01:00
Updates for thrust
This commit is contained in:
@@ -290,7 +290,7 @@ public:
|
|||||||
Msobj m;
|
Msobj m;
|
||||||
peekLocalSite(m, Adbg, myLcoor[ss]);
|
peekLocalSite(m, Adbg, myLcoor[ss]);
|
||||||
ComplexD *md = (ComplexD *)&m;
|
ComplexD *md = (ComplexD *)&m;
|
||||||
for(int i=0; i<nbasis*nbasis; i++) pk += std::norm(md[i]);
|
for(int i=0; i<nbasis*nbasis; i++) pk += md[i].real()*md[i].real() + md[i].imag()*md[i].imag();
|
||||||
}
|
}
|
||||||
RealD gpk = pk;
|
RealD gpk = pk;
|
||||||
grid->GlobalSumVector(&gpk, 1);
|
grid->GlobalSumVector(&gpk, 1);
|
||||||
|
|||||||
@@ -313,10 +313,14 @@ public:
|
|||||||
uint64_t len = (uint64_t)X.rows*w;
|
uint64_t len = (uint64_t)X.rows*w;
|
||||||
std::vector<ComplexD> h(len);
|
std::vector<ComplexD> h(len);
|
||||||
acceleratorCopyFromDevice(X.ColumnWindow(col0), &h[0], len*sizeof(ComplexD));
|
acceleratorCopyFromDevice(X.ColumnWindow(col0), &h[0], len*sizeof(ComplexD));
|
||||||
|
// Member real()/imag(): portable across std::complex (CPU) and
|
||||||
|
// thrust::complex (HIP), where std::norm does not resolve.
|
||||||
double s = 0.0;
|
double s = 0.0;
|
||||||
for(uint64_t i=0; i<len; i++)
|
for(uint64_t i=0; i<len; i++)
|
||||||
{
|
{
|
||||||
s += std::norm(h[i]);
|
double re = h[i].real();
|
||||||
|
double im = h[i].imag();
|
||||||
|
s += re*re + im*im;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@@ -366,9 +370,11 @@ public:
|
|||||||
double mx = 0.0;
|
double mx = 0.0;
|
||||||
for(uint64_t i=0; i<len; i++)
|
for(uint64_t i=0; i<len; i++)
|
||||||
{
|
{
|
||||||
mx = std::max(mx, std::abs(h[i]));
|
double re = h[i].real();
|
||||||
|
double im = h[i].imag();
|
||||||
|
mx = std::max(mx, re*re + im*im);
|
||||||
}
|
}
|
||||||
telLeafMaxInv = std::max(telLeafMaxInv, mx);
|
telLeafMaxInv = std::max(telLeafMaxInv, std::sqrt(mx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user