taichi-dev / taichi

Productive, portable, and performant GPU programming in Python.
https://taichi-lang.org
Apache License 2.0
25.51k stars 2.28k forks source link

Debug option for individual Taichi kernel #6514

Open houkensjtu opened 2 years ago

houkensjtu commented 2 years ago

Concisely describe the proposed feature A debug option for individual kernels comes in handy when a user wants to focus on a certain section of his/her code. I expect this feature to be especially useful when people collaborate on a relatively large program. Currently, the debug=True option will turn all kernels into the debug mode:

ti.init(arch=ti.gpu, debug=True)

However, a user might want to turn on the debug flag for only one of the kernels to avoid dealing with unrelated error messages:

@ti.kernel(debug=True)
def test_debug():  # debug turned on for this kernel
    ...

@ti.kernel
def test_no_debug():  # debug=False will still be the default option
    ....

Please let me know if you have any comments on this request. Thank you!

ailzhang commented 2 years ago

@houkensjtu It's indeed possible (and desired) in the future that we can configure compile options per taichi kernel (which requires a non-trivial amount of refactor).

Also some of the debug features are global instead of per kernel (e.g. vulkan printing) that it's not possible to configure per kernel. So those need to be separated before properly allowing a per-kernel compile config.

A (maybe) short-term thing we can do is adding kernel_name to the log so that you can filter and grep.

yuanming-hu commented 2 years ago

+1. This would be very helpful!