-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add RISC-V Vector extension (RVV) kernels
Signed-off-by: Olaf Bernstein <[email protected]>
- Loading branch information
Showing
147 changed files
with
5,321 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# | ||
# Copyright 2020 - 2022 Free Software Foundation, Inc. | ||
# | ||
# This file is part of VOLK | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
# | ||
|
||
name: Run VOLK tests on different RVV configurations | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
Tests: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install packages | ||
run: | | ||
git submodule update --init --recursive | ||
sudo apt-get update -q -y | ||
sudo apt-get install -y python3-mako cmake qemu-user-static g++-14-riscv64-linux-gnu clang-18 | ||
mkdir build | ||
cd build | ||
- name: Test gcc-14 VLEN=128 | ||
run: | | ||
cd build; rm -rf * | ||
CXX=riscv64-linux-gnu-g++-14 CC=riscv64-linux-gnu-gcc-14 VLEN=128 \ | ||
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/rv64gcv-linux-gnu.cmake .. | ||
make -j$(nproc) | ||
ARGS=-j$(nproc) make test | ||
- name: Test clang-18 VLEN=256 | ||
run: | | ||
cd build; rm -rf * | ||
CXX=clang++-18 CC=clang-18 CFLAGS=--target=riscv64-linux-gnu VLEN=256 \ | ||
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/rv64gcv-linux-gnu.cmake .. | ||
make -j$(nproc) | ||
ARGS=-j$(nproc) make test | ||
- name: Test clang-18 VLEN=512 | ||
run: | | ||
cd build; rm -rf * | ||
CXX=clang++-18 CC=clang-18 CFLAGS=--target=riscv64-linux-gnu VLEN=512 \ | ||
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/rv64gcv-linux-gnu.cmake .. | ||
make -j$(nproc) | ||
ARGS=-j$(nproc) make test | ||
- name: Test clang-18 VLEN=1024 | ||
run: | | ||
cd build; rm -rf * | ||
CXX=clang++-18 CC=clang-18 CFLAGS=--target=riscv64-linux-gnu VLEN=1024 \ | ||
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchains/rv64gcv-linux-gnu.cmake .. | ||
make -j$(nproc) | ||
ARGS=-j$(nproc) make test | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#if (__riscv_v_intrinsic >= 1000000 || __clang_major__ >= 18 || __GNUC__ >= 14) | ||
int main() { return 0; } | ||
#else | ||
#error "rvv intrinsics aren't supported" | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# | ||
# Copyright 2024 Free Software Foundation, Inc. | ||
# | ||
# This file is part of VOLK | ||
# | ||
# SPDX-License-Identifier: LGPL-3.0-or-later | ||
# | ||
|
||
set(CMAKE_SYSTEM_NAME Linux) | ||
set(CMAKE_SYSTEM_PROCESSOR riscv64) | ||
|
||
set(CMAKE_C_COMPILER $ENV{CC}) | ||
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) | ||
set(CMAKE_CXX_COMPILER $ENV{CXX}) | ||
|
||
set(CMAKE_C_FLAGS "$ENV{CFLAGS} -march=rv64gcv" CACHE STRING "" FORCE) | ||
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE) | ||
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -g" CACHE STRING "" FORCE) | ||
|
||
set(CMAKE_OBJCOPY | ||
${RISCV64_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy | ||
CACHE INTERNAL "objcopy tool") | ||
set(CMAKE_SIZE_UTIL | ||
${RISCV64_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size | ||
CACHE INTERNAL "size tool") | ||
|
||
set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH}) | ||
|
||
set(QEMU_VLEN $ENV{VLEN}) | ||
if(NOT QEMU_VLEN) | ||
set(QEMU_VLEN "128") | ||
endif() | ||
|
||
set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-riscv64-static -L /usr/riscv64-linux-gnu/ -cpu rv64,zba=true,zbb=true,v=on,vlen=${QEMU_VLEN},rvv_ta_all_1s=on,rvv_ma_all_1s=on") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Copyright 2024 Free Software Foundation, Inc. | ||
* | ||
* This file is part of VOLK | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
|
||
/* | ||
* This file is intended to hold RVV intrinsics of intrinsics. | ||
* They should be used in VOLK kernels to avoid copy-paste. | ||
*/ | ||
|
||
#ifndef INCLUDE_VOLK_VOLK_RVV_INTRINSICS_H_ | ||
#define INCLUDE_VOLK_VOLK_RVV_INTRINSICS_H_ | ||
#include <riscv_vector.h> | ||
|
||
#define RISCV_SHRINK2(op,T,S,v) __riscv_##op( \ | ||
__riscv_vget_##T##S##m1(v, 0), \ | ||
__riscv_vget_##T##S##m1(v, 1), \ | ||
__riscv_vsetvlmax_e##S##m1()) | ||
|
||
#define RISCV_SHRINK4(op,T,S,v) __riscv_##op( \ | ||
__riscv_##op(__riscv_vget_##T##S##m1(v, 0), \ | ||
__riscv_vget_##T##S##m1(v, 1), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_##op(__riscv_vget_##T##S##m1(v, 2), \ | ||
__riscv_vget_##T##S##m1(v, 3), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_vsetvlmax_e##S##m1()) | ||
|
||
#define RISCV_SHRINK8(op,T,S,v) __riscv_##op( \ | ||
__riscv_##op(__riscv_##op(__riscv_vget_##T##S##m1(v, 0), \ | ||
__riscv_vget_##T##S##m1(v, 1), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_##op(__riscv_vget_##T##S##m1(v, 2), \ | ||
__riscv_vget_##T##S##m1(v, 3), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_##op(__riscv_##op(__riscv_vget_##T##S##m1(v, 4), \ | ||
__riscv_vget_##T##S##m1(v, 5), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_##op(__riscv_vget_##T##S##m1(v, 6), \ | ||
__riscv_vget_##T##S##m1(v, 7), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_vsetvlmax_e##S##m1()), \ | ||
__riscv_vsetvlmax_e##S##m1()) | ||
|
||
#define RISCV_PERM8(f,v,vidx) __riscv_vcreate_v_u8m1_u8m8( \ | ||
f(__riscv_vget_u8m1(v, 0), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 1), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 2), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 3), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 4), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 5), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 6), vidx, __riscv_vsetvlmax_e8m1()), \ | ||
f(__riscv_vget_u8m1(v, 7), vidx, __riscv_vsetvlmax_e8m1())) | ||
|
||
#define RISCV_LUT8(f,vtbl,v) __riscv_vcreate_v_u8m1_u8m8( \ | ||
f(vtbl, __riscv_vget_u8m1(v, 0), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 1), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 2), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 3), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 4), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 5), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 6), __riscv_vsetvlmax_e8m1()), \ | ||
f(vtbl, __riscv_vget_u8m1(v, 7), __riscv_vsetvlmax_e8m1())) | ||
|
||
|
||
#define RISCV_VMFLTZ(T,v,vl) __riscv_vmslt(__riscv_vreinterpret_i##T(v), 0, vl) | ||
|
||
#endif /* INCLUDE_VOLK_VOLK_RVV_INTRINSICS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.