inducer / loopy

A code generator for array-based code on CPUs and GPUs
http://mathema.tician.de/software/loopy
MIT License
565 stars 71 forks source link

Add `test_long_kernel` #826

Open inducer opened 4 months ago

inducer commented 4 months ago

On Python 3.12, this provokes a stack overflow in the scheduler. It is not quite clear why that's the case; pure-Python recursion even with generators seems to respond well to setrecursionlimit():

def f(n):
    if n:
        yield from f(n-1)
    else:
        yield 5

import sys
sys.setrecursionlimit(3500)
print(list(f(3400)))

That said, there have been behavior changes in Py3.12 in this regard, but it is not clear what exactly about Loopy's behavior makes it fall into the 'bad' case.

This is a smaller reproducer of an issue flagged by @a-alveyblanc in the context of tensor product code generated from Pytato.

It appears that Py3.12 will receive some changes soon that mitigate this. More broadly, a better scheduling algorithm would help with this, as would #350.