



FORTRAN Floating-point arithmetic under UNIX on an 11/40.



I.      Introduction


Our  UNIX  system  operates  on  a  CDP emulation of a PDP 11/40.
FORTRAN "number-crunching" programs were found to severely impair
system  throughput.   The  source  of  the  problem  is that UNIX
FORTRAN as received uses 11/45 floating point instructions, which
an 11/40 doesn't have.  This causes two problems:
1.  Floating point operations are simulated, thus slow.
2.   Floating point traps to the system, causing significant sys-
tem overhead.  Apparently, the system  took  the  opportunity  to
evaluate  the status of the processes - a waste of time given the
frequency of floating point traps.

        The  first  problem  above  was  attacked  by  converting
single-precision   floating   point  arithmetic  in  the  FORTRAN
subroutine libraries to make use  of  the  11/40  floating  point
instructions.  These instructions are far less extensive than the
11/45 instructions; several subroutines thus  required  extensive
modification   in   order   to  achieve  reasonable  performance.
Sin/cos, exp, alog, and io are the extreme  cases.   All  conver-
sions required care, since 11/40 floating point is carried out on
the stack whereas an 11/45 has a separate area in which to  carry
out floating point manipulations - the floating point registers.
        Single-precision arithmetic was thus taken care  of,  but
double  precision  operations  still  trapped through the system,
causing the second problem listed above.  To avoid  the  trapping
overhead,  the  new  FPSIM  (fp.o  in /lib/liba.a) has a callable
entry  point.   To  use  from  an  assembler  program,  do   "jsr
pc,fpsim"  followed  by  instruction  to  be simulated.  Floating
point traps WILL continue to function as expected; the "jsr"  and
the   "trap"  are  functionally  equivalent--they  use  the  same
pseudo-floating-registers and the same code to perform the opera-
tion requested.
        Routines written in C could also benefit  (on  an  11/40)
from  use  of  single-precision hardware and the new FPSIM.  This
might be done by changing the assembly  code  output  by  the  C-
compiler.














