devitocodes / devito

DSL and compiler framework for automated finite-differences and stencil computation
http://www.devitoproject.org
MIT License
565 stars 229 forks source link

Symbol objects in dse #196

Closed mloubout closed 7 years ago

mloubout commented 7 years ago

There is an issue with transformer in some cases. The "new" version of Forward/Backward (PR 176) now requires sympy solve as some time indices are not directly accessible. As this fgunction is very slow in default mode I had to include some options :

stencil = solve(eqn, u, rational=False, simplify=False, check=False)[0]

and it produces an error as some symbols are not simplified (obiously as forced to do so)

CustomCompiler: compiled /var/folders/z0/tqrtpj3j5lz5vmpm09lx4mbw0000gp/T/devito-502/bf47a5b6ecf0a303dab8d8789b2303131af7fd05.c [0.12 s]
DSE:  (_cse) 288 --> (_factorize) 245 --> (_optimize_trigonometry) 245 --> (_replace_time_invariants) 245 --> (_factorize) 244 flops; gain: 1.18 X [1.43 s]
Traceback (most recent call last):
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/examples/acoustic/acoustic_example.py", line 103, in <module>
    run(full_run=False, auto_tuning=False, space_order=6, time_order=2, legacy=False)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/examples/acoustic/acoustic_example.py", line 88, in run
    auto_tuning=auto_tuning, compiler=compiler, legacy=legacy,
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/examples/acoustic/Acoustic_codegen.py", line 136, in Forward
    legacy=legacy)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/examples/acoustic/fwi_operators.py", line 76, in ForwardOperator
    compiler=compiler)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/stencilkernel.py", line 95, in __init__
    compiler=self.compiler)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/dle/transformer.py", line 108, in transform
    return Rewriter(node, params, compiler).run(mode)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/dle/transformer.py", line 227, in run
    self._analyze_and_decorate(state)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/dle/transformer.py", line 275, in _analyze_and_decorate
    handle = flatten(k.atoms() for k in j.indices[1:])
AttributeError: 'Symbol' object has no attribute 'indices'

This should be reproducable by on,y running acoustic example from my PR branch.

mloubout commented 7 years ago

I just added a print statement to see what crashes, this is what I get

temp5
Traceback (most recent call last):
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/tests/test_adjointA.py", line 106, in <module>
    test_acoustic(dimensions=(60, 70), time_order=4, space_order=4)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/tests/test_adjointA.py", line 96, in test_acoustic
    rec, _, _, _, _ = acoustic.Forward(save=False, legacy=False)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/examples/acoustic/Acoustic_codegen.py", line 136, in Forward
    legacy=legacy)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/examples/acoustic/fwi_operators.py", line 77, in ForwardOperator
    compiler=compiler)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/stencilkernel.py", line 95, in __init__
    compiler=self.compiler)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/dle/transformer.py", line 108, in transform
    return Rewriter(node, params, compiler).run(mode)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/dle/transformer.py", line 227, in run
    self._analyze_and_decorate(state)
  File "/Users/mloubout/Dropbox/London/CodeGen/devito/devito/dle/transformer.py", line 276, in _analyze_and_decorate
    handle = flatten(k.atoms() for k in j.indices[1:])
AttributeError: 'Symbol' object has no attribute 'indices'

Some way, a temp end up in there.

FabioLuporini commented 7 years ago

This should have been fixed in the latest PR #205 . Could you quickly check this out?

mloubout commented 7 years ago

Sure on it, gonna also open another one for what I sent you yesterday.

EDIT: Yes looks like it is fixed.

FabioLuporini commented 7 years ago

OK, then I'm closing this.