Skip to content

Commit

Permalink
Merge pull request devitocodes#2399 from devitocodes/heuristic-int32
Browse files Browse the repository at this point in the history
compiler: Default to index-mode=int32
  • Loading branch information
mloubout authored Jul 8, 2024
2 parents 156db8e + f61e208 commit f518eb3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
6 changes: 3 additions & 3 deletions devito/core/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions devito/types/dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 7 additions & 17 deletions examples/performance/01_gpu.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tests/test_linearize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit f518eb3

Please sign in to comment.