Beispiel #1
0
def run():    
  if numproc < 2:
    mpitools.mpi_abort() ## the whole point is to run in parallel!
    
  if rank == 0:
    ## front end
    ## import all modules and functions that it will need
    from ooflib.common.EXTRA import mpiGUI
    localGUI = mpiGUI.MpiGUI()
    localGUI.add_function(g)
    localGUI.mainloop() ## mainloop may execute other tasks too.
  else:
    while 1:
      msg = mpitools.recieve_string(0) ## waiting messages from GUI
      if msg == "quit":
        print "quitting process", rank
        sys.stdout.flush()
        sys.exit()
      elif msg == "apply function":
        g()
      mpitools.send_string(msg,0)
Beispiel #2
0
def run():
    if numproc < 2:
        mpitools.mpi_abort()  ## the whole point is to run in parallel!

    if rank == 0:
        ## front end
        ## import all modules and functions that it will need
        from ooflib.common.EXTRA import mpiGUI
        localGUI = mpiGUI.MpiGUI()
        localGUI.add_function(g)
        localGUI.mainloop()  ## mainloop may execute other tasks too.
    else:
        while 1:
            msg = mpitools.recieve_string(0)  ## waiting messages from GUI
            if msg == "quit":
                print "quitting process", rank
                sys.stdout.flush()
                sys.exit()
            elif msg == "apply function":
                g()
            mpitools.send_string(msg, 0)
Beispiel #3
0
mpitools.mpi_initialize(sys.argv)
## no need to use mpi_finalize. The modele  at_exit takes care of that.


numproc = mpitools.size()
myid =    mpitools.rank()
node =    mpitools.get_processor_name()
lag = 0
print "I am proc %d of %d on node %s" %(myid+1, numproc, node)
mpitools.mpi_barrier() ## synchronizes all the processes


  
if numproc < 2:
  print "Demo must run on at least 2 processors to continue"      
  mpitools.mpi_abort()
  ## sys.exit()
  
if myid == 0:
  proc_0_time = time.time()
  msg = "%f"%proc_0_time  
  print 'Processor 1 sending message "%s" to processor %d' %(msg, 2)
  print  start_time, proc_0_time
  mpitools.send_string(msg, 1)
  mpitools.mpi_barrier()
  msg = mpitools.recieve_string(numproc-1)
  print 'Processor 1 received message "%s" from processor %d' %(msg, numproc)
  ## print 'Size of msg was %d bytes' %(SWIG.common.mpitools.bytes())


else:
Beispiel #4
0
    sys.stdout.flush()
    sys.exit()

  def latencyTime(self, control_box, data=None):
    ## message should be sent here.
    global msg
    msg += 50*" "
    startTime = time.time()
    mpitools.send_string(msg, 1)
    msg = mpitools.receive_string(1)
    endTime = time.time()
    print len(msg), endTime -startTime
    sys.stdout.flush()
    
if numproc < 2:
  mpitools.mpi_abort() ## the whole point is to run in parallel!
  
if rank == 0:
  ## start GUI
  import gtk, time
  localGUI = mpiGUI()
  localGUI.mainloop()
else:
  while 1:
    msg = mpitools.receive_string(0) ## waiting messages from GUI
    if msg == "quit":
      ## print "quitting process", rank
      sys.stdout.flush()
      sys.exit()
      ## mpitools.mpi_abort()
    mpitools.send_string(msg,0)