home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / fortran / 5155 < prev    next >
Encoding:
Text File  |  1993-01-24  |  7.5 KB  |  167 lines

  1. Newsgroups: comp.lang.fortran
  2. Path: sparky!uunet!cs.utexas.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uimrl7.mrl.uiuc.edu!ercolessi
  3. From: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
  4. Subject: Re: Compiler groups working on real apps?
  5. References: <1993Jan21.081105.4047@molene.ifremer.fr> <1993Jan22.193019.12936@news.eng.convex.com> <C19wHr.GF3@news.cso.uiuc.edu> <1993Jan23.003639.13681@craycos.com>
  6. Message-ID: <C1Cnq5.1zt@news.cso.uiuc.edu>
  7. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  8. Reply-To: ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi)
  9. Organization: MRL - UIUC
  10. Date: Sun, 24 Jan 1993 08:32:29 GMT
  11. Lines: 154
  12.  
  13. In article <1993Jan23.003639.13681@craycos.com>, jrbd@craycos.com (James Davies) writes:
  14. |>In article <C19wHr.GF3@news.cso.uiuc.edu> ercolessi@uimrl3.mrl.uiuc.edu (furio ercolessi) writes:
  15. |>
  16. |>>This is probably too much to ask.  But I am wondering.  Maybe any one of
  17. |>>us (users) could spend some time in putting together some "typical" code,
  18. |>>containing a simplified version of the loops where our programs spend
  19. |>>most of the time.  Staying within, say, 100 lines.  These "test cases" could 
  20. |>>be posted on c.l.f. (and stored at some anon ftp site) and compiler developers 
  21. |>>could have a look at them and perhaps improve the compilers.
  22. |>>
  23. |>>These typical loops could perhaps also be coded as self-contained
  24. |>>benchmarks a-la-Linpack, inducing a bit of competitiveness :-), 
  25. |>>helping us to understand better the strengths and weaknesses of the
  26. |>>various architectures, but not necessarily so.
  27. |>>
  28. |>>Any comment?
  29. |>
  30. |>You've just described the Livermore Loops.
  31.  
  32. After seeing this comment, I fired up xnetlib, downloaded the Livermore
  33. loops and looked at them.  I must admit I was not familiar with them.
  34. While there is certainly an interesting variety of codes in there (there are 24 
  35. different 'kernels'), at a first glance I was not able to locate something that 
  36. I feel represents the kind of codes I am dealing with.
  37.  
  38. My applications involve classical molecular dynamics (i.e., interacting atoms 
  39. treated like classical masses and moved by time integration of F=ma).
  40. There are typically many thousands of atoms but the interactions are
  41. short ranged, so it's not necessary to loop over all pairs to obtain the
  42. forces.  One makes a topological analysis from time to time and for
  43. each atom singles out the indexes of the other ones which happen to be
  44. hanging around it at that particular time.  Then the time-consuming
  45. computations are done using this data structure.  An example of such
  46. computations is given at the end of this post.
  47.  
  48. This naturally leads to indirect addressing [ A(LIST(J) ], and we also 
  49. use a fair amount of table look-up techniques which are in a sense
  50. similar (in the first case an index is obtained by picking it from 
  51. somewhere, in the second case from a computation, in both cases
  52. the index is only known at run time).  Where are these things
  53. in the Livermore loops? Kernels 13 and 16, if I am not wrong, are the
  54. only ones using indirect addressing. Kernel 16 is awfully coded and seem
  55. to test the ability to deal with a cascade of arithmetic IFs, and I admit
  56. I cannot make much sense out of it.  Kernel 13 does indeed nice
  57. tricky things with indexes, but it spends time doing additions,
  58. real-to-integer conversions and integer shifts.  There are no 
  59. multiplications or divisions in kernel 13.
  60.  
  61. Moreover, these loops play with arrays which are quite small.
  62. For example, 4096 elements in total for each array in kernel 13.
  63. Maybe this is not of much concern to compiler writers, since this is
  64. after all a hardware issue, but nowadays the cache behavior is a 
  65. factor which often dominates benchmark results on real-world programs.  
  66. With present CPUs and memories, array sizes are happily going into the 
  67. millions, usually exceeding the cache sizes.   If compilers are tuned to 
  68. tiny benchmarks which fit into the cache, there could be surprises when 
  69. moving to the real world applications.  It is not rare to see dramatic 
  70. changes in performance when increasing the problem size, or transposing 
  71. arrays, on many new RISC architectures. 
  72. Could compilers at least try to alleviate these problems?
  73.  
  74.                                       ****
  75.  
  76. I cooked up a 'molecular dynamics kernel' that I feel is not well
  77. represented by any of the Livermore loops.  Here it is.  Any comment is
  78. welcome.  In particular if you feel that there *is* a Livermore kernel that 
  79. represents what this code does fairly well, and therefore we can look
  80. at performance results for that kernel and draw conclusions on 
  81. how a certain machine will handle molecular dynamics.
  82.  
  83. At this stage the code below is meant for visual inspection only (there
  84. may be errors). If there is interest I can make a real benchmark out
  85. of it.
  86.  
  87. I think there are a few people out here doing the same stuff [I see
  88. a few competitors on this group from time to time :-) ... to them I say
  89. that my production code is certainly not the junk below :-)]  and 
  90. certainly there are hundreds of CPUs in the world crunching this kind 
  91. of codes as you read this for applications in physics, chemistry and
  92. materials science, so it must not be regarded as esoteric.
  93.  
  94. Thank you to anyone taking the time to consider this! :-)
  95.  
  96.  
  97.     implicit double precision (a-h,o-z)
  98. *       typical production value:
  99.     parameter (n=100000)
  100.     common/c1/ x(n),y(n),z(n),fx(n),fy(n),fz(n)
  101.     parameter (n50=50*n)
  102.     common/c2/ mrkr1(n),mrkr2(n),list(n50)
  103.     parameter (ntab=10000)
  104.     common/c3/ tab(ntab)
  105.     
  106.     do i=1,n
  107. *          do on jlist typically iterates 50 times
  108.        do jlist=mrkr1(i),mrkr2(i)
  109. *             j obtained by indirect addressing.
  110. *             j jumps here and there like crazy typically.
  111. *             mrkr1,mrkr2 and list have been prepared previously.
  112. *             it is guaranteed that j is never equal to i.
  113.           j = list(jlist)
  114. *
  115. *             the x(i),y(i),z(i) are in the range (-0.5,0.5).
  116. *             the following methods A,B,C to fold the distance
  117. *             applying periodic boundary conditions are equivalent,
  118. *             and one can choose the fastest one on a given 
  119. *             machine.  for any of them there is a machine where
  120. *             that way is the fastest way.
  121. *
  122. *             periodic boundary conditions on x using method A
  123.           xij = x(i) - x(j)
  124.           nx = xij + xij
  125.           xij = xij - nx
  126. *             periodic boundary conditions on y using method B
  127.           yij = y(i) - y(j)
  128.           if (yij.gt. 0.5d0) yij = yij - 1.d0
  129.           if (yij.lt.-0.5d0) yij = yij + 1.d0
  130. *             periodic boundary conditions on z using method C
  131.           zij = z(i) - z(j)
  132.           if (abs(zij).gt.0.5d0) zij = zij - sign(1.d0,zij)
  133. *
  134. *             compute distance and do further work only if 
  135. *             lower than a certain threshold:
  136.           rijsq = xij**2 + yij**2 + zij**2
  137.           if (rijsq.lt.rcutsq) then
  138. *                use rijsq to look-up into a table, using
  139. *                linear interpolation:
  140.              sqd = (rijsq - rminsq)*drsqi + 1.d0
  141.              m = sqd
  142.              delsqd = sqd - m
  143.              fff = tab(m+1)*delsqd + tab(m)*(1.d0-delsqd)
  144.              fxij = fff*xij
  145.              fyij = fff*yij
  146.              fzij = fff*zij
  147. *                compute force between pair of particles and
  148. *                apply 3rd Newton's law.
  149.              fx(i) = fx(i) + fxij
  150.              fy(i) = fy(i) + fyij
  151.              fz(i) = fz(i) + fzij
  152.              fx(j) = fx(j) - fxij
  153.              fy(j) = fy(j) - fyij
  154.              fz(j) = fz(j) - fzij
  155.           endif
  156.        enddo
  157.     enddo
  158.  
  159.  
  160. --
  161. furio ercolessi    <furio@uiuc.edu>*    <furio@sissa.it>+
  162. * materials research lab, uni illinois at urbana-champaign
  163. + intl school for advanced studies, trieste, italy   
  164.  
  165. "Change nothing and continue with immaculate consistency"
  166.                                       [ Brian Eno, "Oblique Strategies" ]
  167.