[RISC-V] Need to configure target RISC-V extension for coreclr build

Open
#115,296 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cmake, cpp

Research direction

Start with eng/native/configurecompiler.cmake around the ARM options and CLR_ADDITIONAL_COMPILER_OPTIONS, then inspect src/coreclr/jit/emitriscv64.cpp near emitLoadImmediate. Determine which RISC-V extension configuration approach is intended among the proposals. Done means the selected configuration is wired into the coreclr build and enables the relevant compiler extensions.

Written by the indexing model from the issue text.

Description

arch-riscv area-CodeGen-coreclr

There is a need to enable certain extensions for RISC-V coreclr builds. For example, emitLoadImmediate makes heavy use of bit count intrinsics.

https://github.com/dotnet/runtime/blob/456e1fe3909c0ef47cab4471e7ede424196de668/src/coreclr/jit/emitriscv64.cpp#L1312

We can increase the JIT throughput of this function by enabling Zbb extension. This is only one example where we could improve RISC-V JIT throughput by enabling certain extensions. Other extensions, such as Zba and Zicond can improve throughput at various places.

Currently, the compiler (clang) uses the default configuration for RISC-V target, which "only" enables the rv64gc "profile".

We can use CLR_ADDITIONAL_COMPILER_OPTIONS to pass in -march=rv64gc_zbb to clang:

https://github.com/dotnet/runtime/blob/11afd861995af15d9ac0930ac069813f560e4e9f/eng/native/configurecompiler.cmake#L785-L787

But I was wondering if we should introduce a better way to enable these extensions, akin to what we have for ARM:

https://github.com/dotnet/runtime/blob/11afd861995af15d9ac0930ac069813f560e4e9f/eng/native/configurecompiler.cmake#L753-L756

There are several alternative proposals that I would like to suggest:

  • Introduce RISCV_EXTENSIONS CMake option. User can pass in Zba_Zicond_....
  • Introduce RISCV_PROFILE CMake option. User can pass in rv22, rv23, etc.
  • Introduce options for each extension that might be useful, e.g. RISCV_ZBB=1, adding it only when a need arises.
  • Change the default profile to RVA20/22/23.

cc @dotnet/samsung

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.