@@ -346,7 +346,7 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
346
346
# reductions
347
347
assert intent in {INC , MIN_WRITE , MIN_RW , MAX_WRITE , MAX_RW }
348
348
# We don't need to update roots if performing the same reduction
349
- # again. For example we can increment into an buffer as many times
349
+ # again. For example we can increment into a buffer as many times
350
350
# as we want. The reduction only needs to be done when the
351
351
# data is read.
352
352
if buffer ._roots_valid or intent == buffer ._pending_reduction :
@@ -360,16 +360,20 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
360
360
assert buffer ._pending_reduction is not None
361
361
initializers .append (buffer ._reduce_leaves_to_roots_begin )
362
362
reductions .append (buffer ._reduce_leaves_to_roots_end )
363
+
363
364
# set leaves to appropriate nil value
364
365
if intent == INC :
365
- def _zero ():
366
- buffer ._data [buffer .sf .ileaf ] = 0
367
- reductions .append (_zero )
366
+ nil = 0
368
367
elif intent in {MIN_WRITE , MIN_RW }:
369
- buffer . _data [ buffer . sf . ileaf ] = dtype_limits (buffer .dtype ).max
368
+ nil = dtype_limits (buffer .dtype ).max
370
369
else :
371
370
assert intent in {MAX_WRITE , MAX_RW }
372
- buffer ._data [buffer .sf .ileaf ] = dtype_limits (buffer .dtype ).min
371
+ nil = dtype_limits (buffer .dtype ).min
372
+
373
+ def _init_nil ():
374
+ buffer ._data [buffer .sf .ileaf ] = nil
375
+
376
+ reductions .append (_init_nil )
373
377
374
378
# We are modifying owned values so the leaves must now be wrong
375
379
buffer ._leaves_valid = False
0 commit comments