schell@iris.ucdavis.edu (Stephan Schell) (08/12/89)
Why do integer multiplies take longer than double precision floating point multiplies (at least, in C) ? I timed 180K integer multiply-accumulates and 206K double precision floating point multiply accumulates (including integer-to-double conversion) using the "times()" function. This seems kind of hokey that integer multiplies run slower than double precision floats, doesn't it? Steve Dept of EE & CS Univ. Calif., Davis
daryl@hpcllla.HP.COM (Daryl Odnert) (08/15/89)
First, remember that as a RISC architecture, HP Precision Architecture does not have a generalized integer multiply instruction. However, * Multiplication by compile-time constants can generally be performed in four or fewer (single-cycle) instructions. * Multiplications by variables, including full overflow checking, can be obtained in an average of less than 20 single-cycle instructions. (This average is based on an expected distribution where 80% of the time, the absolute value of one of the operands of the multiply is <= 255.) * Multiplications involving large operands (where the smallest absolute value of the two operands is > 4K) can take between 36 and 56 cycles to complete. These datapoints were taken from "Integer Multiplication and Division on the HP Precision Architecture", Proceedings of the Second International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS II), ACM, October 1987. For floating-point, I think a double precision FMPY instruction on the 9000/825 takes somewhere in the neighborhood of 15 to 20 cycles to complete. An integer to floating point conversion probably takes about the same amount of time. Thus, if the typical operands to your integer multiplies are large values and not determined to be constants by the compiler, your results are reasonable. How are the operands to your multiplies computed? Also, did you use full optimization at compile time? Daryl Odnert Hewlett Packard California Languages Lab daryl%hpcllla@hplabs.hp.com
raj@hpindwa.HP.COM (Richard Jones) (08/15/89)
why is floating-point faster than integer??? one reason could be that the floating point is going to a co-processor, and the integer is being handled by millicode... ...your performance will vary raj
ronw@hpuflfa.HP.COM (Ron Williams) (08/16/89)
Note that HP-PA has no integer multiply instruction. Multiplying by a constant gives fairly good performance since the comiler produces as series of shifts and adds. Multiplying by variables uses the millicode. For integer division there are instructions that are used which are primitive instructions which allow the process to be performed in single cycle steps. Ron Williams HP Ft. Lauderdale ronw@hpfcse ------------ TEL: T-938-2278 {hpfcse}!hpuflfa!ronw FAX: T-938-2293 COMSYS: 3179 AREA CODE: 305 HPDESK: Ron Williams / HP3179/07