示例#1
0
	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)
	
	# 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
示例#2
0
    # 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)

    # 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))
示例#3
0
	# 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()+"----")
	
	# 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
		
示例#4
0
if __name__=='__main__':
	vm=VM(startupDir=os.getcwd(), debug=0)
	
	# Prepare expressions
	exprList=["1+1", "5*5", "bla*bla", "2**7"]
	
	# Create expression to taskID map, initialize values to None
	expr2taskID={}
	expr2taskID.fromkeys(exprList)
	
	# Spawn evaluators that send MsgTaskResult messages with return value (sendBack=True). 
	taskIDList=[]
	taskCount=0
	for expr in exprList:
		print("Spawning evaluator for: "+expr)
		taskIDs=vm.spawnFunction(funclib.pyEvaluator, kwargs={'vm': vm, 'expr': expr}, count=1, sendBack=True)
		if len(taskIDs)>0:
			# Spawn OK
			taskIDList.extend(taskIDs)
			expr2taskID[expr]=taskIDs[0]
			taskCount+=1
			print("  Task ID: %s" % str(taskIDs[0]))
		else:
			taskIDList.append(None)
			print("  Not spawned")
	
	print 
	
	# Collect results from successfully spawned workers and wait for them to exit. 
	running=set(taskIDList)
	results={}
示例#5
0
    # 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() + "----")

    # 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