| 1 | name: linux-riscv64-cpu-gcc |
| 2 | on: |
| 3 | push: |
| 4 | branches: [master] |
| 5 | paths: |
| 6 | - '.github/workflows/linux-riscv64-cpu-gcc.yml' |
| 7 | - 'toolchains/riscv64-linux-gnu.toolchain.cmake' |
| 8 | - 'toolchains/riscv64-unknown-linux-gnu.toolchain.cmake' |
| 9 | - 'CMakeLists.txt' |
| 10 | - 'cmake/**' |
| 11 | - 'src/*' |
| 12 | - 'src/layer/*' |
| 13 | - 'src/layer/riscv/**' |
| 14 | - 'tests/**' |
| 15 | pull_request: |
| 16 | branches: [master] |
| 17 | paths: |
| 18 | - '.github/workflows/linux-riscv64-cpu-gcc.yml' |
| 19 | - 'toolchains/riscv64-linux-gnu.toolchain.cmake' |
| 20 | - 'toolchains/riscv64-unknown-linux-gnu.toolchain.cmake' |
| 21 | - 'CMakeLists.txt' |
| 22 | - 'cmake/**' |
| 23 | - 'src/*' |
| 24 | - 'src/layer/*' |
| 25 | - 'src/layer/riscv/**' |
| 26 | - 'tests/**' |
| 27 | concurrency: |
| 28 | group: linux-riscv64-cpu-gcc-${{ github.ref }} |
| 29 | cancel-in-progress: true |
| 30 | permissions: |
| 31 | contents: read |
| 32 | |
| 33 | jobs: |
| 34 | linux-gcc-riscv64: |
| 35 | runs-on: ubuntu-20.04 |
| 36 | steps: |
| 37 | - uses: actions/checkout@v4 |
| 38 | |
| 39 | - name: cache-qemu |
| 40 | id: cache-qemu |
| 41 | uses: actions/cache@v4 |
| 42 | with: |
| 43 | path: qemu-install |
| 44 | key: qemu-riscv64-install-20220502-4 |
| 45 | - name: install-qemu-build-deps |
| 46 | if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 47 | run: | |
| 48 | sudo apt-get update |
| 49 | sudo apt-get install autoconf automake autotools-dev ninja-build |
| 50 | - name: checkout-qemu |
| 51 | if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 52 | uses: actions/checkout@v4 |
| 53 | with: |
| 54 | repository: qemu/qemu |
| 55 | path: qemu |
| 56 | ref: f5643914a9e8f79c606a76e6a9d7ea82a3fc3e65 |
| 57 | - name: qemu |
| 58 | if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 59 | run: | |
| 60 | cd qemu |
| 61 | 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 |
| 62 | patch -p1 -i 0007-linux-user-Expose-risc-v-V-isa-bit-in-get_elf_hwcap.patch |
| 63 | ./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=riscv64-linux-user --disable-system |
| 64 | make -j$(nproc) |
| 65 | make install |
| 66 | |
| 67 | - name: riscv64-gnu-toolchain |
| 68 | run: | |
| 69 | sudo apt-get update |
| 70 | sudo apt-get install g++-riscv64-linux-gnu |
| 71 | |
| 72 | - name: configure |
| 73 | run: mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/riscv64-linux-gnu.toolchain.cmake -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF -DNCNN_BUILD_TESTS=ON .. |
| 74 | - name: build |
| 75 | run: cmake --build build -j $(nproc) |
| 76 | |
| 77 | - name: test |
| 78 | run: | |
| 79 | export PATH=$GITHUB_WORKSPACE/qemu-install/bin:$PATH |
| 80 | cd build |
| 81 | TESTS_EXECUTABLE_LOADER=qemu-riscv64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-L;/usr/riscv64-linux-gnu" ctest --output-on-failure -j $(nproc) |
| 82 | |
| 83 | linux-gcc-riscv64-c906: |
| 84 | runs-on: [self-hosted, linux, centos] |
| 85 | steps: |
| 86 | - uses: actions/checkout@v4 |
| 87 | |
| 88 | - name: configure |
| 89 | run: | |
| 90 | export RISCV_ROOT_PATH=/data/action/osd/Xuantie-900-gcc-linux-5.10.4-glibc-x86_64-V2.6.1 |
| 91 | mkdir build && cd build |
| 92 | cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/c906-v226.toolchain.cmake -DCMAKE_BUILD_TYPE=release -DNCNN_OPENMP=OFF -DNCNN_THREADS=OFF -DNCNN_RUNTIME_CPU=OFF -DNCNN_RVV=ON -DNCNN_SIMPLEOCV=ON -DNCNN_BUILD_EXAMPLES=ON -DNCNN_BUILD_TESTS=ON .. |
| 93 | - name: build |
| 94 | run: cmake --build build -j 4 |
| 95 | |
| 96 | - name: test |
| 97 | run: | |
| 98 | export PATH=/data/action/osd/xuantie-qemu-x86_64-Ubuntu-18.04-20230413-0706/bin:$PATH |
| 99 | cd build |
| 100 | TESTS_EXECUTABLE_LOADER=qemu-riscv64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-cpu;c906fdv" ctest --output-on-failure -j 4 |
| 101 | |
| 102 | linux-gcc-riscv64-rvv: |
| 103 | runs-on: [self-hosted, linux, centos] |
| 104 | steps: |
| 105 | - uses: actions/checkout@v4 |
| 106 | |
| 107 | #- name: cache-qemu |
| 108 | #id: cache-qemu |
| 109 | #uses: actions/cache@v4 |
| 110 | #with: |
| 111 | #path: qemu-install |
| 112 | #key: qemu-riscv64-install-20220502-3 |
| 113 | #- name: install-qemu-build-deps |
| 114 | #if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 115 | #run: | |
| 116 | #sudo apt-get update |
| 117 | #sudo apt-get install autoconf automake autotools-dev ninja-build |
| 118 | #- name: checkout-qemu |
| 119 | #if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 120 | #uses: actions/checkout@v4 |
| 121 | #with: |
| 122 | #repository: qemu/qemu |
| 123 | #path: qemu |
| 124 | #ref: f5643914a9e8f79c606a76e6a9d7ea82a3fc3e65 |
| 125 | #- name: qemu |
| 126 | #if: steps.cache-qemu.outputs.cache-hit != 'true' |
| 127 | #run: | |
| 128 | #cd qemu |
| 129 | #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 |
| 130 | #patch -p1 -i 0007-linux-user-Expose-risc-v-V-isa-bit-in-get_elf_hwcap.patch |
| 131 | #./configure --prefix=$GITHUB_WORKSPACE/qemu-install --target-list=riscv64-linux-user --disable-system |
| 132 | #make -j2 |
| 133 | #make install |
| 134 | |
| 135 | #- name: cache-riscv |
| 136 | #id: cache-riscv |
| 137 | #uses: actions/cache@v4 |
| 138 | #with: |
| 139 | #path: rv64gcv-install-next |
| 140 | #key: rv64gcv-linux-install-20210504 |
| 141 | |
| 142 | #- name: install-riscv-build-deps |
| 143 | #if: steps.cache-riscv.outputs.cache-hit != 'true' |
| 144 | #run: | |
| 145 | #sudo apt-get update |
| 146 | #sudo apt-get install 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 |
| 147 | |
| 148 | #- name: checkout-riscv-gnu-toolchain |
| 149 | #if: steps.cache-riscv.outputs.cache-hit != 'true' |
| 150 | #uses: actions/checkout@v4 |
| 151 | #with: |
| 152 | #repository: riscv/riscv-gnu-toolchain |
| 153 | #path: riscv-gnu-toolchain |
| 154 | #ref: da01ba455ce3802ffa84fdca3a089079996dbfc3 |
| 155 | #- name: checkout-riscv-gnu-toolchain-submodules |
| 156 | #if: steps.cache-riscv.outputs.cache-hit != 'true' |
| 157 | #run: | |
| 158 | #cd riscv-gnu-toolchain |
| 159 | #git submodule update --init --recursive --depth 1 glibc |
| 160 | #git submodule update --init --recursive --depth 1 newlib |
| 161 | #git submodule update --init --recursive --depth 1 riscv-binutils |
| 162 | #git submodule update --init --recursive --depth 1 riscv-gcc |
| 163 | #git submodule update --init --recursive --depth 1 riscv-dejagnu |
| 164 | #git submodule update --init --recursive --depth 1 riscv-gdb |
| 165 | #- name: riscv-gnu-toolchain |
| 166 | #if: steps.cache-riscv.outputs.cache-hit != 'true' |
| 167 | #run: | |
| 168 | #cd riscv-gnu-toolchain |
| 169 | #sed -i '/__OBSOLETE_MATH/d' newlib/newlib/libm/common/math_errf.c |
| 170 | #./configure --prefix=$GITHUB_WORKSPACE/rv64gcv-install-next --with-arch=rv64gcv_zfh |
| 171 | #make linux |
| 172 | |
| 173 | #- name: riscv-strip-install |
| 174 | #if: steps.cache-riscv.outputs.cache-hit != 'true' |
| 175 | #run: find $GITHUB_WORKSPACE/rv64gcv-install-next -type f | xargs -i strip -g {} || true |
| 176 | |
| 177 | - name: configure |
| 178 | run: export RISCV_ROOT_PATH=/data/action/osd/rv64gcv-install-next && mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/riscv64-unknown-linux-gnu.toolchain.cmake -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF -DNCNN_BUILD_TESTS=ON .. |
| 179 | - name: build |
| 180 | run: cmake --build build -j 4 |
| 181 | |
| 182 | - name: test-vlen256 |
| 183 | run: | |
| 184 | export PATH=/data/action/osd/qemu-install/bin:$PATH |
| 185 | cd build |
| 186 | TESTS_EXECUTABLE_LOADER=qemu-riscv64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-cpu;rv64,v=true,Zfh=true,vlen=256,elen=64,vext_spec=v1.0;-L;/data/action/osd/rv64gcv-install-next/sysroot" ctest --output-on-failure -j 4 |
| 187 | |
| 188 | - name: test-vlen128 |
| 189 | run: | |
| 190 | export PATH=/data/action/osd/qemu-install/bin:$PATH |
| 191 | cd build |
| 192 | TESTS_EXECUTABLE_LOADER=qemu-riscv64 TESTS_EXECUTABLE_LOADER_ARGUMENTS="-cpu;rv64,v=true,Zfh=true,vlen=128,elen=64,vext_spec=v1.0;-L;/data/action/osd/rv64gcv-install-next/sysroot" ctest --output-on-failure -j 4 |