Grinberg actually mentioned it, but got it wrong. He claimed that multiplication and division are indepenently optional, while in the
RISC-V specification, you get none or both.
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level >programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level >programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
Costly to implement and it tends to run slowly (although ARM tries
hard to disprove that part, even on low-end cores like the
Cortex-A53).
And it's not that frequent, which means that if you
throw lots of hardware at making it fast, the payoff will be small.
And because it is slow, various potential use cases avoid it and
prefer to use shifts or multiplication by the inverse, making it even
less frequent.
Even relatively recent architectures like Alpha (1992) and IA-64
(2001) do not include integer division instructions.
So I found the inclusion of division in the RISC-V M extension
surprising. They then separated them again by defining Zmmul.
- anton--- Synchronet 3.22a-Linux NewsLink 1.2
Having it perfectly defined is the critical part {bit patterns in,
bit patterns out} then each implementation can choose for itself
whether to put it in or leave it out.
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level
programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
But "lack of division" is also costly !! especially if some future implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
Even relatively recent architectures like Alpha (1992) and IA-64
(2001) do not include integer division instructions.
So I found the inclusion of division in the RISC-V M extension
surprising.
But "lack of division" is also costly !! especially if some future >implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
Note to -|Architects, put the instruction in even if you are going to
TRAP to SW emulation. Later on when DIV is implemented it just runs
faster and you had to do nothing (but put it in).
The only real problem
was that this was significantly slower than a direct call to a SW
function which did the same operation.
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level
programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
Costly to implement and it tends to run slowly (although ARM tries
hard to disprove that part, even on low-end cores like the
Cortex-A53). And it's not that frequent, which means that if you
throw lots of hardware at making it fast, the payoff will be small.
And because it is slow, various potential use cases avoid it and
prefer to use shifts or multiplication by the inverse, making it even
less frequent.
Even relatively recent architectures like Alpha (1992) and IA-64
(2001) do not include integer division instructions.
So I found the inclusion of division in the RISC-V M extension
surprising. They then separated them again by defining Zmmul.
Intel actually did this correctly back in 1978/79 when they designed the >8087: If you did not have the FPU, then the main 8088 CPU would trap to
an emulation layer which did what was required. The only real problem
was that this was significantly slower than a direct call to a SW
function which did the same operation.
What we ended up with on most applications was a hybrid, where the
compiler would generate calls to a shim, said shim would inspect the >available HW (FPU/No FPU) and patch the call:
On Tue, 27 Oct 2026 17:06:29 GMT
MitchAlsup <user5857@newsgrouper.org.invalid> wrote:
Having it perfectly defined is the critical part {bit patterns in,
bit patterns out} then each implementation can choose for itself
whether to put it in or leave it out.
An interesting question here is "Do one has to include 128b / 64b
division in the ISA or it's better to leave it off?".
AMD decided that it was needed, but it seems that nobody else followed
the suit.
According to Terje Mathisen <terje.mathisen@tmsw.no>:
Intel actually did this correctly back in 1978/79 when they designed the
8087: If you did not have the FPU, then the main 8088 CPU would trap to
an emulation layer which did what was required. The only real problem
was that this was significantly slower than a direct call to a SW
function which did the same operation.
Sadly, no. Without an 8087 the 8088 just ignored the ESC opcode used
by floating instructions, but ...
What we ended up with on most applications was a hybrid, where the
compiler would generate calls to a shim, said shim would inspect the
available HW (FPU/No FPU) and patch the call:
The Wizard C compiler, the predecessor of Turbo C, had a hack where it emitted floating point instructions but with the first byte replaced
by a trap opcode. Then it was roughly as you described, patch it
to a real float instruction if there was an 8087, or call the software version.
An interesting question here is "Do one has to include 128b / 64b
division in the ISA or it's better to leave it off?".
AMD decided that it was needed, but it seems that nobody else followed
the suit.
The same can be seen already in the 32-bit relatives. Most (all?)
RISCs just have 32/32 division, if they have division at all, IA-32
has 64/32. So they continue that in 64-bit RISCs and AMD64.
According to Terje Mathisen <terje.mathisen@tmsw.no>:
Intel actually did this correctly back in 1978/79 when they designed the >>8087: If you did not have the FPU, then the main 8088 CPU would trap to
an emulation layer which did what was required. The only real problem
was that this was significantly slower than a direct call to a SW
function which did the same operation.
Sadly, no. Without an 8087 the 8088 just ignored the ESC opcode used
by floating instructions, but ...
MitchAlsup wrote:
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level
programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
But "lack of division" is also costly !! especially if some future
implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
Intel actually did this correctly back in 1978/79 when they designed the 8087: If you did not have the FPU, then the main 8088 CPU would trap to
an emulation layer which did what was required. The only real problem
was that this was significantly slower than a direct call to a SW
function which did the same operation.
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level
programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
But "lack of division" is also costly !! especially if some future implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
Note to -|Architects, put the instruction in even if you are going to
TRAP to SW emulation. Later on when DIV is implemented it just runs
faster and you had to do nothing (but put it in).
I used TeX on 386. It did relatively small number of floating
point operations.
MitchAlsup <user5857@newsgrouper.org.invalid> wrote:
But "lack of division" is also costly !! especially if some future
implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
You assume binaries or assembler code. In microcontroller world
programs are frequently compiled for one specific CPU model.
MitchAlsup <user5857@newsgrouper.org.invalid> wrote:
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level
programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
But "lack of division" is also costly !! especially if some future implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
You assume binaries or assembler code. In microcontroller world
programs are frequently compiled for one specific CPU model.
And in case of microcontrollers savings due to ommision of
divide circuit can be significant.
I know you do not like
Risc-V, but one small model (CH32V003) even skips multiplication.
IIUC even smallest Arm-s have multiplication (which theoretically
can be slow, but on all small models that I know it 32 bit
multiplication executes in 1 cycle).
Note to -|Architects, put the instruction in even if you are going to
TRAP to SW emulation. Later on when DIV is implemented it just runs
faster and you had to do nothing (but put it in).
You need to make it fast enough so that compilers are not tempted
to call software emulation. Also beware of interrput latency,
if division is slow microcontroller probably should allow
interrupts in the middle of division.
Sadly, no. Without an 8087 the 8088 just ignored the ESC opcode used
by floating instructions, but ...
I did not look at 8088, but 80386 trapped when requested.
antispam@fricas.org (Waldek Hebisch) writes:
I used TeX on 386. It did relatively small number of floating
point operations.
AFAIK TeX does not do FP, or at least the versions from those times
did not. That's because TeX was intended to create reproducible
results across machines, and FP was not useful for that when TeX was
written, because FP operations behaved differently on different
machines.
MitchAlsup <user5857@newsgrouper.org.invalid> wrote:
anton@mips.complang.tuwien.ac.at (Anton Ertl) posted:
makendo <makendo@makendo.invalid> writes:
The case where division is implemented but
multiplication is not does not have a name assigned -- it is pretty
well known that hardware designers, compiler writers and low-level
programmers hate division far more than multiplication, so I doubt
if divison-only hardware is even out in the wild for any ISA...
I don't think that "hate" is the right concept. Division is costly:
But "lack of division" is also costly !! especially if some future
implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
You assume binaries or assembler code. In microcontroller world
programs are frequently compiled for one specific CPU model.
And in case of microcontrollers savings due to ommision of
divide circuit can be significant. I know you do not like
Risc-V, but one small model (CH32V003) even skips multiplication.
IIUC even smallest Arm-s have multiplication (which theoretically
can be slow, but on all small models that I know it 32 bit
multiplication executes in 1 cycle).
Note to -|Architects, put the instruction in even if you are going to
TRAP to SW emulation. Later on when DIV is implemented it just runs
faster and you had to do nothing (but put it in).
You need to make it fast enough so that compilers are not tempted
to call software emulation. Also beware of interrput latency,
if division is slow microcontroller probably should allow
interrupts in the middle of division.
antispam@fricas.org (Waldek Hebisch) writes:
I used TeX on 386. It did relatively small number of floating
point operations.
AFAIK TeX does not do FP, or at least the versions from those times
did not. That's because TeX was intended to create reproducible
results across machines, and FP was not useful for that when TeX was
written, because FP operations behaved differently on different
machines.
- anton
especially if some future
implementation will have division {which it will} and then you have
no direct means to make the dusty decks fast.
Note to -|Architects, put the instruction in even if you are going to
TRAP to SW emulation. Later on when DIV is implemented it just runs
faster and you had to do nothing (but put it in).
Note to -|Architects, put the instruction in even if you areYou need to make it fast enough so that compilers are not
going to TRAP to SW emulation. Later on when DIV is
implemented it just runs faster and you had to do nothing
(but put it in).
tempted to call software emulation. Also beware of interrput
latency,
I am shooting at 10 cycles there and 10 cycles back.
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
Note to -|Architects, put the instruction in even if you areYou need to make it fast enough so that compilers are not
going to TRAP to SW emulation. Later on when DIV is
implemented it just runs faster and you had to do nothing
(but put it in).
tempted to call software emulation. Also beware of interrput
latency,
I am shooting at 10 cycles there and 10 cycles back.
Would it be possible to have a hardware version of polyfill? The
basic idea would be that instead of emulation via trapping, the
software calls a standardized divide routine. On hardware with a
divide instruction it checks the routine and if it sees it's the
standard divide routine it just uses its divide instruction
instead. If it doesn't have hardware division it just runs the
divide routine.
I think I'd be more likely to use new instructions if they worked
this way, providing the standard polyfill routine in the
documentation for the new instruction. The way things work now I
only use them after they've been around for a decade.
Would it be possible to have a hardware version of polyfill? The
basic idea would be that instead of emulation via trapping, the
software calls a standardized divide routine. On hardware with a
divide instruction it checks the routine and if it sees it's the
standard divide routine it just uses its divide instruction
instead. If it doesn't have hardware division it just runs the
divide routine.
Josh Vanderhoof <x@y.z> posted:
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
Note to -|Architects, put the instruction in even if you areYou need to make it fast enough so that compilers are not
going to TRAP to SW emulation. Later on when DIV is
implemented it just runs faster and you had to do nothing
(but put it in).
tempted to call software emulation. Also beware of interrput
latency,
I am shooting at 10 cycles there and 10 cycles back.
Would it be possible to have a hardware version of polyfill? The
basic idea would be that instead of emulation via trapping, the
software calls a standardized divide routine. On hardware with a
divide instruction it checks the routine and if it sees it's the
standard divide routine it just uses its divide instruction
instead. If it doesn't have hardware division it just runs the
divide routine.
I do not see any justification of NOT having DIV as an instruction
and in HW (by means of some king of sequencer). In the same way
we can put 16 GBOoO cores on a single die with 256-bit wide SIMD,
the amount of area saved not doing DIV is invisible when seen at
the die-level.
In the smallest conceivable implementations, DIV is a multiplexer in
the feedback-loop around the integer ADDer and a 5-state sequencer.
For me, I can't see building a core that does not have a 64|u64
multiplier, either.
I think I'd be more likely to use new instructions if they worked
this way, providing the standard polyfill routine in the
documentation for the new instruction. The way things work now I
only use them after they've been around for a decade.
I have no idea what you mean by polyfill.
Josh Vanderhoof <x@y.z> posted:
MitchAlsup <user5857@newsgrouper.org.invalid> writes:
Would it be possible to have a hardware version of polyfill?I am shooting at 10 cycles there and 10 cycles back.Note to -|Architects, put the instruction in even if youYou need to make it fast enough so that compilers are not
are going to TRAP to SW emulation. Later on when DIV is
implemented it just runs faster and you had to do nothing
(but put it in).
tempted to call software emulation. Also beware of
interrput latency,
The basic idea would be that instead of emulation via
trapping, the software calls a standardized divide routine.
On hardware with a divide instruction it checks the routine
and if it sees it's the standard divide routine it just uses
its divide instruction instead. If it doesn't have hardware
division it just runs the divide routine.
I do not see any justification of NOT having DIV as an
instruction and in HW (by means of some king of sequencer). In
the same way we can put 16 GBOoO cores on a single die with
256-bit wide SIMD, the amount of area saved not doing DIV is
invisible when seen at the die-level.
In the smallest conceivable implementations, DIV is a
multiplexer in the feedback-loop around the integer ADDer and a
5-state sequencer.
For me, I can't see building a core that does not have a 64|u64
multiplier, either.
I think I'd be more likely to use new instructions if they
worked this way, providing the standard polyfill routine in
the documentation for the new instruction. The way things
work now I only use them after they've been around for a
decade.
I have no idea what you mean by polyfill.
MitchAlsup <user5857@newsgrouper.org.invalid> writes:There is simply no way to do that for individual instructions intended
Josh Vanderhoof <x@y.z> posted:
MitchAlsup <user5857@newsgrouper.org.invalid> writes: >> > Note to
|e-|Architects, put the instruction in even if you >> > are-a going to
TRAP to SW emulation. Later on when DIV is >> > implemented it just
runs faster and you had to do nothing >> > (but put it in). >>-a You
need to make it fast enough so that compilers are not >> tempted to
call software emulation.-a Also beware of >> interrput-a latency, >-a I >>> am shooting at 10 cycles there and 10 cycles back. -aWould it be >>> possible to have a hardware version of polyfill? The-a basic idea
would be that instead of emulation via trapping, the-a software calls
a standardized divide routine. On hardware with a-a divide instruction
it checks the routine and if it sees it's the-a standard divide
routine it just uses its divide instruction-a instead.-a If it doesn't
have hardware division it just runs the-a divide routine.
I do not see any justification of NOT having DIV as an instruction and
in HW (by means of some king of sequencer). In the same way we can put
16 GBOoO cores on a single die with 256-bit wide SIMD,-a the amount of
area saved not doing DIV is invisible when seen at-a the die-level.
In the smallest conceivable implementations, DIV is a multiplexer in
the feedback-loop around the integer ADDer and a 5-state sequencer.
For me, I can't see building a core that does not have a 64|arCo64
multiplier, either.
I get that, but I'm not really talking about the necessity of divide instructions.-a I'm talking about dealing with processors with different sets of features.
Say instead it's for something called featurex and some processors want
it in hardware and some don't.-a It'd be much easier for someone writing
the software if a standard sequence of instructions for doing featurex > was defined and new processors that do featurex in hardware
automatically checked call targets and recognize when the instruction sequence matches featurex. Then when the routine is called later uses
the dedicated instruction instead doing the call.
It's be really nice because the code would be identical for everything > and also run about as fast as possible on everything. I have no idea howThey have the luxury of JIT everywhere so they can still run at
hard it would be to keep the track of which subroutines are actually new instructions though.
I'd much rather have something like this than have to write multiple versions of things depending on whether or not some CPUID bit is set.
I think I'd be more likely to use new instructions if they worked
this way, providing the standard polyfill routine in the
documentation for the new instruction.-a The way things work now I
only use them after they've been around for a decade.
I have no idea what you mean by polyfill.
When they add new stuff to Javascript they provide equivalent code that works in older versions that's called "polyfill".-a It's convenient
because it lets you use the new API without needing alternate versions > for older interpreters.
Say instead it's for something called featurex and some processors
want it in hardware and some don't. It'd be much easier for
someone writing the software if a standard sequence of
instructions for doing featurex was defined and new processors
that do featurex in hardware automatically checked call targets
and recognize when the instruction sequence matches featurex.
Then when the routine is called later uses the dedicated
instruction instead doing the call.
It's be really nice because the code would be identical for
everything and also run about as fast as possible on everything.
I have no idea how hard it would be to keep the track of which
subroutines are actually new instructions though.
The correct way here is to have a function pointer that initially points
at a thunk which checks (CPUID) the local cpu and then updates the
pointer to go directly to the optimized version.
Josh Vanderhoof <x@y.z> schrieb:
Say instead it's for something called featurex and some processors
want it in hardware and some don't. It'd be much easier for
someone writing the software if a standard sequence of
instructions for doing featurex was defined and new processors
that do featurex in hardware automatically checked call targets
and recognize when the instruction sequence matches featurex.
Then when the routine is called later uses the dedicated
instruction instead doing the call.
You could have instructions that either do things in hardware or
jump to a subroutine at a defined address from a jump table
index by opcode. That would solve the problem, I think, and
It's be really nice because the code would be identical for
everything and also run about as fast as possible on everything.
I have no idea how hard it would be to keep the track of which
subroutines are actually new instructions though.
this would be OK.
Has anybody actually done this?
Seems obvious, but maybe only
in hindsight, and could save the RISC-V compiler writers a
lot of grief, at least as far as compatibility is concerned, but
cost would be another matter.
Thomas Koenig <tkoenig@netcologne.de> posted:
Josh Vanderhoof <x@y.z> schrieb:
Say instead it's for something called featurex and some processors
want it in hardware and some don't. It'd be much easier for
someone writing the software if a standard sequence of
instructions for doing featurex was defined and new processors
that do featurex in hardware automatically checked call targets
and recognize when the instruction sequence matches featurex.
Then when the routine is called later uses the dedicated
instruction instead doing the call.
You could have instructions that either do things in hardware or
jump to a subroutine at a defined address from a jump table
index by opcode. That would solve the problem, I think, and
That would add LDD-latency plus JUMP-latency to instruction-latency--
even if the index was extracted by HW. Probably around 5-6 cycles.
It's be really nice because the code would be identical for
everything and also run about as fast as possible on everything.
I have no idea how hard it would be to keep the track of which
subroutines are actually new instructions though.
this would be OK.
Has anybody actually done this?
How do you think microCode works ??
Terje Mathisen <terje.mathisen@tmsw.no> schrieb:
The correct way here is to have a function pointer that initially points
at a thunk which checks (CPUID) the local cpu and then updates the
pointer to go directly to the optimized version.
gfortran does that for calling different versions of matmul
compiled with different flags.
MitchAlsup <user5857@newsgrouper.org.invalid> schrieb:
Thomas Koenig <tkoenig@netcologne.de> posted:
You could have instructions that either do things in hardware or
jump to a subroutine at a defined address from a jump table
index by opcode. That would solve the problem, I think, and
That would add LDD-latency plus JUMP-latency to instruction-latency--
even if the index was extracted by HW. Probably around 5-6 cycles.
What I was thinking of was to expose this in the ISA, so people
could use multiplication etc without having to switch on CPU
type, which is a pain.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 55:42:04 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,687 |