facebookincubator / cinder

Cinder is Meta's internal performance-oriented production version of CPython.
https://trycinder.com
Other
3.49k stars 121 forks source link

No pattern found for opcode Fadd: Xxr #87

Open belm0 opened 2 years ago

belm0 commented 2 years ago
$ docker run -v $PWD:/vol -it --rm ghcr.io/facebookincubator/cinder-runtime:cinder-3.8 -X jit -m compiler --static vol/autogen_bug.py
JIT: /cinder/src/Jit/codegen/autogen.cpp:143 -- assertion failed: func != nullptr
No pattern found for opcode Fadd: Xxr
from __static__ import box, double, inline

@inline
def foo(a: double, b: double) -> double:
    return b - a

def main():
    c: double = 0.
    for _ in range(10):
        c += foo(.4, .97)
    print('done', box(c))

if __name__ == '__main__':
    main()

The problem goes away if @inline is removed.

See in seen in cinder-3.8.6c2de94

belm0 commented 2 years ago

workaround is to explicitly cast the float literals to double:

c += foo(double(.4), double(.97))

it's surprising to have @inline change the conventions of implicit conversion of the args

carljm commented 2 years ago

Yes, inlining definitely shouldn't have that effect, this is just a bug where the JIT is missing support for some float operations, it looks like. Float support is unfortunately not super well baked still (we don't use it much in prod), but we should be able to to get around to fixing this at some point, thanks for the report!