|
8 | 8 | from devito import ( # noqa |
9 | 9 | Abs, Conj, Constant, Dimension, Eq, Function, Ge, Grid, Gt, Imag, Le, Lt, Max, Min, |
10 | 10 | Operator, Real, SubDimension, SubDomain, TimeFunction, configuration, cos, norm, sin, |
11 | | - solve |
| 11 | + solve, switchconfig |
12 | 12 | ) |
13 | 13 | from devito.finite_differences.differentiable import Mul, SafeInv, Weights |
14 | 14 | from devito.ir import Expression, FindNodes, ccode |
15 | 15 | from devito.ir.support.guards import GuardExpr, pairwise_or, simplify_and |
16 | 16 | from devito.mpi.halo_scheme import HaloTouch |
17 | 17 | from devito.symbolics import ( # noqa |
18 | 18 | INT, BaseCast, CallFromPointer, Cast, DefFunction, FieldFromComposite, |
19 | | - FieldFromPointer, IntDiv, ListInitializer, Namespace, ReservedWord, Rvalue, SizeOf, |
20 | | - VectorAccess, evalrel, pow_to_mul, retrieve_derivatives, retrieve_functions, |
| 19 | + FieldFromPointer, IntDiv, ListInitializer, Namespace, ReservedWord, RoundUp, Rvalue, |
| 20 | + SizeOf, VectorAccess, evalrel, pow_to_mul, retrieve_derivatives, retrieve_functions, |
21 | 21 | retrieve_indexed, uxreplace |
22 | 22 | ) |
23 | 23 | from devito.tools import CustomDtype, as_tuple |
@@ -390,6 +390,20 @@ def test_safeinv(): |
390 | 390 | assert str(v) == 'u[x, y]' |
391 | 391 |
|
392 | 392 |
|
| 393 | +def test_roundup(): |
| 394 | + grid = Grid(shape=(11, 11)) |
| 395 | + u = Function(name='u', grid=grid) |
| 396 | + a = dSymbol('a', dtype=np.int32) |
| 397 | + |
| 398 | + expr = RoundUp(a, 16) |
| 399 | + with switchconfig(platform='bdw', language='openmp'): |
| 400 | + op = Operator(Eq(u, u + expr)) |
| 401 | + |
| 402 | + assert ccode(expr) == 'ROUND_UP(a, 16)' |
| 403 | + assert '#define ROUND_UP(a,b)' in str(op) |
| 404 | + assert 'ROUND_UP(a, 16)' in str(op) |
| 405 | + |
| 406 | + |
393 | 407 | def test_def_function(): |
394 | 408 | foo0 = DefFunction('foo', arguments=['a', 'b'], template=['int']) |
395 | 409 | foo1 = DefFunction('foo', arguments=['a', 'b'], template=['int']) |
|
0 commit comments