Re: [webkit-dev] Transformations precision: double - float
On Mon, Oct 15, 2012 at 9:35 AM, Gabor Rapcsanyi rga...@inf.u-szeged.huwrote: On 10/12/2012 11:23 AM, Tom Hudson wrote: Do you have particular bottleneck functions that you have reason to believe would benefit from ARM SIMD optimizations? Under what workloads, and how much benefit? We've see a few ridiculously expensive transform functions in WebKit that my colleagues in Chapel Hill might be able to recall, but usually it's the rendering engines that are hot, not WebKit itself. Yes, you're right that the rendering engine is usually the basic bottleneck, but why shouldn't we optimize WebKit where it is possible. For example the function what you asking is TransformationMatrix::multiply(). I made a test which could be speed up with optimizing this matrix multiplication. I uploaded here: https://bugs.webkit.org/show_bug.cgi?id=98913 You are suggesting a massive change to WebKit based on an hypothetical universe in which a certain function is important. The problem is the same claim can be done for about any function of WebKit. You can handcraft a microbenchmark exercising a slow function and redesign everything to make that particular function fast. Does this add a lot of value to the project? No so much. As much as I am in favor of increasing the use of SIMD, especially on ARM, I am really not a fan of the idea of switching to float on such weak premises. Benjamin ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
Yes I agree that we need to do some measures to see the benefits of floats. But it's not just about the performance and memory gain of the floats, I would like to make ARM SIMD optimizations for the transformation functions to fasten up them, but ARM NEON technology only works with floats that's why I want to change the doubles. I would prefer a typedef solution to make this configurable as Ryosuke said, and then the ports could chose whether they need floats, doubles or long doubles. - Gabor On Oct 10, 2012, at 9:00 AM, Gabor Rapcsanyi rga...@inf.u-szeged.hu wrote: That was a long time ago and there were no objections Unless there's something in the spec requiring double precision it makes sense to move away from double precision throughout WebKit. I’m a little concerned about this. The programming interface to the graphics system on OS X uses doubles, so it’s likely we’ll be introducing float to double conversions for at least that platform if we change things inside WebKit that are currently doubles to float en masse. Similarly, the native data type for numbers in JavaScript is double. So any time we are passing a number from JavaScript to WebKit it’s likely that additional double to float conversions will be required as we change internals to use doubles instead of floats. On the other hand, there may also be performance boost or memory gains from using float instead of double. If we do make this change, I think we need to do performance testing as we do so, perhaps on more than one platform, to see if these changes are leading to benefits or not. I also think that “we should always use float unless a spec mandates double” is probably not the right rule of thumb. There are many factors other than “a spec” at play here. -- Darin ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
Hello! That was a long time ago and there were no objections so I made a bug for the further discussions and patches: https://bugs.webkit.org/show_bug.cgi?id=98913 Regards, Gabor What CPU executes single precision floating point values at the same speed as double precision? Here's a benchmark from NASA giving a comparison of single vs. double precision performance for one of their simulations. https://modelingguru.nasa.gov/docs/DOC-1664. Single precision maps better to GPU backends, and CPU's SIMD computations than double. Unless there's something in the spec requiring double precision it makes sense to move away from double precision throughout WebKit. It's fairly trivial to make SIMD types that can have CPU architecture specific implementations. As an example of how to do this in the wild there's the Sony vectormath library that's present in the Bullet Physics Library. http://bullet.svn.sourceforge.net/viewvc/bullet/trunk/Extras/vectormathlibrary/include/vectormath/. As Kui noted the TransformationMatrix is a hotspot that could be helped by SIMD. Making the solution generic enough to target multiple architectures using SIMD should help the performance on all the platforms. Don -Original Message- From: webkit-dev-boun...@lists.webkit.org [mailto:webkit-dev-boun...@lists.webkit.org] On Behalf Of Simon Fraser Sent: Monday, May 21, 2012 10:35 AM To: Zoltan Herczeg Cc: webkit-dev@lists.webkit.org Subject: Re: [webkit-dev] Transformations precision: double - float TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
Hi, I have the same questions. Using float, It's easier to map to OGLES2, Decrease memory usage and accelerated using ARM SIMD. if you do profiling for CSS transformation/Animation, you'll find TransformationMatrix hotspots that should be well optimized using NEON. -Kuii On Mon, May 21, 2012 at 6:55 PM, Stephen Chenney schen...@chromium.org wrote: Ideally WebKit would avoid casts by consistently using either double or floats everywhere a floating point representation is needed. I don't think it's as simple as adding a typedef, but maybe it is. In any event it would have to be spelled out in the style guide. My gut feeling is that floats are enough for web layout, and map better onto GPU back ends where bandwidth (memory) really matters. Is there anything in the specs that force one or the other, or both? Is there a compelling web content scenario that demands double precision? Stephen. On Mon, May 21, 2012 at 1:37 PM, Ryosuke Niwa rn...@webkit.org wrote: Maybe you can add a typedef in Platform.h to make it configurable? e.g. maybe you want to be able to use long double instead of regular double in the future. - Ryosuke On Mon, May 21, 2012 at 10:34 AM, Simon Fraser simon.fra...@apple.com wrote: TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
Would something like this work for testing in short term? template class T class TransformationMatrix_T { T data[16]; }; typedef TransformationMatrix TransformationMatrix_Tfloat; typedef TransformationMatrixD TransformationMatrix_Tdouble; .. Wasim -Original Message- From: webkit-dev-boun...@lists.webkit.org [mailto:webkit-dev-boun...@lists.webkit.org] On Behalf Of kui zheng Sent: 22 May 2012 14:04 To: Stephen Chenney Cc: webkit-dev@lists.webkit.org Subject: Re: [webkit-dev] Transformations precision: double - float Hi, I have the same questions. Using float, It's easier to map to OGLES2, Decrease memory usage and accelerated using ARM SIMD. if you do profiling for CSS transformation/Animation, you'll find TransformationMatrix hotspots that should be well optimized using NEON. -Kuii On Mon, May 21, 2012 at 6:55 PM, Stephen Chenney schen...@chromium.org wrote: Ideally WebKit would avoid casts by consistently using either double or floats everywhere a floating point representation is needed. I don't think it's as simple as adding a typedef, but maybe it is. In any event it would have to be spelled out in the style guide. My gut feeling is that floats are enough for web layout, and map better onto GPU back ends where bandwidth (memory) really matters. Is there anything in the specs that force one or the other, or both? Is there a compelling web content scenario that demands double precision? Stephen. On Mon, May 21, 2012 at 1:37 PM, Ryosuke Niwa rn...@webkit.org wrote: Maybe you can add a typedef in Platform.h to make it configurable? e.g. maybe you want to be able to use long double instead of regular double in the future. - Ryosuke On Mon, May 21, 2012 at 10:34 AM, Simon Fraser simon.fra...@apple.com wrote: TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
What CPU executes single precision floating point values at the same speed as double precision? Here's a benchmark from NASA giving a comparison of single vs. double precision performance for one of their simulations. https://modelingguru.nasa.gov/docs/DOC-1664. Single precision maps better to GPU backends, and CPU's SIMD computations than double. Unless there's something in the spec requiring double precision it makes sense to move away from double precision throughout WebKit. It's fairly trivial to make SIMD types that can have CPU architecture specific implementations. As an example of how to do this in the wild there's the Sony vectormath library that's present in the Bullet Physics Library. http://bullet.svn.sourceforge.net/viewvc/bullet/trunk/Extras/vectormathlibrary/include/vectormath/. As Kui noted the TransformationMatrix is a hotspot that could be helped by SIMD. Making the solution generic enough to target multiple architectures using SIMD should help the performance on all the platforms. Don -Original Message- From: webkit-dev-boun...@lists.webkit.org [mailto:webkit-dev-boun...@lists.webkit.org] On Behalf Of Simon Fraser Sent: Monday, May 21, 2012 10:35 AM To: Zoltan Herczeg Cc: webkit-dev@lists.webkit.org Subject: Re: [webkit-dev] Transformations precision: double - float TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
[webkit-dev] Transformations precision: double - float
Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
Maybe you can add a typedef in Platform.h to make it configurable? e.g. maybe you want to be able to use long double instead of regular double in the future. - Ryosuke On Mon, May 21, 2012 at 10:34 AM, Simon Fraser simon.fra...@apple.comwrote: TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
Re: [webkit-dev] Transformations precision: double - float
Ideally WebKit would avoid casts by consistently using either double or floats everywhere a floating point representation is needed. I don't think it's as simple as adding a typedef, but maybe it is. In any event it would have to be spelled out in the style guide. My gut feeling is that floats are enough for web layout, and map better onto GPU back ends where bandwidth (memory) really matters. Is there anything in the specs that force one or the other, or both? Is there a compelling web content scenario that demands double precision? Stephen. On Mon, May 21, 2012 at 1:37 PM, Ryosuke Niwa rn...@webkit.org wrote: Maybe you can add a typedef in Platform.h to make it configurable? e.g. maybe you want to be able to use long double instead of regular double in the future. - Ryosuke On Mon, May 21, 2012 at 10:34 AM, Simon Fraser simon.fra...@apple.comwrote: TransformationMatrix started out as floats, then got changed to doubles in http://trac.webkit.org/changeset/40761 This was done because on most hardware there is no penalty for using doubles over floats, and provided a better match with our system APIs that used doubles. I'd prefer to take a forward-looking stance here, and assume that in time hardware will catch up. Simon On May 21, 2012, at 4:04 AM, Zoltan Herczeg wrote: Hi, is there any reason why the transformations in WebKit use doubles? We could optimize some functions further with ARM SIMD if they would be floats. Is there any objection to make them float if the change would have no other side effects except some rounding because of the lower precision? Regards, Zoltan ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev