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

[llvm] Remove LLVM functions related to a SNode tree from the module when the SNode tree is destroyed #4356

Merged
merged 13 commits into from
Feb 25, 2022

Conversation

lin-hitonami
Copy link
Contributor

Related issue = #4023

@netlify
Copy link

netlify bot commented Feb 22, 2022

✔️ Deploy Preview for docsite-preview ready!

🔨 Explore the source changes: ec75577

🔍 Inspect the deploy log: https://app.netlify.com/sites/docsite-preview/deploys/6218d2a8f217020007666cc1

😎 Browse the preview: https://deploy-preview-4356--docsite-preview.netlify.app

@ifsheldon
Copy link

Well done!
I tested this on 0.8.11 and got drastic performance downgrade while the Taichi compiled from this PR has a stable performance.

import taichi as ti
from tqdm import tqdm

if __name__ == "__main__":
    ti.init(ti.cpu)
    iterations = 10000
    for i in tqdm(range(iterations)):
        x = ti.field(ti.f32)
        fb = ti.FieldsBuilder()
        fb.place(x)
        snodetree = fb.finalize()
        snodetree.destroy()

@ifsheldon
Copy link

But we will still have performance downgrade when the number of allocated and not destroyed SNodeTree is large. Try this.

import taichi as ti
from tqdm import tqdm

if __name__ == "__main__":
    ti.init(ti.cpu)
    iterations = 2
    snode_tree_num = 1000
    for i in range(iterations):
        snode_trees = []
        for j in tqdm(range(snode_tree_num)):
            x = ti.field(ti.f32)
            fb = ti.FieldsBuilder()
            fb.place(x)
            snodetree = fb.finalize()
            snode_trees.append(snodetree)
        for snodetree in snode_trees:
            snodetree.destroy()

@lin-hitonami lin-hitonami marked this pull request as ready for review February 25, 2022 04:38
Copy link
Contributor

@ailzhang ailzhang left a comment

Choose a reason for hiding this comment

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

LGTM!

taichi/struct/struct_llvm.cpp Outdated Show resolved Hide resolved
Copy link
Member

@k-ye k-ye left a comment

Choose a reason for hiding this comment

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

LGTM!

tests/cpp/codegen/refine_coordinates_test.cpp Outdated Show resolved Hide resolved
Co-authored-by: Ye Kuang <k-ye@users.noreply.github.com>
@lin-hitonami
Copy link
Contributor Author

/format

@lin-hitonami lin-hitonami merged commit a54af78 into taichi-dev:master Feb 25, 2022
@lin-hitonami lin-hitonami deleted the del_function branch February 25, 2022 13:41
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.

5 participants