home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / compiler / 2081 < prev    next >
Encoding:
Text File  |  1993-01-04  |  10.1 KB  |  226 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!spool.mu.edu!enterpoop.mit.edu!world!iecc!compilers-sender
  3. From: syiek@tartan.com
  4. Subject: High Quality DSP Compilers
  5. Reply-To: syiek@tartan.com
  6. Organization: Compilers Central
  7. Date: Mon, 4 Jan 1993 22:43:42 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <93-01-008@comp.compilers>
  10. Keywords: DSP, optimize, comment
  11. References: <92-12-094@comp.compilers> <92-12-097@comp.compilers>
  12. Sender: compilers-sender@iecc.cambridge.ma.us
  13. Lines: 211
  14.  
  15. Response to Johan Van Praet and Jeff Enderwick
  16. (discussion of DSP compiler quality).
  17.  
  18. Tartan Inc. is a supplier of Ada development systems for real-time
  19. embedded systems.  We produced the first Ada compiler for a DSP (the
  20. TMS320C3x in '90), and currently also have TMS320C31 and TMS320C40
  21. compilers.
  22.  
  23. As you may already know, the use of Ada is mandated by the U.S.
  24. Department of Defense (DOD) for all defense-related programs.  Use of
  25. assembly is usually limited to 5% or less of a total application.
  26.  
  27. Most real-time DSP applications require extremely tight code.
  28. Traditionally this could only be achieved through careful assembly
  29. language coding.  Thus it is not unusual for DSP users to reject
  30. high-level language compilers, (sometimes before even trying them),
  31. because of this previous experience.
  32.  
  33. Fortunately, the DOD mandate makes it very hard to reject an Ada compiler
  34. without first trying it out.  As a result, the Tartan Ada DSP compilers
  35. are often benchmarked against other compilers and hand coded assembly.
  36. The results have been surprising (but not to us!): Tartan Ada consistently
  37. outperforms other DSP compilers and is usually only slightly slower than
  38. hand coded assembly.  Indeed there are cases where the compiler has
  39. produced code that runs faster or is smaller than hand coded assembly.
  40.  
  41. There are published accounts of several of these benchmarking efforts.
  42. Two are: 
  43.  
  44.    P.K. Lawlis and T.W. Elam "Ada Outperforms Assembly: A Case Study"
  45.    Proceedings of TRI-Ada '92
  46.    Orlando, Florida 1992.
  47.  
  48.    Ralph E. Crafts, "Ada vs. C for the DSP - Advantage Ada",
  49.    Ada Strategies, Vol 5. No. 4, April 1991.
  50.  
  51. The Lawlis paper discusses an incident where the compiler was used to
  52. produced a version of an algorithm that was the same size as hand coded
  53. assembly, but ran twice as fast.
  54.  
  55. There are many technical reasons why the compiler performs as well as it
  56. does.  I refer you to the following papers: 
  57.  
  58.    D.A. Syiek "Challenging Assembly Code Quality,"
  59.    Proceedings of the International Conference on DSP Applications 
  60.    and Technology,
  61.    Berlin, Germany, 1991.
  62.  
  63.    D.A. Syiek and D. Burton
  64.    "Optimizing Ada Code for the TI SMJ320C30 Digital Signal Processor",
  65.    Proceedings of the International Conference on DSP Applications 
  66.    and Technology,
  67.    Brussels, Belgium, 1990.
  68.  
  69. ======================================================================
  70.  
  71. Some specific responses to Johan Van Praet's message:
  72.  
  73. >What causes this factor of 5 on the code size?
  74.  
  75. It is speed that usually matters for my customers.  However, the Lawlis
  76. paper describes how the Ada compiler was also used to produce a version
  77. that was twice as small as the hand-coded assembly.  This is a factor of
  78. 0.5 !
  79.  
  80. >The instruction set of a DSP processor does not lend itself
  81. >to conventional compiling techniques ?
  82.  
  83. All machines are unique to some degree.  A good compiler technology will
  84. accommodate this uniqueness across a wide variety of machines.  We had few
  85. real problems finding ways to generate good TMS320C3x/C4x code.  We expect
  86. few problems when (and if) we tackle other DSP architectures in the
  87. future.
  88.  
  89. >the High Level Languages are not useful for DSP?
  90. >not enough parallelism in C (too difficult to extract the parallelism)?
  91. >too many possible constructs in C ? (a subset of C is better)
  92. >non-procedural languages as e.g. Silage are better ?
  93.  
  94. 1. There are many that believe that C is NOT an example of a modern high 
  95.    level language.  I will pretend that you use "C" as a meta-variable for 
  96.    high-level language (HLL).
  97. 2. You can kill performance in ANY language with bad coding style.
  98.    Conversely, you can tune code easily in a high level language, (but 
  99.    not always the same way for all languages, compilers and targets).
  100. 3. Parallelism at what level?
  101.       Are you building a multiprocessor and want your algorithm magically
  102.       distributed across the system?
  103.       Or do you have asynchronous functional units in your CPU?
  104.       Is the instruction pipeline visible at the user level?
  105.       Are there multiple operations per instruction?
  106. 4. The Tartan TMS320C3x/C4x Ada compiler is able to "fold" loops (make
  107.    software pipelines) and generate parallel instructions.  The parallel
  108.    instructions are also used in many pre-canned sequences and
  109.    library functions invoked automatically where applicable.  Finally, the
  110.    parallel instructions may be created in unusual places through an 
  111.    algorithm we call "threads" that is too combinatorially complex to
  112.    duplicate by hand.
  113.  
  114. >no possibility of using all the provided tricks for the DSP
  115. >processors ?
  116.  
  117. Almost all good compilers contain language extensions, compiler built-ins,
  118. or libraries that allow you to touch the hardware features no matter what
  119. the input language.  For example, the Tartan compiler contains constructs
  120. for using the circular and bit-reversed addressing features of the
  121. TMS320C3x/C4x. 
  122.  
  123. > no global ordering and scheduling of the generated code ?
  124.  
  125. At the machine code level, we schedule code to avoid pipeline delays both
  126. for delayed branching and for all other pipeline locks.  At a higher
  127. level, scheduled tasking and interrupt handling usually deal with the
  128. remainder of the the dynamic scheduling issues.  Automatic multiprocessor
  129. scheduling is usually not a requirement of embedded systems.  Tasks are
  130. statically divided up amongst the resources.
  131.  
  132. >no or not enough use of the low-overhead-loop facility of a
  133. >processor as the "DO" for Motorola and the "RPT" for Texas
  134. >Instruments processors ?
  135.  
  136. The Tartan TMS320C3x/C4x compilers automatically use the RPTS and RPTB
  137. instructions where appropriate.  In fact there are about a dozen
  138. specialized looping constructs the compiler chooses from when building
  139. iteration loops, depending on the nesting depth, iteration count,
  140. resources available ... etc.
  141.  
  142. >no use of special addressing ? (e.g. in circular buffers)
  143.  
  144. As already stated, the Tartan compiler contains constructs for doing
  145. circular addressing and bit-reversed addressing.
  146.  
  147. >no use of special block data moves ?
  148.  
  149. The Tartan compiler uses fast block move sequences whenever appropriate.
  150.  
  151. >I also know of three code generation approaches that would generate more
  152. >optimal code :
  153.  
  154. Now you know of a fourth.  Furthermore it is mature and off-the-shelf and
  155. supports a standardized high-level language.
  156.  
  157. >What is their quality on real life examples ?
  158.  
  159. Tartan has a large customer base - it seems like just about every company
  160. in the defense industry owns a Tartan compiler.  Our DSP compilers have
  161. been used to build many delivered systems.  The feedback we get from our
  162. customers is VERY positive.
  163.  
  164. So what does this mean to the commercial (non-DOD) world:
  165.  
  166.    1. You COULD start using Ada.  If you have a large application, there
  167.       is much evidence that the high cost of entry will pay for itself 
  168.       several times over.  However, much of the commercial world:
  169.       a. Builds small systems on rather primitive fixed-point DSP processors 
  170.          for which good compilers do not exist.
  171.       b. Refuses to consider Ada and will not even study the cost-benefit.
  172.  
  173.   2. Tartan recently formed a commercial division in order to leverage our
  174.      existing technology into that market.  There already two products
  175.      designed to boost C performance: FasTar (high speed trig function
  176.      library) and FloTar (double precision floats for the C3x/C4x).  Look
  177.      for more ambitious products in the coming year.
  178.  
  179. ======================================================================
  180.  
  181. Specific responses to Enderwick's message:
  182.  
  183. I agree with much of what you say.  The difference between your
  184. perspective and mine is that my customers are generally creating
  185. lower-production-volume systems using the newer floating-point chips.
  186. These systems are large (often measured in 100K line increments) and have
  187. such long life expectancies that 100% assembly code is totally impractical
  188. (even if the DOD would allow it).
  189.  
  190. In a large system, the 90-10 rule tends to hold up pretty well (90% of the
  191. time is spent in 10% of the code).  A small amount of time spent tuning
  192. the key 10% of the Ada code usually gets the algorithm to perform in the
  193. required time.  The compiler contains assembly code insertion capability
  194. (with symbolic reference to Ada variables) as well as assembly code
  195. interface capability.  These can be (and are) used as a last resort and
  196. usually on less than 5% of the total code.
  197.  
  198. The register selection problem you mention shows up on the C3x/C4x as
  199. well.  Since loop folding and other parallelization techniques are done
  200. AFTER the code is generated, registers must often be re-assigned to get
  201. the right ones.  The compiler does not always come up with the ideal
  202. solution (but we are working on it!).  However, since most loops employing
  203. parallel instructions are 5 or 6 instructions long, its not really a big
  204. deal to use a machine code insert.
  205.  
  206. Your comment about the referenced schemes being "library goop-together"
  207. matches my limited understanding of them as well.  However, as you also
  208. note, this is a powerful approach.  Tartan uses this approach in a limited
  209. way by providing some amount of library routines, often with high speed
  210. interfacing supported directly from the code generator of the compiler.
  211. For example, complex numbers are supported in this way, as are mixed
  212. complex/real operations and complex vectors.  It is likely that we will
  213. expand on this as time goes by.
  214.  
  215. David A. Syiek
  216. Tartan Inc., Monroeville, PA 15146
  217. (412) 856-3600, FAX:856-3636
  218. syiek@tartan.com
  219. [Does Tartan have DSP compilers for other languages or just Ada?  I can
  220. imagine that there'd be a market for Fortran, considering all the numeric
  221. Fortran code there is, or maybe C++ for people who want a cool language.
  222. -John]
  223. -- 
  224. Send compilers articles to compilers@iecc.cambridge.ma.us or
  225. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  226.