def jobProcessor(value): hostID = MPI.hostID() taskID = MPI.taskID() print("Processing " + str(value) + " on " + str(hostID) + " " + str(taskID)) return 2 * value
def printMsgMPI(msg, n): hostID=MPI.hostID() taskID=MPI.taskID() for ii in range(n): print("h="+str(hostID)+" t="+str(taskID)+": "+msg+" : "+str(ii)) cOS.Yield() return n
def printMsgMPI(msg, n): hostID = MPI.hostID() taskID = MPI.taskID() for ii in range(n): print("h=" + str(hostID) + " t=" + str(taskID) + ": " + msg + " : " + str(ii)) cOS.Yield() return n
def deRun(prob, popSize, runIndex, maxiter=75000, maxGen=1500, w=0.5, pc=0.3): hostID=MPI.hostID() taskID=MPI.taskID() print str(hostID)+" "+str(taskID)+(" evaluating %s, run=%2d, popsize=%3d" % (prob.name, runIndex+1, popSize)) random.seed() opt=DifferentialEvolution( prob, prob.xl, prob.xh, debug=0, maxiter=maxiter, maxGen=maxGen, populationSize=popSize, w=w, pc=pc ) cc=CostCollector() opt.installPlugin(cc) opt.reset(zeros(len(prob.xl))) opt.run() cc.finalize() return (opt.f, cc.fval)
def deRun(prob, popSize, runIndex, maxiter=75000, maxGen=1500, w=0.5, pc=0.3): hostID = MPI.hostID() taskID = MPI.taskID() print str(hostID) + " " + str(taskID) + ( " evaluating %s, run=%2d, popsize=%3d" % (prob.name, runIndex + 1, popSize)) random.seed() opt = DifferentialEvolution(prob, prob.xl, prob.xh, debug=0, maxiter=maxiter, maxGen=maxGen, populationSize=popSize, w=w, pc=pc) cc = CostCollector() opt.installPlugin(cc) opt.reset(zeros(len(prob.xl))) opt.run() cc.finalize() return (opt.f, cc.fval)
# Print statistics import sys # Starting a task with mpirun starts multiple identical processes. # If MPI is imported then the main program is executed only at slot 0. # If not, all slots execute the main program. from pyopus.parallel.mpi import MPI as VM if __name__=='__main__': vm=VM(debug=2) # Print info print("---- Master") print("Host ID : "+str(vm.hostID())) print("Task ID : "+str(vm.taskID())) print("Parent ID : "+str(vm.parentTaskID())) # Print hosts and processes print("---- Hosts and tasks\n"+vm.formatSpawnerConfig()+"----") # Print process slot info print("Total process slots: "+str(vm.slots())) print("Free process slots : "+str(vm.freeSlots())) vm.finalize()
# Measures the message delay and average transfer speed for messages of various sizes import sys from pyopus.parallel.mpi import MPI as VM from pyopus.parallel.base import MsgTaskExit, MsgTaskResult import funclib import os, time import numpy as np if __name__=='__main__': # Set work direcotry on worker to be the same as on the spawner. vm=VM(startupDir=os.getcwd(), debug=1) # Get hosts, find a non-local host myHostID=vm.hostID() # Find a remote host for hostID in vm.hosts(): if hostID!=myHostID: break # See if we have at least one remote host. if hostID==myHostID: print("\nWarning. Measuring local communication speed.") # Prepare data sizes dataSizes=[0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000] # Spawn bounceBack() taskIDs=vm.spawnFunction(funclib.bounceBack, kwargs={'vm': vm}, targetList=[hostID], count=1)
# Measures the message delay and average transfer speed for messages of various sizes import sys from pyopus.parallel.mpi import MPI as VM from pyopus.parallel.base import MsgTaskExit, MsgTaskResult import funclib import os, time import numpy as np if __name__ == '__main__': # Set work direcotry on worker to be the same as on the spawner. vm = VM(startupDir=os.getcwd(), debug=1) # Get hosts, find a non-local host myHostID = vm.hostID() # Find a remote host for hostID in vm.hosts(): if hostID != myHostID: break # See if we have at least one remote host. if hostID == myHostID: print("\nWarning. Measuring local communication speed.") # Prepare data sizes dataSizes = [0, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000] # Spawn bounceBack() taskIDs = vm.spawnFunction(funclib.bounceBack, kwargs={'vm': vm},
def jobProcessor(value): hostID=MPI.hostID() taskID=MPI.taskID() print("Processing "+str(value)+ " on "+ str(hostID)+" "+str(taskID)) return 2*value
# Print statistics import sys # Starting a task with mpirun starts multiple identical processes. # If MPI is imported then the main program is executed only at slot 0. # If not, all slots execute the main program. from pyopus.parallel.mpi import MPI as VM if __name__ == '__main__': vm = VM(debug=2) # Print info print("---- Master") print("Host ID : " + str(vm.hostID())) print("Task ID : " + str(vm.taskID())) print("Parent ID : " + str(vm.parentTaskID())) # Print hosts and processes print("---- Hosts and tasks\n" + vm.formatSpawnerConfig() + "----") # Print process slot info print("Total process slots: " + str(vm.slots())) print("Free process slots : " + str(vm.freeSlots())) vm.finalize()