-
Notifications
You must be signed in to change notification settings - Fork 411
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
ankithadas
wants to merge
1
commit into
AMReX-Codes:development
Choose a base branch
from
ankithadas:ApplyBCTagsMLEBABecLap
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Updated applyBC to use ParallelFor on Vector of tags for GPU builds #4619
ankithadas
wants to merge
1
commit into
AMReX-Codes:development
from
ankithadas:ApplyBCTagsMLEBABecLap
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)
Error loading related location
Loading
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)
Error loading related location
Loading
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)
Error loading related location
Loading
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Additional background
Checklist
The proposed changes: