1 | #------------------------------------------------------------------------------ |
---|
2 | # Import necessary modules |
---|
3 | #------------------------------------------------------------------------------ |
---|
4 | import anuga |
---|
5 | import subprocess |
---|
6 | import csv |
---|
7 | import os |
---|
8 | import time |
---|
9 | import liststore |
---|
10 | from anuga.abstract_2d_finite_volumes.util import add_directories |
---|
11 | from anuga.utilities.log_analyser import analyse_log |
---|
12 | |
---|
13 | #------------------------------------------------------------------------------ |
---|
14 | # Set up variables for the correct directories to store the output |
---|
15 | #------------------------------------------------------------------------------ |
---|
16 | home = os.getenv('INUNDATIONHOME') |
---|
17 | host = os.getenv('HOST') |
---|
18 | scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"]) |
---|
19 | file1 = 'ex1.csv' |
---|
20 | file_path = os.path.join(scenariodir, file1) |
---|
21 | storel ='storel.txt' |
---|
22 | file_path_storel = os.path.join(scenariodir, storel) |
---|
23 | storea ='storea.txt' |
---|
24 | file_path_storea = os.path.join(scenariodir, storea) |
---|
25 | storen ='storen.txt' |
---|
26 | file_path_storen = os.path.join(scenariodir, storen) |
---|
27 | |
---|
28 | #create and set up the files |
---|
29 | spamWriter = csv.writer(open(file_path, 'wb')) |
---|
30 | spamWriter.writerow(['Number Of Triangles' ,'Max Triangle Area', 'Extent', 'Space Used MB' , 'Time Taken s']) |
---|
31 | e = open(file_path_storea,'a') |
---|
32 | e.close() |
---|
33 | e = open(file_path_storel,'a') |
---|
34 | e.close() |
---|
35 | e = open(file_path_storen,'a') |
---|
36 | e.close() |
---|
37 | |
---|
38 | # this is the main loops that assigns the maximum triangle area (m) and the map side length(l) |
---|
39 | |
---|
40 | n = 4 #number of processors to use |
---|
41 | for m in range(90,100,10): |
---|
42 | for l in range(100,2000,100): |
---|
43 | |
---|
44 | #write these values to file |
---|
45 | g = open(file_path_storel,'r+') |
---|
46 | g.write(str(l)) |
---|
47 | h = open(file_path_storea,'r+') |
---|
48 | h.write(str(m)) |
---|
49 | |
---|
50 | z = time.time()# time it |
---|
51 | |
---|
52 | #the different ways each host calls MPI properly |
---|
53 | if (host == 'cyclone.agso.gov.au'): |
---|
54 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
55 | if (host == 'tornado.agso.gov.au'): |
---|
56 | subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
57 | if (host == 'vayu1'): |
---|
58 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
59 | if (host == 'rhe-compute1.ga.gov.au'): |
---|
60 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) |
---|
61 | if (host == 'xe'): |
---|
62 | subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) |
---|
63 | |
---|
64 | y = time.time()# time it |
---|
65 | |
---|
66 | # read the number of triangles from this file |
---|
67 | f = open(file_path_storen,'r+') |
---|
68 | i = float(f.readline()) |
---|
69 | f.close() |
---|
70 | |
---|
71 | spamWriter.writerow([i,d,(l*l),'x' ,(y-z)])# record it |
---|
72 | |
---|
73 | print 'Done' |
---|
74 | |
---|
75 | analyse_log(scenariodir, 'metalog.csv') #get the memory statistics from the log files |
---|
76 | |
---|