AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
503 stars 336 forks source link

convert IndexType to IndexTypeND #3988

Closed AlexanderSinn closed 1 day ago

AlexanderSinn commented 2 weeks ago

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:

AlexanderSinn commented 2 days ago

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

WeiqunZhang commented 2 days ago

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

AlexanderSinn commented 2 days ago

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

AlexanderSinn commented 2 days ago

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

WeiqunZhang commented 2 days ago

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 commented 2 days ago

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

AlexanderSinn commented 2 days ago

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

AlexanderSinn commented 2 days ago

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 commented 2 days ago

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 commented 2 days ago

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

AlexanderSinn commented 2 days ago

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

WeiqunZhang commented 2 days ago

That Windows CI is really slow. https://github.com/AMReX-Codes/amrex/pull/4012