From 7f6762a0540b01062df5cb8ea4236dcfb2773474 Mon Sep 17 00:00:00 2001 From: Fabio Luporini Date: Thu, 4 Jul 2024 14:01:37 +0000 Subject: [PATCH] compiler: Default to index-mode=int32 --- devito/core/operator.py | 6 +++--- devito/types/dense.py | 9 +++++---- tests/test_linearize.py | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/devito/core/operator.py b/devito/core/operator.py index fa0baa11f24..390f2469d72 100644 --- a/devito/core/operator.py +++ b/devito/core/operator.py @@ -115,10 +115,10 @@ class BasicOperator(Operator): stencil-like data accesses. """ - INDEX_MODE = "int64" + INDEX_MODE = "int32" """ - The type of the expression used to compute array indices. Either `int64` - (default) or `int32`. + The type of the expression used to compute array indices. Either `int32` + (default) or `int64`. """ ERRCTL = None diff --git a/devito/types/dense.py b/devito/types/dense.py index 5060b57746a..dfae835c5b7 100644 --- a/devito/types/dense.py +++ b/devito/types/dense.py @@ -866,10 +866,11 @@ def _arg_check(self, args, intervals, **kwargs): if args.options['index-mode'] == 'int32' and \ args.options['linearize'] and \ data.size - 1 >= np.iinfo(np.int32).max: - raise InvalidArgument("`%s`, with its %d elements, may be too big for " - "int32 pointer arithmetic, which might cause an " - "overflow. Use the 'index-mode=int64' option" - % (self, data.size)) + raise InvalidArgument("`%s`, with its %d elements, is too big for " + "int32 pointer arithmetic. Consider using the " + "'index-mode=int64' option, the save=Buffer(..) " + "API (TimeFunction only), or domain " + "decomposition via MPI" % (self.name, data.size)) def _arg_finalize(self, args, alias=None): key = alias or self diff --git a/tests/test_linearize.py b/tests/test_linearize.py index d4e23ecc03a..0a95d1e3f34 100644 --- a/tests/test_linearize.py +++ b/tests/test_linearize.py @@ -185,7 +185,7 @@ def test_codegen_quality0(mode): exprs = FindNodes(Expression).visit(op) assert len(exprs) == 6 - assert all('const long' in str(i) for i in exprs[:-2]) + assert all('const int' in str(i) for i in exprs[:-2]) # Only four access macros necessary, namely `uL0`, `bufL0`, `bufL1` # for the efunc args @@ -207,8 +207,8 @@ def test_codegen_quality1(): # 11 expressions in total are expected, 8 of which are for the linearized accesses exprs = FindNodes(Expression).visit(op) assert len(exprs) == 11 - assert all('const long' in str(i) for i in exprs[:-3]) - assert all('const long' not in str(i) for i in exprs[-3:]) + assert all('const int' in str(i) for i in exprs[:-3]) + assert all('const int' not in str(i) for i in exprs[-3:]) # Only two access macros necessary, namely `uL0` and `r1L0` (the other five # obviously are _POSIX_C_SOURCE, MIN, MAX, START, STOP)