|
[Sponsors] |
![]() |
![]() |
#1 |
Senior Member
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20 ![]() |
Hi all,
because of this: http://www.hpcwire.com/features/17885244.html?viewAll=y it might make sense to generate a mixed sp/dp solver. I found all mesh operations to be very critical for meshes with short edge length but I want to do all calculations in single precision. How can this be done? As far as I can see this needs some quite basic changes in OpenFOAM? Thanks and regards Bastian |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 ![]() ![]() |
Hi,
what the article is saying is that they keep double precision accuracy, using single precision operations on the machine. Clearly I don't know the details of their implementation, however what they do seems to manipulate a double type as a set of floats, which, as a concept is not new. Similar ideas are used, with a different goal, in arbitrary precision libraries (GNU MP http://gmplib.org/ for example). Best,
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. ![]() |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
Senior Member
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20 ![]() |
Quote:
Regards Bastian |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 ![]() ![]() |
Not that I know. In your case you actually care of double precision accuracy. If you need a mesh in double precision (can't you simply scale it? or is the aspect ratio extreme?), you need, for example, to compute differential operators in double precision too for example, or you end up in large errors.
Best,
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. ![]() |
|
![]() |
![]() |
![]() |
![]() |
#5 | |
Senior Member
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20 ![]() |
Quote:
I don't really understand how you want to scale the mesh? Yes, I have high aspect ratios. I have the following observations:
Regards Bastian |
||
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
Hi Bastian,
Unfortunately, what you want is not possible without a hell of a lot of effort. Every single number in foam is templated on the scalar type, which can be compiled for either float or double, but not a mix of both (as you probably know). To have only the mesh work in double precision, you would have to redefine every single scalar or scalar derived variable used in the mesh. This would mean duplicating a massive number of foam data structures. This is not something you can do on the weekend. However, arbitrary variable precision would be a really useful thing to have. I know that the code Xflow uses 10 bit precision as part of its acceleration strategy. It would be fantastic if we could get say 40% speed-up by doing the same kind of thing. Eugene |
|
![]() |
![]() |
![]() |
![]() |
#7 | ||||
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 ![]() ![]() |
Quote:
One doubt/suggestion. What happens if you increase the accuracy used to write the mesh in OpenFOAM? Check in controlDict the writePrecision option. The default is 6 digits if you use ASCII format. As an alternative, try the binary format. Quote:
Quote:
Quote:
Alberto
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. ![]() |
|||||
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
A more viable option might be to translate only some specific matrix solution components to reduced precision and see how that works out. Interestingly, GMP is already included with the foam distribution as a Gcc dependency. Seems criminal not to take advantage of it!
You could also check whether it is possible to use gmp to template the scalars in foam onto something like a 48bit number. This obviously won't give you quite the speed-up of a 32bit float or the accuracy of a 64bit double, but the compromise might be acceptable and it would be much easier than re-writing large chunks of code. Eugene |
|
![]() |
![]() |
![]() |
![]() |
#9 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 ![]() |
Did it already. Not sure how useful this would be, but I guess it doesn't hurt to post it:
http://www.ecs.umass.edu/~smenon/tarballs/multiPrecision.tgz Basically wraps around the MPFR library to provide arbitrary precision arithmetic. You can replace the scalar class with this. |
|
![]() |
![]() |
![]() |
![]() |
#10 | |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#11 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 ![]() |
Well, at least not at the linear-solvers level. The performance would go through the floor if I tried that, but I don't see why not.
I was mainly using it for geometric intersection calculations, since those tend to be finicky about round-off. Clearly, this is intended for numerical robustness, and not performance. |
|
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 ![]() |
I will put it on my list of things to try. Thanks for the wrapper code Sandeep.
|
|
![]() |
![]() |
![]() |
![]() |
#13 |
Senior Member
Klaus
Join Date: Mar 2009
Posts: 280
Rep Power: 22 ![]() |
Hello Sandeep,would you please repost the the multiPrecision wrapper for arbitrary precision.
I'd like to use it with linear solvers. Klaus |
|
![]() |
![]() |
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Single or double precision | Jonas Larsson | Main CFD Forum | 16 | June 20, 2017 06:53 |
Single v.s. double precision | Confused | CFX | 15 | November 10, 2016 04:42 |
Parallel User Defined Real Gas Model | aeroman | FLUENT | 4 | July 1, 2015 06:09 |
Switch from single precision to double precision | kk81 | OpenFOAM Bugs | 0 | March 11, 2010 06:14 |
OpenFOAM Double precision vs Single Precision | alexandrepereira | OpenFOAM Running, Solving & CFD | 1 | June 11, 2008 14:30 |