예제 #1
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()
	
예제 #2
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()
예제 #3
0
from pyopus.parallel.mpi import MPI as VM
# By default stdout is forwarded to the mpirun terminal

import funclib 
from pyopus.parallel.base import MsgTaskExit, MsgTaskResult
import os, time

if __name__=='__main__':
	# Startup dir must be the same as the one where funclib is located 
	# so we can import it (funclib is not in PYTHONPATH). 
	# MPI guarantees this by default, while PVM does not. 
	vm=VM(startupDir=os.getcwd(), debug=2)
	
	# Get host list. 
	hostIDs=vm.hosts()
	initialFreeSlots=vm.freeSlots()
	print("Hosts: ")
	for hostID in hostIDs:
		print("  "+str(hostID))
	print("Free slots: "+str(initialFreeSlots))
	
	# Spawn 2 tasks anywhere, send vm as argument with name 'vm'.  
	# The spawned function must be defined in an importable module outside main .py file. 
	print("\nSpawning 2 tasks, anywhere.")
	taskIDs=vm.spawnFunction(funclib.hello, kwargs={'vm': vm}, count=2)
	print("Spawned: ")
	for task in taskIDs:
		print "  ", str(task)
	print("Free slots: "+str(vm.freeSlots())+"\n")
	
	print("----\n"+vm.formatSpawnerConfig()+"----")
예제 #4
0
from pyopus.parallel.mpi import MPI as VM
# By default stdout is forwarded to the mpirun terminal

import funclib
from pyopus.parallel.base import MsgTaskExit, MsgTaskResult
import os, time

if __name__ == '__main__':
    # Startup dir must be the same as the one where funclib is located
    # so we can import it (funclib is not in PYTHONPATH).
    # MPI guarantees this by default, while PVM does not.
    vm = VM(startupDir=os.getcwd(), debug=2)

    # Get host list.
    hostIDs = vm.hosts()
    initialFreeSlots = vm.freeSlots()
    print("Hosts: ")
    for hostID in hostIDs:
        print("  " + str(hostID))
    print("Free slots: " + str(initialFreeSlots))

    # Spawn 2 tasks anywhere, send vm as argument with name 'vm'.
    # The spawned function must be defined in an importable module outside main .py file.
    print("\nSpawning 2 tasks, anywhere.")
    taskIDs = vm.spawnFunction(funclib.hello, kwargs={'vm': vm}, count=2)
    print("Spawned: ")
    for task in taskIDs:
        print "  ", str(task)
    print("Free slots: " + str(vm.freeSlots()) + "\n")

    print("----\n" + vm.formatSpawnerConfig() + "----")