Skip to content

Commit

Permalink
port rvv intrinsic 1.0+ (#5642)
Browse files Browse the repository at this point in the history
* zfh zvfh xtheadvector infra
* dispatch for rvv and xtheadvector
* dispatch for non-vector zfh
* port xtheadvector recp rsqrt trunc
* general rvv gemm
* c906 and c910 ci
* old tuple code clean
* update riscv64 ci
* update build doc
* drop old th1520 toolchain
  • Loading branch information
nihui authored Dec 4, 2024
1 parent 3d224f2 commit 19caca3
Show file tree
Hide file tree
Showing 174 changed files with 16,980 additions and 18,054 deletions.
143 changes: 0 additions & 143 deletions .ci/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -840,149 +840,6 @@ jobs:
- name: codecov
run: ./codecov -t ${{settings.CODECOV_TOKEN.access_token}} -C ${{ ci.sha }} -B ${{ ci.head_ref }} -f build/lcov.info

linux-gcc-riscv64-rvv:
name: linux-gcc-riscv64-rvv
strategy:
matrix:
OPENMP: ['OFF', 'ON']

runs-on:
pool-name: docker
container:
image: bkci/ci:ubuntu
steps:
- name: checkout
checkout: self
with:
strategy: FRESH_CHECKOUT
enableSubmodule: false
enableGitLfs: false

- name: install-deps
run: |
apt-get update
apt-get install -y lcov libcapstone4 libglib2.0-0
curl https://uploader.codecov.io/verification.gpg | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -Os https://uploader.codecov.io/latest/linux/codecov
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x codecov
- name: cache-qemu
id: cache-qemu
uses: cache@1.*
with:
cachePaths: qemu-install
cacheKey: qemu-riscv64-install-20230624-1

- name: checkout-qemu
if: steps.cache-qemu.outputs.cacheHit != 'true'
checkout: https://github.com/qemu/qemu.git
with:
pullType: COMMIT_ID
refName: b455ce4c2f300c8ba47cba7232dd03261368a4cb
localPath: qemu
enableSubmodule: false
enableGitLfs: false

- name: qemu
if: steps.cache-qemu.outputs.cacheHit != 'true'
run: |
echo 'deb-src http://mirrors.cloud.tencent.com/debian bullseye main' | tee -a /etc/apt/sources.list
echo 'deb-src http://mirrors.cloud.tencent.com/debian bullseye-updates main' | tee -a /etc/apt/sources.list
apt-get update
apt-get build-dep -y qemu
apt-get install -y python3-pip
python3 -m pip install --upgrade pip
apt-get remove -y python3-setuptools
pip3 install -U setuptools
cd qemu
wget https://raw.githubusercontent.com/nihui/ncnn-assets/master/qemu-patches/0007-linux-user-Expose-risc-v-V-isa-bit-in-get_elf_hwcap.patch
patch -p1 -i 0007-linux-user-Expose-risc-v-V-isa-bit-in-get_elf_hwcap.patch
./configure --prefix=${{ci.workspace}}/qemu-install --target-list=riscv64-linux-user --disable-system
make -j$(nproc)
make install
- name: cache-rv64gcv
id: cache-rv64gcv
uses: cache@1.*
with:
cachePaths: rv64gcv-install
cacheKey: rv64gcv-linux-install-20221029-1

- name: checkout-riscv-gnu-toolchain
if: steps.cache-rv64gcv.outputs.cacheHit != 'true'
checkout: https://github.com/riscv/riscv-gnu-toolchain.git
with:
pullType: COMMIT_ID
refName: da01ba455ce3802ffa84fdca3a089079996dbfc3
localPath: riscv-gnu-toolchain
enableSubmodule: false
enableGitLfs: false

- name: riscv-gnu-toolchain
if: steps.cache-rv64gcv.outputs.cacheHit != 'true'
run: |
apt-get update
apt-get install -y autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev device-tree-compiler
cd riscv-gnu-toolchain
git submodule update --init --recursive --depth 1 glibc
git submodule update --init --recursive --depth 1 newlib
#git submodule update --init --recursive --depth 1 riscv-binutils
#git submodule update --init --recursive --depth 1 riscv-gcc
git submodule update --init --recursive --depth 1 riscv-dejagnu
git submodule update --init --recursive --depth 1 riscv-gdb
rm -rf riscv-binutils
git clone -b binutils-2_39-branch https://sourceware.org/git/binutils-gdb.git riscv-binutils
rm -rf riscv-gcc
git clone -b riscv-gcc-rvv-next https://github.com/riscv-collab/riscv-gcc.git riscv-gcc
cd riscv-gcc
git checkout 8a0c1b106f01c455a8fb478cfe52d859a69020fd
cd ..
sed -i '/__OBSOLETE_MATH/d' newlib/newlib/libm/common/math_errf.c
./configure --prefix=${{ci.workspace}}/rv64gcv-install --with-arch=rv64gcv_zfh
make linux -j$(nproc)
find ${{ci.workspace}}/rv64gcv-install -type f | xargs -i strip -g {} || true
- name: build
run: |
export RISCV_ROOT_PATH=${{ci.workspace}}/rv64gcv-install
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/riscv64-unknown-linux-gnu.toolchain.cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_C_FLAGS="-O1" -DCMAKE_CXX_FLAGS="-O1" -DNCNN_COVERAGE=ON -DNCNN_RUNTIME_CPU=OFF -DNCNN_RVV=ON -DNCNN_OPENMP=${{matrix.OPENMP}} -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF -DNCNN_BUILD_TESTS=ON ..
cmake --build . -j 4
- name: test-vlen128
run: |
export PATH=${{ci.workspace}}/qemu-install/bin:$PATH
cd build
TESTS_EXECUTABLE_LOADER=qemu-riscv64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-cpu;rv64,v=true,Zfh=true,x-zvfh=true,vlen=128,elen=64,vext_spec=v1.0;-L;${{ci.workspace}}/rv64gcv-install/sysroot" ctest --output-on-failure -j 4
- name: lcov-collect-vlen128
run: |
cd build
lcov --gcov-tool ${{ci.workspace}}/rv64gcv-install/bin/riscv64-unknown-linux-gnu-gcov -d ./src -c -o lcov.info
lcov -r lcov.info '/usr/*' -o lcov.info
lcov -r lcov.info '*/build/*' -o lcov.info
lcov -r lcov.info '*/rv64gcv-install/*' -o lcov.info
lcov --list lcov.info
- name: codecov-vlen128
run: ./codecov -t ${{settings.CODECOV_TOKEN.access_token}} -C ${{ ci.sha }} -B ${{ ci.head_ref }} -f build/lcov.info
- name: test-vlen256
run: |
export PATH=${{ci.workspace}}/qemu-install/bin:$PATH
cd build
TESTS_EXECUTABLE_LOADER=qemu-riscv64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-cpu;rv64,v=true,Zfh=true,x-zvfh=true,vlen=256,elen=64,vext_spec=v1.0;-L;${{ci.workspace}}/rv64gcv-install/sysroot" ctest --output-on-failure -j 4
- name: lcov-collect-vlen256
run: |
cd build
lcov --gcov-tool ${{ci.workspace}}/rv64gcv-install/bin/riscv64-unknown-linux-gnu-gcov -d ./src -c -o lcov.info
lcov -r lcov.info '/usr/*' -o lcov.info
lcov -r lcov.info '*/build/*' -o lcov.info
lcov -r lcov.info '*/rv64gcv-install/*' -o lcov.info
lcov --list lcov.info
- name: codecov-vlen256
run: ./codecov -t ${{settings.CODECOV_TOKEN.access_token}} -C ${{ ci.sha }} -B ${{ ci.head_ref }} -f build/lcov.info

linux-gcc-loongarch64:
name: linux-gcc-loongarch64
strategy:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'src/*'
- 'src/layer/*'
- 'src/layer/arm/**'
- 'src/layer/riscv/**'
- 'src/layer/x86/**'
- 'src/layer/vulkan/**'
pull_request:
Expand All @@ -20,6 +21,7 @@ on:
- 'src/*'
- 'src/layer/*'
- 'src/layer/arm/**'
- 'src/layer/riscv/**'
- 'src/layer/x86/**'
- 'src/layer/vulkan/**'
concurrency:
Expand Down Expand Up @@ -64,6 +66,11 @@ jobs:
mkdir build-x86_64 && cd build-x86_64
cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" ..
cmake --build . -j $(nproc)
- name: riscv64
run: |
mkdir build-riscv64 && cd build-riscv64
cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DANDROID_ABI="riscv64" ..
cmake --build . -j $(nproc)
- name: armeabi-v7a-shared
run: |
Expand All @@ -85,6 +92,11 @@ jobs:
mkdir build-x86_64-shared && cd build-x86_64-shared
cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DANDROID_ABI="x86_64" -DNCNN_SHARED_LIB=ON ..
cmake --build . -j $(nproc)
- name: riscv64-shared
run: |
mkdir build-riscv64-shared && cd build-riscv64-shared
cmake ${{ env.NCNN_CMAKE_OPTIONS }} -DANDROID_ABI="riscv64" -DNCNN_SHARED_LIB=ON ..
cmake --build . -j $(nproc)
ndk-r16b:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: elf-riscv32-cpu-gcc
name: elf-riscv32
on:
push:
branches: [master]
paths:
- '.github/workflows/elf-riscv32-cpu-gcc.yml'
- '.github/workflows/elf-riscv32.yml'
- 'toolchains/riscv32-unknown-elf.toolchain.cmake'
- 'CMakeLists.txt'
- 'cmake/**'
Expand All @@ -14,7 +14,7 @@ on:
pull_request:
branches: [master]
paths:
- '.github/workflows/elf-riscv32-cpu-gcc.yml'
- '.github/workflows/elf-riscv32.yml'
- 'toolchains/riscv32-unknown-elf.toolchain.cmake'
- 'CMakeLists.txt'
- 'cmake/**'
Expand All @@ -23,7 +23,7 @@ on:
- 'src/layer/riscv/**'
- 'tests/**'
concurrency:
group: elf-riscv32-cpu-gcc-${{ github.ref }}
group: elf-riscv32-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: elf-riscv64-cpu-gcc
name: elf-riscv64
on:
push:
branches: [master]
paths:
- '.github/workflows/elf-riscv64-cpu-gcc.yml'
- '.github/workflows/elf-riscv64.yml'
- 'toolchains/riscv64-unknown-elf.toolchain.cmake'
- 'CMakeLists.txt'
- 'cmake/**'
Expand All @@ -14,7 +14,7 @@ on:
pull_request:
branches: [master]
paths:
- '.github/workflows/elf-riscv64-cpu-gcc.yml'
- '.github/workflows/elf-riscv64.yml'
- 'toolchains/riscv64-unknown-elf.toolchain.cmake'
- 'CMakeLists.txt'
- 'cmake/**'
Expand All @@ -23,7 +23,7 @@ on:
- 'src/layer/riscv/**'
- 'tests/**'
concurrency:
group: elf-riscv64-cpu-gcc-${{ github.ref }}
group: elf-riscv64-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: linux-aarch64-cpu-gcc
name: linux-aarch64
on:
push:
branches: [master]
paths:
- '.github/workflows/linux-aarch64-cpu-gcc.yml'
- '.github/workflows/linux-aarch64.yml'
- 'toolchains/aarch64-linux-gnu.toolchain.cmake'
- 'CMakeLists.txt'
- 'cmake/**'
Expand All @@ -14,7 +14,7 @@ on:
pull_request:
branches: [master]
paths:
- '.github/workflows/linux-aarch64-cpu-gcc.yml'
- '.github/workflows/linux-aarch64.yml'
- 'toolchains/aarch64-linux-gnu.toolchain.cmake'
- 'CMakeLists.txt'
- 'cmake/**'
Expand All @@ -23,13 +23,13 @@ on:
- 'src/layer/arm/**'
- 'tests/**'
concurrency:
group: linux-aarch64-cpu-gcc-${{ github.ref }}
group: linux-aarch64-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read

jobs:
linux-gcc:
gcc-aarch64:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
cd build-simplestl-simplemath
TESTS_EXECUTABLE_LOADER=qemu-aarch64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/aarch64-linux-gnu" ctest --output-on-failure -j $(nproc)
linux-gcc-arm82:
gcc-arm82:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
cd build-noint8
TESTS_EXECUTABLE_LOADER=qemu-aarch64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/aarch64-linux-gnu" ctest --output-on-failure -j $(nproc)
linux-gcc-arm86:
gcc-arm86:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: linux-arm-cpu-gcc
name: linux-arm
on:
push:
branches: [master]
paths:
- '.github/workflows/linux-arm-cpu-gcc.yml'
- '.github/workflows/linux-arm.yml'
- 'toolchains/arm-linux-gnueabi.toolchain.cmake'
- 'toolchains/arm-linux-gnueabihf.toolchain.cmake'
- 'CMakeLists.txt'
Expand All @@ -15,7 +15,7 @@ on:
pull_request:
branches: [master]
paths:
- '.github/workflows/linux-arm-cpu-gcc.yml'
- '.github/workflows/linux-arm.yml'
- 'toolchains/arm-linux-gnueabi.toolchain.cmake'
- 'toolchains/arm-linux-gnueabihf.toolchain.cmake'
- 'CMakeLists.txt'
Expand All @@ -25,13 +25,13 @@ on:
- 'src/layer/arm/**'
- 'tests/**'
concurrency:
group: linux-arm-cpu-gcc-${{ github.ref }}
group: linux-arm-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read

jobs:
linux-gcc-arm:
gcc-arm:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
cd build-noint8
TESTS_EXECUTABLE_LOADER=qemu-arm TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/arm-linux-gnueabi" ctest --output-on-failure -j $(nproc)
linux-gcc-armhf:
gcc-armhf:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
cd build-noint8
TESTS_EXECUTABLE_LOADER=qemu-arm TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/arm-linux-gnueabihf" ctest --output-on-failure -j $(nproc)
linux-gcc-armhf-vfpv3-d16:
gcc-armhf-vfpv3-d16:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: linux-loongarch64-cpu-gcc
name: linux-loongarch64
on:
push:
branches: [master]
paths:
- '.github/workflows/linux-loongarch64-cpu-gcc.yml'
- '.github/workflows/linux-loongarch64.yml'
- 'toolchains/loongarch64-linux-gnu.toolchain.cmake'
- 'toolchains/loongarch64-unknown-linux-gnu.toolchain.cmake'
- 'CMakeLists.txt'
Expand All @@ -15,7 +15,7 @@ on:
pull_request:
branches: [master]
paths:
- '.github/workflows/linux-loongarch64-cpu-gcc.yml'
- '.github/workflows/linux-loongarch64.yml'
- 'toolchains/loongarch64-linux-gnu.toolchain.cmake'
- 'toolchains/loongarch64-unknown-linux-gnu.toolchain.cmake'
- 'CMakeLists.txt'
Expand All @@ -25,13 +25,13 @@ on:
- 'src/layer/loongarch/**'
- 'tests/**'
concurrency:
group: linux-loongarch64-cpu-gcc-${{ github.ref }}
group: linux-loongarch64-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read

jobs:
linux-gcc-loongarch64:
gcc-loongarch64:
runs-on: [self-hosted, linux, centos]

steps:
Expand Down
Loading

0 comments on commit 19caca3

Please sign in to comment.