Changeset 8544


Ignore:
Timestamp:
Aug 30, 2012, 7:00:09 PM (13 years ago)
Author:
steve
Message:

Working on parallel_api

Location:
trunk/anuga_core/source
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/file_conversion/sww2dem.py

    r8541 r8544  
    3434            cellsize=10,
    3535            number_of_decimal_places=None,
    36             NODATA_value=-9999,
     36            NODATA_value=-9999.0,
    3737            easting_min=None,
    3838            easting_max=None,
     
    332332    outside_indices = interp.get_outside_poly_indices()
    333333
     334    #print outside_indices
     335
    334336    if verbose:
    335337        log.critical('Interpolated values are in [%f, %f]'
     
    342344
    343345    for i in outside_indices:
     346        #print 'change grid_value',NODATA_value
    344347        grid_values[i] = NODATA_value
    345348
  • trunk/anuga_core/source/anuga_parallel/distribute_mesh.py

    r8543 r8544  
    11341134
    11351135    i=0
    1136     i +=1 ; print 'send', i
    1137     protocol(num.array(setup_array, num.int))
    1138     pypar.send(setup_array, p, bypass=True)
     1136
     1137    x = num.array(setup_array, num.int)
     1138    pypar.send(x, p, bypass=True)
    11391139
    11401140
    11411141    # ghost layer width
    1142     i +=1 ; print 'send', i
    1143     protocol(num.array(submesh["ghost_layer_width"][p], num.int))
    1144     pypar.send(num.array(submesh["ghost_layer_width"][p], num.int), p, bypass=True)
     1142    x = num.array(submesh["ghost_layer_width"][p], num.int)
     1143    pypar.send(x, p, bypass=True)
    11451144
    11461145
    11471146    # send the number of triangles per processor
    1148     i +=1 ; print 'send', i
    1149     protocol(num.array(triangles_per_proc))
    1150     pypar.send(num.array(triangles_per_proc), p, bypass=True)
     1147    x = num.array(triangles_per_proc)
     1148    pypar.send(x, p, bypass=True)
    11511149
    11521150    # send the nodes
    1153     i +=1 ; print 'send', i
    1154     protocol(num.array(submesh["full_nodes"][p], num.float))
    1155     #pypar.send(num.array(submesh["full_nodes"][p], num.float), p, bypass=False)
    1156     pypar.send(num.array(submesh["full_nodes"][p], num.float), p)
    1157 
    1158 
    1159     i +=1 ; print 'send', i
    1160     protocol(num.array(submesh["ghost_nodes"][p], num.float))
    1161     pypar.send(num.array(submesh["ghost_nodes"][p], num.float),p, bypass=False)
     1151    x = num.array(submesh["full_nodes"][p], num.float)
     1152    pypar.send(x, p, bypass=True)
     1153
     1154    x = num.array(submesh["ghost_nodes"][p], num.float)
     1155    pypar.send(x, p, bypass=True)
    11621156
    11631157    # send the triangles
    1164 
    1165     i +=1 ; print 'send', i
    1166     protocol(num.array(submesh["full_triangles"][p],  num.int))
    1167     pypar.send(num.array(submesh["full_triangles"][p],  num.int), p, bypass=False)
    1168     i +=1 ; print 'send', i
    1169     protocol(num.array(submesh["ghost_triangles"][p], num.int))
    1170     pypar.send(num.array(submesh["ghost_triangles"][p], num.int), p, bypass=False)
     1158    x = num.array(submesh["full_triangles"][p], num.int)
     1159    pypar.send(x, p, bypass=True)
     1160
     1161    # send ghost triangles
     1162    x = num.array(submesh["ghost_triangles"][p], num.int)
     1163    pypar.send(x, p, bypass=True)
     1164
    11711165
    11721166    # send the boundary
    1173 
    11741167    bc = []
    11751168    for b in submesh["full_boundary"][p]:
    11761169        bc.append([b[0], b[1], tagmap[submesh["full_boundary"][p][b]]])
    11771170
    1178     i +=1 ; print 'send', i
    1179     protocol(num.array(bc, num.int))
    1180     pypar.send(num.array(bc, num.int), p, bypass=False)
     1171    x = num.array(bc, num.int)
     1172    pypar.send(x, p, bypass=True)
     1173
    11811174
    11821175    bc = []
     
    11841177        bc.append([b[0], b[1], tagmap[submesh["ghost_boundary"][p][b]]])
    11851178
    1186     i +=1 ; print 'send', i
    1187     protocol(num.array(bc, num.int))
    1188     pypar.send(num.array(bc, num.int), p, bypass=False)
     1179    x = num.array(bc, num.int)
     1180    pypar.send(x, p, bypass=True)
     1181
     1182
    11891183
    11901184    # send the communication pattern
    1191 
    1192     # submesh["ghost_commun"][p] is numpy array
    1193     i +=1 ; print 'send', i
    1194     protocol(submesh["ghost_commun"][p])
    1195     pypar.send(submesh["ghost_commun"][p], p, bypass=False)
    1196 
    1197     i +=1 ; print 'send', i
    1198     protocol(num.array(flat_full_commun, num.int))
    1199     pypar.send(num.array(flat_full_commun, num.int), p, bypass=False)
     1185    x = submesh["ghost_commun"][p]
     1186    pypar.send(x, p, bypass=True)
     1187
     1188
     1189    x = num.array(flat_full_commun, num.int)
     1190    pypar.send(x, p, bypass=True)
     1191
    12001192
    12011193    # send the quantities
    1202 
    1203    
    12041194    for k in submesh["full_quan"]:
    1205         print 'send full', ++i, k
    1206         protocol(num.array(submesh["full_quan"][k][p], num.float))
    1207         pypar.send(num.array(submesh["full_quan"][k][p], num.float), p, bypass=False)
     1195        x = num.array(submesh["full_quan"][k][p], num.float)
     1196        pypar.send(x, p, bypass=True)
    12081197       
    12091198    for k in submesh["ghost_quan"]:
    1210         print 'send ghost', ++i, k
    1211         protocol(num.array(submesh["ghost_quan"][k][p], num.float))
    1212         pypar.send(num.array(submesh["ghost_quan"][k][p], num.float),p, bypass=False)
     1199        x = num.array(submesh["ghost_quan"][k][p], num.float)
     1200        pypar.send(x,p, bypass=True)
    12131201       
    12141202
     
    12711259
    12721260
     1261
     1262    print 'setup_array', setup_array
     1263   
    12731264    # ghost layer width
    12741265    x = num.zeros((1,),num.int)
     
    12831274
    12841275    # receive the full nodes
    1285 #    x = num.zeros((no_full_nodes,),num.int)
    1286 #    pypar.receive(p, buffer=x,  bypass=True)
    1287 #    submesh_cell["full_nodes"] = x
    1288 
    1289 
    1290     submesh_cell["full_nodes"] = pypar.receive(p)
     1276    x = num.zeros((no_full_nodes,3),num.float)
     1277    pypar.receive(p, buffer=x,  bypass=True)
     1278    submesh_cell["full_nodes"] = x
     1279
     1280
    12911281    # receive the ghost nodes
    1292 
    1293     submesh_cell["ghost_nodes"] = pypar.receive(p, bypass=False)
     1282    x = num.zeros((no_ghost_nodes,3),num.float)
     1283    pypar.receive(p, buffer=x,  bypass=True)
     1284    submesh_cell["ghost_nodes"] = x
    12941285   
    12951286    # receive the full triangles
    1296 
    1297     submesh_cell["full_triangles"] = pypar.receive(p, bypass=False)
     1287    x = num.zeros((no_full_triangles,3),num.int)
     1288    pypar.receive(p, buffer=x,  bypass=True)
     1289    submesh_cell["full_triangles"] = x
     1290
    12981291   
    12991292    # receive the ghost triangles
    1300 
    1301     submesh_cell["ghost_triangles"] = pypar.receive(p, bypass=False)
     1293    x = num.zeros((no_ghost_triangles,4),num.int)
     1294    pypar.receive(p, buffer=x,  bypass=True)
     1295    submesh_cell["ghost_triangles"] = x
     1296
     1297
    13021298
    13031299    # receive the full boundary
    1304 
    1305     bnd_c = pypar.receive(p, bypass=False)
     1300    x = num.zeros((no_full_boundary,3),num.int)
     1301    pypar.receive(p, buffer=x,  bypass=True)
     1302    bnd_c = x
    13061303
    13071304    submesh_cell["full_boundary"] = {}
     
    13091306        submesh_cell["full_boundary"][b[0],b[1]]=itagmap[b[2]]
    13101307
     1308
    13111309    # receive the ghost boundary
    1312 
    1313     bnd_c = pypar.receive(p, bypass=False)
     1310    x = num.zeros((no_ghost_boundary,3),num.int)
     1311    pypar.receive(p, buffer=x,  bypass=True)
     1312    bnd_c = x
    13141313
    13151314    submesh_cell["ghost_boundary"] = {}
     
    13181317
    13191318    # receive the ghost communication pattern
    1320 
    1321     submesh_cell["ghost_commun"] = pypar.receive(p, bypass=False)
     1319    x = num.zeros((no_ghost_commun,2),num.int)
     1320    pypar.receive(p, buffer=x,  bypass=True)
     1321    submesh_cell["ghost_commun"] = x
    13221322   
    13231323    # receive the full communication pattern
    1324 
    1325     full_commun = pypar.receive(p, bypass=False)
     1324    x = num.zeros((no_full_commun,2),num.int)
     1325    pypar.receive(p, buffer=x,  bypass=True)
     1326    full_commun = x
    13261327
    13271328    submesh_cell["full_commun"] = {}
     
    13341335
    13351336    submesh_cell["full_quan"]={}
    1336    
    13371337    for i in range(no_quantities):
    1338         tmp = pypar.receive(p, bypass=False)
    1339         submesh_cell["full_quan"][qkeys[i]]=num.zeros((no_full_triangles,3), num.float)
    1340         submesh_cell["full_quan"][qkeys[i]][:] = tmp[:]
     1338        x = num.zeros((no_full_triangles,3), num.float)
     1339        pypar.receive(p, buffer=x, bypass=True)
     1340        submesh_cell["full_quan"][qkeys[i]]= x
    13411341
    13421342    submesh_cell["ghost_quan"]={}
    13431343    for i in range(no_quantities):
    1344         tmp = pypar.receive(p, bypass=False)
    1345         submesh_cell["ghost_quan"][qkeys[i]]= num.zeros((no_ghost_triangles,3), num.float)
    1346         submesh_cell["ghost_quan"][qkeys[i]][:] = tmp[:]
     1344        x = num.zeros((no_ghost_triangles,3), num.float)
     1345        pypar.receive(p, buffer=x, bypass=True)
     1346        submesh_cell["ghost_quan"][qkeys[i]]= x
    13471347   
    13481348    return submesh_cell, triangles_per_proc,\
  • trunk/anuga_core/source/anuga_parallel/parallel_api.py

    r8543 r8544  
    44"""
    55
    6 
     6import numpy as num
    77
    88# The abstract Python-MPI interface
     
    9393        boundary_map = domain.boundary_map
    9494        for p in range(1, numprocs):
     95            # FIXME SR: Creates cPickle dump
    9596            send(boundary_map, p)
    9697    else:
     
    127128            print 'p2s_map', p2s_map
    128129
     130
     131        def protocol(x):
     132            vanilla=False
     133            import pypar
     134            control_info, x = pypar.create_control_info(x, vanilla, return_object=True)
     135            print 'protocol', control_info[0]
     136           
    129137        # Send serial to parallel (s2p) and parallel to serial (p2s) triangle mapping to proc 1 .. numprocs
    130138        for p in range(1, numprocs):
    131139            # FIXME SR: Creates cPickle dump
    132             send(s2p_map, p)
     140
     141            print '*** s2p'
     142            protocol(s2p_map)
     143
     144            n = len(s2p_map)
     145            s2p_map_keys_flat = num.reshape(num.array(s2p_map.keys(),num.int), (n,1) )
     146
     147            print s2p_map_keys_flat.shape
     148
     149            s2p_map_values_flat = num.array(s2p_map.values(),num.int)
     150            print s2p_map_values_flat.shape
     151           
     152            s2p_map_flat = num.concatenate( (s2p_map_keys_flat, s2p_map_values_flat), axis=1 )
     153            #print s2p_map_keys_flat
     154            #print s2p_map_values_flat
     155            #print s2p_map_flat
     156
     157            send(s2p_map_flat, p)
    133158            # FIXME SR: Creates cPickle dump
     159            #print p2s_map
    134160            send(p2s_map, p)
    135161
     
    153179       
    154180        # Recieve serial to parallel (s2p) and parallel to serial (p2s) triangle mapping
    155         s2p_map = receive(0)
     181        s2p_map_flat = receive(0)
     182        s2p_map = dict.fromkeys(s2p_map_flat[:,0], s2p_map_flat[:,1:2])
     183
    156184        p2s_map = receive(0)
    157185
Note: See TracChangeset for help on using the changeset viewer.