Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Clarify Vector Integer Extension source EMUL constraint #479

Closed
JamesKenneyImperas opened this issue May 17, 2020 · 10 comments
Closed

Clarify Vector Integer Extension source EMUL constraint #479

JamesKenneyImperas opened this issue May 17, 2020 · 10 comments
Labels
Resolve for v1.0 To be resolved for v1.0 draft

Comments

@JamesKenneyImperas
Copy link

For Vector Integer Extension instructions, the specification states:

If the source EEW is not a supported width or the source EMUL is not a supported LMUL, an illegal instruction exception is raised.

I can understand the source EEW constraint, but can you please clarify why the source EMUL constraint is necessary? It means (for example) that these instructions can never be used when LMUL=1/8.

@David-Horner
Copy link
Contributor

David-Horner commented May 18, 2020 via email

@JamesKenneyImperas
Copy link
Author

JamesKenneyImperas commented May 18, 2020

To clarify this further for others who may be confused, LMUL and SEW are constrained by the (somewhat mind-bending) statement:

Implementations must support fractional LMUL settings for LMUL = SEW/ELEN, for the ELEN value at LMUL=1. An attempt to set an unsupported SEW and LMUL configuration sets the vill bit in vtype.

For an example implementation with ELEN=64, I think this means that these settings would be legal:

        vsetvli     t0, t0, e8,mf8      // LMUL=1/8, SEW/ELEN=1/8
        vsetvli     t0, t0, e8,mf4      // LMUL=1/4, SEW/ELEN=1/8
        vsetvli     t0, t0, e8,mf2      // LMUL=1/2, SEW/ELEN=1/8
        vsetvli     t0, t0, e16,mf4     // LMUL=1/4, SEW/ELEN=1/4
        vsetvli     t0, t0, e16,mf2     // LMUL=1/2, SEW/ELEN=1/4
        vsetvli     t0, t0, e32,mf2     // LMUL=1/2, SEW/ELEN=1/2

Whereas these settings would be illegal, and set vtype.vill=1:

        vsetvli     t0, t0, e16,mf8     // LMUL=1/8, SEW/ELEN=1/4
        vsetvli     t0, t0, e32,mf4     // LMUL=1/4, SEW/ELEN=1/2
        vsetvli     t0, t0, e32,mf8     // LMUL=1/8, SEW/ELEN=1/2
        vsetvli     t0, t0, e64,mf2     // LMUL=1/2, SEW/ELEN=1
        vsetvli     t0, t0, e64,mf4     // LMUL=1/4, SEW/ELEN=1
        vsetvli     t0, t0, e64,mf8     // LMUL=1/8, SEW/ELEN=1

In the above implementation, when SEW=64, the minimum legal LMUL is 1, meaning that source EEW of 1/2, 1/4 and 1/8 are all legal.

Similarly, when SEW=32, the minimum legal LMUL is 1/2. vzext.vf8/vsext.vf8 would violate the source EEW constraint and are therefore illegal. vzext.vf4/vsext.vf4 have source EMUL of 1/2 * 1/4 = 1/8, which is legal; vzext.vf2/vsext.vf2 have source EMUL of 1/2 * 1/2 = 1/4, which is legal.

When SEW=16, the minimum legal LMUL is 1/4. vzext.vf8/vsext.vf8 and vzext.vf4/vsext.vf4 would violate the source EEW constraint and are therefore illegal. vzext.vf2/vsext.vf2 have source EMUL of 1/4 * 1/2 = 1/8, which is legal.

When SEW=8, all vzext/vsext instructions violate the source EEW constraint and are therefore illegal.

Assuming that the EMUL constraint is indeed redundant, I think it might be better to remove it, and leave just the EEW constraint.

@David-Horner
Copy link
Contributor

David-Horner commented May 18, 2020 via email

@David-Horner
Copy link
Contributor

David-Horner commented May 18, 2020 via email

@solomatnikov
Copy link

Whereas these settings would be illegal, and set vtype.vill=1:

        vsetvli     t0, t0, e16,mf8     // LMUL=1/8, SEW/ELEN=1/4
        vsetvli     t0, t0, e32,mf4     // LMUL=1/4, SEW/ELEN=1/2
        vsetvli     t0, t0, e32,mf8     // LMUL=1/8, SEW/ELEN=1/2
        vsetvli     t0, t0, e64,mf2     // LMUL=1/2, SEW/ELEN=1
        vsetvli     t0, t0, e64,mf4     // LMUL=1/4, SEW/ELEN=1
        vsetvli     t0, t0, e64,mf8     // LMUL=1/8, SEW/ELEN=1

In the above implementation, when SEW=64, the minimum legal LMUL is 1, meaning that source EEW of 1/2, 1/4 and 1/8 are all legal.

If VLEN==SEW==64, then setting LMUL to 1/2, 1/4 or 1/8 doesn't make sense.

@David-Horner
Copy link
Contributor

David-Horner commented May 18, 2020 via email

@solomatnikov
Copy link

In the above implementation, when SEW=64, the minimum legal LMUL is 1,
meaning that source EEW of 1/2, 1/4 and 1/8 are all legal.

If VLEN==SEW==64, then setting LMUL to 1/2, 1/4 or 1/8 doesn't make sense.

Conversely when vlen equals 128 256 and 512 then 1/2 1/4 & 1/8 do make sense. The original limitation doesn't mention VLEN.
The original limitation doesn't mention VLEN.

For SW portability reasons it makes sense to make these constraints conservative, i.e. to make sure SW works independently of VLEN.

@kasanovic it would be good to add a note explaining reasoning behind these constraints.

@aswaterman
Copy link
Collaborator

I would support turning the following sentence into a bijection, forbidding implementations to be more permissive about which SEWs they allow for a given fractional LMUL: "Implementations must support fractional LMUL settings for LMUL ≥ SEW/ELEN, for the ELEN value at LMUL=1"

@JamesKenneyImperas
Copy link
Author

I agree with Andrew that this statement is more accurate. Assuming my concrete examples in the third comment here are correct, I think it would help general understanding to add them to the specification to clarify what the sentence means.

@kasanovic
Copy link
Collaborator

Resolved in task group.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolve for v1.0 To be resolved for v1.0 draft
Projects
None yet
Development

No branches or pull requests

5 participants