- 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/triangles/area/main.py
r8328 r8331 17 17 host = os.getenv('HOST') 18 18 scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"]) 19 file1 = 'ex1.csv'20 19 meta = 'metalog.csv' 21 20 meta_path = os.path.join(scenariodir, meta) 22 21 final = 'final.csv' 23 22 final_path = os.path.join(scenariodir, final) 24 storen ='storen.txt'25 file_path_storen = os.path.join(scenariodir, storen)26 27 #set up needed files28 firstex1 = open(file_path, 'wb')29 spamWriter = csv.writer(firstex1)30 spamWriter.writerow(['Number of Triangles','Max Area(m^2)','Extent(m^2)' , 'Time Taken(s)','Space Used'])31 e = open(file_path_storen,'a')32 e.close()33 23 34 24 # this is the main loops that assigns the maximum triangle area (m) and the map side length(l) … … 37 27 for m in range(90,100,10): 38 28 for l in range(100,2000,100): 39 40 z = time.time()# time it41 42 29 #the different ways each host calls MPI properly 43 30 if (host == 'cyclone.agso.gov.au'): 44 31 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) 45 if (host == 'tornado.agso.gov.au'):32 elif (host == 'tornado.agso.gov.au'): 46 33 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) 47 if (host == 'vayu1'): 48 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) 49 if (host == 'rhe-compute1.ga.gov.au'): 34 elif (host == 'rhe-compute1.ga.gov.au'): 50 35 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py',str(m),str(l)]) 51 if (host == 'xe'):36 else: 52 37 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) 53 38 54 y = time.time()# time it55 56 # read the number of triangles from this file57 f = open(file_path_storen,'r+')58 i = float(f.readline())59 f.close()60 61 spamWriter.writerow([i,m,(l*l),'x' ,(y-z)])# record it62 63 39 print 'Done' 64 40 65 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files 41 #get the important data for the experiments from the anuga experiments 42 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 66 43 67 #close ex1.csv so we can read from it for a different csv reader object 68 firstex1.close() 69 70 #merge the metalog useful memory info and the ex1 recorded info into one csv file named final 71 ex1 = csv.reader(open(file_path,'rb')) 44 #open files to read from and write to 72 45 metalog = csv.reader(open(meta_path,'rb')) 73 46 final = csv.writer(open(final_path,'wb')) 74 47 48 #list stores the index of the values requird 49 indexlist = [] 75 50 76 for row in ex1: 77 d = metalog.next() 78 final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]]) 51 #read in the first row 52 firstrow = metalog.next() 79 53 54 #get the indices of the values we want, so that the data can be condensed 55 indexlist.append(firstrow.index("beforetime")) 56 indexlist.append(firstrow.index("aftertime")) 57 indexlist.append(firstrow.index("beforesimulationmemory")) 58 indexlist.append(firstrow.index("aftermeshmemory")) 59 indexlist.append(firstrow.index("afterinitialconditionsmemory")) 60 indexlist.append(firstrow.index("afterboundarymemory")) 61 indexlist.append(firstrow.index("aftersimulationmemory")) 62 indexlist.append(firstrow.index("variable1")) 63 64 #not all experiments have 3 variables, but some do 65 try: 66 indexlist.append(firstrow.index("variable2")) 67 except ValueError: 68 indexlist.append(firstrow.index("beforetime")) 69 try: 70 indexlist.append(firstrow.index("variable3")) 71 except ValueError: 72 indexlist.append(firstrow.index("aftertime")) 73 74 #write the header for the final csv 75 final.writerow(["TimeTaken(s)",firstrow[(indexlist[2])], 76 firstrow[(indexlist[3])],firstrow[(indexlist[4])], 77 firstrow[(indexlist[5])],firstrow[(indexlist[6])], 78 firstrow[(indexlist[7])],firstrow[(indexlist[8])], 79 firstrow[(indexlist[9])]]) 80 81 #write the data for each column in the final csv 82 for row in metalog: 83 84 #manipulate the beginning and end time to get the time taken 85 begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S') 86 end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S') 87 taken = time.mktime(end) - time.mktime(begin) 88 89 #write to file 90 final.writerow([str(taken),row[(indexlist[2])], 91 row[(indexlist[3])],row[(indexlist[4])], 92 row[(indexlist[5])],row[(indexlist[6])], 93 row[(indexlist[7])],row[(indexlist[8])], 94 row[(indexlist[9])]])
Note: See TracChangeset
for help on using the changeset viewer.