taichi-dev / taichi

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

How does Taichi make use of constant memory? #8348

Open QTY412Charles opened 1 year ago

QTY412Charles commented 1 year ago

For all I know, constant cache is designed to increase the efficiency when the same data is visited by multiple threads in a wrap. So the first question is: when the constant cache will be used in taichi? For example, a constant variable is declared, when it's called in parallel by a kernel in taichi scope, will it be read-in constant cache firstly, and then visited by different threads to increase the visiting efficiency?
The second question is: Whether the data in matrix field declared in global memory can be read-in constant cache automatically by taichi under the situation when they are simutaneously visited by different threads in a wrap? Or some similar declarations of constant memory to be used as exploting CUDA by C++ should be employed to make use of constant memory in taichi?

ailzhang commented 1 year ago

Hi @QTY412Charles, we currently don't have an explicit API to use constant memory but our codegen make use of it under the hood.