CozySynthesizer / cozy

The collection synthesizer
https://cozy.uwplse.org
Apache License 2.0
209 stars 18 forks source link

Failed codegen: EMapKeys #105

Open izgzhen opened 5 years ago

izgzhen commented 5 years ago

https://gist.github.com/izgzhen/2b35cb49b2347e18ec48f9b5aa1fc545

Traceback (most recent call last):
  File "/home/zgzhen/anaconda3/bin/cozy", line 11, in <module>
    load_entry_point('cozy', 'console_scripts', 'cozy')()
  File "/home/zgzhen/projects/cozy/cozy/main.py", line 188, in run
    codegen.CxxPrinter(out=out, use_qhash=args.use_qhash).visit(impl, state_map, share_info, abstract_state=ast.spec.statevars)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 93, in g
    ret = f(*args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 817, in visit_Spec
    self.visit(stm)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 528, in visit_SSeq
    self.visit(ss)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 514, in visit_SAssign
    value = self.visit(s.rhs)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 332, in visit_Exp
    raise NotImplementedError(e)
NotImplementedError: EMapKeys(EMove(EVar('_map482932').with_type(TMap(TInt(), TBag(TRecord((('orderkey', TInt()), ('partkey', TInt()), ('suppkey', TInt()), ('linenumber', TInt()), ('quantity', TFloat()), ('extendedprice', TFloat()), ('discount', TFloat()), ('tax', TFloat()), ('returnflag', TNative('char')), ('linestatus', TNative('char')), ('shipdate', TNative('uint64_t')), ('commitdate', TNative('uint64_t')), ('receiptdate', TNative('uint64_t')), ('shipinstruct', TString()), ('shipmode', TString()), ('comment', TString()))))))).with_type(TMap(TInt(), TBag(TRecord((('orderkey', TInt()), ('partkey', TInt()), ('suppkey', TInt()), ('linenumber', TInt()), ('quantity', TFloat()), ('extendedprice', TFloat()), ('discount', TFloat()), ('tax', TFloat()), ('returnflag', TNative('char')), ('linestatus', TNative('char')), ('shipdate', TNative('uint64_t')), ('commitdate', TNative('uint64_t')), ('receiptdate', TNative('uint64_t')), ('shipinstruct', TString()), ('shipmode', TString()), ('comment', TString()))))))).with_type(TBag(TInt()))
izgzhen commented 5 years ago

This is not a bug that can be reproduced every time. Trying to hook into PyCharm debugger to fix it.

izgzhen commented 5 years ago

Looks part of tpch-q02

izgzhen commented 5 years ago

can't reproduce

izgzhen commented 5 years ago
Implementation was dumped to /tmp/failed_codegen.py
Traceback (most recent call last):
  File "/home/zgzhen/projects/cozy/.venv/bin/cozy", line 11, in <module>
    load_entry_point('cozy', 'console_scripts', 'cozy')()
  File "/home/zgzhen/projects/cozy/cozy/main.py", line 188, in run
    codegen.CxxPrinter(out=out, use_qhash=args.use_qhash).visit(impl, state_map, share_info, abstract_state=ast.spec.statevars)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 93, in g
    ret = f(*args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 817, in visit_Spec
    self.visit(stm)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 528, in visit_SSeq
    self.visit(ss)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 514, in visit_SAssign
    value = self.visit(s.rhs)
  File "/home/zgzhen/projects/cozy/cozy/common.py", line 281, in visit
    return f(x, *args, **kwargs)
  File "/home/zgzhen/projects/cozy/cozy/codegen/cxx.py", line 332, in visit_Exp
    raise NotImplementedError(e)
NotImplementedError: EMapKeys(EMove(EVar('_map294339').with_type(TMap(TInt(), TBag(TRecord((('orderkey', TInt()), ('partkey', TInt()), ('suppkey', TInt()), ('linenumber', TInt()), ('quantity', TFloat()), ('extendedprice', TFloat()), ('discount', TFloat()), ('tax', TFloat()), ('returnflag', TNative('char')), ('linestatus', TNative('char')), ('shipdate', TNative('uint64_t')), ('commitdate', TNative('uint64_t')), ('receiptdate', TNative('uint64_t')), ('shipinstruct', TString()), ('shipmode', TString()), ('comment', TString()))))))).with_type(TMap(TInt(), TBag(TRecord((('orderkey', TInt()), ('partkey', TInt()), ('suppkey', TInt()), ('linenumber', TInt()), ('quantity', TFloat()), ('extendedprice', TFloat()), ('discount', TFloat()), ('tax', TFloat()), ('returnflag', TNative('char')), ('linestatus', TNative('char')), ('shipdate', TNative('uint64_t')), ('commitdate', TNative('uint64_t')), ('receiptdate', TNative('uint64_t')), ('shipinstruct', TString()), ('shipmode', TString()), ('comment', TString()))))))).with_type(TBag(TInt()))

Another instance. failed_codegen.py.txt

izgzhen commented 5 years ago

In C++, there is no direct way to express the "keys of a map". Normally, we iterate through them, but this requires a callback/continuation

izgzhen commented 5 years ago

The root cause of why such expression is generated is unclear either.