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

Add Zmmul section to M chapter #648

Merged
merged 2 commits into from
May 17, 2021
Merged

Add Zmmul section to M chapter #648

merged 2 commits into from
May 17, 2021

Conversation

aswaterman
Copy link
Member

Contributed by @allenjbaum, with some of my own edits.

@aswaterman aswaterman requested a review from kasanovic May 15, 2021 22:48
@kasanovic
Copy link
Collaborator

Commentary is incorrect that it cannot co-exist with the M extension, e.g. F can coexist with D. It would be non-canonical (and redundant) but legal to have Zmmul_M or M_Zmmul in ISA string. I would also drop the commentary around exception and non-conforming use of {M-Zmmul} opcodes - this is common across every instruction. Zmmul should be written as adding to base, not as subtracting from M.

@aswaterman
Copy link
Member Author

I thought you might say both of those things, but wanted to maintain fidelity to Allen's original text before getting feedback from others.

@kasanovic kasanovic merged commit 9ebb0f0 into master May 17, 2021
@kasanovic kasanovic deleted the zmmul branch May 17, 2021 08:41
@allenjbaum
Copy link

allenjbaum commented May 17, 2021 via email

@kito-cheng
Copy link
Member

Does here version for Zmmul? or it just follow version of M?

@kasanovic
Copy link
Collaborator

M does imply/require Zmmul.

ISA strings are purely additive, and tool chains should not assume absence of a feature because of the presence of a different feature.

F and D are a fine example of this. Just because string includes F does not imply it does not include D.

The gcc -mno-div flag should continue to be used to exclude generate of divide instructions, but also, lack of M (and lack of any other future ISA string that might include divide) should also tell compiler not to use instructions that are not present in ISA.

@allenjbaum
Copy link

allenjbaum commented May 17, 2021 via email

@aswaterman
Copy link
Member Author

The -mno-div option is the problem here, not the ISA formulation. The subtractive approach is going to be untenable in the long term as we add more extensions, especially overlapping ones. The right way to specify this combination is e.g. -march=rv32i_zmmul, not -march=rv32im -mno-div.

We have no choice to support the legacy compiler flag for now. But we can avoid adding any more subtractive flags going forward, and we can deprecate this one over time. So it need not affect our long-term thinking about ISA extensions.

I think the compiler documentation is the right place to describe this idiosyncrasy, not the spec.

@kasanovic
Copy link
Collaborator

Yes, the tool chain has to accept the new ISA extension and "do the right thing".

I think -mno-div is OK as a compiler option, but it's meaning is for the compiler not to generate divide instructions, not to indicate what the ISA is. So for example, -mno-div should not set ELF flags in binary to indicate ISA doesn't have divide - it should simply not generate divide instructions.

@kito-cheng
Copy link
Member

From the view of compiler developer, I strongly prefer using -march as the unify interface rather than add options like -m[no]-div, -m[no]-mul and potential option in future.

We have ELF attribute to record arch string already, so we can know the which extension are used for the binary.

@allenjbaum
Copy link

allenjbaum commented May 18, 2021 via email

@aswaterman
Copy link
Member Author

Sounds like the tail wagging the dog. Ask for a waiver, and attach Kito’s most recent comment to justify the waiver request?

@kito-cheng
Copy link
Member

I think here is 2 options for GCC*:

  1. Keep -m[no-]-div for compatible, but no functional and emit warning to tell user it should using zmmul.
  2. Keep -m[no-]-div for compatible, but still functional, and emit warning to tell user it should using zmmul in future.

Personally I would prefer 1, I could implement that on upstream GCC and ask LLVM community to implement that once this settle down.

  • clang/LLVM never implement -mno-div so there is only one choose is implement zmmul, and RISC-V LLVM community intent to not implement -mno-div.

@jim-wilson
Copy link

There are university projects that use -mno-div. Removing that before adding zmmul will cause problems for those users. Certainly once zmmul support exists, we don't need -mno-div anymore, and can deprecate it. Probably best to have a transition period though or we will have some confused users. Also probably best that it gets formally ratified before -mno-div is removed or we will have to explain to confused users how to use explicit version numbers to enable a non-ratified feature, and what exactly those valid version numbers are. Though the doc doesn't give zmmul any explicit version number, so not obvious what version numbers we should use for this non ratified feature.

GCC still has the rule that an extension must be frozen before we can add support for it on mainline, and I haven't seen anything about zmmul being frozen. I don't even see it in the specification status spreadsheet. Maybe the addition of this section to the doc implies that it is frozen?

@aswaterman
Copy link
Member Author

aswaterman commented May 19, 2021

I agree with Jim's take.

I don't believe Zmmul has been declared frozen. Adding it to a draft version of a spec is not an implicit indication of frozennesss (even though we ordinarily only merge stuff that we consider very close).

I will assign Zmmul a version number, 0.1, for now. (My expectation is that it will be frozen as-is, and the version number will soon be increased to 1.0 without any changes being made.)

@allenjbaum
Copy link

allenjbaum commented May 19, 2021 via email

@kito-cheng
Copy link
Member

Update from LLVM community[1]:

Summary:
They intend to support both -mno-div and zmmul extension, but -mno-div will be deprecated once zmmul is frozen.

[1] https://reviews.llvm.org/D102839

Note:
Deprecating not means we will remove the functionality of -mno-div immediately, we will emit warning but still functional, then obsolete that in next release cycle.

For GNU toolchain one cycle means at least one year, deprecate is one cycle, obsolete in next cycle, so removing the -mno-div should be at least 2 years later after zmmul extension frozen.

@allenjbaum
Copy link

allenjbaum commented Jun 4, 2021 via email

@allenjbaum
Copy link

allenjbaum commented Jun 4, 2021 via email

dougpuob pushed a commit to dougpuob/llvm-project that referenced this pull request Jun 5, 2021
This patch implements recently merged extension [Zmmul](riscv/riscv-isa-manual#648), a subextension of M (Integer Multiplication and Division) consisting only multiplication part of it.

Differential Revision: https://reviews.llvm.org/D103313
@Liaoshihua
Copy link

Liaoshihua commented Oct 9, 2021

I had added zmmul extension in gcc-11.1.0 and binutils-2.37 .
Could you take a look at it for me?
@allenjbaum @kito-cheng

@allenjbaum
Copy link

I can't review your changes, but I can send you the directions to test it. I don't have your contact information though.

@Liaoshihua
Copy link

I can't review your changes, but I can send you the directions to test it. I don't have your contact information though.

shihua@iscas.ac.cn

thanks

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.

None yet

6 participants