-
Notifications
You must be signed in to change notification settings - Fork 35
Support for eew!=sew cases for unitstride/strided load instructions #73
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
base: main
Are you sure you want to change the base?
Changes from 11 commits
dbf970f
9dca229
1ee7e64
080b3b9
9f0f705
8b77143
75f6fb6
bb382cc
9c6c6ae
8fd7d8f
c904418
87b9bb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package generator | |
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "math" | ||
| ) | ||
|
|
||
| func (i *Insn) genCodeVdRs1mRs2Vm(pos int) []string { | ||
|
|
@@ -17,47 +18,65 @@ func (i *Insn) genCodeVdRs1mRs2Vm(pos int) []string { | |
|
|
||
| for _, c := range combinations[pos:] { | ||
| builder := strings.Builder{} | ||
| builder.WriteString(c.initialize()) | ||
|
|
||
| builder.WriteString(i.gWriteRandomData(LMUL(1))) | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(0, LMUL(1), SEW(32))) | ||
|
|
||
| vd := int(c.LMUL1) | ||
| builder.WriteString(i.gWriteRandomData(c.LMUL1)) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(vd+(nf*int(c.LMUL1)), c.LMUL1, c.SEW)) | ||
| } | ||
| builder.WriteString(i.gWriteIntegerTestData(c.LMUL1*LMUL(nfields), c.SEW, 0)) | ||
| var sew SEW = 8 // sew is data width, c.SEW is offset width | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no offset width in unit-stride and constant-stride instructions. |
||
| for ; sew <= SEW(i.Option.XLEN); sew <<= 1 { | ||
| if int(sew) > int(float64(i.Option.XLEN)*float64(c.LMUL)) { | ||
| continue | ||
| } | ||
| emul := (float64(c.SEW) / float64(sew)) * float64(c.LMUL) * float64(nfields) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not emul. |
||
| if emul > 8 || emul < 1./8 { | ||
| continue | ||
| } | ||
| emul = math.Max(emul, 1) // offset lmul | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used. |
||
| builder.WriteString(c.initialize()) | ||
|
|
||
| builder.WriteString("# -------------- TEST BEGIN --------------\n") | ||
| builder.WriteString(i.gVsetvli(c.Vl, c.SEW, c.LMUL)) | ||
| builder.WriteString(fmt.Sprintf("%s v%d, (a0), zero%s\n", i.Name, vd, v0t(c.Mask))) | ||
| builder.WriteString("# -------------- TEST END --------------\n") | ||
| builder.WriteString(i.gWriteRandomData(LMUL(1))) | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(0, LMUL(1), SEW(32))) | ||
|
|
||
| builder.WriteString(i.gResultDataAddr()) | ||
| builder.WriteString(i.gStoreRegisterGroupIntoResultData(vd, c.LMUL1, c.SEW)) | ||
| builder.WriteString(i.gMagicInsn(vd, c.LMUL1)) | ||
| lmul1 := LMUL(math.Max((float64(c.SEW)/float64(sew))*float64(c.LMUL), 1)) | ||
| vd := int(lmul1) | ||
|
|
||
| for _, stride := range []int{minStride, 0, 1, maxStride} { | ||
| stride = stride * int(c.SEW) / 8 | ||
| builder.WriteString(i.gWriteRandomData(c.LMUL1)) | ||
| builder.WriteString(i.gWriteIntegerTestData(lmul1*LMUL(nfields), sew, 0)) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(vd+(nf*int(c.LMUL1)), c.LMUL1, c.SEW)) | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(vd+(nf*int(lmul1)), lmul1, sew)) | ||
| builder.WriteString(fmt.Sprintf("li a5, %d\n", i.vlenb()*int(lmul1))) | ||
| builder.WriteString("add a0, a0, a5\n") | ||
| } | ||
| builder.WriteString(i.gWriteIntegerTestData(c.LMUL1*LMUL(nfields*stride), c.SEW, 0)) | ||
| builder.WriteString(fmt.Sprintf("li a5, %d\n", -minStride*i.vlenb()*int(c.LMUL1))) | ||
| builder.WriteString("add a0, a0, a5\n") | ||
|
|
||
| builder.WriteString("# -------------- TEST BEGIN --------------\n") | ||
| builder.WriteString(fmt.Sprintf("li s0, %d # stride\n", stride)) | ||
| builder.WriteString(i.gVsetvli(c.Vl, c.SEW, c.LMUL)) | ||
| builder.WriteString(fmt.Sprintf("%s v%d, (a0), s0%s\n", i.Name, vd, v0t(c.Mask))) | ||
| builder.WriteString(i.gVsetvli(c.Vl, sew, c.LMUL)) | ||
| builder.WriteString(fmt.Sprintf("%s v%d, (a0), zero%s\n", i.Name, vd, v0t(c.Mask))) | ||
| builder.WriteString("# -------------- TEST END --------------\n") | ||
|
|
||
| builder.WriteString(i.gResultDataAddr()) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gStoreRegisterGroupIntoResultData(vd+(nf*int(c.LMUL1)), c.LMUL1, c.SEW)) | ||
| builder.WriteString(i.gMagicInsn(vd+(nf*int(c.LMUL1)), c.LMUL1)) | ||
| builder.WriteString(i.gStoreRegisterGroupIntoResultData(vd+(nf*int(lmul1)), lmul1, sew)) | ||
| builder.WriteString(i.gMagicInsn(vd+(nf*int(lmul1)), lmul1)) | ||
| } | ||
|
|
||
| for _, stride := range []int{minStride, 0, 1, maxStride} { | ||
| stride = stride * int(c.SEW) / 8 | ||
|
|
||
| builder.WriteString(i.gWriteIntegerTestData(lmul1*LMUL(nfields), sew, 0)) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(vd+(nf*int(lmul1)), lmul1, sew)) | ||
| builder.WriteString(fmt.Sprintf("li a5, %d\n", i.vlenb()*int(lmul1))) | ||
| builder.WriteString("add a0, a0, a5\n") | ||
| } | ||
| builder.WriteString(fmt.Sprintf("li a5, %d\n", -minStride*i.vlenb()*int(c.LMUL1))) | ||
| builder.WriteString("add a0, a0, a5\n") | ||
|
|
||
| builder.WriteString("# -------------- TEST BEGIN --------------\n") | ||
| builder.WriteString(fmt.Sprintf("li s0, %d # stride\n", stride)) | ||
| builder.WriteString(i.gVsetvli(c.Vl, sew, c.LMUL)) | ||
| builder.WriteString(fmt.Sprintf("%s v%d, (a0), s0%s\n", i.Name, vd, v0t(c.Mask))) | ||
| builder.WriteString("# -------------- TEST END --------------\n") | ||
|
|
||
| builder.WriteString(i.gResultDataAddr()) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gStoreRegisterGroupIntoResultData(vd+(nf*int(lmul1)), lmul1, sew)) | ||
| builder.WriteString(i.gMagicInsn(vd+(nf*int(lmul1)), lmul1)) | ||
| } | ||
| } | ||
| } | ||
| res = append(res, builder.String()) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ package generator | |
| import ( | ||
| "fmt" | ||
| "strings" | ||
| "math" | ||
| ) | ||
|
|
||
| func (i *Insn) genCodeVdRs1mVm(pos int) []string { | ||
|
|
@@ -17,27 +18,41 @@ func (i *Insn) genCodeVdRs1mVm(pos int) []string { | |
|
|
||
| for _, c := range combinations[pos:] { | ||
| builder := strings.Builder{} | ||
| builder.WriteString(c.initialize()) | ||
|
|
||
| builder.WriteString(i.gWriteRandomData(LMUL(1))) | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(0, LMUL(1), SEW(32))) | ||
|
|
||
| vd := int(c.LMUL1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why there are so many changes in the following code. When SEW != EEW, there is only 1 thing changed, which is the EMUL. |
||
| builder.WriteString(i.gWriteRandomData(c.LMUL1)) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(vd+(nf*int(c.LMUL1)), c.LMUL1, c.SEW)) | ||
| } | ||
| builder.WriteString(i.gWriteIntegerTestData(c.LMUL1*LMUL(nfields), c.SEW, 0)) | ||
|
|
||
| builder.WriteString("# -------------- TEST BEGIN --------------\n") | ||
| builder.WriteString(i.gVsetvli(c.Vl, c.SEW, c.LMUL)) | ||
| builder.WriteString(fmt.Sprintf("%s v%d, (a0)%s\n", i.Name, vd, v0t(c.Mask))) | ||
| builder.WriteString("# -------------- TEST END --------------\n") | ||
|
|
||
| builder.WriteString(i.gResultDataAddr()) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gStoreRegisterGroupIntoResultData(vd+(nf*int(c.LMUL1)), c.LMUL1, c.SEW)) | ||
| builder.WriteString(i.gMagicInsn(vd+(nf*int(c.LMUL1)), c.LMUL1)) | ||
| var sew SEW = 8 // sew is data width, c.SEW is offset width | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is no offset width in unit-stride and constant-stride instructions. |
||
| for ; sew <= SEW(i.Option.XLEN); sew <<= 1 { | ||
| if int(sew) > int(float64(i.Option.XLEN)*float64(c.LMUL)) { | ||
| continue | ||
| } | ||
| emul := (float64(c.SEW) / float64(sew)) * float64(c.LMUL) * float64(nfields) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not emul. |
||
| if emul > 8 || emul < 1./8 { | ||
| continue | ||
| } | ||
| emul = math.Max(emul, 1) // offset lmul | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used. |
||
| builder.WriteString(c.initialize()) | ||
|
|
||
| builder.WriteString(i.gWriteRandomData(LMUL(1))) | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(0, LMUL(1), SEW(32))) | ||
|
|
||
| lmul1 := LMUL(math.Max((float64(c.SEW)/float64(sew))*float64(c.LMUL), 1)) | ||
| vd := int(lmul1) | ||
|
|
||
| builder.WriteString(i.gWriteIntegerTestData(lmul1*LMUL(nfields), sew, 0)) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gLoadDataIntoRegisterGroup(vd+(nf*int(lmul1)), lmul1, sew)) | ||
| builder.WriteString(fmt.Sprintf("li a5, %d\n", i.vlenb()*int(lmul1))) | ||
| builder.WriteString("add a0, a0, a5\n") | ||
| } | ||
|
|
||
| builder.WriteString("# -------------- TEST BEGIN --------------\n") | ||
| builder.WriteString(i.gVsetvli(c.Vl, sew, c.LMUL)) | ||
| builder.WriteString(fmt.Sprintf("%s v%d, (a0)%s\n", i.Name, vd, v0t(c.Mask))) | ||
| builder.WriteString("# -------------- TEST END --------------\n") | ||
|
|
||
| builder.WriteString(i.gResultDataAddr()) | ||
| for nf := 0; nf < nfields; nf++ { | ||
| builder.WriteString(i.gStoreRegisterGroupIntoResultData(vd+(nf*int(lmul1)), lmul1, sew)) | ||
| builder.WriteString(i.gMagicInsn(vd+(nf*int(lmul1)), lmul1)) | ||
| } | ||
| } | ||
|
|
||
| res = append(res, builder.String()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why there are so many changes in the following code. When SEW != EEW, there is only 1 thing changed, which is the EMUL.