Re: Converting code from single to double precision
- From: nospam@xxxxxxxxxxxxx (Richard Maine)
- Date: Fri, 27 Jul 2007 17:46:10 -0700
Colin Watters <qolin.see_signature@xxxxxxxxxxxxx> wrote:
Anyone know of a tool to take the donkey work out of this?
Not off-hand. At least not if you want to catch everything instead of
just the simple stuff. I wasted quite a lot of time in my youth doing
conversions like that. The amount of time spent convinced me to adopt an
f77 style that made such conversions simple. It is possible to adopt
such styles. But if you take random code that was written without a
thought to the matter, it can be quite complicated.
It is bad enough having to catch such things as specific intrinsics and
literal constants in the middle of expressions in ways that matter (such
as function actual arguments). You might find a tool that can handle
that. (Though I can't point you toone). But when people start playing
equivalence and common "games", it can become essentially impossible to
automate conversion. Sometimes you practically have to rewrite in cases
where it is bad enough. Been there. Done that. Have the scars.
And I'm not even counting the cases of bit twiddling, since that is
nonstandard/nonportable anyway.
Also, are there any compilers these days that DON'T have a command-line
option to treat all single precision variables and constants as
double-precision?
Yes. Last time I checked, this was pretty much a FAQ for g77, and the
answer was no, that it did not do that. Let's see. A quick google check
finds the g77 online docs at
<http://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/>. See section 15.3.7. G77
is still widely used.
Also note that my experience with such command-line switches is that
they vary quite widely in the fine points of exactly what they do.
Admitedly my experience is mostly on the old side because I long ago
decided not to use such switches because of the compilers that didn't
have the switches at all (which used to be a lot of them) and the
differences in details among the comiplers that did have such switches.
Perhaps things have changed since then, but then...
These days I strongly recommend using f90/f95 anyway. With f90, it is
easy to adopt a style that makes such conversions painless. Of course,
the language doesn't force you to use such a style. You can still write
code that is just as had as ever to port. But at least it is fairly
straightforward to use such a style, unlike in f77 where you really had
to go out of your way (and most people didn't).
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.
- References:
- Converting code from single to double precision
- From: Colin Watters
- Converting code from single to double precision
- Prev by Date: Re: forall and do loop
- Next by Date: Re: Converting code from single to double precision
- Previous by thread: Converting code from single to double precision
- Next by thread: Re: Converting code from single to double precision
- Index(es):