Skip to content

Commit

Permalink
oneAPI Beta 8 (AMReX-Codes#1243)
Browse files Browse the repository at this point in the history
In beta8, C++11 user defined literals are broken because of the use of long
double.  We have implemented a workaround by overloading operator "" _rt
with `const char*` argument and our own `atof`.  But, because Clang does not
evaluate the new version of the operator at compile time, we now avoid using
`_rt` in AMReX.  In the long term, we may have to remove it entirely if the
long double issue is not resolved in DPC++.

With the workaround, we can enable the DPC++ CI test again.
  • Loading branch information
WeiqunZhang authored Aug 10, 2020
1 parent e3f25aa commit 63d3865
Show file tree
Hide file tree
Showing 49 changed files with 1,324 additions and 1,249 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,7 @@ jobs:
-DCUDA_ARCH=6.0
make -j 2 tutorials
# Build libamrex and all tutorials with DPC++
# broken in beta08
# https://github.com/intel/llvm/issues/2187
tutorials-dpcpp:
if: false
name: DPCPP@PubBeta GFortran@7.5 C++17 [tutorials]
runs-on: ubuntu-latest
steps:
Expand All @@ -169,7 +165,7 @@ jobs:
- name: Build & Install
run: |
set +e
source /opt/intel/inteloneapi/setvars.sh
source /opt/intel/oneapi/setvars.sh
set -e
mkdir build
cd build
Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_Amr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3108,7 +3108,7 @@ Amr::printGridInfo (std::ostream& os,
int numgrid = bs.size();
Long ncells = amr_level[lev]->countCells();
double ntot = Geom(lev).Domain().d_numPts();
Real frac = 100.0_rt*(Real(ncells) / ntot);
Real frac = Real(100.0)*(Real(ncells) / ntot);
const DistributionMapping& map = amr_level[lev]->get_new_data(0).DistributionMap();

os << " Level "
Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_extrapolater_2D_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx,
// set all crse cells to zero first
for (int j = lo.y-1; j <= hi.y+1; ++j) {
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = 0.0_rt;
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Src/Amr/AMReX_extrapolater_3D_K.H
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ amrex_first_order_extrap_cpu(amrex::Box const& bx,
for (int k = lo.z-1; k <= hi.z+1; ++k) {
for (int j = lo.y-1; j <= hi.y+1; ++j) {
for (int i = lo.x-1; i <= hi.x+1; ++i) {
if (mask(i,j,k) == crsecell) data(i,j,k,n) = 0.0_rt;
if (mask(i,j,k) == crsecell) data(i,j,k,n) = Real(0.0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Src/AmrCore/AMReX_AmrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ AmrCore::printGridSummary (std::ostream& os, int min_lev, int max_lev) const noe
int numgrid = bs.size();
Long ncells = bs.numPts();
double ntot = Geom(lev).Domain().d_numPts();
Real frac = 100.0_rt*(Real(ncells) / ntot);
Real frac = Real(100.0)*(Real(ncells) / ntot);

os << " Level "
<< lev
Expand Down
6 changes: 3 additions & 3 deletions Src/AmrCore/AMReX_ErrorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,9 @@ operator << (std::ostream& os,
amrex::ParallelFor(bx,
[=] AMREX_GPU_HOST_DEVICE (int i, int j, int k) noexcept
{
GpuArray<Real,AMREX_SPACEDIM> pt = {{AMREX_D_DECL(plo[0]+(Real(i)+0.5_rt)*dx[0],
plo[1]+(Real(j)+0.5_rt)*dx[1],
plo[2]+(Real(k)+0.5_rt)*dx[2])}};
GpuArray<Real,AMREX_SPACEDIM> pt = {{AMREX_D_DECL(plo[0]+(Real(i)+Real(0.5))*dx[0],
plo[1]+(Real(j)+Real(0.5))*dx[1],
plo[2]+(Real(k)+Real(0.5))*dx[2])}};
if (tag_rb.contains(pt.data())) {
tag(i,j,k) = tagval;
}
Expand Down
54 changes: 27 additions & 27 deletions Src/AmrCore/AMReX_Interp_1D_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ ccinterp_compute_voff (Box const& cbx, IntVect const& ratio, Geometry const& cge
const int ic = amrex::coarsen(i, ratio[0]);
const int ii = i - flo.x;
const int iic = ic - clo.x;
const Real fcen = 0.5_rt*(fvc[ii ]+fvc[ii +1]);
const Real ccen = 0.5_rt*(cvc[iic]+cvc[iic+1]);
const Real fcen = Real(0.5)*(fvc[ii ]+fvc[ii +1]);
const Real ccen = Real(0.5)*(cvc[iic]+cvc[iic+1]);
xoff[ii] = (fcen-ccen)/(cvc[iic+1]-cvc[iic]);
}

Expand All @@ -51,28 +51,28 @@ compute_slopes (const Dim3& lo, const Dim3& hi,
{
AMREX_PRAGMA_SIMD
for (int i = lo.x; i <= hi.x; ++i) {
slopes(i,0,0,ns) = 0.5_rt*(u(i+1,0,0,nu)-u(i-1,0,0,nu));
slopes(i,0,0,ns) = Real(0.5)*(u(i+1,0,0,nu)-u(i-1,0,0,nu));
}

if (lo.x == slo.x && (bc.lo(0) == BCType::ext_dir || bc.lo(0) == BCType::hoextrap))
{
const int i = slo.x;
if (shi.x-slo.x >= 1) {
slopes(i,0,0,ns) = -(16._rt/15._rt)*u(i-1,0,0,nu) + 0.5_rt*u(i,0,0,nu)
+ (2._rt/3._rt)*u(i+1,0,0,nu) - 0.1_rt*u(i+2,0,0,nu);
slopes(i,0,0,ns) = -Real(16./15.)*u(i-1,0,0,nu) + Real(0.5)*u(i,0,0,nu)
+ Real(2./3.)*u(i+1,0,0,nu) - Real(0.1)*u(i+2,0,0,nu);
} else {
slopes(i,0,0,ns) = 0.25_rt*(u(i+1,0,0,nu)+5._rt*u(i,0,0,nu)-6._rt*u(i-1,0,0,nu));
slopes(i,0,0,ns) = Real(0.25)*(u(i+1,0,0,nu)+Real(5.)*u(i,0,0,nu)-Real(6.)*u(i-1,0,0,nu));
}
}

if (hi.x == shi.x && (bc.hi(0) == BCType::ext_dir || bc.hi(0) == BCType::hoextrap))
{
const int i = shi.x;
if (shi.x-slo.x >= 1) {
slopes(i,0,0,ns) = (16._rt/15._rt)*u(i+1,0,0,nu) - 0.5_rt*u(i,0,0,nu)
- (2._rt/3._rt)*u(i-1,0,0,nu) + 0.1_rt*u(i-2,0,0,nu);
slopes(i,0,0,ns) = Real(16./15.)*u(i+1,0,0,nu) - Real(0.5)*u(i,0,0,nu)
- Real(2./3.)*u(i-1,0,0,nu) + Real(0.1)*u(i-2,0,0,nu);
} else {
slopes(i,0,0,ns) = -0.25_rt*(u(i-1,0,0,nu)+5._rt*u(i,0,0,nu)-6._rt*u(i+1,0,0,nu));
slopes(i,0,0,ns) = -Real(0.25)*(u(i-1,0,0,nu)+Real(5.)*u(i,0,0,nu)-Real(6.)*u(i+1,0,0,nu));
}
}
}
Expand All @@ -94,7 +94,7 @@ cellconslin_slopes_linlim (Box const& bx, Array4<Real> const& slopes,

AMREX_PRAGMA_SIMD
for (int i = lo.x; i <= hi.x; ++i) {
sf(i,0,0) = 1.0_rt;
sf(i,0,0) = Real(1.);
}

for (int n = 0; n < ncomp; ++n)
Expand All @@ -105,14 +105,14 @@ cellconslin_slopes_linlim (Box const& bx, Array4<Real> const& slopes,
AMREX_PRAGMA_SIMD
for (int i = lo.x; i <= hi.x; ++i) {
Real cen = slopes(i,0,0,n);
Real forw = 2.0_rt*(u(i+1,0,0,nu)-u(i ,0,0,nu));
Real back = 2.0_rt*(u(i ,0,0,nu)-u(i-1,0,0,nu));
Real slp = (forw*back >= 0.0_rt) ? amrex::min(amrex::Math::abs(forw),amrex::Math::abs(back)) : 0.0_rt;
slopes(i,0,0,n) = amrex::Math::copysign(1.0_rt,cen)*amrex::min(slp,amrex::Math::abs(cen));
if (cen != 0.0_rt) {
Real forw = Real(2.)*(u(i+1,0,0,nu)-u(i ,0,0,nu));
Real back = Real(2.)*(u(i ,0,0,nu)-u(i-1,0,0,nu));
Real slp = (forw*back >= Real(0.)) ? amrex::min(amrex::Math::abs(forw),amrex::Math::abs(back)) : Real(0.);
slopes(i,0,0,n) = amrex::Math::copysign(Real(1.),cen)*amrex::min(slp,amrex::Math::abs(cen));
if (cen != Real(0.)) {
sf(i,0,0) = amrex::min(sf(i,0,0), slopes(i,0,0,n)/cen);
} else {
sf(i,0,0) = 0.0_rt;
sf(i,0,0) = Real(0.);
}
}
}
Expand Down Expand Up @@ -181,10 +181,10 @@ cellconslin_slopes_mclim (Box const& bx, Array4<Real> const& slopes,
AMREX_PRAGMA_SIMD
for (int i = lo.x; i <= hi.x; ++i) {
Real cen = slopes(i,0,0,n);
Real forw = 2.0_rt*(u(i+1,0,0,nu)-u(i ,0,0,nu));
Real back = 2.0_rt*(u(i ,0,0,nu)-u(i-1,0,0,nu));
Real slp = (forw*back >= 0.0_rt) ? amrex::min(amrex::Math::abs(forw),amrex::Math::abs(back)) : 0.0_rt;
slopes(i,0,0,n) = amrex::Math::copysign(1.0_rt,cen)*amrex::min(slp,amrex::Math::abs(cen));
Real forw = Real(2.)*(u(i+1,0,0,nu)-u(i ,0,0,nu));
Real back = Real(2.)*(u(i ,0,0,nu)-u(i-1,0,0,nu));
Real slp = (forw*back >= Real(0.)) ? amrex::min(amrex::Math::abs(forw),amrex::Math::abs(back)) : Real(0.);
slopes(i,0,0,n) = amrex::Math::copysign(Real(1.),cen)*amrex::min(slp,amrex::Math::abs(cen));
}
}
}
Expand All @@ -208,12 +208,12 @@ cellconslin_fine_alpha (Box const& bx, Array4<Real> const& alpha,
const int ic = amrex::coarsen(i,ratio[0]);
const Real dummy_fine = xoff[i-vlo.x]*slopes(ic,0,0,n);

if (dummy_fine > mm(ic,0,0,n+ncomp) && dummy_fine != 0.0_rt) {
if (dummy_fine > mm(ic,0,0,n+ncomp) && dummy_fine != Real(0.)) {
alpha(i,0,0,n) = mm(ic,0,0,n+ncomp) / dummy_fine;
} else if (dummy_fine < mm(ic,0,0,n) && dummy_fine != 0.0_rt) {
} else if (dummy_fine < mm(ic,0,0,n) && dummy_fine != Real(0.)) {
alpha(i,0,0,n) = mm(ic,0,0,n) / dummy_fine;
} else {
alpha(i,0,0,n) = 1.0_rt;
alpha(i,0,0,n) = Real(1.);
}
}
}
Expand All @@ -230,7 +230,7 @@ cellconslin_slopes_mmlim (Box const& bx, Array4<Real> const& slopes,
for (int n = 0; n < ncomp; ++n) {
for (int i = lo.x; i <= hi.x; ++i) {
const int ii = i*ratio[0];
Real a = 1.0_rt;
Real a = Real(1.);
for (int ioff = 0; ioff < ratio[0]; ++ioff) {
a = amrex::min(a, alpha(ii+ioff,0,0,n));
}
Expand Down Expand Up @@ -265,7 +265,7 @@ nodebilin_slopes (Box const& bx, Array4<T> const& slope, Array4<T const> const&
const auto lo = amrex::lbound(bx);
const auto hi = amrex::ubound(bx);

const Real rx = 1.0_rt/ratio[0];
const Real rx = Real(1.)/ratio[0];

for (int n = 0; n < ncomp; ++n) {
AMREX_PRAGMA_SIMD
Expand Down Expand Up @@ -302,8 +302,8 @@ face_linear_interp_x (int i, int /*j*/, int /*k*/, int n, Array4<T> const& fine,
Array4<T const> const& crse, IntVect const& ratio) noexcept
{
int ii = amrex::coarsen(i,ratio[0]);
Real const w = static_cast<Real>(i-ii*ratio[0]) * (1.0_rt/ratio[0]);
fine(i,0,0,n) = (1.0_rt-w) * crse(ii,0,0,n) + w * crse(ii+1,0,0,n);
Real const w = static_cast<Real>(i-ii*ratio[0]) * (Real(1.)/ratio[0]);
fine(i,0,0,n) = (Real(1.)-w) * crse(ii,0,0,n) + w * crse(ii+1,0,0,n);
}

}
Expand Down
Loading

0 comments on commit 63d3865

Please sign in to comment.