🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #12121

Re: More on Linpack pivoting: isamax and instruction set design

#12121
From: Richard A. O'Keefe
Date: Sun, 16 Jun 1991 09:07
55 lines
3022 bytes
In article <1991Jun14.134338.4673@linus.mitre.org>, bs@frieda.mitre.org (Robert D. Silverman) writes:
> :	    absdx = abs(dx(i))
> :	    ibig  = absdx .le. dmax
> 	    ^^^^^^^^^^^^^^^^^^^^^^^ 
> I would be very interested in seeing the assembler code that gets
> emitted for this line of Fortran. How can this statement get executed
> WITHOUT a branch??

Quite a lot of machines can do this, including VAXes, MC680x0, MC88k,
Prime 50 series, Burroughs machines, NS32?32.  Since you asked for
assembler, here's NS32532 assembly code.

	# assume that DX is a static address and that I is in R0
	absf	DX[R0:D], F0	# F0 := abs(dx(i))
	# assume that dmax is in F1
	cmpf	F1, F0		# N := F1 > F0, Z := F1 = F0
	# assume that ibig is to be in R1
	sgtd	R1		# R1 := 1 if abs(dx(i)) > dmax, 0 otherwise

Indeed, even an 8086 can do it.  Once you've done the comparison,
	lahf			# AH := [Sign,Zero,*,Aux,*,Parity,*,Carry]
will do the trick, if your Fortran compiler takes "negative" as the
representation of .true., "non-negative" as the representation of .false.

> I also have never seen a machine that has conditional assignment
> implemented as an instruction!

Perhaps someone who knows the ARM instruction set can comment on this.
There was a trick that could be used on KA-10s.  Registers could be
addressed as memory.  If the NS32532 supported that hack for FP
registers, then something like
	movf	F1, "F0"[R1:D]
would be usable in this case.  I have a notion that something similar
could be done on the AMD 29000.

As a single instruction, you may not find it, but it isn't hard to do a
conditional assignment using straight-line code.  Suppose R0 holds a 0
or 1 (which we may destroy), and we want to do
	R2 := R3 IF R0
Here's the code, using NS32532 mnemonics.
	negd	r0, r0	# r0 := if <change wanted> then ~0 else 0
	andd	r0, r3	# if not <change wanted> then r3 := 0
	comd	r0, r0	# r0 := if <change wanted> then 0 else ~0
	andd	r0, r2	# if <change wanted> then r2 := 0
	ord	r3, r2	# r2 := if <change wanted> then 0 | r3
			#       else r2 | 0

Of course, as Herman Rubin will point out if I don't, this involves doing
bitwise operations on the floating-point registers, which is why I quietly
did it to R2, R3 instead of F1, F0.  (NB:  the instructions above are just
a simple MUX done wordwise.)

-- 
Q:  What should I know about quicksort?   A:  That it is *slow*.
Q:  When should I use it?  A:  When you have only 256 words of main storage.
Technical Details
Message-ID: <6357@goanna.cs.rmit.oz.au>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!munnari.oz.au!goanna!ok
References: <396@validgh.com> <1991Jun13.234834.22970@neon.Stanford.EDU> <1991Jun14.134338.4673@linus.mitre.org>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!munnari.oz.au!goanna!ok
From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
Newsgroups: comp.arch
Subject: Re: More on Linpack pivoting: isamax and instruction set design
Message-ID: <6357@goanna.cs.rmit.oz.au>
Date: 16 Jun 91 09:07:19 GMT
Article-I.D.: goanna.6357
References: <396@validgh.com> <1991Jun13.234834.22970@neon.Stanford.EDU> <1991Jun14.134338.4673@linus.mitre.org>
Organization: Comp Sci, RMIT, Melbourne, Australia
Lines: 55