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

convert IndexType to IndexTypeND #3988

Conversation

AlexanderSinn
Copy link
Member

@AlexanderSinn AlexanderSinn commented Jun 17, 2024

Summary

Similar to #3969 but for IndexType.

Additional background

A maximum of 31 dimensions are supported so that (1u << dim) can fit into an unsigned int.

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

@AlexanderSinn
Copy link
Member Author

Not sure what's wrong with the CUDA EB 2D Hypre CI test.

@WeiqunZhang
Copy link
Member

Even without any cache hits, that hypre cuda eb 2d test usually takes about 20 minutes.

@AlexanderSinn
Copy link
Member Author

Im actually able to reproduce the compilation hanging on a HPC cluster (without hypre).

@AlexanderSinn
Copy link
Member Author

It seems that AMReX_EB2_MultiGFab.cpp and AMReX_MLCurlCurl.cpp are affected.

@WeiqunZhang
Copy link
Member

For me MLCurlCurl is fine. The issue is this in GFab::buildTypes in AMReX_EB2_MultiGFab.cpp. If I comment that out, it builds.

    AMREX_LAUNCH_HOST_DEVICE_LAMBDA ( nodal_box, tbx,
    {
        amrex_eb2_build_types(tbx, bxg2, s, cell, fx, fy);
    });

@WeiqunZhang
Copy link
Member

it's this line cell(i,j,k).setCovered(); on my local computer.

@AlexanderSinn
Copy link
Member Author

For me too, I also commented out cell(i,j,k).setSingleValued();, maybe I was impatient.

@AlexanderSinn
Copy link
Member Author

AlexanderSinn commented Jul 2, 2024

Not sure what's going on here. If I change it to this, it compiles. Maybe It's something in the if condition that causes it?

        if (    s(i,j  ,k) < 0.0_rt && s(i+1,j  ,k) < 0.0_rt
            && s(i,j+1,k) < 0.0_rt && s(i+1,j+1,k) < 0.0_rt)
        {
            cell(i,j,k).setRegular();
            cell(i,j,k).setCovered();
            cell(i,j,k).setSingleValued();
        }
        else if (s(i,j  ,k) >= 0.0_rt && s(i+1,j  ,k) >= 0.0_rt
            &&  s(i,j+1,k) >= 0.0_rt && s(i+1,j+1,k) >= 0.0_rt)
        {
            //cell(i,j,k).setCovered();
        }
        else
        {
            //cell(i,j,k).setSingleValued();
        }

@WeiqunZhang
Copy link
Member

Could you try this?

diff --git a/Src/Base/AMReX_GpuRange.H b/Src/Base/AMReX_GpuRange.H
index ecf9a32fd2..08c77595e7 100644
--- a/Src/Base/AMReX_GpuRange.H
+++ b/Src/Base/AMReX_GpuRange.H
@@ -51,7 +51,7 @@ AMREX_FORCE_INLINE Box at (Box const& b, Long offset) noexcept
                                 static_cast<int>(j),
                                 static_cast<int>(k))};
         iv += b.smallEnd();
-        return Box(iv,iv,b.type());
+        return Box(iv,iv,b.ixType());
     ))
     AMREX_IF_ON_HOST((
         amrex::ignore_unused(offset);

It's more efficient this way anyway.

@WeiqunZhang
Copy link
Member

3d actually compiles, but not 2d. This is some weird nvcc bug.

@AlexanderSinn
Copy link
Member Author

It works with the changes to the at function, great!

@WeiqunZhang
Copy link
Member

That Windows CI is really slow. #4012

@WeiqunZhang WeiqunZhang enabled auto-merge (squash) July 3, 2024 01:06
@WeiqunZhang WeiqunZhang merged commit 7dc2081 into AMReX-Codes:development Jul 3, 2024
70 checks passed
@AlexanderSinn AlexanderSinn mentioned this pull request Jul 3, 2024
5 tasks
WeiqunZhang pushed a commit that referenced this pull request Aug 2, 2024
## Summary

Similar to #3969 and #3988 but for Box.

## Additional background

It should be checked that the changes to BoxIndexer do not affect the
compiled GPU code.
In my testing, it gives the same performance as development. 

Example usage:
```C++
amrex::BoxND b1{amrex::IntVectND{1,2,3}, amrex::IntVectND{4,5,6}, amrex::IntVectND{1,0,1}};
// ((1,2,3) (4,5,6) (1,0,1))
auto b2 = amrex::BoxCat(b1, b1, b1);
// ((1,2,3,1,2,3,1,2,3) (4,5,6,4,5,6,4,5,6) (1,0,1,1,0,1,1,0,1))
auto [b3, b4, b5, b6, b7] = amrex::BoxSplit<1, 4, 2, 1, 1>(b2);
// ((1) (4) (1))((2,3,1,2) (5,6,4,5) (0,1,1,0))((3,1) (6,4) (1,1))((2) (5) (0))((3) (6) (1))
auto b8 = amrex::BoxResize<2>(b4);
// ((2,3) (5,6) (0,1))
auto b9 = amrex::BoxResize<5>(b8);
// ((2,3,0,0,0) (5,6,0,0,0) (0,1,0,0,0))
```
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