Re: Cray style vectors

Liste des GroupesRevenir à c arch 
Sujet : Re: Cray style vectors
De : tkoenig (at) *nospam* netcologne.de (Thomas Koenig)
Groupes : comp.arch
Date : 12. Mar 2024, 08:03:24
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <usouns$5e0s$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
User-Agent : slrn/1.0.3 (Linux)
MitchAlsup1 <mitchalsup@aol.com> schrieb:
Thomas Koenig wrote:

However, what I did put in the paper (and what the subsequent
revision by a J3 subcommittee left in) is a prohibition against
using unsigneds in a DO loop.  The reason is semantics of
negative strides.
>
Currently, in Fortran, the number of iterations of the loop
>
    do i=m1,m2,m3
....
    end do
>
is (m2-m1+m3)/m3 unless that value is negative, in which case it
is zero (m3 defaults to 1 if it is not present).
>
So,
>
   do i=1,3,-1
>
will be executed zero times, as will
>
  do i=3,1
>
Translating that into arithmetic with unsigned integers makes
little sense, how many times should
>
    do i=1,3,4294967295
>
be executed?
>
3-1+4294967295 = 4294967297 // (m2-m1+m3)
>
4294967297 / 4294967295 = 1.0000000004656612874161594750863
>
So the loop should be executed one time. {{And yes I know 4294967295 ==
0x1,0000,0001}} What would you expect on a 36-bit machine (2s-complement)
where 4294967295 is representable naturally ??

Correct (of course).

The same result would be expected for

   do i=1u,3u,-1u

(asusming an u suffix for unsigned numbers).

The problem is that this violates a Fortran basic assumption since
FORTRAN 77, which is that DO loops can be zero-trip.

This is a can of worms that I would like to leave unopened.

Same goes for array slices.  Even assuming that no negative
indices are used, the slice a(1:3:-1) is zero-sized in Fortran,
as is a(3:1) .

For a(1u:3u:-1u) the same logic that you outlined above would apply,
making it a slice with one element.

Not going there :-)

Date Sujet#  Auteur
11 Mar 24 * Re: Cray style vectors10Thomas Koenig
11 Mar 24 `* Re: Cray style vectors9Michael S
11 Mar 24  +* Re: Cray style vectors7Thomas Koenig
11 Mar 24  i`* Re: Cray style vectors6Michael S
11 Mar 24  i +* Re: Cray style vectors2Thomas Koenig
12 Mar 24  i i`- Re: Cray style vectors1Thomas Koenig
12 Mar 24  i `* Re: Cray style vectors3Anton Ertl
12 Mar 24  i  `* Re: Cray style vectors2Thomas Koenig
12 Mar 24  i   `- Re: Cray style vectors1MitchAlsup1
11 Mar 24  `- Re: Cray style vectors1David Brown

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal