Changeset 8326 for trunk/anuga_work/development/mem_time_tests/hardware
- Timestamp:
- Jan 31, 2012, 10:54:12 AM (13 years ago)
- Location:
- trunk/anuga_work/development/mem_time_tests/hardware
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_work/development/mem_time_tests/hardware/cairns/main.py
r8320 r8326 5 5 # Import necessary modules 6 6 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 7 import anuga 9 import random10 8 import subprocess 11 9 import csv 12 10 import os 13 11 import time 14 import liststore15 from anuga.utilities import system_tools, log16 12 from anuga.abstract_2d_finite_volumes.util import add_directories 13 from anuga.utilities.log_analyser import analyse_log 17 14 18 19 #------------------------------------------------------------------------------ 20 # Setup computational domain 21 #------------------------------------------------------------------------------ 22 a = [] 15 #-------------------------------------------------------------------------------------- 16 # Set up variables for the correct directories to store the output 17 #-------------------------------------------------------------------------------------- 23 18 host = os.getenv('HOST') 24 home 1= os.getenv('INUNDATIONHOME')25 scenariodir = add_directories(home 1, ["data","mem_time_test", "parallel","cairns"])19 home = os.getenv('INUNDATIONHOME') 20 scenariodir = add_directories(home, ["data","mem_time_test", "parallel","cairns"]) 26 21 file1 = 'ex1.csv' 27 22 file_path = os.path.join(scenariodir, file1) 28 store ='store.txt'29 file_path_store = os.path.join(scenariodir, store)30 31 log.log_filename = os.path.join(scenariodir, 'log.txt')32 23 33 24 spamWriter = csv.writer(open(file_path, 'wb')) 34 25 spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s']) 35 e = open(file_path_store,'a')36 e.close()37 26 27 28 # main loop that runs macpus - 1 times 38 29 maxcpus = 18 39 30 40 31 for n in range(1,maxcpus,1): 41 z = time.time() 42 y = time.time() 32 z = time.time() # time it 43 33 34 #the necessary ways to run this script in parallel on the different hosts we use 44 35 if (host == 'cyclone.agso.gov.au'): 45 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])36 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 46 37 if (host == 'tornado.agso.gov.au'): 47 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])38 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 48 39 if (host == 'vayu1'): 49 40 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) … … 53 44 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 54 45 55 liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] 56 f = open(file_path_store,'r+') 57 x = float(f.readline()) 58 f.close() 59 spamWriter.writerow([n,x ,(y-z)]) 60 print a 46 y = time.time()# time it 47 spamWriter.writerow([n,'x' ,(y-z)]) # write recorded results 48 print 'DONE' 61 49 50 analyse_log(scenariodir, 'metalog.csv') # interrogate log files for the memory usage information -
trunk/anuga_work/development/mem_time_tests/hardware/cairns/project.py
r8311 r8326 1 1 """ Common filenames and locations for topographic data, meshes and outputs. 2 2 This file defines the parameters of the scenario you wish to run. 3 4 Parameters differ from example to make the code run faster, and so the data is stored and found in the correct places 3 5 """ 4 6 -
trunk/anuga_work/development/mem_time_tests/hardware/cairns/runcairns.py
r8311 r8326 10 10 11 11 Geoscience Australia, 2004-present 12 13 This has remained unchanged aside from the parallelism added, the resource statistics 14 and the output directories, its also been scaled down so it runs faster 12 15 """ 13 16 … … 19 22 import time 20 23 import sys 24 import anuga 25 from anuga_parallel import distribute, myid, numprocs 26 from anuga.abstract_2d_finite_volumes.util import add_directories 27 from anuga.utilities import log 21 28 22 # Related major packages23 import anuga24 import liststore25 29 26 30 # Application specific imports 27 31 import project # Definition of file names and polygons 28 32 29 from anuga_parallel import distribute, myid, numprocs, finalize, barrier 30 from anuga.abstract_2d_finite_volumes.util import add_directories 31 from anuga.utilities import system_tools, log 33 34 # set up variables for the correct output directories 35 home = os.getenv('INUNDATIONHOME') 36 scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "cairns"]) 37 h = 'CAIRNS.msh' 38 file_pathh = os.path.join(scenariodir, h) 39 store ='store.txt' 40 file_path_store = os.path.join(scenariodir, store) 41 scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", 42 "cairns", "parrallel-" + str(numprocs) +"-"+str(myid)]) 43 log.log_filename = os.path.join(scenariodirV, "anuga.log") 44 log._setup = False 32 45 33 46 34 home2 = os.getenv('INUNDATIONHOME') 35 36 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "parallel", "cairns"]) 37 38 h = 'CAIRNS.msh' 39 file_pathh = os.path.join(scenariodir2, h) 40 store ='store.txt' 41 file_path_store = os.path.join(scenariodir2, store) 42 43 44 system_tools.MemoryUpdate() 45 47 log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics at this point 46 48 #------------------------------------------------------------------------------ 47 49 # Preparation of topographic data … … 49 51 #------------------------------------------------------------------------------ 50 52 # Create DEM from asc data 51 anuga.asc2dem(os.path.join(scenariodir 2, 'cairns.asc'), use_cache=True, verbose=True)53 anuga.asc2dem(os.path.join(scenariodir, 'cairns.asc'), use_cache=True, verbose=True) 52 54 53 55 # Create pts file for onshore DEM 54 anuga.dem2pts(os.path.join(scenariodir 2,'cairns.dem'), use_cache=True, verbose=True)56 anuga.dem2pts(os.path.join(scenariodir,'cairns.dem'), use_cache=True, verbose=True) 55 57 56 58 #------------------------------------------------------------------------------ … … 58 60 # overall clipping polygon with a tagged 59 61 # boundary and interior regions as defined in project.py 62 # (in serial, so the set up only runs once) 60 63 #------------------------------------------------------------------------------ 61 64 if myid == 0: … … 77 80 else: 78 81 domain = None 82 83 log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics at this point 79 84 85 #parallel 80 86 domain = distribute(domain) 81 87 … … 84 90 #------------------------------------------------------------------------------ 85 91 domain.set_name('cairns_' + project.scenario) # Name of sww file 86 domain.set_datadir(scenariodir 2) # Store sww output here92 domain.set_datadir(scenariodirV) # Store sww output here 87 93 domain.set_minimum_storable_height(0.01) # Store only depth > 1cm 88 94 … … 95 101 domain.set_quantity('friction', 0.0) 96 102 domain.set_quantity('elevation', 97 filename=os.path.join(scenariodir 2, 'cairns.pts'),103 filename=os.path.join(scenariodir, 'cairns.pts'), 98 104 use_cache=True, 99 105 verbose=True, 100 106 alpha=0.1) 107 log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics at this point 101 108 102 109 #------------------------------------------------------------------------------ … … 138 145 'onshore': Bd, 139 146 'top': Bd}) 140 147 log.resource_usage_timing(prefix='afterboundary') #get memory statistics at this point 141 148 #------------------------------------------------------------------------------ 142 149 # Evolve system through time … … 175 182 print domain.boundary_statistics(tags='ocean_east') 176 183 184 177 185 print 'That took %.2f seconds' %(time.time()-t0) 178 186 179 liststore.spacelist[myid] = system_tools.MemoryUpdate()[0] 180 a = sum(liststore.spacelist) 181 182 f = open(file_path_store, 'r+') 183 f.write(str(a)) 184 187 log.resource_usage_timing(prefix='aftersimulation') #get memory statistics at this point -
trunk/anuga_work/development/mem_time_tests/hardware/template/main.py
r8320 r8326 5 5 # Import necessary modules 6 6 #------------------------------------------------------------------------------ 7 # Import standard shallow water domain and standard boundaries.8 7 import anuga 9 8 import random 10 9 import subprocess 11 import run_parallel12 10 import csv 13 11 import os 14 12 import time 15 import liststore16 from anuga.utilities import system_tools, log17 13 from anuga.abstract_2d_finite_volumes.util import add_directories 14 from anuga.utilities.log_analyser import analyse_log 18 15 19 20 #------------------------------------------------------------------------------ 21 # Setup computational domain 22 #------------------------------------------------------------------------------ 23 a = [] 16 #------------------------------------------------------------------------------- 17 # Set up variables for the correct directories to store the output 18 #------------------------------------------------------------------------------- 24 19 host = os.getenv('HOST') 25 20 home = os.getenv('INUNDATIONHOME') … … 27 22 file1 = 'ex1.csv' 28 23 file_path = os.path.join(scenariodir, file1) 29 storel ='storel.txt'30 file_path_storel = os.path.join(scenariodir, storel)31 storea ='storea.txt'32 file_path_storea = os.path.join(scenariodir, storea)33 store ='store.txt'34 file_path_store = os.path.join(scenariodir, store)35 storen ='storen.txt'36 file_path_storen = os.path.join(scenariodir, storen)37 38 log.log_filename = os.path.join(scenariodir, 'log.txt')39 40 24 spamWriter = csv.writer(open(file_path, 'wb')) 41 25 spamWriter.writerow(['Number Of Processors' , 'Space Used MB' , 'Time Taken s','Total Space']) 42 e = open(file_path_store,'a')43 e.close()44 26 45 27 28 #main loop that runs maxcpus - 1 times 29 maxcpus = 40 46 30 47 for n in range(1,40,1): 48 z = time.time() 31 for n in range(1,maxcpus,1): 32 z = time.time()# time it 33 34 #the different ways each HOST requires the parallel script to be run 49 35 if (host == 'cyclone.agso.gov.au'): 50 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])36 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_cyclone', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 51 37 if (host == 'tornado.agso.gov.au'): 52 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python 2.6', 'runcairns.py'])38 subprocess.call(['mpirun', '-np', str(n), '-hostfile' ,'~/machinefiles/test.machines_tornado', '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 53 39 if (host == 'vayu1'): 54 40 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) … … 57 43 if (host == 'xe'): 58 44 subprocess.call(['mpirun', '-np', str(n), '-x','PYTHONPATH','-x','INUNDATIONHOME','python', 'runcairns.py']) 59 60 y = time.time() 61 f = open(file_path_store,'r+') 62 x = float(f.readline()) 63 f.close() 64 spamWriter.writerow([n,liststore.spacelist,(y-z),x]) 65 liststore.spacelist = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] 66 print a 45 67 46 47 y = time.time() #time it 48 spamWriter.writerow([n,(y-z)]) #record it 49 50 print 'Done' 51 52 analyse_log(scenariodir, 'metalog.csv') #get all the memory usage statistics -
trunk/anuga_work/development/mem_time_tests/hardware/template/runcairns.py
r8311 r8326 1 """Script for running a tsunami inundation scenario for Cairns, QLD Australia. 1 """ 2 This experiment was based heavily on the cairns demo given in the user manual and found in 3 the anuga repository. 2 4 3 Source data such as elevation and boundary data is assumed to be available in 4 directories specified by project.py 5 The output sww file is stored in directory named after the scenario, i.e 6 slide or fixed_wave. 7 8 The scenario is defined by a triangular mesh created from project.polygon, 9 the elevation data and a tsunami wave generated by a submarine mass failure. 10 11 Geoscience Australia, 2004-present 5 However, it has been simplified so that it doesnt require all the files the cairns demo does 12 6 """ 13 7 … … 15 9 # Import necessary modules 16 10 #------------------------------------------------------------------------------ 17 # Standard modules18 11 import os 19 12 import time 20 13 import sys 14 import anuga 15 from anuga_parallel import distribute, myid, numprocs 16 from anuga.abstract_2d_finite_volumes.util import add_directories 17 from anuga.utilities import log 21 18 22 # Related major packages 23 import anuga 19 #set up variables for the correct I/O directories for data storage 20 home = os.getenv('INUNDATIONHOME') 21 scenariodir = add_directories(home, ["data", "mem_time_test", "parallel", "template"]) 22 scenariodirV = add_directories(home, ["data","mem_time_test", "parallel", 23 "template", "template-" + str(numprocs) +"-"+ str(myid)]) 24 h = 'CAIRNS.msh' 25 file_pathh = os.path.join(scenariodirV, h) 26 log.log_filename = os.path.join(scenariodirV, "anuga.log") 27 log._setup = False 24 28 25 from anuga_parallel import distribute, myid 26 import liststore 27 from anuga.abstract_2d_finite_volumes.util import add_directories 28 from anuga.utilities import system_tools, log 29 log.resource_usage_timing(prefix = 'BeforeSimulation')#get memory statistics here 30 #------------------------------------------------------------------------------ 31 #Create the domain and mesh for the resource experiment on only one processor 32 #------------------------------------------------------------------------------ 29 33 30 31 home2 = os.getenv('INUNDATIONHOME')32 33 scenariodir2 = add_directories(home2, ["data", "mem_time_test", "triangles", "area"])34 35 store ='store.txt'36 file_path_store = os.path.join(scenariodir2, store)37 h = 'cairnsmesh.msh'38 file_pathh = os.path.join(scenariodir2, h)39 40 41 system_tools.MemoryUpdate()42 #------------------------------------------------------------------------------43 # Create the triangular mesh and domain based on44 # overall clipping polygon with a tagged45 # boundary and interior regions as defined in project.py46 #------------------------------------------------------------------------------47 34 if myid == 0: 48 35 domain = anuga.create_domain_from_regions([(0.0,0.0),(10000.0,10000.0),(0.0,10000.0),(10000.0,0.0)], … … 52 39 'left': [3]}, 53 40 maximum_triangle_area=100.0, 54 mesh_filename=file_pathh 55 #,interior_regions=INTERIORREGIONS#, 56 #use_cache=True, 57 #verbose=True) 58 ) 59 60 # Print some stats about mesh and domain 61 #print 'Number of triangles = ', len(domain) 62 #print 'The extent is ', domain.get_extent() 63 #print domain.statistics() 41 mesh_filename=file_pathh) 64 42 else: 65 43 domain = None 66 44 45 #parallel 67 46 domain = distribute(domain) 68 69 #------------------------------------------------------------------------------70 # Setup parameters of computational domain71 #------------------------------------------------------------------------------72 47 domain.set_name('CAIRNS') # Name of sww file 73 domain.set_datadir(scenariodir2) # Store sww output here 48 domain.set_datadir(scenariodirV)# Store sww output here 49 log.resource_usage_timing(prefix = 'AfterMesh')#get memory statistics here 74 50 75 51 #------------------------------------------------------------------------------ … … 86 62 domain.set_quantity('elevation',topography,alpha=0.1) 87 63 88 64 log.resource_usage_timing(prefix='afterinitialconditions') #get memory statistics here 89 65 90 66 #------------------------------------------------------------------------------ … … 94 70 Bi = anuga.Dirichlet_boundary([tide, 223.52, 0]) # inflow 95 71 Bo = anuga.Dirichlet_boundary([-tide, 223.52, 0]) # inflow 96 Bs = anuga.Transmissive_stage_zero_momentum_boundary(domain) # Neutral boundary97 72 Br = anuga.Reflective_boundary(domain) 98 #Bw = anuga.Time_boundary(domain=domain,function=lambda t: [(60<t<3660)*50, 0, 0]) 99 domain.set_boundary({'right': Bo, 100 'bottom': Br, 101 'left': Bi, 102 'top': Br}) 73 domain.set_boundary({'right': Bo,'bottom': Br,'left': Bi,'top': Br}) 103 74 75 log.resource_usage_timing(prefix='afterboundary') #get memory statistics here 104 76 #------------------------------------------------------------------------------ 105 77 # Evolve system through time 106 78 #------------------------------------------------------------------------------ 107 108 # Save every two mins leading up to wave approaching land109 79 for t in domain.evolve(yieldstep=120, finaltime=2000): 110 80 print domain.timestepping_statistics() 111 112 81 113 liststore.spacelist[myid] = system_tools.MemoryUpdate()[0] 114 a = sum(liststore.spacelist) 115 print liststore.spacelist 116 117 f = open(file_path_store, 'r+') 118 f.write(str(a)) 119 82 log.resource_usage_timing(prefix='aftersimulation')#get memory statistics here
Note: See TracChangeset
for help on using the changeset viewer.