Skip to content

why does changing from scatter to gather kill performance in this particular case? #4416

Answered by bcolloran
bcolloran asked this question in Q&A
Discussion options

You must be logged in to vote

Aha! I probably should have tried this sooner, but it did not occur to me based on my understanding of how the Taichi compiler works under the hood...

When I split the "after change" kernel above into two @ti.kernels instead of one big @ti.kernel ---

@ti.kernel
def update_velocity_from_momentum():
    # "TLMPM Contacts", Alg. 1; needed for line 18
    for i, j in grid_m:
        if grid_m[i, j] > 0:
            grid_v[i, j] = grid_mv[i, j] / grid_m[i, j]
    # "TLMPM Contacts", Alg. 1, line 14 combined with 17
    for i, j in grid_m:
        if grid_m[i, j] > 0:
            grid_v_next_tmp[i, j] = grid_v[i, j] + grid_f[i, j] * dt / grid_m[i, j]

@ti.kernel
def update_particle_velocity():
…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by bcolloran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants