Block-Structured AMR Software Framework
amrex::Math::FastDivmodU64 Struct Reference

#include <AMReX_Math.H>

Public Member Functions

 FastDivmodU64 (std::uint64_t divisor_)
 
 FastDivmodU64 ()=default
 Default construct an invalid FastDivmodU64. More...
 
AMREX_GPU_HOST_DEVICE std::uint64_t divide (std::uint64_t dividend) const
 Returns the quotient of floor(dividend / divisor) More...
 
AMREX_GPU_HOST_DEVICE std::uint64_t modulus (std::uint64_t quotient, std::uint64_t dividend) const
 Computes the remainder given a computed quotient and dividend. More...
 
AMREX_GPU_HOST_DEVICE std::uint64_t divmod (std::uint64_t &remainder, std::uint64_t dividend) const
 Returns the quotient of floor(dividend / divisor) and computes the remainder. More...
 
AMREX_GPU_HOST_DEVICE void operator() (std::uint64_t &quotient, std::uint64_t &remainder, std::uint64_t dividend) const
 

Public Attributes

std::uint64_t divisor = 0
 

Detailed Description

Object to encapsulate the fast division+modulus operation for 64b integer division.

Example:

uint64_t quotient, remainder, dividend, divisor;

FastDivmodU64 divmod(divisor);

divmod(quotient, remainder, dividend);

// quotient = (dividend / divisor) // remainder = (dividend % divisor)

Constructor & Destructor Documentation

◆ FastDivmodU64() [1/2]

amrex::Math::FastDivmodU64::FastDivmodU64 ( std::uint64_t  divisor_)
inline

◆ FastDivmodU64() [2/2]

amrex::Math::FastDivmodU64::FastDivmodU64 ( )
default

Default construct an invalid FastDivmodU64.

Member Function Documentation

◆ divide()

AMREX_GPU_HOST_DEVICE std::uint64_t amrex::Math::FastDivmodU64::divide ( std::uint64_t  dividend) const
inline

Returns the quotient of floor(dividend / divisor)

◆ divmod()

AMREX_GPU_HOST_DEVICE std::uint64_t amrex::Math::FastDivmodU64::divmod ( std::uint64_t &  remainder,
std::uint64_t  dividend 
) const
inline

Returns the quotient of floor(dividend / divisor) and computes the remainder.

◆ modulus()

AMREX_GPU_HOST_DEVICE std::uint64_t amrex::Math::FastDivmodU64::modulus ( std::uint64_t  quotient,
std::uint64_t  dividend 
) const
inline

Computes the remainder given a computed quotient and dividend.

◆ operator()()

AMREX_GPU_HOST_DEVICE void amrex::Math::FastDivmodU64::operator() ( std::uint64_t &  quotient,
std::uint64_t &  remainder,
std::uint64_t  dividend 
) const
inline

Computes integer division and modulus using precomputed values. This is computationally inexpensive.

Member Data Documentation

◆ divisor

std::uint64_t amrex::Math::FastDivmodU64::divisor = 0

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