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

[aievec] to-llvm/to-cpp flow for emulated fp32xfp32 mul elem #1239

Merged
merged 12 commits into from
Apr 16, 2024

Conversation

jamestcl-amd
Copy link
Collaborator

This PR add the support to the emulated fp32xfp32 elementwise multiplication going through the to-llvm and to-cpp flow.

Changes:

  • Add some of the upd/msc intrinsics to XLLVM.
  • Enable vector->aievec support for the f32xf32 mul_elem and add the corresponding conversion test.
  • Add aievec-to-llvm conversion pattern for the emulated f32xf32 elementwise multiplication.
  • Add aievec-to-llvm conversion tests for the newly added XLLVM ops.
  • Add target llvm translation tests.
  • Add f32xf32_mul_elem e2e tests for the to-llvm and to-cpp flow. This includes the testbench.cc and the test script.

Comment on lines +109 to +130
Arguments<(ins VectorOfLengthAndType<[16], [I64]>:$a,
I32:$shft,
I32:$sign)>;

def I256V32Acc32SrsIntrOp :
AIEVec2_IntrOp<"I256.v32.acc32.srs",
[TypeIs<"res", VectorOfLengthAndType<[32], [I8]>>]>,
Arguments<(ins VectorOfLengthAndType<[16], [I64]>:$lhs,
Arguments<(ins VectorOfLengthAndType<[16], [I64]>:$a,
I32:$shft,
I32:$sign)>;

def I512V16Acc64SrsIntrOp :
AIEVec2_IntrOp<"I512.v16.acc64.srs",
[TypeIs<"res", VectorOfLengthAndType<[16], [I32]>>]>,
Arguments<(ins VectorOfLengthAndType<[16], [I64]>:$lhs,
Arguments<(ins VectorOfLengthAndType<[16], [I64]>:$a,
I32:$shft,
I32:$sign)>;

def Vector16AccFloatToV16BF16IntrOp :
AIEVec2_IntrOp<"v16accfloat.to.v16bf16",
[TypeIs<"res", VectorOfLengthAndType<[16], [BF16]>>]>,
Arguments<(ins VectorOfLengthAndType<[8], [I64]>:$lhs)>;
Arguments<(ins VectorOfLengthAndType<[8], [I64]>:$a)>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit.: Can we find names for the arguments better than "a"? I also don't understand why the "shift" parameter can't just be named just "shift" instead of "shft".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to follow the naming convention from the the definition of CPP intrinsics. Here are some examples.

INTRINSIC(v16accfloat) msc_elem_16_2(v32bfloat16 a, v32bfloat16 b, v16accfloat acc1) {
INTRINSIC(v16accfloat) mac_elem_16_2(v32bfloat16 a, v32bfloat16 b, v16accfloat acc1) {
INTRINSIC(v32bfloat16) insert(v32bfloat16 a, int idx, v16bfloat16 b) {
INTRINSIC(v16accfloat) ups_to_v16accfloat(v16bfloat16 a) {
INTRINSIC(v32int16) lsrs(v32acc32 acc, int shft, int sign) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

But these are not C++ intrinsics, these are LLVM IR intrinsics, and we should do better than "a/b/c" anyway.

Comment on lines +32 to +37
class AIE2bf16MACConf :
Arguments<(ins VectorOfLengthAndType<[32], [BF16]>:$lhs,
VectorOfLengthAndType<[32], [BF16]>:$rhs,
VectorOfLengthAndType<[8], [I64]>:$acc,
I32:$conf)>;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Neat!

@jamestcl-amd jamestcl-amd merged commit de9e2dc into Xilinx:main Apr 16, 2024
54 checks passed
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