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

Zce architecture tests #6

Open
13 tasks
jjscheel opened this issue Mar 16, 2023 · 68 comments
Open
13 tasks

Zce architecture tests #6

jjscheel opened this issue Mar 16, 2023 · 68 comments
Assignees

Comments

@jjscheel
Copy link
Contributor

jjscheel commented Mar 16, 2023

Technical Group

Code Size Reduction TG

ratification-pkg

Code Size

Technical Liaison

Tariq Kurd

Task Category

Arch Tests

Task Sub Category

  • gcc
  • binutils
  • gdb
  • intrinsics
  • Java
  • KVM
  • ld
  • llvm
  • Linux kernel
  • QEMU
  • Spike

Ratification Target

1Q2023

Statement of Work (SOW)

SOW link

SOW Signoffs: (delete those not needed)

  • Task group liaison sign-off date:
  • Development partner sign-off date:
  • ACT SIG sign-off date (if ACT work):

Waiver

  • Freeze
  • Ratification

Pull Request Details

No response

@jjscheel jjscheel self-assigned this Mar 16, 2023
@jjscheel jjscheel moved this from As-planned to Late in RISC-V DevPartner Work Mar 17, 2023
@jjscheel jjscheel moved this from Late to As-planned in RISC-V DevPartner Work Mar 17, 2023
@jjscheel jjscheel moved this from As-planned to At-risk in RISC-V DevPartner Work Mar 17, 2023
@jjscheel jjscheel assigned ptprasanna and unassigned jjscheel Apr 11, 2023
@jjscheel
Copy link
Contributor Author

Per 4/11 email from Prasanna:

Code size reduction: First set of test cases are written, they are being tested against Spike, dei run is in progress until the tests are pass - in progress

@ptprasanna
Copy link

No progress made since last Call. Was busy on Zfinx.

@jjscheel
Copy link
Contributor Author

jjscheel commented May 1, 2023

Ok. Please keep this as a focus item. We need to start showing progress here.

@ptprasanna
Copy link

The dry of the tests designed was resumed against SPIKE, still seeing few failures. Fixing/Modifying the tests/frameworks is underway.

@jjscheel
Copy link
Contributor Author

jjscheel commented May 9, 2023

Glad we are once again making progress!

@jjscheel
Copy link
Contributor Author

@ptprasanna, any update?

@jjscheel
Copy link
Contributor Author

@pz9115, raising this to your attention as @ptprasanna is working a possible toolchain issue.

@ptprasanna
Copy link

Possibly an issue, but discussing with @Abdulwadoodd to get different point of view, before we conclude the issue with the tool chain. Also discussing with @pz9115 as well.

@jjscheel
Copy link
Contributor Author

Feed back from @Abdulwadoodd:

Toolchain works fine for Zce.
The error you are getting is because of illegal operands of instructions: The immediate offset of the instructions in the generated tests are incorrect.
If you look at the spec, c.lb* , c.lh* instructions only allowed to have 2-bit unsigned immediate offset (at max) which is not the case for your tests and hence the compilation error.
Do look the reserved lsb of unimm as well

You can try compiling the instruction like:
c.lh x10, 0(x12)
c.lh x8, 2(x13)

And it would work with the toolchain.

I hope this resolves your issue.

@ptprasanna
Copy link

Zcf - Tests are generated using CTG, but the execution is not successful. Possibly a tool-chain issue (assuming), or the generated test are wrong. Still investigating.
Zcd - Tests are generated using CTG, but the execution is not successful. Possibly a tool-chain issue (assuming), or the generated test are wrong. Still investigating.
Zcb - Tests are generated, but few cover-points are not meeting up, we are getting them sorted
Zcmp - Yet to start the tests
Zcmt - Yet to start the tests

@jjscheel
Copy link
Contributor Author

Thanks, @ptprasanna! Will remove from Agenda for this week. Please feel free to reach out if you need technical assistance debugging.

@jjscheel
Copy link
Contributor Author

@ptprasanna, please update status here.

@anuani21
Copy link

anuani21 commented Jul 20, 2023

Regarding Zcf and Zcd extension, possibly an toolchain issue(assuming) and discussed with @pz9115.

Got a feedback from @pz9115,

1.Since Zce is not upstream yet,need to checkout gcc and binutils into the downstream repo,

Gcc: https://github.com/openhwgroup/corev-gcc/commits/development-08dd5f65b06
Binutils: https://github.com/openhwgroup/corev-binutils-gdb/commits/development-eddf4096b97

  1. Use compile args -march= rv32imaf_zcf -mabi=ilp32f.
  2. As per specification definition,need to discard zcmb extension.

As per the feedback,I have done all the changes but still I am facing the same issue. @pz9115, Can you give me any suggestions to resolve the issue?

@pz9115
Copy link

pz9115 commented Jul 24, 2023

Regarding Zcf and Zcd extension, possibly an toolchain issue(assuming) and discussed with @pz9115.

Got a feedback from @pz9115,

1.Since Zce is not upstream yet,need to checkout gcc and binutils into the downstream repo,

Gcc: https://github.com/openhwgroup/corev-gcc/commits/development-08dd5f65b06 Binutils: https://github.com/openhwgroup/corev-binutils-gdb/commits/development-eddf4096b97

  1. Use compile args -march= rv32imaf_zcf -mabi=ilp32f.
  2. As per specification definition,need to discard zcmb extension.

As per the feedback,I have done all the changes but still I am facing the same issue. @pz9115, Can you give me any suggestions to resolve the issue?

Hi @anuani21, Can you provide the error log for me to learn more about the cause of the error, thanks.

@anuani21
Copy link

Hi @pz9115,

Here I have attached the error log for your reference.

error-log.odt

@pz9115
Copy link

pz9115 commented Jul 25, 2023

Hi @pz9115,

Here I have attached the error log for your reference.

error-log.odt

Hi @anuani21, I found some compressed instructions that used in the log file, such as:

c.flw f15,-0x4(f15)
c.flw f14,0x0(f13)
c.flw f12,0x28(f11)

Where you use fpr as the second operand. As the instruction defination, it load from memory, computes an effective address by adding the zero-extended as offset scaled by 4.

So you should use gpr instead fpr as the second operand and set the offset positive and multiple it 4, such as:

c.flw f15,0x4(x15)
c.flw f14,0x0(x13)
c.flw f12,0x28(x11)

@Abdulwadoodd
Copy link
Member

Hi @ptprasanna, @jjscheel

RISC-V Config PR is merged which adds support of Code size reduction extension to riscv-config tool
PR link: riscv-software-src/riscv-config#129

This was critical because RISCOF and ISAC use riscv config to run tests and generate coverage reports respectively. One can run Zce ACTs using RISCOF by updating the riscv-config version.

@anuani21
Copy link

@jjscheel,

No progress made since last Call. Was busy on Debug ACT for Native Triggers.

@anuani21
Copy link

anuani21 commented Oct 1, 2024

@jjscheel,

Updates from IITM,

  • There are five sub-extensions in Zce
  1. Zcb -it is already merged.

  2. Zcf -Raised a PR.

  3. Zcd - Raised a PR.
    - Riscv-ctg : Add support for Zcf and Zcd extension riscv-software-src/riscv-ctg#122
    - Riscv-isac: Add support for Zcf and Zcd extension riscv-software-src/riscv-isac#100
    - Riscv-arch-test: [ACT] [CTG] [ISAC] Add support for Zcf and Zcd extension riscv-non-isa/riscv-arch-test#497

  4. Zcmp - popret and popretz instructions are pending.
    5.. Zcmt- completed. Need to raise a Pr along with zcmp extension

  • We will complete Zcmp and raise a PR for Zcmp and Zcmt extension together before the next meeting.

@jjscheel
Copy link
Contributor Author

jjscheel commented Oct 1, 2024

Great. THANKS!!!

@anuani21
Copy link

@jjscheel,

Updates from IITM,

  1. Zcf&Zcd extension:
    Re-submiited the PR in riscv-ctg and riscv-isac into riscv-arch-test [ACT] [CTG] [ISAC] Add support for Zcf and Zcd extension riscv-non-isa/riscv-arch-test#497

  2. Zcmp and Zcmt extension: We will raise a PR within this week.

@JAYANTH-IITM
Copy link

JAYANTH-IITM commented Oct 29, 2024

Update :
I am currently working on ACT for Zcmp and Zcmt .

While running the test I am encounter this assembler error which is saying "Zcm* is not compatible with C extension" .
I have raised the same issue in arch-test repo (riscv-non-isa/riscv-arch-test#543) in which allen suggested to include c in ISA ( RV32ICZicsr_Zca_Zcmp ) , but even after that the error was not resolved .

I asked tariq sir also about this error , to which sir suggested it might be toolchain bug.

@pz9115 sir can you please help me here . I have attched ss of the error
Image

@pz9115
Copy link

pz9115 commented Oct 29, 2024

Update : I am currently working on ACT for Zcmp and Zcmt .

While running the test I am encounter this assembler error which is saying "Zcm* is not compatible with C extension" . I have raised the same issue in arch-test repo (riscv-non-isa/riscv-arch-test#543) in which allen suggested to include c in ISA ( RV32ICZicsr_Zca_Zcmp ) , but even after that the error was not resolved .

I asked tariq sir also about this error , to which sir suggested it might be toolchain bug.

@pz9115 sir can you please help me here . I have attched ss of the error Image

@JAYANTH-IITM I think this is cause by the toolchain version issue, we'd better update both gcc and binutils to the latest upstream line.
There is no release version of riscv-gnu-toolchain yet, which means we need to build it manually, here is the steps:

First, use git clone get the riscv-gnu-toolchain

git clone https://github.com/riscv-collab/riscv-gnu-toolchain.git

Then we need to prepare the environment, On Ubuntu, executing the following command should suffice:

$ sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev

The next step, go into subdir gcc and binutils, update the code to the upstream version:

cd gcc
git fetch origin
git checkout origin/trunk
cd ../binutils
git fetch origin
git checkout origin/trunk

After this, we need to set the toolchain installation directory(in --prefix=, like /opt/riscv) and build it(the time cost based on your CPU performance, usually it takes about half an hour)

./configure --prefix=/opt/riscv --with-arch=rv32ic_zicsr_zca_zcmp --with-abi=ilp32
make -j$(nproc)

If you meet any problems in toolchain, please feel free to ask me at anytime.

@IC41558-IITM
Copy link

Thank you sir . will update the toolchain and redo the tests .

@JAYANTH-IITM
Copy link

Hi @pz9115 ,
I need both zcmp and zcmt , so in arch do use (-with-arch=rv32ic_zicsr_zca_zcmp_zcmt ) , or do i need to do it separately ( one with _zcmp and another with _zcmt )

@pz9115
Copy link

pz9115 commented Nov 2, 2024

Hi @pz9115 , I need both zcmp and zcmt , so in arch do use (-with-arch=rv32ic_zicsr_zca_zcmp_zcmt ) , or do i need to do it separately ( one with _zcmp and another with _zcmt )

Hi @JAYANTH-IITM ,it needs to use the first form I think(-with-arch=rv32ic_zicsr_zca_zcmp_zcmt), but currently zcmt haven't merged in upstream yet,. It means that you need to apply the zcmt patch into binutils and then re-build the toolchain, the patch link is

https://patchwork.sourceware.org/project/binutils/patch/[email protected]/

you can click the right up botton mobox to download it, and deploy it using git in the binutils repository.

"""
git am v5-RISC-V-Add-Zcmt-instructions-and-csr..patch
"""

@JAYANTH-IITM
Copy link

Hi @pz9115 ,
I tried to apply the patch for zcmt , but i am encountering this error

" Applying: RISC-V: Add Zcmt instructions and csr.
error: patch failed: gas/config/tc-riscv.c:3922
error: gas/config/tc-riscv.c: patch does not apply
error: patch failed: include/opcode/riscv-opc.h:2305
error: include/opcode/riscv-opc.h: patch does not apply
error: patch failed: opcodes/riscv-opc.c:362
error: opcodes/riscv-opc.c: patch does not apply
Patch failed at 0001 RISC-V: Add Zcmt instructions and csr. " . I am not sure how to proceed after this . Can you please help here

@pz9115
Copy link

pz9115 commented Nov 5, 2024

Hi @pz9115 , I tried to apply the patch for zcmt , but i am encountering this error

" Applying: RISC-V: Add Zcmt instructions and csr. error: patch failed: gas/config/tc-riscv.c:3922 error: gas/config/tc-riscv.c: patch does not apply error: patch failed: include/opcode/riscv-opc.h:2305 error: include/opcode/riscv-opc.h: patch does not apply error: patch failed: opcodes/riscv-opc.c:362 error: opcodes/riscv-opc.c: patch does not apply Patch failed at 0001 RISC-V: Add Zcmt instructions and csr. " . I am not sure how to proceed after this . Can you please help here

I think this is caused by binutils submodule not updated correctly, please checkout the binutils into the latest master branch,
https://sourceware.org/git/?p=binutils-gdb.git;a=summary

@JAYANTH-IITM
Copy link

Toolchain working fine @pz9115 . Thank you !

@JAYANTH-IITM
Copy link

JAYANTH-IITM commented Nov 7, 2024

@pz9115 @tariqkurd-repo , for the instruction cm.popret and cm.popretz it is working only for imm_val (spimm) 0 , for imm_val 1 , 2 and 3 it is not working. But cm.push and cm.pop is working fine . Can you please guide here .

@allenjbaum , the test macro that I written for zcmp and zcmt does not append any signature ( but i am able get the expected coverage for all instruction as expected , expect for the above case ) . attached the test_macro for reference

  1. do i need to append signature ?
  2. what is the expected signature ? can you please help here test_macros.zip

sorry , closed by mistake

@pz9115
Copy link

pz9115 commented Nov 7, 2024

@pz9115 @tariqkurd-repo , for the instruction cm.popret and cm.popretz it is working only for imm_val (spimm) 0 , for imm_val 1 , 2 and 3 it is not working. But cm.push and cm.pop is working fine . Can you please guide here .

I tested with a simple example spimm.s and it works fine

target:
        cm.popret {ra}, 16
        cm.popret {ra}, 32
        cm.popret {ra}, 48
        cm.popret {ra}, 64
        cm.popretz {ra}, 16
        cm.popretz {ra}, 32
        cm.popretz {ra}, 48
        cm.popretz {ra}, 64
/opt/riscv/bin/riscv64-unknown-elf-as -march=rv32ima_zcmp -mabi=ilp32 spimm.s -o spimm.o
/opt/riscv/bin/riscv64-unknown-elf-objdump -d spimm.o
spimm.o:     file format elf32-littleriscv


Disassembly of section .text:

00000000 <target>:
   0:   be42                    cm.popret       {ra},16
   2:   be46                    cm.popret       {ra},32
   4:   be4a                    cm.popret       {ra},48
   6:   be4e                    cm.popret       {ra},64
   8:   bc42                    cm.popretz      {ra},16
   a:   bc46                    cm.popretz      {ra},32
   c:   bc4a                    cm.popretz      {ra},48
   e:   bc4e                    cm.popretz      {ra},64

The stack_adj (16|32|48|64) corresponding to the stack_adj_base + 16 * spimm. In this example, the ra set the adj_base equal 16, and when spimm pass form 0~3, total stack_adj comes into (16|32|48|64). It has the same behaviour with cm.pop as expected.

Could you give more detail about this error, thanks.

@allenjbaum , the test macro that I written for zcmp and zcmt does not append any signature ( but i am able get the expected coverage for all instruction as expected , expect for the above case ) . attached the test_macro for reference

  1. do i need to append signature ?
  2. what is the expected signature ? can you please help here test_macros.zip

sorry , closed by mistake

@JAYANTH-IITM
Copy link

    .section .text
    .global _start

_start:
	cm.popret {ra}, 16
	cm.popret {ra,s0}, 16
	cm.popret {ra,s0-s1}, 16
	cm.popret {ra,s0-s2}, 16

when i try to execute this i am encountering ( I tried the same by using x register , but the same ) inside of using (ra , s0-s1) if (ra,s0,s1) is used it working ( which does not match with the spec )

$ riscv64-unknown-elf-as -march=rv64imac_zcmp -o test.o spimm.s
spimm.s: Assembler messages:
spimm.s:7: Error: illegal operands `cm.popret {ra,s0-s1},16'
spimm.s:8: Error: illegal operands `cm.popret {ra,s0-s2},16'

@pz9115
Copy link

pz9115 commented Nov 7, 2024

    .section .text
    .global _start

_start:
	cm.popret {ra}, 16
	cm.popret {ra,s0}, 16
	cm.popret {ra,s0-s1}, 16
	cm.popret {ra,s0-s2}, 16

when i try to execute this i am encountering ( I tried the same by using x register , but the same ) inside of using (ra , s0-s1) if (ra,s0,s1) is used it working ( which does not match with the spec )

$ riscv64-unknown-elf-as -march=rv64imac_zcmp -o test.o spimm.s
spimm.s: Assembler messages:
spimm.s:7: Error: illegal operands `cm.popret {ra,s0-s1},16'
spimm.s:8: Error: illegal operands `cm.popret {ra,s0-s2},16'

Let me explain why it's wrong here, in Zcmp, the base of stack_adj will change when using more S-registers as the arguments.

You can find the stack_adj setting in https://github.com/riscvarchive/riscv-code-size-reduction/blob/main/Zc-specification/pushpop_vars.adoc

Using -march=rv64imac_zcmp to compile cm.popret {ra,s0-s1} will match to the case 6 in RV64, sets the stack_adj_base equal to 32, so it should to use cm.popret {ra,s0-s1},32 in this case.

@JAYANTH-IITM
Copy link

JAYANTH-IITM commented Nov 12, 2024

Updates from IIT-M ,

  1. Tests for Zcmp and Zcmt are complete . Not getting expected coverage in cm.popret and cm.popretz . Other than these two , getting expected coverage in all other test.

reg : expected signature for zmp and zcmt test, need some guidance here @allenjbaum

@allenjbaum
Copy link

allenjbaum commented Nov 12, 2024 via email

@allenjbaum
Copy link

There are multiple problems with this test (and probably the others):

  • the stack data area is supposed to contain the address that is returned to when executing the instruction - but it is unintialized, so the test will be jumping to a unknown location, which will cause the test to abort (if you're lucky).

That return address entry should be the address of an instruction that follows the POPRET. Preferably, the macro should put noops after the POPRET and point the return address to be after those noops so we can write tests that will trap during the execution (which I'm pretty sure is not part of the coverage that was defined).
The other popped registers should have unique values that we can test for to ensure the correct addresses have been popped (e.g. walking ones)

  • the instruction performs a RET operation as part of its execution, yet the macro adds another RET after the instruction. This will cause an infinite loop (or would if the stack was actually properly initialized).

  • no signature is stored. Architectural state that is updated by any test should be stored into the signature (which in this case is every register that is popped off the stack) Furthermore, any register that is popped that is known to contain an address must be converted to an offset from the segments xx_BEGIN label (which in this case is the return address relative to CODE_BEGIN.

  • If a signature had been stored, the test would abort because no memory was allocated for it

@anuani21
Copy link

@jjscheel,

  • Allen suggested some changes in the test for Zcmp extension.
  • I have rewriting the test to incorporate the changes for Zcmp extension.

@anuani21
Copy link

anuani21 commented Jan 7, 2025

@jjscheel,

Zcf and Zcd PR is merged to dev.

@jjscheel
Copy link
Contributor Author

jjscheel commented Jan 7, 2025

Thanks, @anuani21. Can you kindly provide a pointer to the PRs?

@anuani21
Copy link

anuani21 commented Jan 7, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: At-risk
Development

No branches or pull requests

9 participants