Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

"Our vision is to speed up time, eventually eliminating it." -- Alex Schure


devel / comp.arch / Re: Encoding saturating arithmetic

SubjectAuthor
* Re: Encoding saturating arithmeticJimBrakefield
`* Re: Encoding saturating arithmeticluke.l...@gmail.com
 `* Re: Encoding saturating arithmeticMitchAlsup
  `- Re: Encoding saturating arithmeticJimBrakefield

1
Re: Encoding saturating arithmetic

<39de509a-d048-4915-a922-7f8b73cebc84n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=32217&group=comp.arch#32217

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:590c:0:b0:621:357e:14e2 with SMTP id ez12-20020ad4590c000000b00621357e14e2mr2661174qvb.9.1684089128150;
Sun, 14 May 2023 11:32:08 -0700 (PDT)
X-Received: by 2002:a05:6870:c7b2:b0:192:61a0:6222 with SMTP id
dy50-20020a056870c7b200b0019261a06222mr10010852oab.4.1684089127881; Sun, 14
May 2023 11:32:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.swapon.de!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Sun, 14 May 2023 11:32:07 -0700 (PDT)
In-Reply-To: <tl651l$2ndr0$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=136.50.14.162; posting-account=AoizIQoAAADa7kQDpB0DAj2jwddxXUgl
NNTP-Posting-Host: 136.50.14.162
References: <tl4k53$3f0sn$1@newsreader4.netcologne.de> <85f0cd46-5c5c-424c-a50b-d2583cc5eb15n@googlegroups.com>
<47eb5ce6-c1f9-42fa-a9f9-42713e2c2d5en@googlegroups.com> <tl651l$2ndr0$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <39de509a-d048-4915-a922-7f8b73cebc84n@googlegroups.com>
Subject: Re: Encoding saturating arithmetic
From: jim.brakefield@ieee.org (JimBrakefield)
Injection-Date: Sun, 14 May 2023 18:32:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4418
 by: JimBrakefield - Sun, 14 May 2023 18:32 UTC

On Thursday, November 17, 2022 at 2:20:08 PM UTC-6, Stephen Fuld wrote:
> On 11/17/2022 11:36 AM, MitchAlsup wrote:
> > On Thursday, November 17, 2022 at 9:36:22 AM UTC-6, timca...@aol.com wrote:
> >> On Thursday, November 17, 2022 at 1:25:42 AM UTC-5, Thomas Koenig wrote:
> >>> Seems like saturating arithmetic is a thing, apparently with
> >>> integers. I can see that for applications that interface with
> >>> the real world with limited-range sensors or actuators (no sense
> >>> in trying to put more than 20 mA on a 4-20 mA current loop).
> >>>
> >>> And floating point (usually?) does not need it.
> >>>
> >>> What's the best way of encoding this in an ISA? To cover the
> >>> range of 8,16,32,64 bit calculations would need two bits. Or,
> >>> if somebody has, let's say, a 12-bit sensor, intermediate lengths
> >>> might also come in handy to clip results to between -2048..2047.
> >>>
> >>> Or is it just not worth the bother? Maybe people who have
> >>> experience with embedded CPUs can say something about this.
> > <
> >> IIRC, saturating adds & subtracts are used for things like JPEG & MPEG encoding/decoding.
> >> For 12 bit, you could do 16 bit and then have ceiling/floor operations to "clip" the result.
> > <
> > For ADA: one would want to saturate at particular end-of-range which
> > may not be power of 2.
> > Do most of the rest: one would saturate to the size of a container which
> > may not be a power of 2.
> > <
> > If one can avoid integer overflow in the actual calculation, one can
> > have an extract instruction (or a saturate instruction) that provides
> > the necessary bounds (operands) and an instruction that does::
> > <
> > if( x < lbounds ) r = lbounds;
> > else if( x > ubounds ) r = ubounds;
> > else r = x;
> A few comments.
>
> 1. I think that saturating arithmetic is a pretty big thing in DSPs. If
> that is so, then perhaps someone who is familiar with the usage patterns
> there can chime in.
>
> 2. I recall that the Mill will offer saturating arithmetic. Perhaps
> Ivan can provide more information.
>
> 3. There is a fundamental question of whether to include the saturation
> in the arithmetic instructions or as a separate instruction after the
> arithmetic instruction. There are arguments on both sides.
>
>
> 4. Your example requires a three operand instruction. This is
> frequently overkill, as for example, if the arithmetic operation was an
> unsigned add, there is no need to test the lower bounds, and a simple,
> two operand MAX instruction would be sufficient.
>
>
>
> --
> - Stephen Fuld
> (e-mail address disguised to prevent spam)

A three operand median instruction does saturation between arbitrary bounds, for speed it needs three comparators.
Used in image processing and DSP for spike removal, have not seen median in any ISA?
Of course a MAX MIN pair will do the job for saturation.

Re: Encoding saturating arithmetic

<1a82dd7a-5855-41bb-aad9-be27e5ed936cn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=32226&group=comp.arch#32226

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ac8:7f0d:0:b0:3ef:3b04:b8e2 with SMTP id f13-20020ac87f0d000000b003ef3b04b8e2mr11823669qtk.0.1684202930145;
Mon, 15 May 2023 19:08:50 -0700 (PDT)
X-Received: by 2002:a05:6871:109:b0:192:5684:dceb with SMTP id
y9-20020a056871010900b001925684dcebmr13407517oab.9.1684202929996; Mon, 15 May
2023 19:08:49 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Mon, 15 May 2023 19:08:49 -0700 (PDT)
In-Reply-To: <39de509a-d048-4915-a922-7f8b73cebc84n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=92.19.80.230; posting-account=soFpvwoAAADIBXOYOBcm_mixNPAaxW9p
NNTP-Posting-Host: 92.19.80.230
References: <tl4k53$3f0sn$1@newsreader4.netcologne.de> <85f0cd46-5c5c-424c-a50b-d2583cc5eb15n@googlegroups.com>
<47eb5ce6-c1f9-42fa-a9f9-42713e2c2d5en@googlegroups.com> <tl651l$2ndr0$1@dont-email.me>
<39de509a-d048-4915-a922-7f8b73cebc84n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1a82dd7a-5855-41bb-aad9-be27e5ed936cn@googlegroups.com>
Subject: Re: Encoding saturating arithmetic
From: luke.leighton@gmail.com (luke.l...@gmail.com)
Injection-Date: Tue, 16 May 2023 02:08:50 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 28
 by: luke.l...@gmail.com - Tue, 16 May 2023 02:08 UTC

On Sunday, May 14, 2023 at 7:32:09 PM UTC+1, JimBrakefield wrote:

> Of course a MAX MIN pair will do the job for saturation.

only if you are prepared to sacrifice 2x more of the regfile
(assuming Vector-Packing or PackedSIMD), unless you
have a Carry-Out and/or Overflow Condition-Code flag

assuming that you are not doing huge horizontal-sum
arithmetic the rollover (or borrow) will only be in the N+1th bit.

but if you do not have CCs/Carry then the only way to
know *after the fact* is to use 2N-wide arithmetic ops,
then use 2N-wide MAX and 2N-wide MIN to limit to an
N-wide result that *only then* can be safely Vector-Packed
or Packed-SIMD at width N

and given that you can only do 1/2 the number of operations
you now have far larger register spill and/or far larger
regfiles than otherwise necessary, at which point your Audio/Video
DSP product is no longer commercially competitive in either
die area or power consumption.

if the MIN/MAX is driven by N+1 by taking an extra carry-in
bit *then* you can stay at N-wide rather than 2N-wide.
can anyone forsee any problems with that?

MIN(RA, RB, CA): if RA+(CA<<N) < RB return RA else RB

Re: Encoding saturating arithmetic

<1d2703f2-d85c-4c87-ae2c-a25841559fd5n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=32232&group=comp.arch#32232

  copy link   Newsgroups: comp.arch
X-Received: by 2002:a05:620a:40c9:b0:759:1240:5848 with SMTP id g9-20020a05620a40c900b0075912405848mr4667594qko.15.1684247392709;
Tue, 16 May 2023 07:29:52 -0700 (PDT)
X-Received: by 2002:a4a:c986:0:b0:54f:d1e1:34bb with SMTP id
u6-20020a4ac986000000b0054fd1e134bbmr6209801ooq.1.1684247392388; Tue, 16 May
2023 07:29:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Tue, 16 May 2023 07:29:52 -0700 (PDT)
In-Reply-To: <1a82dd7a-5855-41bb-aad9-be27e5ed936cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:291:29f0:d0:de98:8af3:957a;
posting-account=H_G_JQkAAADS6onOMb-dqvUozKse7mcM
NNTP-Posting-Host: 2600:1700:291:29f0:d0:de98:8af3:957a
References: <tl4k53$3f0sn$1@newsreader4.netcologne.de> <85f0cd46-5c5c-424c-a50b-d2583cc5eb15n@googlegroups.com>
<47eb5ce6-c1f9-42fa-a9f9-42713e2c2d5en@googlegroups.com> <tl651l$2ndr0$1@dont-email.me>
<39de509a-d048-4915-a922-7f8b73cebc84n@googlegroups.com> <1a82dd7a-5855-41bb-aad9-be27e5ed936cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1d2703f2-d85c-4c87-ae2c-a25841559fd5n@googlegroups.com>
Subject: Re: Encoding saturating arithmetic
From: MitchAlsup@aol.com (MitchAlsup)
Injection-Date: Tue, 16 May 2023 14:29:52 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3144
 by: MitchAlsup - Tue, 16 May 2023 14:29 UTC

On Monday, May 15, 2023 at 9:08:51 PM UTC-5, luke.l...@gmail.com wrote:
> On Sunday, May 14, 2023 at 7:32:09 PM UTC+1, JimBrakefield wrote:
>
> > Of course a MAX MIN pair will do the job for saturation.
> only if you are prepared to sacrifice 2x more of the regfile
> (assuming Vector-Packing or PackedSIMD), unless you
> have a Carry-Out and/or Overflow Condition-Code flag
>
> assuming that you are not doing huge horizontal-sum
> arithmetic the rollover (or borrow) will only be in the N+1th bit.
>
> but if you do not have CCs/Carry then the only way to
<
Only is too strong, change that to obvious.
<
> know *after the fact* is to use 2N-wide arithmetic ops,
> then use 2N-wide MAX and 2N-wide MIN to limit to an
> N-wide result that *only then* can be safely Vector-Packed
> or Packed-SIMD at width N
<
You also have the problem of type consistency::
Is ADD Rd,Rs,#0xFFFFFFFF
A subtract by 1 or an add of a huge number ???
And how do you tell the difference.
>
> and given that you can only do 1/2 the number of operations
> you now have far larger register spill and/or far larger
> regfiles than otherwise necessary, at which point your Audio/Video
> DSP product is no longer commercially competitive in either
> die area or power consumption.
>
> if the MIN/MAX is driven by N+1 by taking an extra carry-in
> bit *then* you can stay at N-wide rather than 2N-wide.
> can anyone forsee any problems with that?
>
> MIN(RA, RB, CA): if RA+(CA<<N) < RB return RA else RB
<
Don't see how that works::
<
MIN(MAX(calculated, biglimit), littlelimit)

Re: Encoding saturating arithmetic

<2184abe1-99ee-4ddc-8211-9f8a61a416b3n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=32234&group=comp.arch#32234

  copy link   Newsgroups: comp.arch
X-Received: by 2002:ad4:4f2f:0:b0:61b:5ea2:4a0a with SMTP id fc15-20020ad44f2f000000b0061b5ea24a0amr6736486qvb.5.1684248254246;
Tue, 16 May 2023 07:44:14 -0700 (PDT)
X-Received: by 2002:aca:f3c2:0:b0:38e:ab70:28dc with SMTP id
r185-20020acaf3c2000000b0038eab7028dcmr6361254oih.8.1684248253905; Tue, 16
May 2023 07:44:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.neodome.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch
Date: Tue, 16 May 2023 07:44:13 -0700 (PDT)
In-Reply-To: <1d2703f2-d85c-4c87-ae2c-a25841559fd5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=136.50.14.162; posting-account=AoizIQoAAADa7kQDpB0DAj2jwddxXUgl
NNTP-Posting-Host: 136.50.14.162
References: <tl4k53$3f0sn$1@newsreader4.netcologne.de> <85f0cd46-5c5c-424c-a50b-d2583cc5eb15n@googlegroups.com>
<47eb5ce6-c1f9-42fa-a9f9-42713e2c2d5en@googlegroups.com> <tl651l$2ndr0$1@dont-email.me>
<39de509a-d048-4915-a922-7f8b73cebc84n@googlegroups.com> <1a82dd7a-5855-41bb-aad9-be27e5ed936cn@googlegroups.com>
<1d2703f2-d85c-4c87-ae2c-a25841559fd5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2184abe1-99ee-4ddc-8211-9f8a61a416b3n@googlegroups.com>
Subject: Re: Encoding saturating arithmetic
From: jim.brakefield@ieee.org (JimBrakefield)
Injection-Date: Tue, 16 May 2023 14:44:14 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3440
 by: JimBrakefield - Tue, 16 May 2023 14:44 UTC

On Tuesday, May 16, 2023 at 9:29:54 AM UTC-5, MitchAlsup wrote:
> On Monday, May 15, 2023 at 9:08:51 PM UTC-5, luke.l...@gmail.com wrote:
> > On Sunday, May 14, 2023 at 7:32:09 PM UTC+1, JimBrakefield wrote:
> >
> > > Of course a MAX MIN pair will do the job for saturation.
> > only if you are prepared to sacrifice 2x more of the regfile
> > (assuming Vector-Packing or PackedSIMD), unless you
> > have a Carry-Out and/or Overflow Condition-Code flag
> >
> > assuming that you are not doing huge horizontal-sum
> > arithmetic the rollover (or borrow) will only be in the N+1th bit.
> >
> > but if you do not have CCs/Carry then the only way to
> <
> Only is too strong, change that to obvious.
> <
> > know *after the fact* is to use 2N-wide arithmetic ops,
> > then use 2N-wide MAX and 2N-wide MIN to limit to an
> > N-wide result that *only then* can be safely Vector-Packed
> > or Packed-SIMD at width N
> <
> You also have the problem of type consistency::
> Is ADD Rd,Rs,#0xFFFFFFFF
> A subtract by 1 or an add of a huge number ???
> And how do you tell the difference.
> >
> > and given that you can only do 1/2 the number of operations
> > you now have far larger register spill and/or far larger
> > regfiles than otherwise necessary, at which point your Audio/Video
> > DSP product is no longer commercially competitive in either
> > die area or power consumption.
> >
> > if the MIN/MAX is driven by N+1 by taking an extra carry-in
> > bit *then* you can stay at N-wide rather than 2N-wide.
> > can anyone forsee any problems with that?
> >
> > MIN(RA, RB, CA): if RA+(CA<<N) < RB return RA else RB
> <
> Don't see how that works::
> <
> MIN(MAX(calculated, biglimit), littlelimit)

Yes there is a problem. For signal processing where data is typically 12-bits, not so much.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor