ECN No Name Newsletter: January, 1988

The ECN No Name Newsletter is no longer being published. This is an archived issue.

[previous article] [next article]

Optimization and Floating Point options on the Sun Workstation

Dwight D. McKay

The Sun Workstation has a variety of compiler optimization and floating point options which differ from the other systems around ECN. Here are a few helpful hints about using these options.

The most important thing to remember about optimization of code on the Sun workstation is this: No optimization is done unless requested. You must specify an optimization and/or floating point option if you want the compiler to try and improve the performance of your code.

The basic optimization option is "-O". This option invokes a limited global optimizer on C and Pascal programs and a more powerful optimizer, /usr/lib/iropt on Fortran programs. Fortran users should consult the Floating-Point Programmer's Guide for the Sun Workstation for additional information and caveats about using the -O option with the Fortran compiler.

Floating point math is one of the most time consuming operations done by many programs. Using special purpose hardware to do floating point math can greatly speed up a given program which does a great deal of number crunching.

On Suns, you have four basic floating point option flags which you can give to the C, fortran (f77) or pascal compilers :

Flag            Hardware Required       Consequences
==============================================================
-fswitch        none, works on all      slightly larger binary
-f68881         MC68881 chip            only runs on Suns
                                           with MC68881*
-ffpa           Sun FPA board           only runs on Suns
                                           with FPA
-fsoft          none, uses software     slow
==============================================================

The -fsoft option is the Sun default. It uses software to do floating point math and although slow, it will run on all Sun workstations. The two hardware specific options, -f68881 and -ffpa use specific hardware for fast (MC68881) and fastest (FPA) floating point math. However, code generated with these options cannot be run on Suns without the correct hardware installed. Therefore, we recommend you use the -fswitch option if you intend your program to be run on a variety of Suns. This option generates additional code to detect and use either the FPA or MC68881 chip if available or software if no floating point hardware is installed.

You can specify the floating point option you use most often for all of the compilers by setting the environment variable FLOAT_OPTION. To do this in csh(1), you would type one the following:

   setenv FLOAT_OPTION f68881
   setenv FLOAT_OPTION fsky
   setenv FLOAT_OPTION ffpa

This command can be added to your .cshrc file so it will be set any time you login or startup a new window. Other options which work in this manner are fswitch, ffpa, and fsoft.

WARNING: You cannot link together pieces of code compiled with different floating point options. If you try to do this you will get one of the following error messages:

     Undefined: fsky_used
     Undefined: f68881_used
     Undefined: ffpa_used

For additional information on floating point facilities on Suns, take a look at the Floating-Point Programmer's Guide for the Sun Workstation, which is part of the Sun Workstation manual set.

*Most ECN Suns have 68881. You may check on your Sun by typing "/usr/etc/mc68881version".


webmaster@ecn.purdue.edu
Last modified: Saturday, 01-Nov-97 11:55:22 EST

[HTML Check] HTML