intel cnrs - inria Semi-automatic implementation of the complementary error function Anastasia Volkova (Intel & Inria) Jean-Michel Muller (CNRS) ARITH-26 June 11, 2019
intel cnrs - inria Don’t write code, generate it. • Mathematical functions are costly → rich trade-off possibilities • Standard libm is not enough • A ” flavor”per application/target platform → high human resource consumption A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 1/13
intel cnrs - inria Don’t write code, generate it. • Mathematical functions are costly → rich trade-off possibilities • Standard libm is not enough • A ” flavor”per application/target platform → high human resource consumption Our approach: G UARANTEED ACCURACY • Automate P ERFORMANCE • Generate code on-demand • Adapt for specific context A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 1/13
intel cnrs - inria Metalibm code generator for libm and beyond Code gen/optim Property detection Function C code Domain splitting Domain Gappa certificate Target error Polynomial … approximation (fpminimax) • Easy to use • Performance comparable to handwritten code • Deals with a variety of elementary functions www.metalibm.org A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 2/13
intel cnrs - inria Metalibm code generator for libm and beyond Code gen/optim Property detection Function C code Domain splitting Domain Gappa certificate Target error Polynomial … approximation (fpminimax) • Easy to use • Performance comparable to handwritten code • Deals with a variety of elementary functions ...but special functions remain a challenge www.metalibm.org A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 2/13
intel cnrs - inria Erf and erfc � x 2 e − t 2 dt 2 erfc(x) erf( x ) = √ π erf(x) 1 . 5 0 � ∞ 1 e − t 2 dt 2 erfc( x ) = √ π 0 . 5 x 0 Some properties: − 0 . 5 erfc( x ) = 1 − erf( x ) − 1 − 4 − 2 0 2 4 erfc( − x ) = 2 − erfc( x ) A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 3/13
intel cnrs - inria Erf and erfc � x 2 e − t 2 dt 2 erfc(x) erf( x ) = √ π erf(x) 1 . 5 0 � ∞ 1 e − t 2 dt 2 erfc( x ) = √ π 0 . 5 x 0 Some properties: − 0 . 5 erfc( x ) = 1 − erf( x ) − 1 − 4 − 2 0 2 4 erfc( − x ) = 2 − erfc( x ) Metalibm with binary64 target accuracy: • deals with erf( x ) on [ 0 ; 6 ] within 49 sec • fails with erfc( x ) on [ 0 ; 28 ] even after 3 h A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 3/13
intel cnrs - inria Erf and erfc � x 2 e − t 2 dt 2 erfc(x) erf( x ) = √ π erf(x) 1 . 5 0 � ∞ 1 e − t 2 dt 2 erfc( x ) = √ π 0 . 5 x 0 Some properties: − 0 . 5 erfc( x ) = 1 − erf( x ) − 1 − 4 − 2 0 2 4 erfc( − x ) = 2 − erfc( x ) Metalibm with binary64 target accuracy: • deals with erf( x ) on [ 0 ; 6 ] within 49 sec • fails with erfc( x ) on [ 0 ; 28 ] even after 3 h Issues: • erfc( x ) is too ” flat” • not close enough to asymptotic expression e − x 2 / ( x √ π ) A. Volkova, J.-M. Muller Semi-automatic code generation for the erfc(x) function 3/13
Recommend
More recommend