exo-lang / exo

Exocompilation for productive programming of hardware accelerators
https://exo-lang.dev
MIT License
304 stars 28 forks source link

Implement value sensitive analysis #287

Open yamaguchi1024 opened 2 years ago

yamaguchi1024 commented 2 years ago

Potentially a paper idea?

The following code does not work because of Check_FissionLoop PXL_20221111_223711705

@proc
def blur(g : R[100], inp: R[102]):
    f : R[101]
    for j in seq(0, 101):
        f[j] = inp[j] + inp[j+1]
    for i in seq(0, 100):
        g[i] = f[i] + f[i+1]

print("This is original blur")
print(blur)
blur = add_loop(blur, 'for j in _:_ #0', 'i', 100)
print(blur)
blur = fusion(blur, 'for i in _:_ #0', 'for i in _:_ #1')
print(blur)
This is original blur
def blur(g: R[100] @ DRAM, inp: R[102] @ DRAM):
    f: R[101] @ DRAM
    for j in seq(0, 101):
        f[j] = inp[j] + inp[j + 1]
    for i in seq(0, 100):
        g[i] = f[i] + f[i + 1]

def blur(g: R[100] @ DRAM, inp: R[102] @ DRAM):
    f: R[101] @ DRAM
    for i in seq(0, 100):
        for j in seq(0, 101):
            f[j] = inp[j] + inp[j + 1]
    for i in seq(0, 100):
        g[i] = f[i] + f[i + 1]

Traceback (most recent call last):
  File "/home/yuka/.local/bin/exocc", line 8, in <module>
    sys.exit(main())
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/main.py", line 37, in main
    library = [
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/main.py", line 40, in <listcomp>
    for proc in get_procs_from_module(load_user_code(mod))
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/main.py", line 69, in load_user_code
    loader.exec_module(user_module)
  File "<frozen importlib._bootstrap_external>", line 855, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/yuka/exo/blur.py", line 22, in <module>
    blur = fusion(blur, 'for i in _:_ #0', 'for i in _:_ #1')
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/API_scheduling.py", line 101, in __call__
    return self.func(*bound_args.args, **bound_args.kwargs)
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/API_scheduling.py", line 1743, in fusion
    return SCHED(proc_c, s1, s2).result()
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/LoopIR_scheduling.py", line 2818, in __init__
    Check_FissionLoop(self.proc, loop, body1, body2)
  File "/home/yuka/.local/lib/python3.9/site-packages/exo/new_eff.py", line 1383, in Check_FissionLoop
    raise SchedulingError(f"Cannot fission loop over {i} at {loop.srcinfo}.")
exo.new_eff.SchedulingError: <<<unknown directive>>>: Cannot fission loop over i at /home/yuka/exo/blur.py:13:4.
rachitnigam commented 1 year ago

We should refer to this when thinking about the analysis rewrite but it is not subsumed by that effort.