Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The offline cache doesn't work properly on the program that contains indirect recursive calls to real functions #6877

Open
Tracked by #4401
PGZXB opened this issue Dec 12, 2022 · 0 comments
Labels
bug We've confirmed that this is an BUG

Comments

@PGZXB
Copy link
Contributor

PGZXB commented Dec 12, 2022

t1.py

import taichi as ti

ti.init(arch=ti.cpu, offline_cache=True, offline_cache_file_path='one/path/to/cache')

@ti.experimental.real_func
def B(i: ti.i32):
  print(f'-> B ', end='')
  if i != 0:
    A(i - 1)

@ti.experimental.real_func
def A(i: ti.i32):
  print(f'-> A ', end='')
  if i != 0:
    B(i - 1)

@ti.kernel
def K1(i: ti.i32):
  print('K1 ', end='')
  A(i)
  print()
  
@ti.kernel
def K2(i: ti.i32):
  print('K2 ', end='')
  B(i)
  print()

K1(5)
K2(5)

t2.py

import taichi as ti

ti.init(arch=ti.cpu, offline_cache=True, offline_cache_file_path='one/path/to/cache')

@ti.experimental.real_func
def B(i: ti.i32):
  print(f'-> B ', end='')
  if i != 0:
    A(i - 1)

@ti.experimental.real_func
def A(i: ti.i32):
  # print(f'-> A ', end='')
  print(f'-> A^ ', end='')
  if i != 0:
    B(i - 1)

@ti.kernel
def K1(i: ti.i32):
  print('K1 ', end='')
  A(i)
  print()
  
@ti.kernel
def K2(i: ti.i32):
  print('K2 ', end='')
  B(i)
  print()

K1(5)
K2(5)

run python t1.py

  • Output:
K1 -> A -> B -> A -> B -> A -> B
K2 -> B -> A -> B -> A -> B -> A

Then, run python t2.py

  • Output:
# The output is wrong
K1 -> A^ -> B -> A^ -> B -> A^ -> B
K2 -> B -> A -> B -> A -> B -> A
  • Correct output:
K1 -> A^ -> B -> A^ -> B -> A^ -> B
K2 -> B -> A^ -> B -> A^ -> B -> A^
@PGZXB PGZXB self-assigned this Dec 12, 2022
@PGZXB PGZXB added the bug We've confirmed that this is an BUG label Dec 12, 2022
@PGZXB PGZXB mentioned this issue Dec 28, 2022
36 tasks
@PGZXB PGZXB removed their assignment Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug We've confirmed that this is an BUG
Projects
Status: Todo
Development

No branches or pull requests

1 participant