def main(argv=sys.argv): try: options = checkInputs(argv) resIdx = ResourceIndex() grids = getHardwareInfo(resIdx, options.dataFile) ptdfname = options.ptdfFile f = open(ptdfname, 'w') for grid in grids: f.write(grid.PTdF("", " ")) f.close() return 0 except PTexception, a: print a.value return 1
def processData(eInfo, mInfo, sInfo, testMode, verbose, opt=None): if mInfo: try: resIdx = ResourceIndex() Hardware.getHardwareInfo(resIdx, mInfo.machineFile) writeList = resIdx.PTdF() f = open(mInfo.machinePTdF, 'w') for w in writeList: f.write(w) f.close() print "PTDF machine data generation complete." except PTexception, a: raise if testMode: print a raise PTexception(a) else: print a.value return -1
def focusTests(pf): print "Focus Tests" try: # try getting a focus template ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) metric = Resource("MFLOPS", "metric") pt = Resource("Paradyn", "performanceTool") ri.addResources([build, env, process0, metric, pt]) fl = ri.createContextTemplate() except: pf.failed("non-PTexception raised when getting focusTemplate") raise else: if len(fl) != 4: pf.failed("wrong number of resources. %d" % len(fl)) else: pf.passed("got focus template successfully") try: # try getting a focus template with two top-level resources withthe # same type ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) compiler = Resource("theOtherCompiler", "compiler") process1 = Resource(execution.name + "|Process-1", "execution|process") ri.addResources([compiler, build, env]) ri.addResources([build, env, process0, process1]) fl = ri.createContextTemplate() except: pf.failed( "non-PTexception raised when getting focusTemplate same types") raise else: if len(fl) != 6: pf.failed("wrong number of resources same types. %d" % len(fl)) else: pf.passed("got focus template successfully same types") try: # try adding a specific focus resources that is a child of a resource # in the template ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) ri.addResources([build, env, process0]) fl = ri.createContextTemplate() newfl = ri.addSpecificContextResource(fl, process0) except: pf.failed("non-PTexception raised when adding specific focus child") raise else: if len(newfl) != 4: pf.failed( "wrong number of resources when adding specific focus child. %d" % len(newfl)) else: pf.passed( "got focus template successfully when adding specific focus child" ) try: # try adding a list of specific focus resources that is a child of # a resource in the template ri = ResourceIndex() build = Resource("mybuild", "build") env = Resource("myenv", "environment") lib = Resource(env.name + "|libmpi.so", "environment|module") ri.addResource(lib) lib = Resource(env.name + "|libelf.so", "environment|module") ri.addResource(lib) compiler = Resource("theCompiler", "compiler") execution = Execution("myexec") process0 = Resource(execution.name + "|Process-0", "execution|process") ri.addResources([compiler, build, env]) process1 = Resource(execution.name + "|Process-1", "execution|process") ri.addResources([compiler, build, env]) ri.addResources([build, env, process0, process1]) fl = ri.createContextTemplate() newfl = ri.addSpecificContextResources(fl, [process0, process1]) except: pf.failed( "non-PTexception raised when adding specific focus child list") raise else: if len(newfl) != 5: pf.failed( "wrong number of resources when adding specific focus child list. %d" % len(newfl)) else: pf.passed( "got focus template successfully when adding specific focus child list" )
p = Resource("eddie", "atype") c = Resource("eddie|schild", "atype|btype") theVerdict = p.isChild(c) except PTexception, a: pf.failed(a.value) except: pf.failed("non-PTexception when try isChild actual child") else: if theVerdict == True: pf.passed("isChild pass actual child") else: pf.failed("isChild fail actual child") try: # try finding a static library ri = ResourceIndex() build = Resource("mybuild", "build") lib = Resource(build.name + "|libmpi.a", "build|module") ri.addResource(lib) env = Resource("myenv", "environment") execution = Execution("myexec") ri.addResources([build, env]) resList = ri.findResourcesByShortType("module") libname = "" for r in resList: if r.name.find("libmpi") >= 0: libname = r.name break except PTexception, a: pf.failed( "PTexception raised when trying to find good static lib with findResourceByShortType: "
f.write(w) f.close() print "PTDF machine data generation complete." except PTexception, a: raise if testMode: print a raise PTexception(a) else: print a.value return -1 if sInfo: ptds = None try: resIdx = ResourceIndex() ptds = connectToDB(testMode, opt) ## set the machine name from command line arg: fullname, type = getMachineName(ptds, sInfo.machineName, "machine") mach = Resource(fullname, type) resIdx.addResource(mach) parsePerf.getSysPerfInfo(resIdx, sInfo.dataDir, sInfo.perfTools, ptds) ptdfname = sInfo.dataDir + "/sys.ptdf" f = open(ptdfname, 'w') # ResourceIndex.PTdF returns a list of strings to write writeLst = resIdx.PTdF() for w in writeLst: f.write(w) f.close()