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

[RISC-V] Detect Zba & Zbb extensions #113676

Merged
merged 9 commits into from
Mar 24, 2025

Conversation

fuad1502
Copy link
Contributor

@fuad1502 fuad1502 commented Mar 19, 2025

In this PR, support for single letter extensions (M, A, F, C, V), and "B" Zba & Zbb extension detection was added. Extensions are detected with hwprobe, or if not available, with hwcap.

Additionally, compOpportunisticallyDependsOn was enabled for RISC-V.

Part of #84834, cc @dotnet/samsung

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Mar 19, 2025
@risc-vv
Copy link

risc-vv commented Mar 19, 2025

993ce36 is being scheduled for building and testing

GIT: 993ce369b6500020de1c8edf78e1613e0a67ee70
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 19, 2025
@am11 am11 added arch-riscv Related to the RISC-V architecture area-VM-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Mar 19, 2025
Copy link
Contributor

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Mar 19, 2025

In this PR, support for single letter extensions (M, A, F, C, V), and "B" extension detection was added

We typically add detection of processor extensions as needed - as part of the work to take advantage of the extension in the codegen.

What are the extensions that you plan to take advantage of in near future? I would only add those.

@fuad1502
Copy link
Contributor Author

We typically add detection of processor extensions as needed - as part of the work to take advantage of the extension in the codegen.

What are the extensions that you plan to take advantage of in near future? I would only add those.

Hi @jkotas , I would like to take advantage of Zbb & Zba (subset of "B" extension). A PR for that is underway. Should I remove the other subsets from "B" extension, then? (remove Zbc, Zbs, Zbkb, Zbkc, Zbkx)

For the I, M, A, F, D extensions, they are already used inside the code. Currently we are assuming all of them are available. With my PR, if any of them are not available, an error would be emitted. So, I think it would be best to keep them in this PR?

For the V extension, I personally don't have a plan to take advantage of it in the near future, but maybe @tomeksowi have an opinion on this?

@am11
Copy link
Member

am11 commented Mar 19, 2025

Our baseline is riscv64gc, so IMAFDZicsrC are implied. (#73437)

Similarly on x64, SSE2 is implied.

@jkotas
Copy link
Member

jkotas commented Mar 19, 2025

With my PR, if any of them are not available, an error would be emitted.

I assume that the runtime C/C++ code takes advantage of these extensions too. Is the runtime going to be able to bootstrap to print this error if any of these baseline extensions are missing?

@jkotas
Copy link
Member

jkotas commented Mar 19, 2025

Is there a way to tell the Linux loader to enforce the baseline at binary level? Ideally, the binary would fail to launch when the processor does not support the extensions that it depends on.

@jkotas
Copy link
Member

jkotas commented Mar 19, 2025

Should I remove the other subsets from "B" extension

Yes, I would only add the ones you plan to use in near future.

@fuad1502 fuad1502 mentioned this pull request Mar 19, 2025
3 tasks
@tomeksowi
Copy link
Contributor

For the V extension, I personally don't have a plan to take advantage of it in the near future, but maybe @tomeksowi have an opinion on this?

We plan to support "V", many RVA22 processors implement it as an option and it will be mandatory since RVA23. Probably not near future, there's still a lot of work with the base and RVA22-mandatory extensions and the "V" dev itself looks huge.

@fuad1502 fuad1502 force-pushed the riscv-jit-opt/extensions branch from 993ce36 to fb3881a Compare March 20, 2025 04:02
@risc-vv
Copy link

risc-vv commented Mar 20, 2025

RISC-V Release-FX-VF2: 0 / 258 (0.00%)
=======================
      passed: 0
      failed: 0
     skipped: 0
      killed: 258
------------------------
  TOTAL libs: 258
 TOTAL tests: 258
   REAL time: 45s 726ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: fb3881af3dd942c6b8b617e0d09fe6a2a474bff3
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-VF2: 9469 / 9545 (99.20%)
=======================
      passed: 9469
      failed: 59
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9651
 TOTAL tests: 9651
   REAL time: 2h 6min 56s 325ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

Build information and commands

GIT: fb3881af3dd942c6b8b617e0d09fe6a2a474bff3
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-QEMU: 9469 / 9545 (99.20%)
=======================
      passed: 9469
      failed: 59
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9651
 TOTAL tests: 9651
   REAL time: 2h 46min 10s 602ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

Build information and commands

GIT: fb3881af3dd942c6b8b617e0d09fe6a2a474bff3
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-QEMU: 0 / 258 (0.00%)
=======================
      passed: 0
      failed: 0
     skipped: 0
      killed: 258
------------------------
  TOTAL libs: 258
 TOTAL tests: 258
   REAL time: 43s 936ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: fb3881af3dd942c6b8b617e0d09fe6a2a474bff3
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

@fuad1502 fuad1502 changed the title [RISC-V] Detect M, A, F, C, V, and "B" extensions [RISC-V] Detect Zba & Zbb extensions Mar 20, 2025
@risc-vv
Copy link

risc-vv commented Mar 21, 2025

RISC-V Release-FX-VF2: 0 / 258 (0.00%)
=======================
      passed: 0
      failed: 0
     skipped: 0
      killed: 258
------------------------
  TOTAL libs: 258
 TOTAL tests: 258
   REAL time: 42s 146ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: fcd3f9578f07e3cf9329a72d44ddaf3296d5ed0a
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-VF2: 9469 / 9545 (99.20%)
=======================
      passed: 9469
      failed: 59
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9651
 TOTAL tests: 9651
   REAL time: 2h 7min 17s 672ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

Build information and commands

GIT: fcd3f9578f07e3cf9329a72d44ddaf3296d5ed0a
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-QEMU: 9469 / 9545 (99.20%)
=======================
      passed: 9469
      failed: 59
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9651
 TOTAL tests: 9651
   REAL time: 2h 45min 34s 657ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

Build information and commands

GIT: fcd3f9578f07e3cf9329a72d44ddaf3296d5ed0a
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-QEMU: 0 / 258 (0.00%)
=======================
      passed: 0
      failed: 0
     skipped: 0
      killed: 258
------------------------
  TOTAL libs: 258
 TOTAL tests: 258
   REAL time: 43s 82ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: fcd3f9578f07e3cf9329a72d44ddaf3296d5ed0a
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: fuad1502/runtime
BRANCH: riscv-jit-opt/extensions
CONFIG: Release
LIB_CONFIG: Release

@fuad1502 fuad1502 marked this pull request as ready for review March 21, 2025 03:42
@risc-vv
Copy link

risc-vv commented Mar 21, 2025

RISC-V Release-FX-VF2: 0 / 258 (0.00%)
=======================
      passed: 0
      failed: 0
     skipped: 0
      killed: 258
------------------------
  TOTAL libs: 258
 TOTAL tests: 258
   REAL time: 44s 15ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: e6737c3186e29ef094ea797e757a9f9a73b9399f
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

@risc-vv
Copy link

risc-vv commented Mar 21, 2025

RISC-V Release-FX-VF2: 0 / 258 (0.00%)
=======================
      passed: 0
      failed: 0
     skipped: 0
      killed: 258
------------------------
  TOTAL libs: 258
 TOTAL tests: 258
   REAL time: 42s 274ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: c553fe47434ff926cc3eb608095e88765d880e3f
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-VF2: 9524 / 9544 (99.79%)
=======================
      passed: 9524
      failed: 3
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9650
 TOTAL tests: 9650
   REAL time: 2h 6min 37s 746ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

Build information and commands

GIT: c553fe47434ff926cc3eb608095e88765d880e3f
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-QEMU: 9524 / 9544 (99.79%)
=======================
      passed: 9524
      failed: 3
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9650
 TOTAL tests: 9650
   REAL time: 2h 45min 52s 260ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

Build information and commands

GIT: c553fe47434ff926cc3eb608095e88765d880e3f
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-QEMU: 640088 / 673778 (95.00%)
=======================
      passed: 640088
      failed: 871
     skipped: 1640
      killed: 32819
------------------------
  TOTAL libs: 258
 TOTAL tests: 675418
   REAL time: 2h 24min 17s 723ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: c553fe47434ff926cc3eb608095e88765d880e3f
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

Copy link
Member

@am11 am11 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@risc-vv
Copy link

risc-vv commented Mar 21, 2025

658410a is being scheduled for building and testing

GIT: 658410aabe9befdc2bc15e4635709617a1542499
REPO: dotnet/runtime
BRANCH: main

@am11
Copy link
Member

am11 commented Mar 21, 2025

There are merge conflicts.

Aside: risc-vv CI could also use the same mechanism as .NET CI: merge main to PR branch before building (and thereby fail the build if there were merge conflicts).

@fuad1502 fuad1502 force-pushed the riscv-jit-opt/extensions branch from 658410a to d81d1ee Compare March 21, 2025 16:25
@risc-vv
Copy link

risc-vv commented Mar 21, 2025

RISC-V Release-CLR-VF2: 9524 / 9544 (99.79%)
=======================
      passed: 9524
      failed: 3
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9650
 TOTAL tests: 9650
   REAL time: 2h 3min 16s 856ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

Build information and commands

GIT: d81d1eec65037ac1be8b3cc9c77ab5e1bb953d60
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-QEMU: 660097 / 687914 (95.96%)
=======================
      passed: 660097
      failed: 889
     skipped: 1574
      killed: 26928
------------------------
  TOTAL libs: 258
 TOTAL tests: 689488
   REAL time: 2h 26min 44s 326ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: d81d1eec65037ac1be8b3cc9c77ab5e1bb953d60
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-VF2: 435202 / 463916 (93.81%)
=======================
      passed: 435202
      failed: 672
     skipped: 1511
      killed: 28042
------------------------
  TOTAL libs: 258
 TOTAL tests: 465427
   REAL time: 2h 51min 43s 617ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: d81d1eec65037ac1be8b3cc9c77ab5e1bb953d60
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-QEMU: 9524 / 9544 (99.79%)
=======================
      passed: 9524
      failed: 3
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9650
 TOTAL tests: 9650
   REAL time: 2h 46min 10s 457ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

Build information and commands

GIT: d81d1eec65037ac1be8b3cc9c77ab5e1bb953d60
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

@jkotas
Copy link
Member

jkotas commented Mar 23, 2025

cc @dotnet/jit-contrib for additional feedback

@risc-vv
Copy link

risc-vv commented Mar 24, 2025

RISC-V Release-CLR-VF2: 9524 / 9544 (99.79%)
=======================
      passed: 9524
      failed: 3
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9650
 TOTAL tests: 9650
   REAL time: 2h 11min 15s 588ms
=======================

Release-CLR-VF2.md, Release-CLR-VF2.xml, testclr_output.tar.gz

Build information and commands

GIT: 6b27297ad6222fb684212b35dbda157ac36bb9ba
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-CLR-QEMU: 9524 / 9544 (99.79%)
=======================
      passed: 9524
      failed: 3
     skipped: 106
      killed: 17
------------------------
  TOTAL libs: 9650
 TOTAL tests: 9650
   REAL time: 2h 48min 15s 567ms
=======================

Release-CLR-QEMU.md, Release-CLR-QEMU.xml, testclr_output.tar.gz

Build information and commands

GIT: 6b27297ad6222fb684212b35dbda157ac36bb9ba
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-VF2: 456184 / 494807 (92.19%)
=======================
      passed: 456184
      failed: 664
     skipped: 1446
      killed: 37959
------------------------
  TOTAL libs: 258
 TOTAL tests: 496253
   REAL time: 3h 7min 17s 239ms
=======================

Release-FX-VF2.md, Release-FX-VF2.xml, testfx_output.tar.gz

Build information and commands

GIT: 6b27297ad6222fb684212b35dbda157ac36bb9ba
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

RISC-V Release-FX-QEMU: 641735 / 677513 (94.72%)
=======================
      passed: 641735
      failed: 876
     skipped: 1640
      killed: 34902
------------------------
  TOTAL libs: 258
 TOTAL tests: 679153
   REAL time: 2h 24min 40s 214ms
=======================

Release-FX-QEMU.md, Release-FX-QEMU.xml, testfx_output.tar.gz

Build information and commands

GIT: 6b27297ad6222fb684212b35dbda157ac36bb9ba
CI: a8426a46d8575dfcb3b5fec0d7d0b7a7c118d690
REPO: dotnet/runtime
BRANCH: main
CONFIG: Release
LIB_CONFIG: Release

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM

@jkotas jkotas merged commit 45a0e10 into dotnet:main Mar 24, 2025
158 of 162 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-riscv Related to the RISC-V architecture area-VM-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants