home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / misc / 3837 < prev    next >
Encoding:
Text File  |  1992-11-22  |  6.1 KB  |  136 lines

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: Hardware Support for Numeric Algorithms
  5. Message-ID: <9232818.19503@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <722061187@sheol.UUCP> <1efh6vINNm6c@network.ucsd.edu> <722228704@sheol.UUCP> <By2MH8.JFB@mentor.cc.purdue.edu>
  9. Date: Mon, 23 Nov 1992 07:38:40 GMT
  10. Lines: 124
  11.  
  12. hrubin@mentor.cc.purdue.edu (Herman Rubin) writes:
  13.  
  14. >In article <722228704@sheol.UUCP> throopw@sheol.UUCP (Wayne Throop) writes:
  15. >
  16. >>Except that when such capabilities are pointed out, he sneers at
  17. >>them, and then asks for something else.  For example, gcc can generate
  18. >>inline procedures with assembly instructions interspersed.  For pointing
  19. >>this out, people get sneered at, and told that the notation isn't
  20. >>simple enough.
  21. >
  22. >Working in a university environment does produce some problems, which
  23. >those with reasonable manpower support do not seem to realize.  I can
  24. >get gcc on some machines, but we do not yet have it on the one I am
  25. >supposed to use for production.
  26.  
  27. Do you have access to ftp and access to roughly 20M of disk space (maybe in
  28. /tmp)? If so, ftp the source and compile it yourself!
  29. It should take about an hour to install, not counting compilation time
  30. (you can compile it in the background while you read news :-).
  31. Considering the time that you and other people have spent posting on this
  32. topic, it would seem like a worthwhile investment.
  33.  
  34. >Also, it cannot be used for program
  35. >design for more than one machine, which is something I am supposed to
  36. >be involved in.
  37.  
  38. Why on earth not?
  39.  
  40. >This is a major reason for asking for a good macro
  41. >translator, to isolate the dependent problems from the independent 
  42. >ones and still be able to communicate.  I cannot reasonably communicate
  43. >SPARCstation program to someone using an RS/6000 or a CRAY Y-MP, but I
  44. >can communicate the algorithm to a mathematician using any one of those
  45. >machines in such a way that a language hacker could come up with good
  46. >code in consultation.
  47.  
  48. In what ways are inline functions and gcc's inline asm constructs insufficient?
  49.  
  50. In a sense the compiler is just a good macro preprocessor, except that it
  51. does type-checking, register allocation, code generation and optimization for
  52. you. If it's code generation is not good enough or doesn't give you access
  53. to all the machine instructions, you can use inline asm. If the register
  54. allocation is suboptimal, you can specify which variables go in registers
  55. and with gcc, even which variables go in which registers.
  56.  
  57. In theory at least, it should be possible to provide high-level code which
  58. serves to communicate your algorithm, but implement that code using
  59. inline functions and inline asm, etc. You haven't said anything which
  60. might convince me that this is not a practical and reasonable approach.
  61.  
  62. >I am not just interested in producing good code for one machine, but
  63. >good code in general, and I believe that this can be done without 
  64. >requiring every mathematician or physicist wanting good procedures 
  65. >for non-uniform random numbers to learn Lisp.
  66.  
  67. So do I, but obviously they will have to learn *something*.
  68. I think that C with inline assembly is probably going to be as good
  69. as anything else.
  70.  
  71. >>: So if C doesn't know how to do a fp divide with integer quotient and a
  72. >>: remainder in one instruction, or how to do a "add in parallel, but
  73. >>: only on those processors in this mask" (a CM),
  74. >>: then no amount of higher-level rewriting will help.
  75. >
  76. >>Yes, this is the most central problem, which Jim Giles mentioned also.
  77. >>Some method is needed which will specify the generated code, and yet
  78. >>will fit in with the optimizations and register allocations and so on
  79. >>which are already in place.  Jim says this "isn't too difficult", but 
  80. >>I think it is the single most difficult part.  I've seen several
  81. >>solutions, each with some advantages over the others.
  82. >
  83. >THIS is one aspect of the problem; the attempt to get a detailed complete
  84. >package, instead of putting partial solutions together;
  85.  
  86. As I have said before, I think that gcc should do the trick.
  87. Inline asm is well integrated into gcc, it's not just a partial
  88. solution.
  89.  
  90. >the attempt to
  91. >take the programmer out of an interactive optimization procedure with the
  92. >compiler
  93.  
  94. Whose attempt?
  95. If you want an interactive optimization procedure, it's already there.
  96.  
  97. 1. Compile with -S
  98. 2. Examine the assembly output file
  99. 3. If looks OK, go to step 6.
  100. 4. Modify compiler flags, introduce new compiler hints, and/or introduce
  101.    inline asm code.
  102. 5. Go to step 1.
  103. 6. Profile the code again (you already did that before examining the assembly
  104.    output, right?) to make sure that it is satisfactory. If not, go back to
  105.    step 1.
  106.  
  107. Of course, next thing someone will be complaining that we need a GUI interface
  108. to do this properly...
  109.  
  110. >the failure to realize that the present so-called optimizations
  111. >and register allocations are often bad; etc.
  112.  
  113. >>But ultimately, when you are going after that last 1% or .1% of speed,
  114. >>you will simply have to spell out the istream, operation by operation.
  115. >>No amounts of hints to the optimizer will ever be enough, because
  116. >>ultimately the optimizer can only deal with hints it is prepared to
  117. >>accept, and if a programmer comes up with something unforseen by the
  118. >>optimizer, there's no simple way to give a hint about it.
  119. >
  120. >So put in simple ways to give hints, instead of saying that no hints
  121. >can be given.  The difference is not the last 1% of speed, but often
  122. >50% of the running time or more.
  123.  
  124. I fully agree that it is important to be able to provide hints to the compiler.
  125. Hell, I just finished my honours thesis on almost exactly that topic!
  126. (although it was for logic programming languages, not for C).
  127.  
  128. The tricky question is exactly what sort of hints are required.
  129. Do you have any particular hints in mind?
  130.  
  131. -- 
  132. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  133. This .signature virus is a self-referential statement that is true - but 
  134. you will only be able to consistently believe it if you copy it to your own
  135. .signature file!
  136.