Skip to content

Updated applyBC to use ParallelFor on Vector of tags for GPU builds #4619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

ankithadas
Copy link
Contributor

Summary

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

Comment on lines +288 to +346
switch (bct) {
case AMREX_LO_NEUMANN:
{
if (mask(i,j,k) == 0 && mask(i+s,j,k) == 1) {
phi(i,j,k,icomp) = phi(i+s,j,k,icomp);
}
break;
}
case AMREX_LO_REFLECT_ODD:
{
if (mask(i,j,k) == 0 && mask(i+s,j,k) == 1) {
phi(i,j,k,icomp) = -phi(i+s,j,k,icomp);
}
break;
}
case AMREX_LO_DIRICHLET:
{
const int NX = amrex::min(blen+1, maxorder);
GpuArray<Real,4> x{-bcl * dxinv, Real(0.5), Real(1.5), Real(2.5)};
Array2D<Real, 0, 3, 0, 2> coef{};
for (int r = 0; r <= maxorder-2; ++r) {
poly_interp_coeff(-Real(0.5), x.data(), r+2, &(coef(0,r)));
}
if (mask(i,j,k) == 0 && mask(i+s,j,k) == 1) {
int order = 1;
bool has_cutfaces = false;
for (int r = 0; r <= NX-2; ++r) {
Real a = area(i+(1-side)+s*r,j,k);
if (a > Real(0.0)) {
++order;
if (a < Real(1.0)) {
has_cutfaces = true;
}
} else {
break;
}
}
if (has_cutfaces) { order = amrex::min(2,order); }
if (order == 1) {
if (inhomog) {
phi(i,j,k,icomp) = bcval(i,j,k,icomp);
} else {
phi(i,j,k,icomp) = Real(0.0);
}
} else {
Real tmp = Real(0.0);
for (int m = 1; m < order; ++m) {
tmp += phi(i+m*s,j,k,icomp) * coef(m,order-2);
}
phi(i,j,k,icomp) = tmp;
if (inhomog) {
phi(i,j,k,icomp) += bcval(i,j,k,icomp)*coef(0,order-2);
}
}
}
break;
}
default: {}
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
101 (41 lines)
.
Comment on lines +359 to +417
switch (bct) {
case AMREX_LO_NEUMANN:
{
if (mask(i,j,k) == 0 && mask(i,j+s,k) == 1) {
phi(i,j,k,icomp) = phi(i,j+s,k,icomp);
}
break;
}
case AMREX_LO_REFLECT_ODD:
{
if (mask(i,j,k) == 0 && mask(i,j+s,k) == 1) {
phi(i,j,k,icomp) = -phi(i,j+s,k,icomp);
}
break;
}
case AMREX_LO_DIRICHLET:
{
const int NX = amrex::min(blen+1, maxorder);
GpuArray<Real,4> x{-bcl * dyinv, Real(0.5), Real(1.5), Real(2.5)};
Array2D<Real, 0, 3, 0, 2> coef{};
for (int r = 0; r <= maxorder-2; ++r) {
poly_interp_coeff(-Real(0.5), x.data(), r+2, &(coef(0,r)));
}
if (mask(i,j,k) == 0 && mask(i,j+s,k) == 1) {
int order = 1;
bool has_cutfaces = false;
for (int r = 0; r <= NX-2; ++r) {
Real a = area(i,j+(1-side)+s*r,k);
if (a > Real(0.0)) {
++order;
if (a < Real(1.0)) {
has_cutfaces = true;
}
} else {
break;
}
}
if (has_cutfaces) { order = amrex::min(2,order); }
if (order == 1) {
if (inhomog) {
phi(i,j,k,icomp) = bcval(i,j,k,icomp);
} else {
phi(i,j,k,icomp) = Real(0.0);
}
} else {
Real tmp = Real(0.0);
for (int m = 1; m < order; ++m) {
tmp += phi(i,j+m*s,k,icomp) * coef(m,order-2);
}
phi(i,j,k,icomp) = tmp;
if (inhomog) {
phi(i,j,k,icomp) += bcval(i,j,k,icomp)*coef(0,order-2);
}
}
}
break;
}
default: {}
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
101 (41 lines)
.
Comment on lines +430 to +488
switch (bct) {
case AMREX_LO_NEUMANN:
{
if (mask(i,j,k) == 0 && mask(i,j,k+s) == 1) {
phi(i,j,k,icomp) = phi(i,j,k+s,icomp);
}
break;
}
case AMREX_LO_REFLECT_ODD:
{
if (mask(i,j,k) == 0 && mask(i,j,k+s) == 1) {
phi(i,j,k,icomp) = -phi(i,j,k+s,icomp);
}
break;
}
case AMREX_LO_DIRICHLET:
{
const int NX = amrex::min(blen+1, maxorder);
GpuArray<Real,4> x{-bcl * dzinv, Real(0.5), Real(1.5), Real(2.5)};
Array2D<Real, 0, 3, 0, 2> coef{};
for (int r = 0; r <= maxorder-2; ++r) {
poly_interp_coeff(-Real(0.5), x.data(), r+2, &(coef(0,r)));
}
if (mask(i,j,k) == 0 && mask(i,j,k+s) == 1) {
int order = 1;
bool has_cutfaces = false;
for (int r = 0; r <= NX-2; ++r) {
Real a = area(i,j,k+(1-side)+s*r);
if (a > Real(0.0)) {
++order;
if (a < Real(1.0)) {
has_cutfaces = true;
}
} else {
break;
}
}
if (has_cutfaces) { order = amrex::min(2,order); }
if (order == 1) {
if (inhomog) {
phi(i,j,k,icomp) = bcval(i,j,k,icomp);
} else {
phi(i,j,k,icomp) = Real(0.0);
}
} else {
Real tmp = Real(0.0);
for (int m = 1; m < order; ++m) {
tmp += phi(i,j,k+m*s,icomp) * coef(m,order-2);
}
phi(i,j,k,icomp) = tmp;
if (inhomog) {
phi(i,j,k,icomp) += bcval(i,j,k,icomp)*coef(0,order-2);
}
}
}
break;
}
default: {}
}

Check notice

Code scanning / CodeQL

Long switch case Note

Switch has at least one case that is too long:
101 (41 lines)
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant