def apply_function(self, control_box, data=None): ## message should be sent here. startTime = time.time() msg = "apply function" mpitools.send_string(msg, 1) ## tells other processors to execute the function callback self.callback() msg = mpitools.recieve_string(1) ## waits for processors to send endTime = time.time() print "processing time=", endTime -startTime sys.stdout.flush()
def apply_function(self, control_box, data=None): ## message should be sent here. startTime = time.time() msg = "apply function" mpitools.send_string( msg, 1) ## tells other processors to execute the function callback self.callback() msg = mpitools.recieve_string(1) ## waits for processors to send endTime = time.time() print "processing time=", endTime - startTime sys.stdout.flush()
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)
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)
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: source = myid-1 destination = (myid+1)%numproc mpitools.mpi_barrier() msg = mpitools.recieve_string(source) print 'Processor %d received message "%s" from processor %d'\ %(myid+1, msg, source+1) ## print 'Size of msg was %d bytes' %(SWIG.common.mpitools.bytes()) proc_time = time.time() msg = msg + '->P' + str(myid) + '->%f'%proc_time #Update message
gtk.mainquit() print "quitting main" sys.stdout.flush() sys.exit() def send_message(self, control_box, data=None): ## message should be sent here. msg = "Hello world!" mpitools.send_string(msg, 1) if numproc < 2: mpitools.mpi_abort() ## the whole point is to run in parallel! if rank == 0: ## start GUI import gtk localGUI = mpiGUI() localGUI.mainloop() else: while 1: msg = mpitools.recieve_string(0) ## waiting messages from GUI if msg == "quit": print "quitting process", rank sys.stdout.flush() sys.exit() print msg, " my rank is ", rank, " my name is ", name sys.stdout.flush() ## no need to use mpi_finalize. at_exit takes care of this implicitly.
## message should be sent here. msg = "Hello world!" mpitools.send_string(msg, 1) if numproc < 2: mpitools.mpi_abort() ## the whole point is to run in parallel! if rank == 0: ## start GUI import gtk localGUI = mpiGUI() localGUI.mainloop() else: while 1: msg = mpitools.recieve_string(0) ## waiting messages from GUI if msg == "quit": print "quitting process", rank sys.stdout.flush() sys.exit() print msg, " my rank is ", rank, " my name is ", name sys.stdout.flush() ## no need to use mpi_finalize. at_exit takes care of this implicitly.