topic Re: Difference float calculation on FPGA and CPU in IntelÂ® QuartusÂ® Prime Software
https://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39104#M8040
<P> </P><P></P> --- Quote Start --- <P></P>Hi, <P></P>I use float point calculation in convolution neural network (opencl). <P></P>Result of calcultaion on FPGA and CPU is similar, but in low byte I get some difference. <P></P>How can I fix this problem ? How can I get result on FPGA identical to result of CPU. <P></P> --- Quote End --- <P></P> <P></P> <P></P>Unless the FP add/sub/mul/div algorithms are EXACTLY the same in each implementation (eg, how rounding is handled) you can reasonably expect a few bits of difference in the mantissa of the final result. This is an age old problem in software using floating point. You should compare the expected and received values to be equal within some error bound, and not expect them to be EXACTLY equal. IE, use: <B>if (abs(a-b) < max_error) ...</B> as opposed to: <B>if (a == b) ...</B> MAX_ERROR should be set to some small tolerance value, like 1e-6, or whatever makes sense for your application. If you go down the path of looking for EXACTLY EQUAL you will be chasing your tail for years.Tue, 15 Aug 2017 04:49:07 GMTAltera_Forum2017-08-15T04:49:07ZDifference float calculation on FPGA and CPU
https://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39102#M8038
<P>Hi, </P><P></P>I use float point calculation in convolution neural network (opencl). <P></P>Result of calcultaion on FPGA and CPU is similar, but in low byte I get some difference. <P></P>How can I fix this problem ? How can I get result on FPGA identical to result of CPU.Mon, 14 Aug 2017 15:18:01 GMThttps://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39102#M8038Altera_Forum2017-08-14T15:18:01ZRe: Difference float calculation on FPGA and CPU
https://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39103#M8039
<P>As long as the floating point operations are carried out in the same order as the CPU code, the output will be exactly the same on the FPGA (a + b + c is not the same as a + c + b or any other permutation of adding these three numbers). Note that parallelizing (including using SIMD) a floating point reduction in an NDRange kernel, or optimizing such operation in a single work-item kernel using a shift register (as outlined in Alrtera's documents) will result in a slightly different output compared to sequential execution on a CPU.</P>Mon, 14 Aug 2017 21:59:09 GMThttps://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39103#M8039Altera_Forum2017-08-14T21:59:09ZRe: Difference float calculation on FPGA and CPU
https://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39104#M8040
<P> </P><P></P> --- Quote Start --- <P></P>Hi, <P></P>I use float point calculation in convolution neural network (opencl). <P></P>Result of calcultaion on FPGA and CPU is similar, but in low byte I get some difference. <P></P>How can I fix this problem ? How can I get result on FPGA identical to result of CPU. <P></P> --- Quote End --- <P></P> <P></P> <P></P>Unless the FP add/sub/mul/div algorithms are EXACTLY the same in each implementation (eg, how rounding is handled) you can reasonably expect a few bits of difference in the mantissa of the final result. This is an age old problem in software using floating point. You should compare the expected and received values to be equal within some error bound, and not expect them to be EXACTLY equal. IE, use: <B>if (abs(a-b) < max_error) ...</B> as opposed to: <B>if (a == b) ...</B> MAX_ERROR should be set to some small tolerance value, like 1e-6, or whatever makes sense for your application. If you go down the path of looking for EXACTLY EQUAL you will be chasing your tail for years.Tue, 15 Aug 2017 04:49:07 GMThttps://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39104#M8040Altera_Forum2017-08-15T04:49:07ZRe: Difference float calculation on FPGA and CPU
https://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39105#M8041
<P>This link can help you: <A href="https://www.altera.com/en_us/pdfs/literature/wp/wp-01028.pdf">https://www.altera.com/en_us/pdfs/literature/wp/wp-01028.pdf</A></P>Wed, 16 Aug 2017 14:49:16 GMThttps://community.intel.com/t5/Intel-Quartus-Prime-Software/Difference-float-calculation-on-FPGA-and-CPU/m-p/39105#M8041Altera_Forum2017-08-16T14:49:16Z