Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Commit 540985c

Browse files
fix halo exchange (#30)
* fix halo exchange * cleanup --------- Co-authored-by: Connor Ward <[email protected]>
1 parent 15e870d commit 540985c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

pyop3/lang.py

+15-10
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
346346
# reductions
347347
assert intent in {INC, MIN_WRITE, MIN_RW, MAX_WRITE, MAX_RW}
348348
# 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
350350
# as we want. The reduction only needs to be done when the
351351
# data is read.
352352
if buffer._roots_valid or intent == buffer._pending_reduction:
@@ -361,6 +361,20 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
361361
initializers.append(buffer._reduce_leaves_to_roots_begin)
362362
reductions.append(buffer._reduce_leaves_to_roots_end)
363363

364+
# set leaves to appropriate nil value
365+
if intent == INC:
366+
nil = 0
367+
elif intent in {MIN_WRITE, MIN_RW}:
368+
nil = dtype_limits(buffer.dtype).max
369+
else:
370+
assert intent in {MAX_WRITE, MAX_RW}
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)
377+
364378
# We are modifying owned values so the leaves must now be wrong
365379
buffer._leaves_valid = False
366380

@@ -370,15 +384,6 @@ def _buffer_exchanges(buffer, intent, *, touches_ghost_points):
370384
else:
371385
buffer._pending_reduction = intent
372386

373-
# set leaves to appropriate nil value
374-
if intent == INC:
375-
buffer._data[buffer.sf.ileaf] = 0
376-
elif intent in {MIN_WRITE, MIN_RW}:
377-
buffer._data[buffer.sf.ileaf] = dtype_limits(buffer.dtype).max
378-
else:
379-
assert intent in {MAX_WRITE, MAX_RW}
380-
buffer._data[buffer.sf.ileaf] = dtype_limits(buffer.dtype).min
381-
382387
return tuple(initializers), tuple(reductions), tuple(broadcasts)
383388

384389

0 commit comments

Comments
 (0)