A general-purpose method for faithfully rounded floating-point function approximation in FPGAs David B. Thomas Imperial College London 1 David Thomas, Imperial College, dt10@ic.ac.uk
FloPoCo : Parameterised primitives 2 David Thomas, Imperial College, dt10@ic.ac.uk
FloPoCo : Parameterised primitives 3 David Thomas, Imperial College, dt10@ic.ac.uk
FloPoCo : Parameterised primitives 4 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Parameterised anything Approximation Input format interval Output format 5 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Parameterised anything 6 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox • Architecture for FPGA function approximation – Deeply pipelined – Floating-point in and out – Faithfully rounded • Method and tool for approximating functions – Handles any most twice-differentiable functions – Completely automated: expression to VHDL – Designed for reliability rather than optimality 7 David Thomas, Imperial College, dt10@ic.ac.uk
1. Motivation 2. The FloatApprox approach 1. Range reduction and approximation method 2. Evaluation architecture 3. Evaluation in hardware 8 David Thomas, Imperial College, dt10@ic.ac.uk
Context: FPGA accelerators • Mathematical or algorithmic specification • Convert to HLS or VHDL implementation – Rely on optimised IP for floating-point – Integrated at link-time into the final design 9 David Thomas, Imperial College, dt10@ic.ac.uk
Context: FPGA accelerators • Mathematical or algorithmic specification • Convert to HLS or VHDL implementation – Rely on optimised IP for floating-point – Integrated at link-time into the final design • Intellectual challenges for accelerator design – Managing memory accesses and bandwidth – Rewriting to tolerate latency of operators – Keeping pipelines occupied – Not : designing low-level IP cores 9 David Thomas, Imperial College, dt10@ic.ac.uk
Floating-point IP: Requirements • Faithfully rounded – Make every bit count – Tractable error analysis • Pipelined for 150MHz+ clock rate – Must be pipelined: RAM and DSPs are multi-cycle – Synthesis tools have limited retiming capability • Working RTL (circuit) implementation – A paper can’t be synthesised 10 David Thomas, Imperial College, dt10@ic.ac.uk
Floating-point IP: Requirements • Faithfully rounded – Make every bit count – Tractable error analysis • Pipelined for 150MHz+ clock rate – Must be pipelined: RAM and DSPs are multi-cycle – Synthesis tools have limited retiming capability • Working RTL (circuit) implementation – A paper can’t be synthesised 10 David Thomas, Imperial College, dt10@ic.ac.uk
A fable... Subject: Floating-point log1p? To: dt10@ic.ac.uk From: phd-slash-industry-bod@somewhere.com Body: I’m converting some code for an accelerator, and it uses log1p. Can I use your core from that PoC you did a while back? 11 David Thomas, Imperial College, dt10@ic.ac.uk
A fable... Subject: Re: Floating-point log1p? To: phd-slash-industry-bod@somewhere.com From: dt10@ic.ac.uk Body: Afraid that was written in Handel- C, I don’t have any VHDL. You could recreate it using the attached maple script, plus write a code gen. > I’m converting some code for an accelerator, and > it uses log1p. Can I use your core from that > PoC you did a while back? 12 David Thomas, Imperial College, dt10@ic.ac.uk
A fable... Subject: Re: Floating-point log1p? To: phd-slash-industry-bod@somewhere.com From: dt10@ic.ac.uk Body: Any luck? > Afraid that was written in Handel- C, I don’t > have any VHDL. You could recreate it using > the attached maple script, plus write a code gen. > > I’m converting some code for an accelerator, and > > it uses log1p. Can I use your core from that > > PoC you did a while back? 13 David Thomas, Imperial College, dt10@ic.ac.uk
... becomes a nightmare Subject: Re: Floating-point log1p? To: phd-slash-industry-bod@somewhere.com From: dt10@ic.ic.ac.uk Body: Oh, we don’t have maple . It’s ok, I found out log1p(x)=log(1+x), and just did that. Works fine. > Any luck? > > Afraid that was written in Handel- C, I don’t > > have any VHDL. You could recreate it using > > the attached maple script, plus write a code gen. 14 David Thomas, Imperial College, dt10@ic.ac.uk
What IP is available? Source Pipelined Faithful RTL add, mul, div FloPoCo Yes Yes Yes log, exp FloPoCo Yes Yes Yes sin, cos FPLibrary No Yes Yes Altera Yes Yes Altera flow only Xilinx Yes ? Vivado HLS only log1p Altera Yes Yes Altera flow only expm1 Altera Yes No OpenCL only erf Altera Yes No OpenCL only 15 David Thomas, Imperial College, dt10@ic.ac.uk
What IP is available? Source Pipelined Faithful RTL add, mul, div FloPoCo Yes Yes Yes log, exp FloPoCo Yes Yes Yes sin, cos FPLibrary No Yes Yes Altera Yes Yes Altera flow only Xilinx Yes ? Vivado HLS only log1p Altera Yes Yes Altera flow only expm1 Altera Yes No OpenCL only erf Altera Yes No OpenCL only 15 David Thomas, Imperial College, dt10@ic.ac.uk
What IP is available? Source Pipelined Faithful RTL add, mul, div FloPoCo Yes Yes Yes log, exp FloPoCo Yes Yes Yes sin, cos FPLibrary No Yes Yes Altera Yes Yes Altera flow only Xilinx Yes ? Vivado HLS only log1p Altera Yes Yes Altera flow only expm1 Altera Yes No OpenCL only erf Altera Yes No OpenCL only 15 David Thomas, Imperial College, dt10@ic.ac.uk
Motivation for FloatApprox • We currently have : + , - , * , / , log , exp – Use existing IP: FloPoCo, Xilinx, Altera, ... 16 David Thomas, Imperial College, dt10@ic.ac.uk
Motivation for FloatApprox • We currently have : + , - , * , / , log , exp – Use existing IP: FloPoCo, Xilinx, Altera, ... • We should have : log1p, expm1, erf, sin, acos, ... – What FloatApprox does badly... ... but better than anything else available 16 David Thomas, Imperial College, dt10@ic.ac.uk
Motivation for FloatApprox • We currently have : + , - , * , / , log , exp – Use existing IP: FloPoCo, Xilinx, Altera, ... • We should have : log1p, expm1, erf, sin, acos, ... – What FloatApprox does badly... ... but better than anything else available • What I want : sqrt(-2 log(x)), 1/(1+exp(-x)) – What FloatApprox does well 16 David Thomas, Imperial College, dt10@ic.ac.uk
Goals of FloatApprox • As a tool – Convert any function f(x) to RTL – Able to handle most smooth functions • Smooth = twice differentiable for our purposes – Suitable for automated use • Input : data-types, range, function • Output : faithfully rounded circuit 17 David Thomas, Imperial College, dt10@ic.ac.uk
Goals of FloatApprox • As a tool – Convert any function f(x) to RTL – Able to handle most smooth functions • Smooth = twice differentiable for our purposes – Suitable for automated use • Input : data-types, range, function • Output : faithfully rounded circuit • As generated IP – Pipelined – Faithfully rounded – Working RTL 17 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox: requirements • User can specify any specified target function • Parameterised floating-point representation – Input and output formats can be distinct • Portable between platforms • Usable from many languages • Open-source • Low latency • Minimal resource 19 David Thomas, Imperial College, dt10@ic.ac.uk
Architecture and Approximation • Architecture : – General template for creating any approximator • Approximation – Configuring the template for a given function 20 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Approximation • Given a function f t how do we create f a ? 21 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Approximation • Given a function f t how do we create f a ? • Segment the function so that segments are: 21 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Approximation • Given a function f t how do we create f a ? • Segment the function so that segments are: 1. Contained in one input binade 21 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Approximation • Given a function f t how do we create f a ? • Segment the function so that segments are: 1. Contained in one input binade 1. Contained in one output binade 21 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Approximation • Given a function f t how do we create f a ? • Segment the function so that segments are: 1. Contained in one input binade 1. Contained in one output binade 1. FaithfulFixed: can faithfully approximate with fixed-point polynomial of degree d 21 David Thomas, Imperial College, dt10@ic.ac.uk
FloatApprox : Approximation • Given a function f t how do we create f a ? • Segment the function so that segments are: 1. Contained in one input binade 2. Monotonically increasing or decreasing in range 3. Contained in one output binade 4. FaithfulReal: can approx. with real degree d poly 5. FaithfulFixed: can faithfully approximate with fixed-point polynomial of degree d 21 David Thomas, Imperial College, dt10@ic.ac.uk
Recommend
More recommend