@@ -2067,19 +2067,24 @@ def test_merge_smart_if_within_conditional(self, mode):
20672067 for n in FindNodes (Conditional ).visit (op1 ):
20682068 assert len (FindNodes (HaloUpdateCall ).visit (n )) == 0
20692069
2070+ @pytest .mark .parametrize ('dtype' , [np .float32 , np .complex64 ])
20702071 @pytest .mark .parallel (mode = 2 )
2071- def test_allreduce_time (self , mode ):
2072+ def test_allreduce_time (self , dtype , mode ):
20722073 space_order = 8
20732074 nx , ny = 11 , 11
20742075
20752076 grid = Grid (shape = (nx , ny ))
20762077 tt = grid .time_dim
20772078 nt = 10
20782079
2079- ux = TimeFunction (name = "ux" , grid = grid , time_order = 1 , space_order = space_order )
2080- g = TimeFunction (name = "g" , grid = grid , dimensions = (tt , ), shape = (nt ,))
2080+ c = tt if dtype == np .float32 else tt + tt * 1j
2081+
2082+ ux = TimeFunction (name = "ux" , grid = grid , time_order = 1 , space_order = space_order ,
2083+ dtype = dtype )
2084+ g = TimeFunction (name = "g" , grid = grid , dimensions = (tt , ), shape = (nt ,),
2085+ dtype = dtype )
20812086
2082- op = Operator ([Eq (ux .forward , ux + tt ), Inc (g , ux )], name = "Op" )
2087+ op = Operator ([Eq (ux .forward , ux + c ), Inc (g , ux )], name = "Op" )
20832088 assert_structure (op , ['t,x,y' , 't' ], 'txy' )
20842089
20852090 # Reduce should be in time loop but not in space loop
@@ -2091,7 +2096,10 @@ def test_allreduce_time(self, mode):
20912096 assert len (FindNodes (Call ).visit (i )) == 0
20922097
20932098 op .apply (time_m = 0 , time_M = nt - 1 )
2094- assert np .isclose (np .max (g .data ), 4356.0 )
2099+ if dtype == np .float32 :
2100+ assert np .isclose (np .max (g .data ), 4356.0 )
2101+ else :
2102+ assert np .isclose (np .max (g .data ), 4356.0 + 4356.0j )
20952103
20962104 @pytest .mark .parallel (mode = 2 )
20972105 def test_multi_allreduce_time (self , mode ):
0 commit comments