Skip to content

[OpenMP][RISCV] Add riscv32 support #99494

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wangpc-pp
Copy link
Contributor

CMake flags and some core changes are added to support riscv32
platform basically.

Fix #99427

@llvmbot llvmbot added openmp:libomp OpenMP host runtime openmp:libomptarget OpenMP offload runtime labels Jul 18, 2024
@asb asb requested review from mikhailramalho and removed request for asb July 18, 2024 15:16
@asb
Copy link
Contributor

asb commented Jul 18, 2024

Tagging my colleague @mikhailramalho who's been doing some RV32 stuff recently so can at least provide additional testing if not a full code review.

@mikhailramalho
Copy link
Member

@wangpc-pp could you provide instructions on how to test this patch?

I can use the setup I have to test libc to test your patch.

@wangpc-pp
Copy link
Contributor Author

@wangpc-pp could you provide instructions on how to test this patch?

I can use the setup I have to test libc to test your patch.

Thanks!
The process can be:

  1. Build a rv32 Clang/LLVM toolchian.
  2. Build openmp and install it to the above toolchain:
cmake -DCMAKE_INSTALL_PREFIX=${TOOLCHAIN_PATH} \
    -DCMAKE_C_COMPILER=${TOOLCHAIN_PATH}/bin/clang \
    -DCMAKE_CXX_COMPILER=${TOOLCHAIN_PATH}/bin/clang++ \
    -DOPENMP_ENABLE_LIBOMPTARGET=Off \
    -DCMAKE_C_FLAGS="-march=rv32gc" \
    -DCMAKE_CXX_FLAGS="-march=rv32gc" \
    -DCMAKE_BUILD_TYPE=Release \
    -DLIBOMP_ARCH=riscv32 \
    -DLIBOMP_HAVE_WARN_SHARED_TEXTREL_FLAG=On \
    -DLIBOMP_HAVE_AS_NEEDED_FLAG=On \
    -DLIBOMP_HAVE_VERSION_SCRIPT_FLAG=On \
    -DLIBOMP_HAVE_STATIC_LIBGCC_FLAG=On \
    -DLIBOMP_HAVE_Z_NOEXECSTACK_FLAG=On \
    -DDISABLE_OMPD_GDB_PLUGIN=On \
    -DLIBOMP_OMPD_GDB_SUPPORT=Off \
    -DLIBOMP_ENABLE_SHARED=ON \
    ../openmp

You may set LIBOMP_ENABLE_SHARED to OFF to build static libraries.
3. Compile and run tests under openmp/runtime/src.

Copy link
Contributor

You may also need changes in OMPT and OMPD. They are arch dependent I think.

@wangpc-pp
Copy link
Contributor Author

You may also need changes in OMPT and OMPD. They are arch dependent I think.

I just searched "riscv64" and made riscv32 changes around riscv64 codes. We may not need to change OMPT/OMPD, or they are lack of riscv64 support?

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

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

The structure of the code change looks good to me, but I'm not familiar with RISC-V arch so I'm not sure the technical soundness of the asm changes. I suppose it has been tested.

@dtcxzyw
Copy link
Member

dtcxzyw commented Nov 16, 2024

Reverse ping.

CMake flags and some core changes are added to support riscv32
platform basically.

Fix llvm#99427
@wangpc-pp
Copy link
Contributor Author

Reverse ping.

I can't guarantee the correctness of this implementation... It's hard to test.

@shiltian
Copy link
Contributor

We need to test it to ensure that most of it works as expected.

@jprotze
Copy link
Collaborator

jprotze commented Nov 18, 2024

For ompt, only the tests use some arch/isa specific assumptions. If the tests succeed, no changes are necessary. Otherwise, some tweaks might be necessary in runtime/test/ompt/callback.h look for ARCH specific code.

Ompd is usually only activated for selected supported architectures. If you want to support OpenMP debugging for the architecture, you would need to check whether it works out of the box, or whether changes are necessary.

@joshua-arch1
Copy link
Contributor

Can you run the suite https://github.com/OpenMP-Validation-and-Verification/OpenMP_VV? Actually there are several tests failed for riscv64. I think what we need to do now is to improve the riscv64 implementation first and then riscv32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime openmp:libomptarget OpenMP offload runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenMP project can't be built on riscv32 platforms
10 participants