Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: Default to index-mode=int32 #2399

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading