Ignore:
Timestamp:
Feb 10, 2012, 10:34:08 AM (12 years ago)
Author:
pittj
Message:

update for the new experiments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/mem_time_tests/hardware/template/main.py

    r8328 r8331  
    66#------------------------------------------------------------------------------
    77import anuga
    8 import random
    98import subprocess
    109import csv
     
    2019home = os.getenv('INUNDATIONHOME')
    2120scenariodir = add_directories(home, ["data","mem_time_test", "parallel","template"])
    22 file1 = 'ex1.csv'
    23 file_path = os.path.join(scenariodir, file1)
    24 
    25 firstex1 = open(file_path, 'wb')
    26 spamWriter = csv.writer(firstex1)
    27 spamWriter.writerow(['Number Of Processors' ,'Time Taken (s)'])
     21meta_path = os.path.join(scenariodir, 'metalog.csv')
     22final_path = os.path.join(scenariodir, 'final.csv')
    2823
    2924
     
    3227
    3328for n in range(1,maxcpus,1):
    34     z = time.time()# time it
    35 
     29 
    3630    #the different ways each HOST requires the parallel script to be run
    3731    if (host == 'cyclone.agso.gov.au'):
    3832        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    39     if (host == 'tornado.agso.gov.au'):
     33    elif (host == 'tornado.agso.gov.au'):
    4034        subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    41     if (host == 'vayu1'):
    42         subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    43     if (host == 'rhe-compute1.ga.gov.au'):
     35    elif (host == 'rhe-compute1.ga.gov.au'):
    4436        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python2.6', 'runcairns.py'])
    45     if (host == 'xe'):
     37    else:
    4638        subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py'])
    4739   
    4840
    49     y = time.time() #time it
    50     spamWriter.writerow([n,(y-z)]) #record it
    51 
    5241print 'Done'
    5342
    54 analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files
     43#get the important data for the experiments from the anuga experiments
     44analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv'))
    5545
    56 #close ex1.csv so we can read from it for a different csv reader object
    57 firstex1.close()
    58 
    59 #merge the metalog useful memory info and the ex1 recorded info into one csv file named final
    60 ex1 = csv.reader(open(file_path,'rb'))
     46#open files to read from and write to
    6147metalog = csv.reader(open(meta_path,'rb'))
    6248final = csv.writer(open(final_path,'wb'))
    6349
     50#list stores the index of the values requird
     51indexlist = []
    6452
    65 for row in ex1:
    66     d = metalog.next()
    67     final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]])
     53#read in the first row
     54firstrow = metalog.next()
     55
     56#get the indices of the values we want, so that the data can be condensed
     57indexlist.append(firstrow.index("beforetime"))
     58indexlist.append(firstrow.index("aftertime"))
     59indexlist.append(firstrow.index("beforesimulationmemory"))
     60indexlist.append(firstrow.index("aftermeshmemory"))
     61indexlist.append(firstrow.index("afterinitialconditionsmemory"))
     62indexlist.append(firstrow.index("afterboundarymemory"))
     63indexlist.append(firstrow.index("aftersimulationmemory"))
     64indexlist.append(firstrow.index("variable1"))
     65
     66#not all experiments have 3 variables, but some do
     67try:
     68    indexlist.append(firstrow.index("variable2"))
     69except ValueError:
     70    indexlist.append(firstrow.index("beforetime"))
     71try:
     72    indexlist.append(firstrow.index("variable3"))
     73except ValueError:
     74    indexlist.append(firstrow.index("aftertime"))
     75
     76#write the header for the final csv
     77final.writerow(["TimeTaken(s)",firstrow[(indexlist[2])],
     78                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
     79                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
     80                firstrow[(indexlist[7])],firstrow[(indexlist[8])],
     81                firstrow[(indexlist[9])]])
     82
     83#write the data for each column in the final csv
     84for row in metalog:
     85
     86    #manipulate the beginning and end time to get the time taken
     87    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
     88    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
     89    taken = time.mktime(end) - time.mktime(begin)
     90
     91    #write to file
     92    final.writerow([str(taken),row[(indexlist[2])],
     93                    row[(indexlist[3])],row[(indexlist[4])],
     94                    row[(indexlist[5])],row[(indexlist[6])],
     95                    row[(indexlist[7])],row[(indexlist[8])],
     96                    row[(indexlist[9])]])
Note: See TracChangeset for help on using the changeset viewer.