Changeset 1601
- Timestamp:
- Jul 12, 2005, 6:09:22 PM (19 years ago)
- Location:
- inundation/ga/storm_surge/parallel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/parallel/parallel_shallow_water.py
r1598 r1601 60 60 # Buffers for synchronisation of timesteps 61 61 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) 63 65 64 66 65 67 self.communication_time = 0.0 66 68 self.communication_reduce_time = 0.0 69 self.communication_broadcast_time = 0.0 67 70 68 71 … … 76 79 assert self.conserved_quantities[2] == 'ymomentum', msg 77 80 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): 81 108 82 109 # Calculate local timestep … … 84 111 85 112 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 87 176 88 177 … … 92 181 use_reduce_broadcast = True 93 182 if use_reduce_broadcast: 183 t0 = time.time() 94 184 pypar.reduce(self.local_timestep, pypar.MIN, 0, 95 185 buffer=self.global_timestep, 96 186 bypass=True) 97 98 pypar.broadcast(self.global_timestep, 0, 99 bypass=True) 187 self.communication_reduce_time += time.time()-t0 188 189 190 100 191 101 192 else: 102 193 #Try using straight send and receives 194 t0 = time.time() 103 195 self.global_timestep[0] = self.timestep 104 196 … … 114 206 pypar.send(self.local_timestep, 0, 115 207 use_buffer=True, bypass=True) 208 self.communication_reduce_time += time.time()-t0 116 209 117 210 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 119 216 120 217 121 218 self.timestep = self.global_timestep[0] 122 self.communication_reduce_time += time.time()-t0 123 219 220 221 #update_timestep = update_timestep_2 124 222 125 223 def update_ghosts(self): -
inundation/ga/storm_surge/parallel/run_parallel_sw_merimbula.py
r1599 r1601 145 145 ghost_recv_dict = ghost_recv_dict) 146 146 147 #domain.initialise_visualiser(rect=rect)148 147 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 148 try: 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 153 except: 154 print 'No visualiser' 153 155 154 156 … … 190 192 print 'Communication time %.2f seconds'%domain.communication_time 191 193 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.