Skip to content
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

Porting fortran files to cpp in Src/Extern/HYPRE #1049

Merged
merged 22 commits into from
Jul 6, 2020

Conversation

OscarAntepara
Copy link
Contributor

I have replaced AMReX_HABEC_2D.F90 with AMReX_Habec_2D_K.H and AMReX_Habec_2D.cpp
I have replaced AMReX_HABEC_3D.F90 with AMReX_Habec_3D_K.H and AMReX_Habec_3D.cpp

@WeiqunZhang
Copy link
Member

Thanks for the PR! There are two issues need to be fixed. First, this breaks PETSc because Src/Extern/PETSc uses some files in Src/Extern/HYPRE. So you need to convert PETSc too. Second, it breaks when hypre uses long integer. For example, line 285 of AMReX_Habec_2D.cpp should use HYPRE_int instead of int.

@OscarAntepara
Copy link
Contributor Author

OscarAntepara commented Jun 27, 2020

There are still some issues that I have to check

@OscarAntepara OscarAntepara changed the title Porting fortran files to cpp in Src/Extern/HYPRE WIP: Porting fortran files to cpp in Src/Extern/HYPRE Jun 27, 2020
@OscarAntepara OscarAntepara changed the title WIP: Porting fortran files to cpp in Src/Extern/HYPRE Porting fortran files to cpp in Src/Extern/HYPRE Jun 30, 2020
Co-authored-by: WeiqunZhang <WeiqunZhang@lbl.gov>
namespace amrex {

AMREX_FORCE_INLINE
void amrex_hpacoef (Box const& box,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 2d version of amrex_hpacoef is identical to the 3d version. Could we move them to a new file AMReX_Habec_K.H? Maybe move the following block in AMReX_HypreABecLap.cpp to AMReX_Habec_K.H too?

#if (AMREX_SPACEDIM == 2)                                                                                                                                                                                  
#include <AMReX_Habec_2D_K.H>
#elif (AMREX_SPACEDIM == 3)
#include <AMReX_Habec_3D_K.H>
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!!

@WeiqunZhang
Copy link
Member

Currently it does not compile with USE_CUDA=TRUE. Some kernels are not GPU ready yet. To make it fully work with GPU is beyond the scope of this PR. But at least we should make it compile, and we should disable GPU launch region for functions that are not ready for GPU. To disabe launch region, you can git grep LaunchSafeGuard for examples. You will need to use AMREX_HOST_DEVICE_PARALLEL_FOR_3D instead of AMREX_PARALLEL_FOR_3D, so that the launch region flag is respected.

@OscarAntepara
Copy link
Contributor Author

Now it compiles with USE_CUDA=TRUE


diag_arr(i,j,k) = 1.0/mat_tmpPtr[0];

for (int ic=0; ic<=5; ic++){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 4 instead of 5?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh yeah, now it is fixed! Thanks.

Comment on lines 96 to 98
AMREX_HOST_DEVICE_PARALLEL_FOR_3D (box, i, j, k,
{
if (msk_arr(lo.x-1,j,k) > 0 && i==lo.x){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
AMREX_HOST_DEVICE_PARALLEL_FOR_3D (box, i, j, k,
{
if (msk_arr(lo.x-1,j,k) > 0 && i==lo.x){
Box tbx = box;
tbx.setSmall(0,lo.x).setBig(0,lo.x); // 0: x-direction
AMREX_HOST_DEVICE_PARALLEL_FOR_3D (tbx, i, j, k,
{

The looping is on a slice only. Could you fix in other place too including 3D?

OscarAntepara and others added 2 commits July 6, 2020 09:47
Co-authored-by: WeiqunZhang <WeiqunZhang@lbl.gov>
@WeiqunZhang WeiqunZhang merged commit 579a0c4 into AMReX-Codes:development Jul 6, 2020
dwillcox pushed a commit to dwillcox/amrex that referenced this pull request Oct 3, 2020
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.

2 participants