From: Bernd Paysan on
Nick Maclaren wrote:
> Exactly, WHY is it natural for a complex number to be aligned according
> to its size rather than according to the size of its real components?
>
> Half an hour is allowed for this question. Extra marks will be give
> for reasons that are independent of specific architectures. No marks
> will be given for answers that simplify to "Because it makes my style
> of programming easier."

Natural alignment is based on the largest native data type (for the ISA). So
if your ISA has instructions to deal with reals, the natural alignment is
for the reals. If your ISA has instructions to deal with complex numbers
(pairs of reals), natural alignment is for pairs of reals. If you want to
keep your alignment the same between different implementations (don't want
to check the alignment restrictions, or the data dump is used as file
format), use the size of the complex number as alignment.

--
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://www.jwdt.com/~paysan/
From: Nick Maclaren on

In article <4q8rirFlt18fU1(a)individual.net>,
=?ISO-8859-1?Q?Jan_Vorbr=FCggen?= <jvorbrueggen(a)not-mediasec.de> writes:
|>
|> > Exactly, WHY is it natural for a complex number to be aligned according
|> > to its size rather than according to the size of its real components?
|>
|> It isn't, in this case. If you had a instruction in your ISA that actually
|> worked on a complex number as a whole, the answer would be different. But you
|> don't, so it's natural alignment is that of its real component.

Actually, in many ISAs, you do. You often have multiple load/stores.
Anyway, most people program in a language and not to an ISA - quite
rightly - so see below.

|> But then, I'd rather not have Fortran definition (for some historical reasons)
|> that you can actually consider a complex number as a structure of two reals of
|> a certain defined arrangement. However, this has nothing to do with your ISA,
|> but at what level of abstraction a programming language should be defined.

And the context of this thread was my denial of the claim that the
languages hide such issues from the programmer!


Regards,
Nick Maclaren.
From: Jan Vorbrüggen on
> |> But then, I'd rather not have Fortran definition (for some historical reasons)
> |> that you can actually consider a complex number as a structure of two reals of
> |> a certain defined arrangement. However, this has nothing to do with your ISA,
> |> but at what level of abstraction a programming language should be defined.
>
> And the context of this thread was my denial of the claim that the
> languages hide such issues from the programmer!

I believe that most people think this is a deficiency in the standard which
cannot be changed for reasons of backward compatibility. If one were doing
the Fortran standard "froms scratch" today, such a detail would be left open
to the implementation, I'm sure.

Jan
From: Nick Maclaren on

In article <4q8vtvFlqq0oU1(a)individual.net>,
=?ISO-8859-1?Q?Jan_Vorbr=FCggen?= <jvorbrueggen(a)not-mediasec.de> writes:
|> >
|> > |> But then, I'd rather not have Fortran definition (for some historical reasons)
|> > |> that you can actually consider a complex number as a structure of two reals of
|> > |> a certain defined arrangement. However, this has nothing to do with your ISA,
|> > |> but at what level of abstraction a programming language should be defined.
|> >
|> > And the context of this thread was my denial of the claim that the
|> > languages hide such issues from the programmer!
|>
|> I believe that most people think this is a deficiency in the standard which
|> cannot be changed for reasons of backward compatibility. If one were doing
|> the Fortran standard "froms scratch" today, such a detail would be left open
|> to the implementation, I'm sure.

For Fortran, I agree. But C and C++ did it deliberately, and with
the experience of Fortran as a guide.


Regards,
Nick Maclaren.
From: Alexander Terekhov on

"Eric P." wrote:
[...]
> Anyway, I go by what the Intel manual says.

That will lead you to clinic. x86 native for WB is x86-under-Itanic/aka
TSO minus "remote write atomicity" (in Itanic's formal memory model
speak). Apart from a few minor details, that is. It's pretty obvious
that the manual (as far as "memory ordering" is concerned) was written
for testers sitting on "system bus", not software programmers.

regards,
alexander.