source: trunk/anuga_work/development/mem_time_tests/triangles/area/main.py @ 8328

Last change on this file since 8328 was 8328, checked in by pittj, 13 years ago

metalog and ex1 merge added, code is now correct across all major experiments

  • Property svn:executable set to *
File size: 3.2 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import subprocess
6import csv
7import os
8import time
9import liststore
10from anuga.abstract_2d_finite_volumes.util import add_directories
11from anuga.utilities.log_analyser import analyse_log
12
13#------------------------------------------------------------------------------
14# Set up variables for the correct directories to store the output
15#------------------------------------------------------------------------------
16home = os.getenv('INUNDATIONHOME')
17host = os.getenv('HOST')
18scenariodir = add_directories(home, ["data","mem_time_test", "triangles","area"])
19file1 = 'ex1.csv'
20meta = 'metalog.csv'
21meta_path = os.path.join(scenariodir, meta)
22final = 'final.csv'
23final_path = os.path.join(scenariodir, final)
24storen ='storen.txt'
25file_path_storen = os.path.join(scenariodir, storen)
26
27#set up needed files
28firstex1 = open(file_path, 'wb')
29spamWriter = csv.writer(firstex1)
30spamWriter.writerow(['Number of Triangles','Max Area(m^2)','Extent(m^2)' , 'Time Taken(s)','Space Used'])
31e = open(file_path_storen,'a')
32e.close()
33
34# this is the main loops that assigns the maximum triangle area (m) and the map side length(l)
35
36n = 4 #number of processors to use
37for m in range(90,100,10):
38     for l in range(100,2000,100):
39               
40        z = time.time()# time it
41
42        #the different ways each host calls MPI properly
43        if (host == 'cyclone.agso.gov.au'):
44            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'):
46            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'):
50            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py',str(m),str(l)])   
51        if (host == 'xe'):
52            subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py',str(m),str(l)]) 
53       
54        y = time.time()# time it
55
56        # read the number of triangles from this file
57        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 it
62
63print 'Done'
64
65analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files
66
67#close ex1.csv so we can read from it for a different csv reader object
68firstex1.close()
69
70#merge the metalog useful memory info and the ex1 recorded info into one csv file named final
71ex1 = csv.reader(open(file_path,'rb'))
72metalog = csv.reader(open(meta_path,'rb'))
73final = csv.writer(open(final_path,'wb'))
74
75
76for 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]])
79
Note: See TracBrowser for help on using the repository browser.