title: Running Bulk Synchronous Parallel Model (BSP) in Python
body: <p>The BSP Parallel Programming Model has several benefits - the programmer need not explicitly care about synchronization, deadlocks become impossible and reasoning about speed becomes much easier than with traditional methods. There is a Python interface to the BSPlib in the SciPy: </p>
  
  <pre><code>import Scientific.BSP
  </code></pre>
  
  <p>I wrote a little program to test BSP. The Program is a simple random experiment which "calculates" the probalbility that throwing <code>n</code> dice yields a sum of <code>k</code>: </p>
  
  <pre><code>from Scientific.BSP import ParSequence, ParFunction, ParRootFunction
  from sys import argv
  from random import randint
  n = int(argv[1]) ; m = int(argv[2]) ; k = int(argv[3])
  
  def sumWuerfe(ws): return len([w for w in ws if sum(w)==k])
  glb_sumWuerfe= ParFunction(sumWuerfe)
  def ausgabe(result): print float(result)/len(wuerfe)
  glb_ausgabe = ParRootFunction(output)
  wuerfe = [[randint(1,6) for _ in range(n)] for _ in range(m)]
  glb_wuerfe = ParSequence(wuerfe)
  
  # The parallel calc:
  ergs = glb_sumWuerfe(glb_wuerfe)
  # collecting the results in Processor 0:
  ergsGesamt= results.reduce(lambda x,y:x+y, 0)
  
  glb_output(ergsGesamt)
  </code></pre>
  
  <p>The program works fine, but: It uses just one process! </p>
  
  <p><strong>My Question</strong>: Anyone knows how to tell this Pythonb-BSP-Script to use 4 (or 8 or 16) Processes? I thought this BSP Implementation woould use MPI, but starting the script via <code>mpiexe -n 4 randExp.py</code> doesnt work.</p>