home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / wizards / 3627 < prev    next >
Encoding:
Text File  |  1992-08-15  |  7.0 KB  |  159 lines

  1. Newsgroups: comp.unix.wizards
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!caen!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
  3. From: terry@cs.weber.edu (A Wizard of Earth C)
  4. Subject: Re: MP CPU-time phenomena
  5. Message-ID: <1992Aug16.015606.4668@fcom.cc.utah.edu>
  6. Sender: news@fcom.cc.utah.edu
  7. Organization: Weber State University  (Ogden, UT)
  8. References: <15250002@hprpcd.rose.hp.com> <1992Aug14.063450.25740@fcom.cc.utah.edu> <1992Aug15.172139.13498@ctr.columbia.edu>
  9. Date: Sun, 16 Aug 92 01:56:06 GMT
  10. Lines: 147
  11.  
  12. In article <1992Aug15.172139.13498@ctr.columbia.edu> kibirev@csa.bu.edu (oleg kibirev) writes:
  13. [ ... Big, hairy discussion on benchmarking parallel processors using a non
  14.  parallel algorythm and the fallacies thereof ... ]
  15. >Hmmm, won't this work? 
  16. >
  17. >while(fork()>0);
  18. >for(;;i++);
  19.  
  20.     If you mean "will it operate", the answer is "yes"... however:
  21.  
  22. o    On most reasonable systems, the number of forks is not equal to
  23.     the number of processors available; rather, there is a hard limit
  24.     on the number of processes you instantiate.
  25.  
  26. o    On systems without a hard limit, you will go until either the process
  27.     table is full or has sizeof(process table) - 1 processes (if you
  28.     are given the standard safety net so you can log in as root and kill
  29.     the damn things), or, like a NeXT, your swap file will grow to consume
  30.     the file system in which it lives, and the machine will crash.
  31.  
  32. o    'i' is presumably a stack or volatile variable, and is not in shared
  33.     memory.  As such, it is most likely located in a copy-on-write
  34.     (unless your box is copy-on-fork, which is worse).  This means you
  35.     will not increment i once per process, you will increment your
  36.     particular per-process copy of i.  This is relatively useless unless
  37.     you can arrive at an aggregate value.
  38.  
  39. o    If 'i' is in shared memory per-processor access to it will be
  40.     semaphored.  Thus even though it will increment once per process
  41.     running simultaneously on multiple processors, access to the memory
  42.     location is per-processor serialized, so you don't get multiple
  43.     increments in the same set of clock cycles within which a single
  44.     processor could increment a local variable.  Worse, due to the
  45.     operation of an interprocessor mutex and cache coherency problems,
  46.     you will actually increment the thing less frequently than if a
  47.     single processor is trying to increment a variable in local cache.
  48.  
  49. o    These boxes have better things to do with their processors, even if
  50.     your user code is the only thing running as a user app (swapping,
  51.     to name one).  Your processes will not all be guaranteed to get
  52.     either the same number or size of CPU quantum.
  53.  
  54.     How does parallel processing ever do *anything* then?  Well, I'm
  55. glad I asked for you(8-); that's really the question that needs to be
  56. resolved:
  57.  
  58.     It does it by paralellizing things which are paralellizable.  It may
  59. do this at various granularities (from high to low):
  60.  
  61.     o    Session granularity: I run on one processor, and Phil runs
  62.         on the other; by virtue of the fact that we each have our
  63.         own processor, but are using one machine, it looks like
  64.         we both have shared resources on seperate machines (ASMP
  65.         and/or things like NFS and lpd can make this seem to happen
  66.         even if the processors aren't in the same case).
  67.     
  68.     o    Process granularity (parallel make and similar beasts), where
  69.         one task is split into multiple processes, which can, but
  70.         are not required to, run on seperate processors simultaneously.
  71.     
  72.     o    Thread of execution granularity (POSIX threads/Solaris 2.0/
  73.         AIX kernel premption) where:
  74.  
  75.         Thread 0:    for( i=0; i<4; i++)
  76.                     for( j=0; j<20; j++)
  77.                         x[ i][ j] = foo;
  78.         
  79.         Gets split into:
  80.  
  81.         Thread 0:    for( j=0; j<20; j++)
  82.                     x[ 0][ j] = foo;
  83.         Thread 1:    for( j=0; j<20; j++)
  84.                     x[ 1][ j] = foo;
  85.         Thread 2:    for( j=0; j<20; j++)
  86.                     x[ 2][ j] = foo;
  87.         Thread 3:    for( j=0; j<20; j++)
  88.                     x[ 3][ j] = foo;
  89.  
  90.         And each thread is capable of being run by a seperate
  91.         processor.  This relies moderately on compiler technology
  92.         which is mostly there.  It falls into the category of loop
  93.         unrolling style optimizations.
  94.  
  95.     o    Code reording granularity.  This requires extensive knowledge
  96.         of the code (either by the programmer, in terms of hints to
  97.         the compiler, or in terms of syntactically parallel languages),
  98.         and extreme knowledge by the compiler of the underlying
  99.         secheduling mechanisms (with hooks for manipulation).  This
  100.         is sometimes called a shared context process centric model.
  101.         (There are some *very* good papers on this on wuarchive).
  102.  
  103.  
  104.  
  105.  
  106.     I guess the whole point of where this is going is "can I add a whole
  107. bunch of PC's (or their moral equivalent) together and get supercomputer
  108. performance?  The answer is yes, but only for parallel dissoluable problems.
  109.  
  110.  
  111.     The original poster was trying to determine how much better a
  112. parallel machine was than a non-parallel machine of equivalent capability
  113. of a single one of the parallel machines processors.  He was unpleasently
  114. suprosed that for(;;) i++; didn't increment the variable n times as fast
  115. for n processors (for reason's I hope are clear now).
  116.  
  117.     The suggestion that he build a model of the parallel behaviour based
  118. on the parallelizability of his intended application is not unreasonable.
  119. Most client/server databases (Oracle, for instance) benefit greatly from
  120. session and process granularity on something like a Sequent.  The added
  121. benefits of SMP vs. ASMP in this case are dynamic load balancing and
  122. distribution of "interrupt" style processing within the kernel (an ASMP
  123. machine, for instance, must direct all I/O through a single processor as
  124. a serialization mechanism).
  125.  
  126.     I won't argue the (de)merits of MP computing here; even though
  127. there are problems which can't be dissolved at any of the granularities
  128. currently supported, there are other problems that lend themselves to
  129. partial parallelization, or even total paralellization (fluidic modelling,
  130. to name one).  Whichever case the final intended application of the original
  131. poster falls into, predicting the behaviour certainly can't be done without
  132. a model (ie: a test program) that dissolves to the same granularity as the
  133. final application.
  134.  
  135.     for(;;) i++; isn't rationally divisible (ie: dividing it may in fact
  136. force it to take longer) and thus models a non parallelizable application.
  137.  
  138.     while(fork()>0); for(;;i++); is rationally divisable if it isn't the
  139. same i in each child at process granularity.
  140.  
  141.     If the intended application does not fit either category, a new model
  142. is needed; if it *does* fit either category, than he's probably paying a
  143. premium for resource sharing between what are in effect multiple seperate
  144. machines in the same box.  Thus either the test model was broken or the
  145. expectation of the user were broken.
  146.  
  147.  
  148.                     Terry Lambert
  149.                     terry_lambert@gateway.novell.com
  150.                     terry@icarus.weber.edu
  151. ---
  152. Any opinions in this posting are my own and not those of my present
  153. or previous employers.
  154. -- 
  155. -------------------------------------------------------------------------------
  156.                                                        terry@icarus.weber.edu
  157.  "I have an 8 user poetic license" - me
  158. -------------------------------------------------------------------------------
  159.