home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / arch / 10449 < prev    next >
Encoding:
Internet Message Format  |  1992-11-07  |  3.3 KB

  1. Xref: sparky comp.arch:10449 comp.lang.misc:3521
  2. Newsgroups: comp.arch,comp.lang.misc
  3. Path: sparky!uunet!spool.mu.edu!uwm.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!sample.eng.ohio-state.edu!purdue!mentor.cc.purdue.edu!hrubin
  4. From: hrubin@mentor.cc.purdue.edu (Herman Rubin)
  5. Subject: Re: Hardware Support for Numeric Algorithms
  6. Message-ID: <BxAJMA.DKy@mentor.cc.purdue.edu>
  7. Keywords: n
  8. Organization: Purdue University Statistics Department
  9. References: <1992Oct29.153514.22927@yrloc.ipsa.reuter.COM> <1992Nov5.202412.7266@linus.mitre.org> <1992Nov6.075459.13348@coe.montana.edu>
  10. Date: Fri, 6 Nov 1992 10:54:09 GMT
  11. Lines: 57
  12.  
  13. In article <1992Nov6.075459.13348@coe.montana.edu> osycs@giac1.oscs.montana.edu (Craig Spannring) writes:
  14.  
  15.             .............................
  16.  
  17. >Large scale computing demands that you to avoid the unreadable
  18. >micro-optimizations that Herman is suggesting.  If one of your little
  19. >attempts at optimizing the code ends up producing incorrect results
  20. >then you've just wasted months of research time.  Meanwhile your
  21. >colleagues that have programs producing correct results are getting
  22. >published and getting grants.  How much research and computing time are
  23. >you wasting with buggy programs?
  24.  
  25. As I see it, every one of the "micro-optimizations" I used is something
  26. which is totally natural to someone who has not been brainwashed out of
  27. gotos.  The code I posted originally was buggy do to an attempt to avoid
  28. gotos in situations for which I was aware of alternatives which would not
  29. slow down to code.
  30.  
  31. >The second problem with these 'optimizations' is that they aren't.
  32. >Herman seems to be most concerned with saving a few clock cycles per
  33. >iteration.  The only significant performance gains will be found be
  34. >using an algorithm that uses fewer iterations.  Example-  Even a highly
  35. >optimized bubble sort will run slower than an unoptimized quick sort
  36. >for the large data sets you are refering to.
  37.  
  38. You are partially correct here.  I can get an improvement in the code
  39. which produces different results, and uses the same average number of
  40. resources of each type, by changing the algorithm to start out
  41.  
  42. start:    g = ...;
  43.     n += (g-1);
  44.     g = ...;
  45.     if (g==1) goto label1;
  46.  
  47. and have each situation here have the g value 1 less.  This now 
  48. reduces the average number of uses of start: per output of n and m
  49. by a factor of 2 to 1.54.  Other "micro-optimizations", which some
  50. of my correspondents found, can make speedups.  But they use some
  51. code "duplication" (really duplication but with some initialization
  52. removed) and at least as many gotos.  By using vectorization tricks,
  53. which instead of producing a fixed number of outputs produce a
  54. variable number, and by using vector insertions, that this type of
  55. program can be significantly speeded up.
  56.  
  57. Additional performance improvements can be obtained by instead
  58. ending the higher g's off and using a fallthrough to label1, 
  59. as 77% of the loop exits do this.  This is the situation both
  60. in this modified code and the original.  This can be done by
  61. exporting most of the instructions into another block; would
  62. your optimizing compilers find this?  Certainly not without
  63. being given the 77% information above in some manner.
  64.     
  65. -- 
  66. Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907-1399
  67. Phone: (317)494-6054
  68. hrubin@snap.stat.purdue.edu (Internet, bitnet)  
  69. {purdue,pur-ee}!snap.stat!hrubin(UUCP)
  70.