|
13 | 13 | ) |
14 | 14 | from devito.data import LEFT, OWNED |
15 | 15 | from devito.finite_differences.tools import centered, direct, left, right, transpose |
16 | | -from devito.ir import Backward, Forward, GuardBound, GuardBoundNext, GuardFactor |
| 16 | +from devito.ir import ( |
| 17 | + Backward, Forward, GuardBound, GuardBoundNext, GuardFactor, GuardOverflow |
| 18 | +) |
17 | 19 | from devito.mpi.halo_scheme import Halo |
18 | 20 | from devito.mpi.routines import ( |
19 | 21 | MPIMsgEnriched, MPIRegion, MPIRequestObject, MPIStatusObject |
20 | 22 | ) |
21 | 23 | from devito.symbolics import ( |
22 | 24 | CallFromPointer, Cast, DefFunction, FieldFromPointer, IntDiv, ListInitializer, SizeOf, |
23 | | - indexify, pow_to_mul |
| 25 | + as_long, indexify, pow_to_mul |
24 | 26 | ) |
25 | 27 | from devito.symbolics.unevaluation import Mod |
26 | 28 | from devito.tools import EnrichedTuple |
@@ -566,6 +568,22 @@ def test_guard_bound_next(self, pickle, direction): |
566 | 568 |
|
567 | 569 | assert str(gbn) == str(new_gbn) |
568 | 570 |
|
| 571 | + @pytest.mark.parametrize('negated', [False, True]) |
| 572 | + def test_guard_overflow(self, pickle, negated): |
| 573 | + d = Dimension(name='d') |
| 574 | + freespace = Scalar(name='freespace') |
| 575 | + size = SizeOf(np.float32)*as_long((d + 4)*(d + 8)) |
| 576 | + |
| 577 | + guard = GuardOverflow(freespace, size) |
| 578 | + if negated: |
| 579 | + guard = guard.negated |
| 580 | + |
| 581 | + new_guard = pickle.loads(pickle.dumps(guard)) |
| 582 | + |
| 583 | + assert type(new_guard) is type(guard) |
| 584 | + assert str(new_guard) == str(guard) |
| 585 | + assert new_guard.canonical is new_guard |
| 586 | + |
569 | 587 | def test_temp_function(self, pickle): |
570 | 588 | grid = Grid(shape=(3, 3)) |
571 | 589 | d = Dimension(name='d') |
|
0 commit comments