예제 #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
	
	# 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)
	
	# Check if it succeeded
	if len(taskIDs)<1:
		print("Failed to spawn bounceBack().")
		exit(-1)
		
	taskID=taskIDs[0]
	
	print "Task layout:"
	print vm.formatSpawnerConfig()
	
	print("Measuring message delivery time and data throughput to "+str(hostID)+".")
	print("Bounce back task: "+str(taskID))
	
	# Go through data sizes
	total_time=0
	for dataSize in dataSizes:
		# Create data
		data=np.random.randint(0, 256, size=dataSize).astype(np.uint8)
		
		# How many times do we need to cycle send/receive for runtime=1s? 
		if total_time>0 and oldDataSize>0:
			# Calculate new repeats for 1 secons run
			repeats=int(repeats/total_time*2.0*oldDataSize/dataSize)
			if repeats==0:
예제 #3
0
    # Spawn bounceBack()
    taskIDs = vm.spawnFunction(funclib.bounceBack,
                               kwargs={'vm': vm},
                               targetList=[hostID],
                               count=1)

    # Check if it succeeded
    if len(taskIDs) < 1:
        print("Failed to spawn bounceBack().")
        exit(-1)

    taskID = taskIDs[0]

    print "Task layout:"
    print vm.formatSpawnerConfig()

    print("Measuring message delivery time and data throughput to " +
          str(hostID) + ".")
    print("Bounce back task: " + str(taskID))

    # Go through data sizes
    total_time = 0
    for dataSize in dataSizes:
        # Create data
        data = np.random.randint(0, 256, size=dataSize).astype(np.uint8)

        # How many times do we need to cycle send/receive for runtime=1s?
        if total_time > 0 and oldDataSize > 0:
            # Calculate new repeats for 1 secons run
            repeats = int(repeats / total_time * 2.0 * oldDataSize / dataSize)
예제 #4
0
	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()+"----")
	
	# Blocking receive 4 messages (2 return values and 2 exit)
	while vm.freeSlots()!=initialFreeSlots:
		received=vm.receiveMessage()
		
		# Handle error (None) and timeout (empty tuple)
		if received is None or len(received)==0:
			continue
		
		# Unpack
		(fromId, msg)=received
		
		# Note that the received message may be comming from a dead worker. 
		# Verify that the message is comming from one of our workers. 
		if fromId not in taskIDs:
예제 #5
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()
예제 #6
0
    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() + "----")

    # Blocking receive 4 messages (2 return values and 2 exit)
    while vm.freeSlots() != initialFreeSlots:
        received = vm.receiveMessage()

        # Handle error (None) and timeout (empty tuple)
        if received is None or len(received) == 0:
            continue

        # Unpack
        (fromId, msg) = received

        # Note that the received message may be comming from a dead worker.
        # Verify that the message is comming from one of our workers.
        if fromId not in taskIDs: