Re: Byte Addressability And Beyond

Liste des GroupesRevenir à c arch 
Sujet : Re: Byte Addressability And Beyond
De : mitchalsup (at) *nospam* aol.com (MitchAlsup1)
Groupes : comp.arch
Date : 07. May 2024, 22:56:09
Autres entêtes
Organisation : Rocksolid Light
Message-ID : <3a7599a8472de98c5ba814f5448e1b96@www.novabbs.org>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : Rocksolid Light
EricP wrote:

Terje Mathisen wrote:
Terje Mathisen wrote:
EricP wrote:
MitchAlsup1 wrote:
BGB wrote:
>
On 5/5/2024 10:31 AM, Scott Lurndal wrote:
Thomas Koenig <tkoenig@netcologne.de> writes:
Scott Lurndal <scott@slp53.sl.home> schrieb:
>
>
Not as of yet in my case, but bitfield extract might happen eventually.
Issue is finding a way to pull it off that is useful and cheaper than shift+mask (and probably adding some mechanism to pattern-match it from the AST or similar).
>
But, but but but:: it IS shift and Mask !!
>
Annoyingly, a good general case instruction could not be encoded in a 32-bit instruction form at this point (could either add a few special cases as 32-bit ops, or use a 64-bit encoding; or do it as a 2RI op rather than 3RI but this is lame...).
>
Then again, say:
   BITEXTR  Imm10, Rn  //Rn=(Rn>>(Imm&63))&((1<<((Imm>>6)&15))-1)
Could potentially still be useful.
>
    SL    Rd,Rc,<width:offset>
>
Is a bit field extract instruction, it is also a smash instruction (smashing a 64-bit value into a 8-bit or 12-bit or 47 bit for whatever
purpose is needed)
>
    SR    Rd,Rc,<width:offset>
>
Positions the value in a register (Rc) such that it fits the alignment of
a field.
>
    INS   Rd,Rc,Rf,<width:offset>
>
Inserts the field from Rf into its position <w:o> in Rc, inserts the field and delivers the new container to Rd.
>
I think my instruction set could accomplish pretty much the same
efficiency for bit field operations as bit addresses but without
requiring direct bit addressing.
>
An issue that comes up is when the in-memory bit field is > 56 bits wide
as it might straddle two 64-bit words. If width is <= 56 bits then
a load from a byte address handles most of the shifting and the
rest can be handled within a single register.
>
But if the in-memory bit field is > 56 bits wide it may or may not straddle
a single 64-bit memory location, and require a pair of registers to loaded.
>
x86 does not have bitfield insert/extract, but it does have SHRD/SHLD so it is fairly easy to handle arbitrary length (<= 64 bits) and alignment:
>
; RSI -> target, RCX = # bits to extract, RBX = 64-field size (0..63)
  mov rax,[rsi]
  mov rdx,[rsi+8]

This is what I wanted to avoid: blindly loading the next word
as that could unnecessarilly read a cache line or worse,
trap on an access violation.

Its not that it is difficult to avoid, it just adds to the fiddlyness
(like conditional branches around one or two instructions).

  shrd rax,rdx,cl    ; bit offset
>
  and rax,bitmask[rbx*8] ; 64 mask entries.
>
The last instruction can also be replaced with
>
   shlx rax,rax,rbx    ; Nr of excess bits (64-field to extract)
   shrx rax,rax,rbx
>
or the entire thing can be replaced with this one which calculates the mask on the fly:
>
  mov rax,[rsi]
  mov rdx,[rsi+8]
  or rdi,-1        ; Generate mask
>
  shrd rax,rdx,cl    ; bit offset
  shrx rdi,rdi,rbx    ; excess bits to mask away
>
  and rax,rdi
>
All seems like about 3 clock cycles when hitting the cache.
 I realized this morning that with arbitrary alignment and both signed and unsigned extract, it is better to always shift up first to get rid of the excess and then shift down to align. The main problem here is that you now need different code for straddling and non-straddling items since shifts (including double-wide shifts) have to be less than 64 bits. :-(
 This is not a problem for constant length and alignment since the compiler can chose the correct pattern, but for codecs and compression it does not work. (Or at least not for those 57..64 field lengths).
   mov rax,[rsi]
  shl rax,cl       ; Excess bits above the field we need
  shrx rax,rax,rbx ; rbx=64-field length
 The last instruction would be
   sarx rax,rax,rbx
 if you wanted a signed bitfield.
 No matter how you do it it will be become a bottleneck in any huffmann token  extractor or similar codes. In my own decoders I've tended to grab a 32 (in the old days) or 64-bit chunk into a register and immediately align it. Then I'll use a lookup table over the first N (typically 6-12) bits of this buffer value and let the table decide how many bits to keep for the token, or in the case of longer tokens, select a second-level table to lookup the remaining bits.
 After decrementing the buffer bits remaining counter I'll branch out to refill it, but only if I have at least 32 or 48 free bits. This keeps the number of refills fairly low.
 Terje

There seem to be two use cases, one for bit-wise load and store to
individual bit fields in compiled structures, the other is dynamic
bit fields in bit streams.

The first is bit sized elements in packed arrays, or packed structs,
or packed arrays of packed structs, or packed structs containing packed
array of bit fields, etc. These are supported by some languages
(Ada85 had optional packed arrays and record structs).
For these the field start bit-offset is dynamic but the field size and
type are compile constants and so offer some potential for optimization
(but that could require inlining some of the access subroutines).

Such fields would tend to be both read and written is semi random order
but with a high probability that nearby fields will also be accessed.

The other is bit fields in bit streams being processed sequentially from
lsb to msb order, e.g for a codec. For these the field size and type are
dynamic but the token start offset can be arranged to be in bit[0].
If you know the bit-wise token always starts in bit[0] you don't need to
deal with field straddles, but must dynamically track where the last valid
in-register bit is and detect when to load the next word and append to the
register bit stream.

Bit stream processing would likely be either write-only encode or read-only
decode, proceeding once serially either low to high or high to low order.

Both would simplify greatly with double-wide shifts of register pairs,
as well as double-wide bit field extract and insert.
If you have the later {double-wide bit field extract and insert} why do you need the former {double-wide shifts of register pairs}
And by double-wide bit field extracts--you mean the container is 2 registers
wide and the extracted result is 64-bits (or less) wide; and that for insert
the value being inserted is 64-bits wide and the container it is being inserted
into is 2 registers wide.

Date Sujet#  Auteur
1 May 24 * Byte Addressability And Beyond590Lawrence D'Oliveiro
1 May 24 +* Re: Byte Addressability And Beyond431John Levine
1 May 24 i+* Re: Byte Addressability And Beyond409Lawrence D'Oliveiro
1 May 24 ii+* Re: Byte Addressability And Beyond3John Levine
1 May 24 iii+- Re: Byte Addressability And Beyond1John Levine
1 May 24 iii`- Re: Byte Addressability And Beyond1Lawrence D'Oliveiro
1 May 24 ii+- Re: Byte Addressability And Beyond1Michael S
1 May 24 ii`* Re: Byte Addressability And Beyond404John Levine
2 May 24 ii +* Re: Byte Addressability And Beyond382Lawrence D'Oliveiro
2 May 24 ii i+* Re: Byte Addressability And Beyond4John Levine
2 May 24 ii ii`* Re: Byte Addressability And Beyond3Lawrence D'Oliveiro
2 May 24 ii ii `* Re: Byte Addressability And Beyond2John Levine
5 May 24 ii ii  `- Re: Byte Addressability And Beyond1Lawrence D'Oliveiro
2 May 24 ii i+* Re: Byte Addressability And Beyond367John Savard
2 May 24 ii ii+* Re: Byte Addressability And Beyond2MitchAlsup1
11 May 24 ii iii`- Re: Byte Addressability And Beyond1John Savard
4 May 24 ii ii`* Re: Byte Addressability And Beyond364Lawrence D'Oliveiro
8 May 24 ii ii `* Re: Byte Addressability And Beyond363John Savard
8 May 24 ii ii  +* Re: Byte Addressability And Beyond2Lawrence D'Oliveiro
10 May 24 ii ii  i`- Re: Byte Addressability And Beyond1David Brown
8 May 24 ii ii  `* Re: Byte Addressability And Beyond360MitchAlsup1
8 May 24 ii ii   `* Re: Byte Addressability And Beyond359John Levine
8 May 24 ii ii    +* Re: Byte Addressability And Beyond357Lawrence D'Oliveiro
9 May 24 ii ii    i`* Re: Byte Addressability And Beyond356John Levine
10 May 24 ii ii    i +* Re: Byte Addressability And Beyond354David Brown
10 May 24 ii ii    i i`* Re: Byte Addressability And Beyond353Anton Ertl
11 May 24 ii ii    i i `* Re: Byte Addressability And Beyond352David Brown
11 May 24 ii ii    i i  `* Re: Byte Addressability And Beyond351Anton Ertl
11 May 24 ii ii    i i   +* Re: Byte Addressability And Beyond158David Brown
11 May 24 ii ii    i i   i+- Re: Byte Addressability And Beyond1Anton Ertl
27 May 24 ii ii    i i   i`* Re: Byte Addressability And Beyond156Lawrence D'Oliveiro
27 May 24 ii ii    i i   i `* Re: Byte Addressability And Beyond155John Levine
27 May 24 ii ii    i i   i  `* Re: Byte Addressability And Beyond154Lawrence D'Oliveiro
27 May 24 ii ii    i i   i   `* Re: Byte Addressability And Beyond153John Levine
27 May 24 ii ii    i i   i    +* Re: Byte Addressability And Beyond149John Levine
27 May 24 ii ii    i i   i    i+- Re: Byte Addressability And Beyond1MitchAlsup1
28 May 24 ii ii    i i   i    i`* Re: Byte Addressability And Beyond147Lawrence D'Oliveiro
28 May 24 ii ii    i i   i    i +- Re: encoding conversion, Byte Addressability And Beyond1John Levine
28 May 24 ii ii    i i   i    i `* Re: Byte Addressability And Beyond145Thomas Koenig
29 May 24 ii ii    i i   i    i  +* Re: Byte Addressability And Beyond137Lawrence D'Oliveiro
29 May 24 ii ii    i i   i    i  i`* Re: Byte Addressability And Beyond136Anton Ertl
29 May 24 ii ii    i i   i    i  i +* Re: Byte Addressability And Beyond12Stefan Monnier
29 May 24 ii ii    i i   i    i  i i+* Re: Byte Addressability And Beyond10Stefan Monnier
29 May 24 ii ii    i i   i    i  i ii+* Re: Byte Addressability And Beyond3John Levine
30 May 24 ii ii    i i   i    i  i iii`* Re: Byte Addressability And Beyond2George Neuner
4 Jun 24 ii ii    i i   i    i  i iii `- Re: Byte Addressability And Beyond1George Neuner
30 May 24 ii ii    i i   i    i  i ii`* Re: Byte Addressability And Beyond6Anton Ertl
4 Jun 24 ii ii    i i   i    i  i ii +- Re: Byte Addressability And Beyond1Lawrence D'Oliveiro
4 Jun 24 ii ii    i i   i    i  i ii `* Re: Byte Addressability And Beyond4Stefan Monnier
7 Jun 24 ii ii    i i   i    i  i ii  +- Re: Byte Addressability And Beyond1Terje Mathisen
7 Jun 24 ii ii    i i   i    i  i ii  `* Re: Character non-equivalence, was Byte Addressability And Beyond2John Levine
9 Jun 24 ii ii    i i   i    i  i ii   `- Re: Character non-equivalence, was Byte Addressability And Beyond1Lawrence D'Oliveiro
30 May 24 ii ii    i i   i    i  i i`- Re: Byte Addressability And Beyond1Lawrence D'Oliveiro
30 May 24 ii ii    i i   i    i  i +* Re: Byte Addressability And Beyond117Lawrence D'Oliveiro
30 May 24 ii ii    i i   i    i  i i+* Re: architectural goals, Byte Addressability And Beyond66John Levine
30 May 24 ii ii    i i   i    i  i ii+- Re: architectural goals, Byte Addressability And Beyond1Stephen Fuld
30 May 24 ii ii    i i   i    i  i ii+* Re: architectural goals, Byte Addressability And Beyond22Anton Ertl
30 May 24 ii ii    i i   i    i  i iii`* Re: architectural goals, Byte Addressability And Beyond21Thomas Koenig
30 May 24 ii ii    i i   i    i  i iii +* Re: architectural goals, Byte Addressability And Beyond8Michael S
30 May 24 ii ii    i i   i    i  i iii i+- Re: architectural goals, Byte Addressability And Beyond1Thomas Koenig
30 May 24 ii ii    i i   i    i  i iii i+* Re: IBM architectural goals, Byte Addressability And Beyond5John Levine
30 May 24 ii ii    i i   i    i  i iii ii+* Re: IBM architectural goals, Byte Addressability And Beyond2Michael S
30 May 24 ii ii    i i   i    i  i iii iii`- Re: IBM architectural goals, Byte Addressability And Beyond1John Levine
30 May 24 ii ii    i i   i    i  i iii ii`* Re: IBM architectural goals, Byte Addressability And Beyond2Thomas Koenig
30 May 24 ii ii    i i   i    i  i iii ii `- Re: IBM architectural goals, Byte Addressability And Beyond1John Levine
30 May 24 ii ii    i i   i    i  i iii i`- Re: architectural goals, Byte Addressability And Beyond1Anton Ertl
30 May 24 ii ii    i i   i    i  i iii +* Re: architectural goals, Byte Addressability And Beyond3Anton Ertl
30 May 24 ii ii    i i   i    i  i iii i+- Re: architectural goals, Byte Addressability And Beyond1John Levine
30 May 24 ii ii    i i   i    i  i iii i`- Re: architectural goals, Byte Addressability And Beyond1Thomas Koenig
31 May 24 ii ii    i i   i    i  i iii +* Re: architectural goals, Byte Addressability And Beyond5Terje Mathisen
1 Jun 24 ii ii    i i   i    i  i iii i`* Re: architectural goals, Byte Addressability And Beyond4Thomas Koenig
1 Jun 24 ii ii    i i   i    i  i iii i `* Re: architectural goals, Byte Addressability And Beyond3Anton Ertl
2 Jun 24 ii ii    i i   i    i  i iii i  `* Re: architectural goals, Byte Addressability And Beyond2John Levine
4 Jun 24 ii ii    i i   i    i  i iii i   `- Re: architectural goals, Byte Addressability And Beyond1Stefan Monnier
4 Jun 24 ii ii    i i   i    i  i iii `* Re: architectural goals, Byte Addressability And Beyond4Lawrence D'Oliveiro
4 Jun 24 ii ii    i i   i    i  i iii  +- Re: architectural goals, Byte Addressability And Beyond1MitchAlsup1
4 Jun 24 ii ii    i i   i    i  i iii  +- Re: architectural goals, Byte Addressability And Beyond1Lynn Wheeler
4 Jun 24 ii ii    i i   i    i  i iii  `- Re: architectural goals, Byte Addressability And Beyond1Stefan Monnier
31 May 24 ii ii    i i   i    i  i ii`* Re: architectural goals, Byte Addressability And Beyond42John Savard
31 May 24 ii ii    i i   i    i  i ii `* Re: architectural goals, Byte Addressability And Beyond41John Levine
1 Jun 24 ii ii    i i   i    i  i ii  +* Re: architectural goals, Byte Addressability And Beyond31John Savard
1 Jun 24 ii ii    i i   i    i  i ii  i+* Re: architectural goals, Byte Addressability And Beyond20Thomas Koenig
2 Jun 24 ii ii    i i   i    i  i ii  ii+* Re: architectural goals, Byte Addressability And Beyond6John Savard
2 Jun 24 ii ii    i i   i    i  i ii  iii`* Re: architectural goals, Byte Addressability And Beyond5Thomas Koenig
2 Jun 24 ii ii    i i   i    i  i ii  iii +* Re: architectural goals, Byte Addressability And Beyond3John Levine
3 Jun 24 ii ii    i i   i    i  i ii  iii i`* Re: architectural goals, Byte Addressability And Beyond2OrangeFish
3 Jun 24 ii ii    i i   i    i  i ii  iii i `- Re: architectural goals, Byte Addressability And Beyond1John Levine
4 Jun 24 ii ii    i i   i    i  i ii  iii `- Re: architectural goals, Byte Addressability And Beyond1Lawrence D'Oliveiro
4 Jun 24 ii ii    i i   i    i  i ii  ii`* Re: architectural goals, Byte Addressability And Beyond13Lawrence D'Oliveiro
5 Jun 24 ii ii    i i   i    i  i ii  ii `* Re: architectural goals, Byte Addressability And Beyond12Lawrence D'Oliveiro
5 Jun 24 ii ii    i i   i    i  i ii  ii  +- Re: architectural goals, Byte Addressability And Beyond1Lawrence D'Oliveiro
6 Jun 24 ii ii    i i   i    i  i ii  ii  `* Re: architectural goals, Byte Addressability And Beyond10George Neuner
6 Jun 24 ii ii    i i   i    i  i ii  ii   +* Re: architectural goals, Byte Addressability And Beyond6John Levine
7 Jun 24 ii ii    i i   i    i  i ii  ii   i+* Re: architectural goals, Byte Addressability And Beyond4Lawrence D'Oliveiro
7 Jun 24 ii ii    i i   i    i  i ii  ii   ii`* Re: architectural goals, Byte Addressability And Beyond3Stephen Fuld
7 Jun 24 ii ii    i i   i    i  i ii  ii   ii `* Re: architectural goals, Byte Addressability And Beyond2Lawrence D'Oliveiro
7 Jun 24 ii ii    i i   i    i  i ii  ii   ii  `- Re: architectural goals, Byte Addressability And Beyond1Stephen Fuld
7 Jun 24 ii ii    i i   i    i  i ii  ii   i`- Re: architectural goals, Byte Addressability And Beyond1Terje Mathisen
6 Jun 24 ii ii    i i   i    i  i ii  ii   +- Re: architectural goals, Byte Addressability And Beyond1Lynn Wheeler
6 Jun 24 ii ii    i i   i    i  i ii  ii   +- Re: architectural goals, Byte Addressability And Beyond1OrangeFish
7 Jun 24 ii ii    i i   i    i  i ii  ii   `- Re: architectural goals, Byte Addressability And Beyond1Lawrence D'Oliveiro
2 Jun 24 ii ii    i i   i    i  i ii  i`* Re: architectural goals, Byte Addressability And Beyond10John Dallman
2 Jun 24 ii ii    i i   i    i  i ii  +- Re: architectural goals, Byte Addressability And Beyond1Michael S
2 Jun 24 ii ii    i i   i    i  i ii  +- Re: architectural goals, Byte Addressability And Beyond1John Dallman
4 Jun 24 ii ii    i i   i    i  i ii  `* Re: architectural goals, Byte Addressability And Beyond7Lawrence D'Oliveiro
30 May 24 ii ii    i i   i    i  i i+* Re: Byte Addressability And Beyond49Stephen Fuld
30 May 24 ii ii    i i   i    i  i i`- Re: Byte Addressability And Beyond1Anton Ertl
30 May 24 ii ii    i i   i    i  i +* Re: Byte Addressability And Beyond2Lawrence D'Oliveiro
30 May 24 ii ii    i i   i    i  i `* Re: Byte Addressability And Beyond4Terje Mathisen
30 May 24 ii ii    i i   i    i  `* Re: Byte Addressability And Beyond7Terje Mathisen
28 May 24 ii ii    i i   i    `* Re: Byte Addressability And Beyond3Lawrence D'Oliveiro
12 May 24 ii ii    i i   +* Re: python text, Byte Addressability And Beyond14John Levine
12 May 24 ii ii    i i   `* Re: Byte Addressability And Beyond178Thomas Koenig
27 May 24 ii ii    i `- Re: Byte Addressability And Beyond1Lawrence D'Oliveiro
8 May 24 ii ii    `- Re: Byte Addressability And Beyond1Michael S
2 May 24 ii i`* Re: Byte Addressability And Beyond10MitchAlsup1
2 May 24 ii +* Re: Byte Addressability And Beyond3Michael S
2 May 24 ii `* Re: Byte Addressability And Beyond18Anton Ertl
1 May 24 i+* Byte Order (was: Byte Addressability And Beyond)4Anton Ertl
1 May 24 i`* Re: Byte Addressability And Beyond17Stefan Monnier
1 May 24 +* Re: Byte Addressability And Beyond40MitchAlsup1
1 May 24 +* Re: Byte Addressability And Beyond15Thomas Koenig
1 May 24 +* Re: Byte Addressability And Beyond3Michael S
2 May 24 +* Re: Byte Addressability And Beyond4Lawrence D'Oliveiro
3 May 24 +* Re: Byte Addressability And Beyond75Anton Ertl
5 May 24 +* Re: Byte Addressability And Beyond20John Savard
5 May 24 `- Re: Byte Addressability And Beyond1John Savard

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal