Rate This Document
Findability
Accuracy
Completeness
Readability

Math Library Interface Filter Script

Overview

In locating precision differences, it is often found that differences are caused by different math libraries. So the KML that is compatible with the ICC's math library IMF is developed, in order to make its calculation results consistent with that of the IMF. The KML team simulated the precisions of KML and IMF, the result of which shows that precisions for most functions are consistent.

Precision Function List (Consistent Between KML and IMF)

Function Name

Description

abs

Returns the absolute value of a number.

fabs

Returns the absolute value of a number.

ccos

Returns the cosine value of a complex number.

ccosf

Returns the cosine value of a complex number.

cexp

Returns the exponent value of a complex number.

cexpf

Returns the exponent value of a complex number.

cdiv

Returns the quotient of two complex numbers.

cdivf

Returns the quotient of two complex numbers.

ceil

Returns the upper limit integer of a number.

ceilf

Returns the upper limit integer of a number.

exp

Returns the exponent value of a number.

expf

Returns the exponent value of a number.

clog

Returns the natural logarithm of a complex number.

clogf

Returns the natural logarithm of a complex number.

cosd

Returns the cosine value of an angle.

cosdf

Returns the cosine value of an angle.

cosl

Returns the cosine value of a long double-precision number.

cosl_18

Returns the cosine value of a long double-precision number.

cos

Returns the cosine value of a radian.

cosf

Returns the cosine value of a radian.

csin

Returns the sine value of a complex number.

csinf

Returns the sine value of a complex number.

erf

Returns the error function value of a number.

erff

Returns the error function value of a number.

expl

Returns the exponent value of a long double-precision number.

expl_18

Returns the exponent value of a long double-precision number.

floor

Returns the lower limit integer of a number.

floorf

Returns the lower limit integer of a number.

fmod

Returns the remainder of two numbers.

fmodf

Returns the remainder of two numbers.

frexp

Returns the mantissa and exponent of a number.

frexpf

Returns the mantissa and exponent of a number.

gammaf

Returns the gamma function value of a number.

hypot

Returns the square root of the sum of squares of two numbers.

ldexp

Returns the power value of a number.

ldexpl

Returns the power value of a long double-precision number.

log

Returns the natural logarithm of a number.

logl

Returns the natural logarithm of a long double-precision number.

llrint

Returns a rounded integer of a number.

lround

Returns a rounded integer of a number.

lroundf

Returns a rounded integer of a number.

fmodf_18

Returns the remainder of two numbers.

nearbyint

Returns the nearest integer of a number.

nearbyintf

Returns the nearest integer of a number.

pow

Returns the power value of a number.

powf

Returns the power value of a number.

powl

Returns the power value of a long double-precision number.

powi4i4

Returns the power value of an integer.

powi4i4_18

Returns the power value of an integer.

powi8i4

Returns the power value of a long integer.

powi8i4_18

Returns the power value of a long integer.

powi8i8

Returns the power value of a long integer.

powr4i4

Returns the power value of a real number.

rint

Returns the nearest integer of a number.

rintf

Returns the nearest integer of a number.

round

Returns a rounded integer of a number.

roundf

Returns a rounded integer of a number.

sin

Returns the sine value of a radian.

sinf

Returns the sine value of a radian.

sind

Returns the sine value of an angle.

sindf

Returns the sine value of an angle.

sinl

Returns the sine value of a long double-precision number.

sinl_18

Returns the sine value of a long double-precision number.

sqrt

Returns the square root of a number.

sqrtl

Returns the square root of a long double-precision number.

trunc

Returns the integer part of a number.

truncf

Returns the integer part of a number.

cexp

Calculates the exponential function of a complex number.

cexpf

Calculates the exponential function of a single-precision complex number.

cdiv

Calculates the quotient of two complex numbers.

cdivf

Calculates the quotient of two single-precision complex numbers.

cabs

Calculates the modulus of a complex number.

cpow

Calculates the power function of a complex number.

Check Method

Save the following script as math-filter.sh and run math-filter.sh xx.exe in the binary directory of the application to check all math library interfaces in the application. If there are interfaces that are not aligned with the functions in the x86 math library, contact the KML team to add the interfaces.

#!/bin/bash 
# Save the file as xx.sh, run the cd command to go to the binary directory, and run xx.sh binary name.
name=$(basename $1) 
log_name=${name}_mathlib.log 
echo $name 
echo -e "collect mathlib function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libmathlib.so" >> $log_name 
echo -e "collect bsmath function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libbsmath.so" >> $log_name 
echo -e "collect pgmath function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libpgmath.so" >> $log_name 
echo -e "collect KML function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libk" >> $log_name 
echo -e "collect sys math function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libm.so" >> $log_name 
echo -e "collect fftw function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libfftw3" >> $log_name 
echo -e "collect blas&lapack function...\n" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libopenblas" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "libblas" >> $log_name 
LD_DEBUG=symbols,bindings ldd -r $name |& grep "$name" |grep "normal symbol" |grep "liblapack" >> $log_name