against Platform Uncertainties Thomas Wahl Northeastern University - - PowerPoint PPT Presentation

โ–ถ
against platform uncertainties
SMART_READER_LITE
LIVE PREVIEW

against Platform Uncertainties Thomas Wahl Northeastern University - - PowerPoint PPT Presentation

Stabilizing Numeric Programs against Platform Uncertainties Thomas Wahl Northeastern University August 28, 2017 Example: Ray Tracing int raySphere( float *r, float *s, float radiusSq) { float A = dot3(r,r); float B = -2.0 * dot3(s,r); float C =


slide-1
SLIDE 1

Stabilizing Numeric Programs against Platform Uncertainties

Thomas Wahl Northeastern University August 28, 2017

slide-2
SLIDE 2

Example: Ray Tracing

For the input on the right: AMD GPU A8-3850: ๐ธ = โˆ’0.000122 NVIDIA Quadro 600 GPU: ๐ธ = +0.000244

int raySphere(float *r, float *s, float radiusSq) { float A = dot3(r,r); float B = -2.0 * dot3(s,r); float C = dot3(s,s) - radiusSq; float D = B*B - 4*A*C; if (D > 0.00001) { float sign = ( C > 0.00001 ) ? 1 : -1; โ‹ฎ

slide-3
SLIDE 3

9.0 + 0.9 + 0.09 + 0.009 + 0.0009 + 0.00009 + 0.000009 + 0.0000009

0.099 9.999

9.9999999

0.0009999

CPU: GPU:

9.9 9.9 0.00099

9.0 + 0.9 + 0.09 + 0.009 + 0.0009 + 0.00009 + 0.000009 + 0.0000009

0.0000099

slide-4
SLIDE 4

Platform Variations: Contracted Operations

Fused Multiply-Add (FMA) MULT ADD ROUND ROUND ROUND MULT ADD

๐‘ ๐‘ ๐‘ ๐‘ ๐‘‘ ๐‘‘

๐‘ โŠ— ๐‘ โŠ• ๐‘‘ ๐‘ ร— ๐‘ โŠ• ๐‘‘

slide-5
SLIDE 5

VOLATILITY IN NUMERIC PROGRAMS

slide-6
SLIDE 6

Volatile Expressions

= expression whose semantics depends on the (expression) evaluation model, which determines: Sums, products: Dot products:

  • evaluation order
  • availability and use of hardware features

such as fused multiply-add (FMA) ๐‘”

1 ๐ฝ + ๐‘” 2 ๐ฝ + โ€ฆ + ๐‘” ๐‘œ(๐ฝ)

๐‘”

1 ๐ฝ ร— ๐‘•1 ๐ฝ + โ€ฆ + ๐‘” ๐‘œ ๐ฝ ร— ๐‘•๐‘œ(๐ฝ)

slide-7
SLIDE 7

Quantifying Volatility

Questions:

  • How do we compute this, for input ๐ฝ ?
  • Once computed, what is it good for?

Let ๐‘Œ be a floating-point expression in the program. The volatile bound of ๐‘Œ for input ๐ฝ is min

๐‘ ๐‘Œ ๐ฝ, ๐‘

, max

๐‘ ๐‘Œ ๐ฝ, ๐‘

๐‘: expression evaluation models

slide-8
SLIDE 8
slide-9
SLIDE 9

Volatility in Matrix Calculations

๏ƒผwell-designed programs ๏ƒผhigh degree of reproducibility

slide-10
SLIDE 10

But: Ray Tracing

For some inputs: AMD GPU A8-3850: ๐ธ = โˆ’0.000122 NVIDIA Quadro 600 GPU: ๐ธ = +0.000244

int raySphere(float *r, float *s, float radiusSq) { float A = dot3(r,r); float B = -2.0 * dot3(s,r); float C = dot3(s,s) - radiusSq; float D = B*B - 4*A*C; if (D > 0.00001) { float sign = ( C > 0.00001 ) ? 1 : -1; โ‹ฎ

slide-11
SLIDE 11
slide-12
SLIDE 12

Stabilizing Numeric Programs: Overview

Goal:

  • Improve reproducibility of program results

Naive solution: โ€œdeterminizeโ€ the whole program cl /fp:strict source.cpp

  • implements strict evaluation:

FMA disabled, expressions from left to right

slide-13
SLIDE 13
slide-14
SLIDE 14

Local Stabilization

slide-15
SLIDE 15

Identifying Major Destabilizers

int raySphere(float *r, float *s, float radiusSq) { float A = dot3(r,r); float B = -2.0 * dot3(s,r); float C = dot3(s,s) - radiusSq; float D = B*B - 4*A*C; if (D > 0.00001) { float sign = ( C > 0.00001 ) ? 1 : -1; โ‹ฎ

slide-16
SLIDE 16

Stabilizing ๐ธโ€™s expression

int raySphere(float *r, float *s, float radiusSq) { float A = dot3(r,r); float B = -2.0 * dot3(s,r); float C = dot3(s,s) - radiusSq; /* donโ€™t optimize ... */ float D = B*B - 4*A*C; if (D > 0.00001) { float sign = ( C > 0.00001 ) ? 1 : -1; โ‹ฎ

Stabilizing D = B*B โ€“ 4*A*C : new volatile bound for ๐ธ of [โˆ’0.250000000, 0.125000000]

slide-17
SLIDE 17

Stabilizing ๐ธโ€™s expression not enough

Two causes of large volatile bounds for ๐‘ฌ:

  • 1. volatility caused by ๐ธโ€™s defining expression
  • 2. volatility inherited from earlier expressions,

which causes bloated inputs to ๐ธ !

slide-18
SLIDE 18

Provenance of ๐ธโ€™s Volatility

= for each preceding expression (here: ๐ต, ๐ถ, ๐ท), the contribution to (impact on) ๐ธโ€™s volatility

[VMCAI 2017]

slide-19
SLIDE 19

int raySphere(float *r, float *s, float radiusSq) { float A = dot3(r,r); /* FMA forbidden! */ float B = -2.0 * dot3(s,r); /* donโ€™t reorder! */ float C = dot3(s,s) - radiusSq; float D = B*B - 4*A*C; if (D > 0.00001) { float sign = ( C > 0.00001 ) ? 1 : -1; โ‹ฎ

  • Stabilizing B = 2.0 * dot3(s,r):

new bound for ๐ธ : [-0.002806663, 0.156753913]

  • Stabilizing C = dot3(s,s) - radiusSq

new bound for ๐ธ : [0.125000000, 0.156753913]

slide-20
SLIDE 20

๏ƒผ FPA expressions are volatile: semantics fragile against platform variations ๏ƒผ expose volatility, or prove robustness, on a per-input basis ๏ƒผ repair: make program robust against platform uncertainties

Take-Home Messages

Future plans:

  • platform uncertainties in machine learning (or other big-data)
  • prove robustness for a range of inputs
  • trade-offs: num. stability vs. accuracy (โ„!) vs. efficiency
slide-21
SLIDE 21

Acknowledgements

Joint with (@ NEU):

  • Yijia Gu (stud.), Computer and Information Science
  • Miriam Leeser (fac.) and Mahsa Bayati (stud.), Engineering

http://www.ccs.neu.edu/home/wahl/Research/ /FPA-Heterogeneous/Non-Portability Financial Support: