コード例 #1
0
ファイル: funclib.py プロジェクト: ustaros-ai/pyopus
def jobProcessor(value):
    hostID = MPI.hostID()
    taskID = MPI.taskID()

    print("Processing " + str(value) + " on " + str(hostID) + " " +
          str(taskID))
    return 2 * value
コード例 #2
0
ファイル: funclib.py プロジェクト: xanderhsia/pyopus
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
コード例 #3
0
ファイル: funclib.py プロジェクト: ustaros-ai/pyopus
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
コード例 #4
0
ファイル: funclib.py プロジェクト: xanderhsia/pyopus
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)
	
コード例 #5
0
ファイル: funclib.py プロジェクト: ustaros-ai/pyopus
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)
コード例 #6
0
ファイル: 01-config.py プロジェクト: xanderhsia/pyopus
# 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()
	
コード例 #7
0
ファイル: 03-messaging.py プロジェクト: xanderhsia/pyopus
# 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)
	
コード例 #8
0
ファイル: 03-messaging.py プロジェクト: ustaros-ai/pyopus
# 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},
コード例 #9
0
ファイル: funclib.py プロジェクト: xanderhsia/pyopus
def jobProcessor(value):
	hostID=MPI.hostID()
	taskID=MPI.taskID()
	
	print("Processing "+str(value)+ " on "+ str(hostID)+" "+str(taskID))
	return 2*value
コード例 #10
0
# 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()