Changeset 1603


Ignore:
Timestamp:
Jul 14, 2005, 10:14:26 AM (19 years ago)
Author:
ole
Message:

Played with reduce and broadcast

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

Legend:

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

    r1601 r1603  
    100100
    101101        self.timestep = min(self.local_timesteps)
    102            
     102
     103        pypar.barrier()
    103104        self.communication_broadcast_time += time.time()-t0
    104105
    105106       
    106107
    107     def update_timestep_2(self, yieldstep, finaltime):
    108 
    109         # Calculate local timestep
     108
     109    def update_timestep(self, yieldstep, finaltime):
     110        """Calculate local timestep
     111        """
     112       
     113
     114        #Compute minimal timestep on local process
    110115        Domain.update_timestep(self, yieldstep, finaltime)
    111116
     117
     118
    112119        import time
    113 
    114 
    115 
     120        #Compute minimal timestep across all processes
    116121        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 
    176 
    177 
    178         self.local_timestep[0] = self.timestep
    179 
    180 
    181122        use_reduce_broadcast = True
    182123        if use_reduce_broadcast:
     
    185126                         buffer=self.global_timestep,
    186127                         bypass=True)
    187             self.communication_reduce_time += time.time()-t0           
    188 
    189 
    190128           
    191129           
    192130        else:
    193             #Try using straight send and receives
     131            #Alternative: Try using straight send and receives
    194132            t0 = time.time()           
    195133            self.global_timestep[0] = self.timestep
     
    206144                pypar.send(self.local_timestep, 0,
    207145                           use_buffer=True, bypass=True)
    208             self.communication_reduce_time += time.time()-t0                           
     146
     147
     148
     149        pypar.barrier()
     150        self.communication_reduce_time += time.time()-t0           
     151
    209152
    210153               
    211154
     155        #Broadcast minimal timestep to all
    212156        t0 = time.time()                       
    213157        pypar.broadcast(self.global_timestep, 0,
    214158                        bypass=True)
     159       
     160        pypar.barrier()       
    215161        self.communication_broadcast_time += time.time()-t0
    216162
     
    219165
    220166
    221     #update_timestep = update_timestep_2     
     167    #update_timestep = update_timestep_1     
    222168
    223169    def update_ghosts(self):
  • inundation/ga/storm_surge/parallel/run_parallel_sw_merimbula.py

    r1601 r1603  
    188188        #       (domain.processor,domain.quantities['stage'].get_integral())
    189189
     190
     191#print 'P%d: That took %.2f seconds' %(myid, time.time()-t0)
     192#print 'P%d: Communication time %.2f seconds' %(myid, domain.communication_time)
     193#print 'P%d: Reduction Communication time %.2f seconds' %(myid, domain.communication_reduce_time)
     194#print 'P%d: Broadcast time %.2f seconds' %(myid, domain.communication_broadcast_time)   
     195
     196
     197
    190198if myid == 0:
    191199    print 'That took %.2f seconds' %(time.time()-t0)
     
    193201    print 'Reduction Communication time %.2f seconds'%domain.communication_reduce_time
    194202    print 'Broadcast time %.2f seconds'%domain.communication_broadcast_time
     203
Note: See TracChangeset for help on using the changeset viewer.