Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!gatech!prism!bb16 From: bb16@prism.gatech.EDU (Scott Bostater) Newsgroups: comp.lang.pascal Subject: Re: Sorting with 80x87 Message-ID: <28671@hydra.gatech.EDU> Date: 10 May 91 15:20:46 GMT References: <14826@ccncsu.ColoState.EDU> Organization: Georgia Institute of Technology Lines: 41 In article <14826@ccncsu.ColoState.EDU> mglacy@lamar.ColoState.EDU writes: > >I revised a program to take advantage of my 80287 co-processor. >The program generates some 10,000 values of a random variable, then sorts >them and outputs a frequency distribution for the variable. I find >that, in the {$N+} mode, the program is only marginally faster in overall >exec. time. Everything except the sort seems to run MUCH faster, but >the sort is now a real dog. Sorting in {N+} mode is so slow that it negates >the time saved elsewhere in the program. > Are you still using REAL as your data type? If so, change to either SINGLE or DOUBLE. What happens when you use REAL with {$N+} is as follows: 1) convert 1st 6 byte real to 8 byte double 2) load 8087 with double 3) convert 2nd 6 byte real to 8 byte double 4) load 8087 with double 5) have 8087 to compare function 6) *If* swap necessary 6.1) Pop 8 byte double off 8087 6.2) convert 8 byte double to 6 byte real 6.3) Pop 8 byte double off 8087 6.4) convert 8 byte double to 6 byte real Needless to say there's a whole lot of converting going on and slowing you down If you want a quick test just put the following at the begining of your program (for purposes of readability and maintainabiliy I don't recommend this as a permanent fix!) type Real = Double; This will change all your REAL's to DOUBLEs and you should notice a signifigant speed up. -- Scott Bostater Georgia Tech Research Institute - Radar Systems Analysis "My soul finds rest in God alone; my salvation comes from Him" -Ps 62.1 uucp: ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!bb16 Internet: bb16@prism.gatech.edu