Skip to content

Places with precision issues when compiling for float #1309

@AlexanderSinn

Description

@AlexanderSinn

I made a branch of amrex where amrex::Real is replaced with a special type that checks for out-of-range and precision loss.

AMReX branch:
https://github.com/AlexanderSinn/amrex/tree/try_add_MockReal_attempt_1
HiPACE++ branch:
https://github.com/AlexanderSinn/hipace/tree/test_with_float_using_MockReal

Compile with NOACC, double precision, and in RelWithDebInfo mode.

The input parameter amrex.mock_real_crash_errno can be used to crash at a specific error location to generate a backtrace.

I then ran a standard blowout wake in SI units script at low resolution and took not of all the places with issues, while replacing them with amrex::Real::unchecked_add to remove them from the output.

  • diagnostic: no need to have shape factor when grid is aligned with simulation grid

  • shape factors: cancelation in xmid-xfloor

  • gamma_psi-1._rt for plasma particles

  • derivative shape factor

  • AddRhoIons

  • HPMG:
    both add and sub in: return rhs + acf*phi(i,j,0,n) - lap;
    lap = facx * (phi(i-1,j,0,n) + phi(i+1,j,0,n));
    laplacian() opeprator+=
    restrict_nd

  • Depos etc:
    const amrex::Real xmid = (xp - x_pos_offset) * dx_inv;
    const amrex::Real ymid = (yp - y_pos_offset) * dy_inv;

  • Beam pusher: ( uz * gammap_inv - clight )

  • Beam pusher: ( uz_next * gamma_next_inv - clight );

  • Beam deposition: wq*(1._rt-vz*clightinv);

  • SolvePoissonPsiExmByEypBxEzBz: Bz source term, dy_jx +- dx_jy
    ExmBy calc:
    - (arr(i+1,j,Psi) - arr(i-1,j,Psi))*dx_inv;
    - (arr(i,j+1,Psi) - arr(i,j-1,Psi))*dy_inv
    Bz source derivative_inner: (array(i+is_x_dir,j+is_y_dir) - array(i-is_x_dir,j-is_y_dir)) * dx_inv;

  • doGatherShapeN: ExmByp += (shape_dx* shape_y) * slice_arr(i, j, psi_comp) * dx_inv;

  • GetPosOffset: geom.ProbLo(dir) + geom.ProbHi(dir)

  • InitParticles: plo[0] + (i + r[0] + x_offset)*dx[0];
    plo[1] + (j + r[1] + y_offset)*dx[1];

  • ExplicitDeposition both amrex::Gpu::Atomic::Add

  • amrex::Geometry computeRoundoffDomain: auto idx = int(std::floor((x - plo)*dxinv));

  • InitBeamFixedWeightPDF3D: m_get_momentum.m_u_std[2] = std::sqrt(avg_uz_sq/integral - (avg_uz/integral)*(avg_uz/integral))

  • Diagnostic TrimIOBox const amrex::Real mid = (rbox_3d.lo(slice_dir) + rbox_3d.hi(slice_dir)) / 2.;

  • AdvancePlasmaParticles: PlasmaMomentumPush and DualNumber operator+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions