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

[CIR][Dialect] Add convergent attribute to functions for SIMT languages #840

Merged

Conversation

seven-mile
Copy link
Collaborator

Fix #805. This PR includes end-to-end implementation.

The convergent attribute is set depending on languages, which is wrapped as langOpts.assumeFunctionsAreConvergent().

Therefore, in ClangIR, every cir.func under #cir.lang<opencl_c> is set to be convergent.

After lowering to LLVM IR, PostOrderFunctionAttrs pass will remove unnecessary convergent then. In other words, we will still see convergent on every function with -O0, but not with default optimization level.

The test taken from CodeGenOpenCL/convergent.cl is a bit complicated. However, the core of it is that convergent is set properly for convfun() non_convfun() f() and g(). Merge of two if is more or less a result of generating the same LLVM IR as OG.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Awesome, LGTM

@bcardosolopes bcardosolopes merged commit ba8c248 into llvm:main Sep 16, 2024
7 checks passed
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
…ages (llvm#840)

Fix llvm#805. This PR includes end-to-end implementation.

The `convergent` attribute is set depending on languages, which is
wrapped as `langOpts.assumeFunctionsAreConvergent()`.

Therefore, in ClangIR, every `cir.func` under `#cir.lang<opencl_c>` is
set to be convergent.

After lowering to LLVM IR, `PostOrderFunctionAttrs` pass will remove
unnecessary `convergent` then. In other words, we will still see
`convergent` on every function with `-O0`, but not with default
optimization level.

The test taken from `CodeGenOpenCL/convergent.cl` is a bit complicated.
However, the core of it is that `convergent` is set properly for
`convfun()` `non_convfun()` `f()` and `g()`. Merge of two `if` is more
or less a result of generating the same LLVM IR as OG.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
…ages (llvm#840)

Fix llvm#805. This PR includes end-to-end implementation.

The `convergent` attribute is set depending on languages, which is
wrapped as `langOpts.assumeFunctionsAreConvergent()`.

Therefore, in ClangIR, every `cir.func` under `#cir.lang<opencl_c>` is
set to be convergent.

After lowering to LLVM IR, `PostOrderFunctionAttrs` pass will remove
unnecessary `convergent` then. In other words, we will still see
`convergent` on every function with `-O0`, but not with default
optimization level.

The test taken from `CodeGenOpenCL/convergent.cl` is a bit complicated.
However, the core of it is that `convergent` is set properly for
`convfun()` `non_convfun()` `f()` and `g()`. Merge of two `if` is more
or less a result of generating the same LLVM IR as OG.
smeenai pushed a commit to smeenai/clangir that referenced this pull request Oct 9, 2024
…ages (llvm#840)

Fix llvm#805. This PR includes end-to-end implementation.

The `convergent` attribute is set depending on languages, which is
wrapped as `langOpts.assumeFunctionsAreConvergent()`.

Therefore, in ClangIR, every `cir.func` under `#cir.lang<opencl_c>` is
set to be convergent.

After lowering to LLVM IR, `PostOrderFunctionAttrs` pass will remove
unnecessary `convergent` then. In other words, we will still see
`convergent` on every function with `-O0`, but not with default
optimization level.

The test taken from `CodeGenOpenCL/convergent.cl` is a bit complicated.
However, the core of it is that `convergent` is set properly for
`convfun()` `non_convfun()` `f()` and `g()`. Merge of two `if` is more
or less a result of generating the same LLVM IR as OG.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
…ages (llvm#840)

Fix llvm#805. This PR includes end-to-end implementation.

The `convergent` attribute is set depending on languages, which is
wrapped as `langOpts.assumeFunctionsAreConvergent()`.

Therefore, in ClangIR, every `cir.func` under `#cir.lang<opencl_c>` is
set to be convergent.

After lowering to LLVM IR, `PostOrderFunctionAttrs` pass will remove
unnecessary `convergent` then. In other words, we will still see
`convergent` on every function with `-O0`, but not with default
optimization level.

The test taken from `CodeGenOpenCL/convergent.cl` is a bit complicated.
However, the core of it is that `convergent` is set properly for
`convfun()` `non_convfun()` `f()` and `g()`. Merge of two `if` is more
or less a result of generating the same LLVM IR as OG.
lanza pushed a commit that referenced this pull request Nov 5, 2024
…ages (#840)

Fix #805. This PR includes end-to-end implementation.

The `convergent` attribute is set depending on languages, which is
wrapped as `langOpts.assumeFunctionsAreConvergent()`.

Therefore, in ClangIR, every `cir.func` under `#cir.lang<opencl_c>` is
set to be convergent.

After lowering to LLVM IR, `PostOrderFunctionAttrs` pass will remove
unnecessary `convergent` then. In other words, we will still see
`convergent` on every function with `-O0`, but not with default
optimization level.

The test taken from `CodeGenOpenCL/convergent.cl` is a bit complicated.
However, the core of it is that `convergent` is set properly for
`convfun()` `non_convfun()` `f()` and `g()`. Merge of two `if` is more
or less a result of generating the same LLVM IR as OG.
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.

Add critical convergent attributes to functions for OpenCL
2 participants