Skip to content

Lifted or Undeclared variable scheduled in wrong set of loops #2525

Description

@georgebisbas

Undeclared var, possibly due to wrong scheduling
(Initial thread from @felipeguedessilva,
here: https://devitocodes.slack.com/archives/C7JMLMSG0/p1736908013546609)

mfe.py

from devito import Grid, TimeFunction, Function, Eq, Operator

# Setup Configuration
grid = Grid(shape=(30, 30))

# Symbolic Dimensions
x, y = grid.dimensions
t = grid.stepping_dim

# Reduced MFE Lame Parameters
VS = Function(name="VS", grid=grid, space_order=2)

# Symbolic Fields Construction
v = TimeFunction(name='v', grid=grid, space_order=2)

# Reduced MFE Higdon Condition - Velocity
eqs = []

beta = (1 + (1/VS))
dz = (1 / beta)

eqv1 = Eq(v.forward, v[t, x, y+1])

eqv2 = Eq(v.forward,
          (v[t+1, x-1, y] +
           v[t+1, x, y-1] +
           (dz)*v[t+1, x, y]))

eqs.append(eqv1)
eqs.append(eqv2)

# Operator Definition
op = Operator(eqs)

op(dt=0.1, time=10)

To reproduce:
DEVITO_LOGGING=DEBUG python mfe.py

Error:

Operator `Kernel` generated in 0.18 s
  * lowering.Clusters: 0.09 s (52.3 %)
     * specializing.Clusters: 0.05 s (29.1 %)
  * lowering.IET: 0.07 s (40.7 %)
     * specializing.IET: 0.04 s (23.3 %)
Flops reduction after symbolic optimization: [6 --> 6]
gcc -march=native -O3 -g -fPIC -Wall -std=c99 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -ffast-math -shared -fopenmp /tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.c -lm -o /tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.so
/tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.c: In function ‘Kernel’:
/tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.c:53:31: error: ‘r0’ undeclared (first use in this function); did you mean ‘t0’?
   53 |         v[t1][x + 2][y + 2] = r0*v[t1][x + 2][y + 2] + v[t1][x + 1][y + 2] + v[t1][x + 2][y + 1];
      |                               ^~
      |                               t0
/tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.c:53:31: note: each undeclared identifier is reported only once for each function it appears in
FAILED compiler invocation: gcc -march=native -O3 -g -fPIC -Wall -std=c99 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -ffast-math -shared -fopenmp /tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.c -lm -o /tmp/devito-jitcache-uid1000/5cc44d7ce38ff1f3bbc1699a3fca1f2c9d9896be.so
Traceback (most recent call last):
  File "/home/gb4018/workspace/devitocodes/devito/examples/minimal.py", line 35, in <module>
    op(dt=0.1, time=10)
  File "/home/gb4018/workspace/devitocodes/devito/devito/operator/operator.py", line 833, in __call__
    return self.apply(**kwargs)
  File "/home/gb4018/workspace/devitocodes/devito/devito/operator/operator.py", line 899, in apply
    cfunction = self.cfunction
  File "/home/gb4018/workspace/devitocodes/devito/devito/operator/operator.py", line 786, in cfunction
    self._jit_compile()
  File "/home/gb4018/workspace/devitocodes/devito/devito/operator/operator.py", line 772, in _jit_compile
    recompiled, src_file = self._compiler.jit_compile(self._soname, str(self))
  File "/home/gb4018/workspace/devitocodes/devito/devito/arch/compiler.py", line 379, in jit_compile
    _, _, _, recompiled = compile_from_string(self, target, code, src_file,
  File "/home/gb4018/environments/python310-venv/lib/python3.10/site-packages/codepy/jit.py", line 439, in compile_from_string
    toolchain.build_extension(ext_file, source_paths, debug=debug)
  File "/home/gb4018/environments/python310-venv/lib/python3.10/site-packages/codepy/toolchain.py", line 211, in build_extension
    raise CompileError("module compilation failed")
codepy.CompileError: module compilation failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions