- Timestamp:
- Feb 10, 2012, 10:34:08 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/hardware/template/main.py
r8328 r8331 6 6 #------------------------------------------------------------------------------ 7 7 import anuga 8 import random9 8 import subprocess 10 9 import csv … … 20 19 home = os.getenv('INUNDATIONHOME') 21 20 scenariodir = add_directories(home, ["data","mem_time_test", "parallel","template"]) 22 file1 = 'ex1.csv' 23 file_path = os.path.join(scenariodir, file1) 24 25 firstex1 = open(file_path, 'wb') 26 spamWriter = csv.writer(firstex1) 27 spamWriter.writerow(['Number Of Processors' ,'Time Taken (s)']) 21 meta_path = os.path.join(scenariodir, 'metalog.csv') 22 final_path = os.path.join(scenariodir, 'final.csv') 28 23 29 24 … … 32 27 33 28 for n in range(1,maxcpus,1): 34 z = time.time()# time it 35 29 36 30 #the different ways each HOST requires the parallel script to be run 37 31 if (host == 'cyclone.agso.gov.au'): 38 32 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 39 if (host == 'tornado.agso.gov.au'):33 elif (host == 'tornado.agso.gov.au'): 40 34 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 41 if (host == 'vayu1'): 42 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 43 if (host == 'rhe-compute1.ga.gov.au'): 35 elif (host == 'rhe-compute1.ga.gov.au'): 44 36 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 45 if (host == 'xe'):37 else: 46 38 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 47 39 48 40 49 y = time.time() #time it50 spamWriter.writerow([n,(y-z)]) #record it51 52 41 print 'Done' 53 42 54 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files 43 #get the important data for the experiments from the anuga experiments 44 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 55 45 56 #close ex1.csv so we can read from it for a different csv reader object 57 firstex1.close() 58 59 #merge the metalog useful memory info and the ex1 recorded info into one csv file named final 60 ex1 = csv.reader(open(file_path,'rb')) 46 #open files to read from and write to 61 47 metalog = csv.reader(open(meta_path,'rb')) 62 48 final = csv.writer(open(final_path,'wb')) 63 49 50 #list stores the index of the values requird 51 indexlist = [] 64 52 65 for row in ex1: 66 d = metalog.next() 67 final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]]) 53 #read in the first row 54 firstrow = metalog.next() 55 56 #get the indices of the values we want, so that the data can be condensed 57 indexlist.append(firstrow.index("beforetime")) 58 indexlist.append(firstrow.index("aftertime")) 59 indexlist.append(firstrow.index("beforesimulationmemory")) 60 indexlist.append(firstrow.index("aftermeshmemory")) 61 indexlist.append(firstrow.index("afterinitialconditionsmemory")) 62 indexlist.append(firstrow.index("afterboundarymemory")) 63 indexlist.append(firstrow.index("aftersimulationmemory")) 64 indexlist.append(firstrow.index("variable1")) 65 66 #not all experiments have 3 variables, but some do 67 try: 68 indexlist.append(firstrow.index("variable2")) 69 except ValueError: 70 indexlist.append(firstrow.index("beforetime")) 71 try: 72 indexlist.append(firstrow.index("variable3")) 73 except ValueError: 74 indexlist.append(firstrow.index("aftertime")) 75 76 #write the header for the final csv 77 final.writerow(["TimeTaken(s)",firstrow[(indexlist[2])], 78 firstrow[(indexlist[3])],firstrow[(indexlist[4])], 79 firstrow[(indexlist[5])],firstrow[(indexlist[6])], 80 firstrow[(indexlist[7])],firstrow[(indexlist[8])], 81 firstrow[(indexlist[9])]]) 82 83 #write the data for each column in the final csv 84 for row in metalog: 85 86 #manipulate the beginning and end time to get the time taken 87 begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S') 88 end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S') 89 taken = time.mktime(end) - time.mktime(begin) 90 91 #write to file 92 final.writerow([str(taken),row[(indexlist[2])], 93 row[(indexlist[3])],row[(indexlist[4])], 94 row[(indexlist[5])],row[(indexlist[6])], 95 row[(indexlist[7])],row[(indexlist[8])], 96 row[(indexlist[9])]])
Note: See TracChangeset
for help on using the changeset viewer.