@@ -2242,6 +2242,38 @@ def test_lift_halo_update_outside_distributed(self, mode):
22422242 halo_update = tloop .nodes [0 ].body [0 ].body [0 ].body [0 ]
22432243 assert isinstance (halo_update , HaloUpdateList )
22442244
2245+ @pytest .mark .parallel (mode = 4 )
2246+ def test_ensure_halo_updates_within_seq_loops (self , mode ):
2247+ n = 30
2248+ grid = Grid (shape = (n , n ))
2249+
2250+ x , y = grid .dimensions
2251+ d = Dimension (name = "d" )
2252+
2253+ a = Function (name = "a" , grid = grid , space_order = 8 )
2254+ b = a .func (name = 'b' )
2255+
2256+ g = Function (name = "g" , grid = grid , space_order = 8 , dimensions = (x , y , d ),
2257+ shape = (n , n , 2 ))
2258+ h = g .func (name = 'h' )
2259+
2260+ eqns = [Eq (a , 0.0 ),
2261+ Eq (h , b * g ),
2262+ Inc (a , b * (h .dx + h .dy ))]
2263+
2264+ op = Operator (eqns , opt = ('advanced' , {'openmp' : True }))
2265+ _ = op .cfunction
2266+
2267+ # Check generated code -- expected one halo exchange within a sequential
2268+ # `d` loop
2269+ assert_structure (op , ['x,y' , 'x,y,d' , 'd' , 'x,y,d' ], 'xyddxyd' )
2270+ iters = FindNodes (Iteration ).visit (op )
2271+ assert iters [2 ].dim is d and iters [2 ].is_Parallel
2272+ assert iters [3 ].dim is d and iters [3 ].is_Sequential
2273+
2274+ # Probably unnecessary, but ensures there's no hanging
2275+ op .apply ()
2276+
22452277 @pytest .mark .parallel (mode = 4 )
22462278 def test_halo_inner_dim (self , mode ):
22472279 grid = Grid ((11 , 11 , 11 ))
0 commit comments