Re: Cray style vectors

Liste des GroupesRevenir à c arch 
Sujet : Re: Cray style vectors
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.arch
Date : 13. Mar 2024, 18:09:37
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Mar13.180937@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : xrn 10.11
EricP <ThatWouldBeTelling@thevillage.com> writes:
Anton Ertl wrote:
DCell mmul (Cell a, Cell b) /* signed multiply, mixed precision */
{
  DCell res;
 
  res = UD2D(ummul (a, b));
  if (a < 0)
    res.hi -= b;
  if (b < 0)
    res.hi -= a;
  return res;
}
 
I have this technique from Andrew Haley.  It relies on twos-complement
representation.
 
- anton
>
Yeah, that's what Alpha does with UMULH.
I'm still trying to figure out why it works.

Let's consider the case where a>=0 and b<0, and cells are 64 bits.  ua
is a interpreted as unsigned cell, and ub is b interpreted as unsigned
cell.  The following computations are in Z (the unlimited
integers).  For the case under consideration:

ua=a
ub=b+2^64

res = ua*ub = a*(b+2^64)= a*b + a*2^64

So,

a*b = res - a*2^64

The other cases are similar.

- anton
--
'Anyone trying for "industrial quality" ISA should avoid undefined behavior.'
  Mitch Alsup, <c17fcd89-f024-40e7-a594-88a85ac10d20o@googlegroups.com>

Date Sujet#  Auteur
11 Mar 24 * Re: Cray style vectors11Tim Rentsch
12 Mar 24 `* Re: Cray style vectors10Terje Mathisen
12 Mar 24  +- Re: Cray style vectors1MitchAlsup1
12 Mar 24  +* Re: Cray style vectors3Tim Rentsch
12 Mar 24  i`* Re: Cray style vectors2MitchAlsup1
13 Mar 24  i `- Re: Cray style vectors1Tim Rentsch
13 Mar 24  `* Re: Cray style vectors5Anton Ertl
13 Mar 24   +- Re: Cray style vectors1Tim Rentsch
13 Mar 24   +- Re: Cray style vectors1Anton Ertl
15 Mar 24   `* Re: Cray style vectors2Terje Mathisen
15 Mar 24    `- Re: Cray style vectors1Anton Ertl

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal