taichi-dev / taichi_elements

High-performance multi-material continuum physics engine in Taichi
MIT License
483 stars 69 forks source link

Timing issue #95

Closed you-found-tomasz closed 2 years ago

you-found-tomasz commented 2 years ago

Dear Taichi community,

while running a simulation, I noticed that the first step of mpm.step (16sec) takes significantly longer than the subsequent mpm.step calls (10ms). Why is that the case? And how can it be the first time be decreased?

thank you in advance{

Jack12xl commented 2 years ago

Hi, Because in first step Taichi will take time to compile the ti.kernel(while in the following steps not) to the backend code. You might want to check the Life of a Taichi kernel for details.

And how can it be the first time be decreased?

From my experience, try to use less ti.template when declaring functions parameters (if you can) might help.

you-found-tomasz commented 2 years ago

thank you @Jack12xl!