docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::math::cmath Namespace Reference

Classes

class  CMathNode
class  CMathNodeSerializer
class  CMathNodeDispatcher

Enumerations

enum class  CMathFunction {
  sin , cos , tan , asin ,
  acos , atan , atan2 , sinh ,
  cosh , tanh , asinh , acosh ,
  atanh , exp , exp2 , exp10 ,
  expm1 , log , log10 , log2 ,
  log1p , pow , sqrt , cbrt ,
  hypot , erf , erfc , tgamma ,
  lgamma , fabs , ceil , floor ,
  trunc , round , lround , llround ,
  roundeven , nearbyint , rint , lrint ,
  llrint , fmod , remainder , frexp ,
  ldexp , modf , scalbn , scalbln ,
  ilogb , logb , nextafter , nexttoward ,
  copysign , fmax , fmin , fdim ,
  fma
}
 Enumeration of C math library functions. More...

Functions

data_flow::LibraryNodeCode LibraryNodeType_CMath ("CMath")
data_flow::LibraryNodeCode LibraryNodeType_CMath_Deprecated ("Intrinsic")
constexpr size_t cmath_function_to_arity (CMathFunction func)
 Get arity of CMathFunction enum.
constexpr uint64_t cmath_function_to_flop (CMathFunction func)
 Approximate flop-equivalent cost of a libm call.
constexpr const char * cmath_function_to_stem (CMathFunction func)
 Convert CMathFunction enum to function name stem (without type suffix).
CMathFunction string_to_cmath_function (const std::string &name)
std::string get_cmath_intrinsic_name (CMathFunction func, types::PrimitiveType prim_type)
 Get the correct C math intrinsic name for a given function and primitive type.
std::string get_cmath_approximate_intrinsic_name (CMathFunction func, types::PrimitiveType prim_type)
 Fast, approximate CUDA/HIP device intrinsic for a function, if one exists.

Enumeration Type Documentation

◆ CMathFunction

Enumeration of C math library functions.

Enumerator
sin 
cos 
tan 
asin 
acos 
atan 
atan2 
sinh 
cosh 
tanh 
asinh 
acosh 
atanh 
exp 
exp2 
exp10 
expm1 
log 
log10 
log2 
log1p 
pow 
sqrt 
cbrt 
hypot 
erf 
erfc 
tgamma 
lgamma 
fabs 
ceil 
floor 
trunc 
round 
lround 
llround 
roundeven 
nearbyint 
rint 
lrint 
llrint 
fmod 
remainder 
frexp 
ldexp 
modf 
scalbn 
scalbln 
ilogb 
logb 
nextafter 
nexttoward 
copysign 
fmax 
fmin 
fdim 
fma 

Function Documentation

◆ cmath_function_to_arity()

size_t sdfg::math::cmath::cmath_function_to_arity ( CMathFunction func)
constexpr

Get arity of CMathFunction enum.

Parameters
funcThe CMathFunction enum value
Returns
The arity of the enum as a size_t

◆ cmath_function_to_flop()

uint64_t sdfg::math::cmath::cmath_function_to_flop ( CMathFunction func)
constexpr

Approximate flop-equivalent cost of a libm call.

Elementwise math lowers to a single library call whose polynomial implementation retires several floating-point instructions; FLOPAnalysis weights the node with this instead of counting it as one flop. Values are coarse tiers, not exact per-libm counts. The switch is exhaustive (no default), so adding a CMathFunction without a cost here fails to compile.

◆ cmath_function_to_stem()

const char * sdfg::math::cmath::cmath_function_to_stem ( CMathFunction func)
constexpr

Convert CMathFunction enum to function name stem (without type suffix).

Parameters
funcThe CMathFunction enum value
Returns
The function name stem as a string

◆ get_cmath_approximate_intrinsic_name()

std::string sdfg::math::cmath::get_cmath_approximate_intrinsic_name ( CMathFunction func,
types::PrimitiveType prim_type )
inline

Fast, approximate CUDA/HIP device intrinsic for a function, if one exists.

Returns
The intrinsic name (e.g. "__expf"), or an empty string if there is none for this type

◆ get_cmath_intrinsic_name()

std::string sdfg::math::cmath::get_cmath_intrinsic_name ( CMathFunction func,
types::PrimitiveType prim_type )
inline

Get the correct C math intrinsic name for a given function and primitive type.

Returns the appropriate intrinsic function name based on the primitive type:

  • Float: adds 'f' suffix (e.g., "fmax" -> "fmaxf")
  • Double: uses base name (e.g., "fmax" -> "fmax")
  • Long Double/X86_FP80: adds 'l' suffix (e.g., "fmax" -> "fmaxl")
Parameters
funcThe CMathFunction enum value
prim_typeThe primitive type to generate the intrinsic for
Returns
The correct intrinsic function name

◆ LibraryNodeType_CMath()

data_flow::LibraryNodeCode sdfg::math::cmath::LibraryNodeType_CMath ( "CMath" )
inline

◆ LibraryNodeType_CMath_Deprecated()

data_flow::LibraryNodeCode sdfg::math::cmath::LibraryNodeType_CMath_Deprecated ( "Intrinsic" )
inline

◆ string_to_cmath_function()

CMathFunction sdfg::math::cmath::string_to_cmath_function ( const std::string & name)