source: trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py @ 8328

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

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

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1"""Simple water flow example using ANUGA
2Water flowing down a channel
3"""
4#------------------------------------------------------------------------------
5# Import necessary modules
6#------------------------------------------------------------------------------
7import anuga
8import subprocess
9import csv
10import os
11import time
12from anuga.abstract_2d_finite_volumes.util import add_directories
13from anuga.utilities.log_analyser import analyse_log
14
15#--------------------------------------------------------------------------------------
16# Set up variables for the correct directories to store the output
17#--------------------------------------------------------------------------------------
18host = os.getenv('HOST')
19home = os.getenv('INUNDATIONHOME')
20scenariodir = add_directories(home, ["data","mem_time_test", "parallel","cairns"])
21file1 = 'ex1.csv'
22file_path = os.path.join(scenariodir, file1)
23
24firstex1 = open(file_path, 'wb')
25spamWriter = csv.writer(firstex1)
26spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken (s)'])
27
28
29# main loop that runs macpus - 1 times
30maxcpus = 18
31
32for n in range(1,maxcpus,1):
33    z = time.time() # time it
34
35    #the necessary ways to run this script in parallel on the different hosts we use
36    if (host == 'cyclone.agso.gov.au'):
37        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
38    if (host == 'tornado.agso.gov.au'):
39        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
40    if (host == 'vayu1'):
41        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 
42    if (host == 'rhe-compute1.ga.gov.au'):
43        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py']) 
44    if (host == 'xe'):
45        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
46
47    y = time.time()# time it
48    spamWriter.writerow([n,'x' ,(y-z)]) # write recorded results
49print 'DONE'
50
51analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files
52
53#close ex1.csv so we can read from it for a different csv reader object
54firstex1.close()
55
56#merge the metalog useful memory info and the ex1 recorded info into one csv file named final
57ex1 = csv.reader(open(file_path,'rb'))
58metalog = csv.reader(open(meta_path,'rb'))
59final = csv.writer(open(final_path,'wb'))
60
61
62for row in ex1:
63    d = metalog.next()
64    final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]])
Note: See TracBrowser for help on using the repository browser.