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

[lang] Cleanup parallel sort utility #3858

Merged
merged 2 commits into from
Dec 23, 2021
Merged

Conversation

AmesingFlank
Copy link
Collaborator

@AmesingFlank AmesingFlank commented Dec 23, 2021

This PR moves the parallel_sort function to a different place, so that we don't use import taichi as ti. It also moves the kernel definition outside the python function, so that the kernel isn't recompiled everytime the function is called.

On a tangential note, this sort function is kinda slow. On my macbook, sorting the particles in mpm99 is so slow that the simulation goes down to around 1.2 FPS. This is quite bad, I might try to implement a fast radix sort.

@netlify
Copy link

netlify bot commented Dec 23, 2021

✔️ Deploy Preview for jovial-fermat-aa59dc canceled.

🔨 Explore the source changes: 20dd83a

🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61c3eb60c860390008cb1065

Copy link
Collaborator

@qiao-bo qiao-bo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ailzhang
Copy link
Contributor

btw I feel it's okay to do import taichi as ti in tools :P Is it the only motivation for this change? ;)
import taichi as ti in taichi/lang might be problematic :P

@AmesingFlank
Copy link
Collaborator Author

btw I feel it's okay to do import taichi as ti in tools :P Is it the only motivation for this change? ;) import taichi as ti in taichi/lang might be problematic :P

In my original code in tools, the @ti.kernel was inside a python function, so the kernel decorator is not used until the function is called. As soon as I move the kernel definition to global scope, I started getting error messages that kernel doesn't exists. It is necessary to move the kernel definition out, because otherwise the kernel recompiles every time parallel_sort is called. So basically, putting a taichi kernel inside tools won't work.

@AmesingFlank AmesingFlank merged commit e550d43 into taichi-dev:master Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants