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

[FXML-4614] Add EmitC index types, lower arith.index_cast, arith.index_castui #183

Merged
merged 27 commits into from
May 16, 2024

Conversation

cferry-AMD
Copy link
Collaborator

@cferry-AMD cferry-AMD commented May 10, 2024

This PR:

  • introduces new emitc.size_t and emitc.ssize_t data types, and a type converter (index goes to emitc.size_t),
  • makes the ArithToEmitC pass use the type converter,
  • adds EmitC lowering for arith.index_cast, arith.index_castui.

@cferry-AMD cferry-AMD changed the title [FXML-4614] Add EmitC index types [FXML-4614] Add EmitC index types, lower arith.index_cast, arith.index_castui May 14, 2024
@cferry-AMD
Copy link
Collaborator Author

Leaving this here for today, with the linker failing -- it works on my end with a clean build, so what happens here in the CI is really strange.

@mgehre-amd
Copy link
Collaborator

Leaving this here for today, with the linker failing -- it works on my end with a clean build, so what happens here in the CI is really strange.

Try adding the MLIREmitCTransforms library into the list of dependencies of MLIRArithToEmitC

mlir/test/Dialect/EmitC/types.mlir Outdated Show resolved Hide resolved
mlir/test/Target/Cpp/types.mlir Outdated Show resolved Hide resolved
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td Outdated Show resolved Hide resolved
@cferry-AMD cferry-AMD marked this pull request as ready for review May 15, 2024 09:23
Copy link
Collaborator

@mgehre-amd mgehre-amd left a comment

Choose a reason for hiding this comment

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

Looks good!

@mgehre-amd
Copy link
Collaborator

Can you please check that the behavior of casting between index and i1/bool is correct? Bool behaves pretty special (not truncating but checks v != 0).

Copy link
Collaborator

@josel-amd josel-amd left a comment

Choose a reason for hiding this comment

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

LGTM. Discussed offline a small possible (although unlikely) issue with ssize_t.

@cferry-AMD
Copy link
Collaborator Author

Can you please check that the behavior of casting between index and i1/bool is correct? Bool behaves pretty special (not truncating but checks v != 0).

Good remark. We don't handle that and the same remark was formulated for float-to-int casts where this was made illegal. Per the semantics of index_cast you'll expect a truncation i.e. keep only the parity bit which is clearly defined, so I'd preserve this behavior and do something like (bool)(v & 0x01). How does that sound?

@mgehre-amd
Copy link
Collaborator

Can you please check that the behavior of casting between index and i1/bool is correct? Bool behaves pretty special (not truncating but checks v != 0).

Good remark. We don't handle that and the same remark was formulated for float-to-int casts where this was made illegal. Per the semantics of index_cast you'll expect a truncation i.e. keep only the parity bit which is clearly defined, so I'd preserve this behavior and do something like (bool)(v & 0x01). How does that sound?

Sounds good!

@cferry-AMD
Copy link
Collaborator Author

To be more specific @josel-amd : the discussion was on the fact that ssize_t must only represent all size_t values and -1, excluding anything below -1. However, like we discussed above for truncation when going to size_t, in practice this will rarely if ever cause a problem since most compilers use the largest signed ints they can to implement ssize_t. So we'll just leave this as it is.

@cferry-AMD cferry-AMD merged commit e7188da into feature/fused-ops May 16, 2024
3 checks passed
@cferry-AMD cferry-AMD deleted the corentin.emitc_integral_types branch May 16, 2024 13:25
cferry-AMD added a commit that referenced this pull request May 17, 2024
…ith.index_castui (#183)"

This commit breaks pipelines using ArithToEmitC on programsusing index
variables both inside and outside the arith dialect.
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.

3 participants