Garbage in dead zone
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Garbage in dead zone         


Author: James Van Buskirk
Date: May 25, 2008 21:23

Since Fortran 90, dead zones in data structures have meaning. For
example in N1601.pdf, section 13.7.121:

"If D is an array and E is an array of rank one, the value of
TRANSFER(TRANSFER(E,D),E,SIZE(E)) shall be the value of E."

Thus TRANSFER has to write bits as specified into the dead areas of
data structures and read them back out again, so the dead areas of
data structures can hold good data and should not be messed around
with at unawares by the Fortran processor (IMHO). However:

C:\gcc_mingw64a\test>type ACOSH_c10i.f90
program test
complex(10) z
z = (2.5,0.1)
call xfinit
call sub(z)
end program test
Show full article (2.50Kb)
23 Comments
Re: Garbage in dead zone         


Author: nospam
Date: May 25, 2008 23:48

James Van Buskirk comcast.net> wrote:
> Since Fortran 90, dead zones in data structures have meaning. For
> example in N1601.pdf, section 13.7.121:
>
> "If D is an array and E is an array of rank one, the value of
> TRANSFER(TRANSFER(E,D),E,SIZE(E)) shall be the value of E."
>
> Thus TRANSFER has to write bits as specified into the dead areas of
> data structures and read them back out again, so the dead areas of
> data structures can hold good data and should not be messed around
> with at unawares by the Fortran processor (IMHO).

I think you are reading far more into that specification than is really
there. I'm afraid that the posted code is just too much work for me to
interpret without spending more time and/or getting more help on it. I
don't exactly find TRANSFER to be easy to follow in the best of
situations, and I suspect this isn't the best of situations. However, I
think I have at least a guess at what you are getting at. If my guess is
correct, then I disagree with your conclusions.

1. I really wish that the above bit of the standard would have been more
qualified. It is my belief that there are cases where things simply
cannot work quite literally like that, or even if it is vaguely...
Show full article (3.54Kb)
no comments
Re: Garbage in dead zone         


Author: glen herrmannsfeldt
Date: May 26, 2008 00:34

Richard Maine wrote:
(snip)
> For example, your code has assignments. Assignment is *NOT* guaranteed
> to be a bitwise copy operation. Assignment assigns a value. Any bits
> that don't participate in defining the value need not be preserved.
> There is historical support for things like that, I might add. There
> were systems where assignment of floatting-point values caused
> normalization of them. Well, I think it was assignment. In any case,
> nothing in the Fortran standard prohibitted such normalization on
> assignment.

I think you are right, but it would have caused problems
when REAL variables were used with the A format descriptor
for character I/O (in Fortran 66 days). S/360 doesn't
normalize on assignment, so it worked there when I used it.

-- glen
no comments
Re: Garbage in dead zone         


Author: Steve Lionel
Date: May 26, 2008 06:10

Richard Maine wrote:
> There were systems where assignment of floatting-point values caused
> normalization of them.

X86 processors convert a signaling NaN to a quiet NaN on assignment. I
have seen this bite many programs that inadvisedly used REAL variables
to do arbitrary datatype copying and found that the bit patterns changed.
no comments
Re: Garbage in dead zone         


Author: e p chandler
Date: May 26, 2008 08:06

On May 26, 4:33 am, glen herrmannsfeldt ugcs.caltech.edu> wrote:
> Richard Maine wrote:
>
> (snip)
>
>> For example, your code has assignments. Assignment is *NOT* guaranteed
>> to be a bitwise copy operation. Assignment assigns a value. Any bits
>> that don't participate in defining the value need not be preserved.
>> There is historical support for things like that, I might add. There
>> were systems where assignment of floatting-point values caused
>> normalization of them. Well, I think it was assignment. In any case,
>> nothing in the Fortran standard prohibitted such normalization on
>> assignment.
>
> I think you are right, but it would have caused problems
> when REAL variables were used with the A format descriptor
> for character I/O (in Fortran 66 days).   S/360 doesn't
> normalize on assignment, so it worked there when I used it.
>
> -- glen ...
Show full article (1.43Kb)
no comments
Re: Garbage in dead zone         


Author: Charles Coldwell
Date: May 31, 2008 05:29

"James Van Buskirk" comcast.net> writes:
> Since Fortran 90, dead zones in data structures have meaning. For
> example in N1601.pdf, section 13.7.121:
>
> "If D is an array and E is an array of rank one, the value of
> TRANSFER(TRANSFER(E,D...
Show full article (3.89Kb)
no comments
Re: Garbage in dead zone         


Author: James Van Buskirk
Date: May 31, 2008 13:18

"Charles Coldwell" gmail.com> wrote in message
news:rzpod6mmzei.fsf@gmail.com...
> Let me see if I understand this expression
> transfer([real(cc),0.0_10],0_16)
> correctly. In order to keep things 32-bit aligned, a REAL(KIND=10)
> variable actually occupies twelve bytes in memory instead of ten.

It's more complicated than that. Actually a REAL(KIND=10) variable
takes up 16 bytes on the compiler in question (gfortran for 64-bit
Windows). I gather that some if not all compilers which implement
REAL(KIND=10) variables on 32-bit Windows pad them out to only 12
bytes. I guess the 32-bit Windows people never read

http://www.intel.com/design/processor/manuals/248966.pdf

where it is recommended in section 3.6.3:

"Align 80-bit data so that its base address is a multiple of
sixteen."
> So
> the actual arguments supplied to
> TRANSFER(SOURCE, MOLD [,SIZE])
> are
Show full article (4.04Kb)
no comments
Re: Garbage in dead zone         


Author: Janne Blomqvist
Date: May 31, 2008 15:04

On 2008-05-31, James Van Buskirk comcast.net> wrote:
> "Charles Coldwell" gmail.com> wrote in message
> news:rzpod6mmzei.fsf@gmail.com...
>> correctly. In order to keep things 32-bit aligned, a REAL(KIND=10)
>> variable actually occupies twelve bytes in memory instead of ten.
>
> It's more complicated than that. Actually a REAL(KIND=10) variable
> takes up 16 bytes on the compiler in question (gfortran for 64-bit
> Windows). I gather that some if not all compilers which implement
> REAL(KIND=10) variables on 32-bit Windows pad them out to only 12
> bytes. I guess the 32-bit Windows people never read
>
> http://www.intel.com/design/processor/manuals/248966.pdf
>
> where it is recommended in section 3.6.3:
>
> "Align 80-bit data so that its base address is a multiple...
Show full article (1.60Kb)
no comments
Re: Garbage in dead zone         


Author: glen herrmannsfeldt
Date: May 31, 2008 16:12

Janne Blomqvist wrote:
> On 2008-05-31, James Van Buskirk wrote:
>>"Align 80-bit data so that its base address is a multiple of
>>sixteen."
> I'm quite sure it's not a question of "32-bit windows people" not
> being aware of processor optimization manuals. AFAIK the 32-bit x86
> windows (and Linux and so forth) ABI dates back to the i386, when 4
> byte alignment was enough, and hence 80-bit extended precision fp
> values were padded to 12 bytes. I think the Pentium was the first x86
> chip that got any benefit from bigger alignment. Changing the
> alignments would require changing the ABI, which would impose a rather
> high cost on everybody, and in the grand scheme of things relatively
> few applications would get any significant benefit from it.

Even worse, the four byte alignment for REAL*8 was used, and not
corrected for a long time. I thought by now eight byte alignment
for REAL*8 was pretty well standard. (Yes, Starting with the
pentium is was much slower than odd four byte alignment.)
Show full article (1.25Kb)
no comments
Re: Garbage in dead zone         


Author: nospam
Date: May 31, 2008 17:32

James Van Buskirk comcast.net> wrote:
> What's so hard to read about TRANSFER?

You're kidding, right? I suppose you probably are so used to TRANSFER
that you aren't kidding, though. :-(

Trust me that it is hard to read for lots of people. Me for one, and
I've plenty of data to suggest I'm not alone. Yes, I can figure it out,
but only by sitting down and meticulously working through it. I sure
can't just read it.

And that's for the relatively simple cases (notably ones where the size
of things match). When you get into stuff like what happens when one
side has more bits than the other, then I simply have to drag out the
standard, which is a long ways from just "reading" the code.

I haven't sat down to try to analyze what it is about TRANSFER that
makes it hard for me to read. But I don't need to analyze anything to
observe the fact that it is hard.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
no comments
1 2 3