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

[opt] Added llvm::SeparateConstOffsetFromGEPPass() for shared_memory optimizations #5494

Merged
merged 3 commits into from
Jul 29, 2022

Conversation

jim19930609
Copy link
Contributor

@jim19930609 jim19930609 commented Jul 22, 2022

Related issue = #5472

There's an update for SeparateConstOffsetFromGEPPass() from LLVM10 to LLVM15, supported more patterns and situations.

To enhance it in LLVM10, three dependent passes were added manually, namely LoopStrengthReducePass, IndVarSimplifyPass, and EarlyCSEPass. Once SeparateConstOffsetFromGEPPass() doesn't work as expected for your code, try recompiling Taichi with LLVM15 and likely it's gonna work.

Example:

T : ti.i64 = 40
t_group : ti.i64 = 4 
b_group : ti.i64 = 8 
block_dim : ti.i64 = 192 
Tmax : ti.i64 = 768 

x = ti.field(ti.f32, shape=1)

@ti.kernel
def test():
    ti.loop_config(block_dim=block_dim)
    for t_block in ti.ndrange(T // t_group):
        t = t_block * t_group
        w_pad = ti.simt.block.SharedArray((Tmax,), ti.f32)
    
        ti.simt.block.sync()

        for u in range(0, t+1):
            for bi in ti.static(range(b_group)):
                for i in ti.static(range(t_group)):
                    x[0] = w_pad[(u+bi+i)]

        ti.simt.block.sync()

test()

Before Patch:
[LLVM]

[PTX]

After Patch:
[LLVM]

[PTX]

@netlify
Copy link

netlify bot commented Jul 22, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 5689671
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/62e371e2b6676a000807f728
😎 Deploy Preview https://deploy-preview-5494--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

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.

Thanks!!

@ailzhang ailzhang merged commit 462da20 into taichi-dev:master Jul 29, 2022
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.

2 participants