Changeset 1601


Ignore:
Timestamp:
Jul 12, 2005, 6:09:22 PM (19 years ago)
Author:
ole
Message:

Played with timestep reduction

Location:
inundation/ga/storm_surge/parallel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/parallel/parallel_shallow_water.py

    r1598 r1601  
    6060        # Buffers for synchronisation of timesteps
    6161        self.local_timestep = zeros(1, Float)
    62         self.global_timestep = zeros(1, Float)       
     62        self.global_timestep = zeros(1, Float)
     63       
     64        self.local_timesteps = zeros(self.numproc, Float)       
    6365       
    6466
    6567        self.communication_time = 0.0
    6668        self.communication_reduce_time = 0.0
     69        self.communication_broadcast_time = 0.0       
    6770
    6871
     
    7679        assert self.conserved_quantities[2] == 'ymomentum', msg
    7780
    78 
    79 
    80     def update_timestep(self, yieldstep, finaltime):
     81 
     82    def update_timestep_1(self, yieldstep, finaltime):
     83        """Calculate local timestep using broadcasts
     84        """
     85
     86
     87        Domain.update_timestep(self, yieldstep, finaltime)
     88
     89        import time
     90
     91
     92        t0 = time.time()
     93       
     94        #Broadcast local timestep from every processor to every other
     95        for pid in range(self.numproc):
     96            #print 'P%d calling broadcast from %d' %(self.processor, pid)
     97            self.local_timestep[0] = self.timestep                   
     98            pypar.broadcast(self.local_timestep, pid, bypass=True)
     99            self.local_timesteps[pid] = self.local_timestep[0]           
     100
     101        self.timestep = min(self.local_timesteps)
     102           
     103        self.communication_broadcast_time += time.time()-t0
     104
     105       
     106
     107    def update_timestep_2(self, yieldstep, finaltime):
    81108
    82109        # Calculate local timestep
     
    84111
    85112        import time
    86         t0 = time.time()
     113
     114
     115
     116        self.local_timestep[0] = self.timestep
     117
     118
     119
     120        t0 = time.time()           
     121        pypar.reduce(self.local_timestep, pypar.MIN, self.numproc-1,
     122                     buffer=self.global_timestep,
     123                     bypass=True)
     124
     125
     126
     127
     128
     129        if self.processor == self.numproc-1:
     130            pypar.send(self.global_timestep, 0, use_buffer = True, bypass=True)
     131
     132        if self.processor == 0:
     133            pypar.receive(self.numproc-1, buffer=self.global_timestep,
     134                          bypass=True)   
     135           
     136        self.communication_reduce_time += time.time()-t0                       
     137           
     138
     139        t0 = time.time()                       
     140        pypar.broadcast(self.global_timestep, 0,
     141                        bypass=True)
     142        self.communication_broadcast_time += time.time()-t0
     143
     144       
     145        self.timestep = self.global_timestep[0]
     146
     147
     148           
     149        #else:
     150        #    #Try using straight send and receives
     151        #    t0 = time.time()           
     152        #    self.global_timestep[0] = self.timestep
     153        #   
     154        #    if self.processor == 0:
     155        #        for i in range(1, self.numproc):
     156        #            pypar.receive(i,
     157        #                          buffer=self.local_timestep,
     158        #                          bypass=True)#
     159        #
     160        #            if self.local_timestep[0] < self.global_timestep[0]:
     161        #                self.global_timestep[0] = self.local_timestep[0]
     162        #    else:
     163        #        pypar.send(self.local_timestep, 0,
     164        #                   use_buffer=True, bypass=True)
     165        #    self.communication_reduce_time += time.time()-t0 
     166
     167
     168
     169    def update_timestep(self, yieldstep, finaltime):
     170
     171        # Calculate local timestep
     172        Domain.update_timestep(self, yieldstep, finaltime)
     173
     174        import time
     175
    87176
    88177
     
    92181        use_reduce_broadcast = True
    93182        if use_reduce_broadcast:
     183            t0 = time.time()           
    94184            pypar.reduce(self.local_timestep, pypar.MIN, 0,
    95185                         buffer=self.global_timestep,
    96186                         bypass=True)
    97            
    98             pypar.broadcast(self.global_timestep, 0,
    99                             bypass=True)
     187            self.communication_reduce_time += time.time()-t0           
     188
     189
     190           
    100191           
    101192        else:
    102193            #Try using straight send and receives
     194            t0 = time.time()           
    103195            self.global_timestep[0] = self.timestep
    104196           
     
    114206                pypar.send(self.local_timestep, 0,
    115207                           use_buffer=True, bypass=True)
     208            self.communication_reduce_time += time.time()-t0                           
    116209
    117210               
    118             pypar.broadcast(self.global_timestep, 0, bypass = True)
     211
     212        t0 = time.time()                       
     213        pypar.broadcast(self.global_timestep, 0,
     214                        bypass=True)
     215        self.communication_broadcast_time += time.time()-t0
    119216
    120217       
    121218        self.timestep = self.global_timestep[0]
    122         self.communication_reduce_time += time.time()-t0
    123 
     219
     220
     221    #update_timestep = update_timestep_2     
    124222
    125223    def update_ghosts(self):
  • inundation/ga/storm_surge/parallel/run_parallel_sw_merimbula.py

    r1599 r1601  
    145145                         ghost_recv_dict = ghost_recv_dict)
    146146
    147 #domain.initialise_visualiser(rect=rect)
    148147
    149 domain.initialise_visualiser(rect=rect)
    150 domain.visualiser.coloring['stage'] = True
    151 domain.visualiser.scale_z['stage'] = 0.2
    152 domain.visualiser.scale_z['elevation'] = 0.05
     148try:
     149    domain.initialise_visualiser(rect=rect)
     150    domain.visualiser.coloring['stage'] = True
     151    domain.visualiser.scale_z['stage'] = 0.2
     152    domain.visualiser.scale_z['elevation'] = 0.05
     153except:
     154    print 'No visualiser'
    153155
    154156
     
    190192    print 'Communication time %.2f seconds'%domain.communication_time
    191193    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
     194    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
Note: See TracChangeset for help on using the changeset viewer.