1 | #------------------------------------------------------------------------------ |
---|
2 | # Import necessary modules |
---|
3 | #------------------------------------------------------------------------------ |
---|
4 | import anuga |
---|
5 | import subprocess |
---|
6 | import csv |
---|
7 | import os |
---|
8 | import time |
---|
9 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
10 | from anuga.utilities.log_analyser import analyse_log |
---|
11 | |
---|
12 | #------------------------------------------------------------------------------ |
---|
13 | # Set up variables for the correct directories to store the output |
---|
14 | #------------------------------------------------------------------------------ |
---|
15 | home = os.getenv('INUNDATIONHOME') |
---|
16 | host = os.getenv('HOST') |
---|
17 | scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"]) |
---|
18 | meta = 'metalog.csv' |
---|
19 | meta_path = os.path.join(scenariodir, meta) |
---|
20 | final = 'final.csv' |
---|
21 | final_path = os.path.join(scenariodir, final) |
---|
22 | |
---|
23 | # this is the main loops that assigns the maximum triangle area (m) and the map side length(l) |
---|
24 | |
---|
25 | n = 4 #number of processors to use |
---|
26 | for m in range(90,100,10): |
---|
27 | for l in range(100,2000,100): |
---|
28 | #the different ways each host calls MPI properly |
---|
29 | if (host == 'cyclone.agso.gov.au'): |
---|
30 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) |
---|
31 | elif (host == 'tornado.agso.gov.au'): |
---|
32 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) |
---|
33 | elif (host == 'rhe-compute1.ga.gov.au'): |
---|
34 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py',str(m),str(l)]) |
---|
35 | else: |
---|
36 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) |
---|
37 | |
---|
38 | print 'Done' |
---|
39 | |
---|
40 | #get the important data for the experiments from the anuga experiments |
---|
41 | analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) |
---|
42 | |
---|
43 | #open files to read from and write to |
---|
44 | metalog = csv.reader(open(meta_path,'rb')) |
---|
45 | final = csv.writer(open(final_path,'wb')) |
---|
46 | |
---|
47 | #list stores the index of the values requird |
---|
48 | indexlist = [] |
---|
49 | |
---|
50 | #read in the first row |
---|
51 | firstrow = metalog.next() |
---|
52 | |
---|
53 | #get the indices of the values we want, so that the data can be condensed |
---|
54 | indexlist.append(firstrow.index("beforetime")) |
---|
55 | indexlist.append(firstrow.index("aftertime")) |
---|
56 | indexlist.append(firstrow.index("aftermeshtime")) |
---|
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 | |
---|
63 | indexlist.append(firstrow.index("extent")) |
---|
64 | indexlist.append(firstrow.index("trianglearea")) |
---|
65 | indexlist.append(firstrow.index("numberoftriangles")) |
---|
66 | indexlist.append(firstrow.index("numberofcpus")) |
---|
67 | indexlist.append(firstrow.index("numberoftriangles")) |
---|
68 | indexlist.append(firstrow.index("myid")) |
---|
69 | |
---|
70 | |
---|
71 | #write the header for the final csv |
---|
72 | final.writerow(["TimeTaken(s)","MeshTime(s)", |
---|
73 | firstrow[(indexlist[3])],firstrow[(indexlist[4])], |
---|
74 | firstrow[(indexlist[5])],firstrow[(indexlist[6])], |
---|
75 | firstrow[(indexlist[7])],firstrow[(indexlist[8])], |
---|
76 | firstrow[(indexlist[9])],firstrow[(indexlist[10])], |
---|
77 | firstrow[(indexlist[11])],firstrow[(indexlist[12])], |
---|
78 | firstrow[(indexlist[13])]]) |
---|
79 | |
---|
80 | #write the data for each column in the final csv |
---|
81 | for row in metalog: |
---|
82 | |
---|
83 | #manipulate the beginning and end time to get the time taken |
---|
84 | begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S') |
---|
85 | end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S') |
---|
86 | mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S') |
---|
87 | taken = time.mktime(end) - time.mktime(begin) |
---|
88 | meshtime = time.mktime(mesh) - time.mktime(begin) |
---|
89 | |
---|
90 | #write to file |
---|
91 | final.writerow([str(taken),str(meshtime), |
---|
92 | row[(indexlist[3])],row[(indexlist[4])], |
---|
93 | row[(indexlist[5])],row[(indexlist[6])], |
---|
94 | row[(indexlist[7])],row[(indexlist[8])], |
---|
95 | row[(indexlist[9])],row[(indexlist[10])], |
---|
96 | row[(indexlist[11])],row[(indexlist[12])] |
---|
97 | row[(indexlist[13])]]) |
---|