Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::Math::FastDivmodU32 Struct Reference

Fast division and modulus by a fixed 32-bit divisor, as FastDivmodU64, for dividends below 2^32-1. More...

#include <AMReX_Math.H>

Public Member Functions

 FastDivmodU32 (std::uint32_t divisor_)
 Precompute the constants, in host code only.
 FastDivmodU32 ()=default
__host__ __device__ std::uint32_t divide (std::uint32_t dividend) const
 floor(dividend / divisor), for dividend < 2^32-1.
__host__ __device__ void operator() (std::uint32_t &quotient, std::uint32_t &remainder, std::uint32_t dividend) const

Public Attributes

std::uint32_t divisor = 0
std::uint32_t multiplier = 1U
unsigned int shift_right = 0
unsigned int round_up = 0

Detailed Description

Fast division and modulus by a fixed 32-bit divisor, as FastDivmodU64, for dividends below 2^32-1.

The quotient is a 32-bit multiply-high and a shift, which on GPUs is much cheaper than the 64-bit version.

Constructor & Destructor Documentation

◆ FastDivmodU32() [1/2]

amrex::Math::FastDivmodU32::FastDivmodU32 ( std::uint32_t divisor_)
inline

Precompute the constants, in host code only.

◆ FastDivmodU32() [2/2]

amrex::Math::FastDivmodU32::FastDivmodU32 ( )
default

Member Function Documentation

◆ divide()

__host__ __device__ std::uint32_t amrex::Math::FastDivmodU32::divide ( std::uint32_t dividend) const
inlinenodiscard

floor(dividend / divisor), for dividend < 2^32-1.

◆ operator()()

__host__ __device__ void amrex::Math::FastDivmodU32::operator() ( std::uint32_t & quotient,
std::uint32_t & remainder,
std::uint32_t dividend ) const
inline

Member Data Documentation

◆ divisor

std::uint32_t amrex::Math::FastDivmodU32::divisor = 0

◆ multiplier

std::uint32_t amrex::Math::FastDivmodU32::multiplier = 1U

◆ round_up

unsigned int amrex::Math::FastDivmodU32::round_up = 0

◆ shift_right

unsigned int amrex::Math::FastDivmodU32::shift_right = 0

The documentation for this struct was generated from the following file: