#! /usr/bin/env python #################################################################################### # # Name: emulation.py # Description: emulation script for runing program on DAS2 or linux # to create number of instance in one node # Usage:1) For create instance over different nodes(cpu) # using the following command: # # a) in the das2: # prun emulation.py num_of_nodes num_of_instance other_prg_param # # b) in the normal linux: # python emulation.py nodeid num_of_nodes num_of_instance other_prg_param # example settings: # python emulation.py 0 1 num_of_instance other_prg_param # # by doing this, {nodeid, num_of_nodes, num_of_instance, other_prg_param} # becomes input parameters for emulation.py # # 2) other_prg_param including: # ExperimentType RandomCacheSize BuddyCacheSize r(i.e.Exploration/explitation Rate) ... # # # 3)Output: create many instance over nodes # For each instance: # prgname nodeid num_of_nodes instanceid num_of_instance other_prg_param # # 4) Example: # python emulation.py 0 1 1 1 20 20 0.5 # Author: Jun Wang seawan@gmail.com # Date: Auguest 2005 ###################################################################################### import sys, string from ConfigParser import * from launchmodes import QuietPortableLauncher prgname = '/home3/jwang/buddycast/buddycast.py' #collect arguments nodeid = int(sys.argv[1]) numnodes = int(sys.argv[2]) OUTPUTFILE = sys.argv[3] print 'output file', OUTPUTFILE #numinstances = int(sys.argv[3]) # number of instance configdict = ConfigParser() configdict.read('/home3/jwang/buddycast/emulation.cfg') numinstances = configdict.getint('EMULATION','numInstancesPerProcess') del configdict #print nodeid, numnodes, numinstances # a function for starting many instance def start(cmdline): QuietPortableLauncher(cmdline, cmdline)() #args = string.join(sys.argv[4:], ' ') for instanceid in range(numinstances): #start('%s %d %d %d %d %s' % (prgname, nodeid, numnodes, instanceid, numinstances,args) ) # start('%s %d %d %d %d %s' % (prgname, nodeid, numnodes, instanceid, numinstances, OUTPUTFILE) )