| @@ -0,0 +1,196 @@ | |||
| name: elf-riscv64-cpu-gcc | |||
| on: [push, pull_request] | |||
| jobs: | |||
| newlib-rv64gcv-gcc: | |||
| runs-on: ubuntu-20.04 | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
| with: | |||
| submodules: true | |||
| - name: cache-riscv | |||
| id: cache-riscv | |||
| uses: actions/cache@v1 | |||
| with: | |||
| path: rv64gcv-install | |||
| key: rv64gcv-newlib-install | |||
| - name: install-riscv-build-deps | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| sudo apt-get update | |||
| 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 | |||
| - name: checkout-riscv-gnu-toolchain | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v2 | |||
| with: | |||
| repository: riscv/riscv-gnu-toolchain | |||
| path: riscv-gnu-toolchain | |||
| ref: 5842fde8ee5bb3371643b60ed34906eff7a5fa31 | |||
| - name: checkout-riscv-gnu-toolchain-submodules | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-gnu-toolchain | |||
| 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-glibc | |||
| git submodule update --init --recursive --depth 1 riscv-dejagnu | |||
| git submodule update --init --recursive --depth 1 riscv-newlib | |||
| git submodule update --init --recursive --depth 1 riscv-gdb | |||
| - name: riscv-gnu-toolchain | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-gnu-toolchain | |||
| sed -i '/__OBSOLETE_MATH/d' riscv-newlib/newlib/libm/common/math_errf.c | |||
| ./configure --prefix=$GITHUB_WORKSPACE/rv64gcv-install --with-arch=rv64gcv | |||
| make -j2 | |||
| - name: checkout-riscv-pk | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v2 | |||
| with: | |||
| repository: riscv/riscv-pk | |||
| path: riscv-pk | |||
| ref: 5d9ed238e1cabfbca3c47f50d32894ce94bfc304 | |||
| - name: riscv-pk | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-pk | |||
| mkdir build | |||
| cd build | |||
| export PATH=$GITHUB_WORKSPACE/rv64gcv-install/bin:$PATH | |||
| ../configure --prefix=$GITHUB_WORKSPACE/rv64gcv-install --with-arch=rv64gcv --host=riscv64-unknown-elf | |||
| make -j2 | |||
| make install | |||
| - name: checkout-riscv-isa-sim | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v2 | |||
| with: | |||
| repository: riscv/riscv-isa-sim | |||
| path: riscv-isa-sim | |||
| ref: ecc039ef5726315b7e37e8a9c7b682bbe09c9cf5 | |||
| - name: riscv-isa-sim | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-isa-sim | |||
| mkdir build | |||
| cd build | |||
| export PATH=$GITHUB_WORKSPACE/rv64gcv-install/bin:$PATH | |||
| ../configure --prefix=$GITHUB_WORKSPACE/rv64gcv-install --with-isa=rv64gcv | |||
| make -j2 | |||
| make install | |||
| - name: riscv-strip-install | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: find $GITHUB_WORKSPACE/rv64gcv-install -type f | xargs -i strip -g {} || true | |||
| - name: configure | |||
| run: export RISCV_ROOT_PATH=$GITHUB_WORKSPACE/rv64gcv-install && mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/riscv64-unknown-elf.toolchain.cmake -DNCNN_THREADS=OFF -DNCNN_OPENMP=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| - name: build | |||
| run: cmake --build build -j 2 | |||
| - name: test | |||
| run: | | |||
| sudo apt-get update | |||
| sudo apt-get install device-tree-compiler | |||
| export PATH=$GITHUB_WORKSPACE/rv64gcv-install/bin:$PATH | |||
| cd build | |||
| TESTS_EXECUTABLE_LOADER=spike TESTS_EXECUTABLE_LOADER_ARGUMENTS=$GITHUB_WORKSPACE/rv64gcv-install/riscv64-unknown-elf/bin/pk ctest --output-on-failure -j 2 | |||
| newlib-rv64gc-gcc: | |||
| runs-on: ubuntu-20.04 | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
| with: | |||
| submodules: true | |||
| - name: cache-riscv | |||
| id: cache-riscv | |||
| uses: actions/cache@v1 | |||
| with: | |||
| path: rv64gc-install | |||
| key: rv64gc-newlib-install | |||
| - name: install-riscv-build-deps | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| sudo apt-get update | |||
| 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 | |||
| - name: checkout-riscv-gnu-toolchain | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v2 | |||
| with: | |||
| repository: riscv/riscv-gnu-toolchain | |||
| path: riscv-gnu-toolchain | |||
| ref: 256a4108922f76403a63d6567501c479971d5575 | |||
| - name: checkout-riscv-gnu-toolchain-submodules | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-gnu-toolchain | |||
| 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-glibc | |||
| git submodule update --init --recursive --depth 1 riscv-dejagnu | |||
| git submodule update --init --recursive --depth 1 riscv-newlib | |||
| git submodule update --init --recursive --depth 1 riscv-gdb | |||
| - name: riscv-gnu-toolchain | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-gnu-toolchain | |||
| sed -i '/__OBSOLETE_MATH/d' riscv-newlib/newlib/libm/common/math_errf.c | |||
| ./configure --prefix=$GITHUB_WORKSPACE/rv64gc-install --with-arch=rv64gc | |||
| make -j2 | |||
| - name: checkout-riscv-pk | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v2 | |||
| with: | |||
| repository: riscv/riscv-pk | |||
| path: riscv-pk | |||
| ref: 5d9ed238e1cabfbca3c47f50d32894ce94bfc304 | |||
| - name: riscv-pk | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-pk | |||
| mkdir build | |||
| cd build | |||
| export PATH=$GITHUB_WORKSPACE/rv64gc-install/bin:$PATH | |||
| ../configure --prefix=$GITHUB_WORKSPACE/rv64gc-install --with-arch=rv64gc --host=riscv64-unknown-elf | |||
| make -j2 | |||
| make install | |||
| - name: checkout-riscv-isa-sim | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| uses: actions/checkout@v2 | |||
| with: | |||
| repository: riscv/riscv-isa-sim | |||
| path: riscv-isa-sim | |||
| ref: ecc039ef5726315b7e37e8a9c7b682bbe09c9cf5 | |||
| - name: riscv-isa-sim | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: | | |||
| cd riscv-isa-sim | |||
| mkdir build | |||
| cd build | |||
| export PATH=$GITHUB_WORKSPACE/rv64gc-install/bin:$PATH | |||
| ../configure --prefix=$GITHUB_WORKSPACE/rv64gc-install --with-isa=rv64gc | |||
| make -j2 | |||
| make install | |||
| - name: riscv-strip-install | |||
| if: steps.cache-riscv.outputs.cache-hit != 'true' | |||
| run: find $GITHUB_WORKSPACE/rv64gc-install -type f | xargs -i strip -g {} || true | |||
| - name: configure | |||
| run: export RISCV_ROOT_PATH=$GITHUB_WORKSPACE/rv64gc-install && mkdir build && cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../toolchains/riscv64-unknown-elf.toolchain.cmake -DNCNN_THREADS=OFF -DNCNN_OPENMP=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| - name: build | |||
| run: cmake --build build -j 2 | |||
| - name: test | |||
| run: | | |||
| sudo apt-get update | |||
| sudo apt-get install device-tree-compiler | |||
| export PATH=$GITHUB_WORKSPACE/rv64gc-install/bin:$PATH | |||
| cd build | |||
| TESTS_EXECUTABLE_LOADER=spike TESTS_EXECUTABLE_LOADER_ARGUMENTS=$GITHUB_WORKSPACE/rv64gc-install/riscv64-unknown-elf/bin/pk ctest --output-on-failure -j 2 | |||
| @@ -87,30 +87,6 @@ jobs: | |||
| - name: test | |||
| run: cd build && ctest --output-on-failure -j 2 | |||
| linux-clang-nostdio-simplestl: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
| - name: configure | |||
| env: | |||
| CC: clang | |||
| CXX: clang++ | |||
| run: mkdir build && cd build && cmake -DNCNN_STDIO=OFF -DNCNN_STRING=ON -DNCNN_SIMPLESTL=ON -DNCNN_BUILD_TESTS=OFF -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| - name: build | |||
| run: cmake --build build -j 2 | |||
| linux-clang-nostring-simplestl: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
| - name: configure | |||
| env: | |||
| CC: clang | |||
| CXX: clang++ | |||
| run: mkdir build && cd build && cmake -DNCNN_STDIO=ON -DNCNN_STRING=OFF -DNCNN_SIMPLESTL=ON -DNCNN_BUILD_TESTS=OFF -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| - name: build | |||
| run: cmake --build build -j 2 | |||
| linux-clang-nostdio-nostring-simplestl: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| @@ -69,24 +69,6 @@ jobs: | |||
| - name: test | |||
| run: cd build && ctest --output-on-failure -j 2 | |||
| linux-gcc-nostdio-simplestl: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
| - name: configure | |||
| run: mkdir build && cd build && cmake -DNCNN_STDIO=OFF -DNCNN_STRING=ON -DNCNN_SIMPLESTL=ON -DNCNN_BUILD_TESTS=OFF -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| - name: build | |||
| run: cmake --build build -j 2 | |||
| linux-gcc-nostring-simplestl: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
| - name: configure | |||
| run: mkdir build && cd build && cmake -DNCNN_STDIO=ON -DNCNN_STRING=OFF -DNCNN_SIMPLESTL=ON -DNCNN_BUILD_TESTS=OFF -DNCNN_BUILD_BENCHMARK=OFF -DNCNN_BUILD_TOOLS=OFF -DNCNN_BUILD_EXAMPLES=OFF .. | |||
| - name: build | |||
| run: cmake --build build -j 2 | |||
| linux-gcc-nostdio-nostring-simplestl: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| @@ -27,7 +27,7 @@ jobs: | |||
| - name: build | |||
| run: cmake --build build --config Release -j 2 | |||
| - name: test | |||
| run: cd build; ctest --output-on-failure -j 2 | |||
| run: cd build; ctest -C Release --output-on-failure -j 2 | |||
| windows-vs2019-avx2: | |||
| runs-on: windows-latest | |||
| @@ -55,7 +55,7 @@ jobs: | |||
| - name: build | |||
| run: cmake --build build --config Release -j 2 | |||
| - name: test | |||
| run: cd build; ctest --output-on-failure -j 2 | |||
| run: cd build; ctest -C Release --output-on-failure -j 2 | |||
| windows-vs2019-nostdio-nostring: | |||
| runs-on: windows-latest | |||
| @@ -72,4 +72,4 @@ jobs: | |||
| run: | | |||
| Copy-Item -Path '.\VulkanSDK\RunTimeInstaller\x64\vulkan-1.dll' -Destination 'build\tests' | |||
| $env:VK_ICD_FILENAMES="$env:GITHUB_WORKSPACE\swiftshader-install\vk_swiftshader_icd.json" | |||
| cd build; ctest --output-on-failure -j 2 | |||
| cd build; ctest -C Release --output-on-failure -j 2 | |||
| @@ -54,7 +54,7 @@ matrix: | |||
| dist: 1803-containers | |||
| env: | |||
| - NAME=windows-vs2017 | |||
| - BUILD="mkdir build && cd build && cmake .. && cmake --build . && ctest --output-on-failure -j 2" | |||
| - BUILD="mkdir build && cd build && cmake .. && cmake --build . --config Release && ctest -C Release --output-on-failure -j 2" | |||
| - name: "test-coverage-arm64" | |||
| os: linux | |||
| @@ -25,6 +25,7 @@ option(NCNN_STRING "plain and verbose string" ON) | |||
| option(NCNN_INSTALL_SDK "install ncnn library and headers" ON) | |||
| option(NCNN_OPENCV "minimal opencv structure emulation" OFF) | |||
| option(NCNN_SIMPLESTL "minimal cpp stl structure emulation" OFF) | |||
| option(NCNN_THREADS "build with threads" ON) | |||
| option(NCNN_BENCHMARK "print benchmark information for every layer" OFF) | |||
| option(NCNN_PIXEL "convert and resize from/to image pixel" ON) | |||
| option(NCNN_PIXEL_ROTATE "rotate image pixel orientation" ON) | |||
| @@ -26,6 +26,7 @@ ncnn 是一个为手机端极致优化的高性能神经网络前向计算框架 | |||
| | iOS | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-cpu) | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-cpu) | — | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-64bit-gpu) | | |||
| | iOS Simulator | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-simulator) | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aios-simulator) | — | — | | |||
| | WebAssembly | — | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aweb-assembly) | — | — | | |||
| | RISC-V GCC/Newlib | — | [](https://github.com/Tencent/ncnn/actions?query=workflow%3Aelf-riscv64-cpu-gcc) | — | — | | |||
| --- | |||
| @@ -95,8 +95,15 @@ void benchmark(const char* comment, const ncnn::Mat& _in, const ncnn::Option& op | |||
| // sleep 10 seconds for cooling down SOC :( | |||
| #ifdef _WIN32 | |||
| Sleep(10 * 1000); | |||
| #else | |||
| #elif defined(__unix__) || defined(__APPLE__) | |||
| sleep(10); | |||
| #elif _POSIX_TIMERS | |||
| struct timespec ts; | |||
| ts.tv_sec = 10; | |||
| ts.tv_nsec = 0; | |||
| nanosleep(&ts, &ts); | |||
| #else | |||
| // TODO How to handle it ? | |||
| #endif | |||
| } | |||
| @@ -0,0 +1,5 @@ | |||
| execute_process(COMMAND $ENV{TESTS_EXECUTABLE_LOADER} $ENV{TESTS_EXECUTABLE_LOADER_ARGUMENTS} ${TEST_EXECUTABLE} $ENV{TESTS_ARGUMENTS} RESULT_VARIABLE result) | |||
| if(NOT "${result}" STREQUAL "0") | |||
| message(FATAL_ERROR "Test failed with return value '${result}'") | |||
| endif() | |||
| @@ -145,6 +145,8 @@ macro(ncnn_add_layer class) | |||
| set(arch arm) | |||
| elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(mips)") | |||
| set(arch mips) | |||
| elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(riscv)") | |||
| set(arch riscv) | |||
| else() | |||
| set(arch x86) | |||
| endif() | |||
| @@ -67,7 +67,7 @@ static inline void* fastMalloc(size_t size) | |||
| { | |||
| #if _MSC_VER | |||
| return _aligned_malloc(size, MALLOC_ALIGN); | |||
| #elif _POSIX_C_SOURCE >= 200112L || (__ANDROID__ && __ANDROID_API__ >= 17) | |||
| #elif (defined(__unix__) || defined(__APPLE__)) && _POSIX_C_SOURCE >= 200112L || (__ANDROID__ && __ANDROID_API__ >= 17) | |||
| void* ptr = 0; | |||
| if (posix_memalign(&ptr, MALLOC_ALIGN, size)) | |||
| ptr = 0; | |||
| @@ -90,7 +90,7 @@ static inline void fastFree(void* ptr) | |||
| { | |||
| #if _MSC_VER | |||
| _aligned_free(ptr); | |||
| #elif _POSIX_C_SOURCE >= 200112L || (__ANDROID__ && __ANDROID_API__ >= 17) | |||
| #elif (defined(__unix__) || defined(__APPLE__)) && _POSIX_C_SOURCE >= 200112L || (__ANDROID__ && __ANDROID_API__ >= 17) | |||
| free(ptr); | |||
| #elif __ANDROID__ && __ANDROID_API__ < 17 | |||
| free(ptr); | |||
| @@ -0,0 +1,75 @@ | |||
| // Tencent is pleased to support the open source community by making ncnn available. | |||
| // | |||
| // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved. | |||
| // | |||
| // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except | |||
| // in compliance with the License. You may obtain a copy of the License at | |||
| // | |||
| // https://opensource.org/licenses/BSD-3-Clause | |||
| // | |||
| // Unless required by applicable law or agreed to in writing, software distributed | |||
| // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
| // CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
| // specific language governing permissions and limitations under the License. | |||
| #include "clip_riscv.h" | |||
| #include "riscv-pk/encoding.h" | |||
| namespace ncnn { | |||
| Clip_riscv::Clip_riscv() | |||
| { | |||
| } | |||
| int Clip_riscv::forward_inplace(Mat& bottom_top_blob, const Option& opt) const | |||
| { | |||
| int w = bottom_top_blob.w; | |||
| int h = bottom_top_blob.h; | |||
| int channels = bottom_top_blob.c; | |||
| int size = w * h; | |||
| #pragma omp parallel for num_threads(opt.num_threads) | |||
| for (int q = 0; q < channels; q++) | |||
| { | |||
| float* ptr = bottom_top_blob.channel(q); | |||
| int remain = size; | |||
| #if __riscv_vector | |||
| asm volatile( | |||
| "L0: \n" | |||
| "vsetvli t0, %1, e32, m8 \n" | |||
| "vle32.v v0, (%0) \n" | |||
| "vfmax.vf v0, v0, %4 \n" | |||
| "vfmin.vf v0, v0, %5 \n" | |||
| "vse32.v v0, (%0) \n" | |||
| "slli t1, t0, 2 \n" | |||
| "add %0, %0, t1 \n" | |||
| "sub %1, %1, t0 \n" | |||
| "bnez %1, L0 \n" | |||
| : "=r"(ptr), // %0 | |||
| "=r"(remain) // %1 | |||
| : "0"(ptr), | |||
| "1"(remain), | |||
| "f"(min), // %4 | |||
| "f"(max) // %5 | |||
| : "cc", "memory", "t0", "t1"); | |||
| #else // __riscv_vector | |||
| for (; remain > 0; remain--) | |||
| { | |||
| if (*ptr < min) | |||
| *ptr = min; | |||
| if (*ptr > max) | |||
| *ptr = max; | |||
| ptr++; | |||
| } | |||
| #endif // __riscv_vector | |||
| } | |||
| return 0; | |||
| } | |||
| } //namespace ncnn | |||
| @@ -0,0 +1,32 @@ | |||
| // Tencent is pleased to support the open source community by making ncnn available. | |||
| // | |||
| // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved. | |||
| // | |||
| // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except | |||
| // in compliance with the License. You may obtain a copy of the License at | |||
| // | |||
| // https://opensource.org/licenses/BSD-3-Clause | |||
| // | |||
| // Unless required by applicable law or agreed to in writing, software distributed | |||
| // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
| // CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
| // specific language governing permissions and limitations under the License. | |||
| #ifndef LAYER_CLIP_RISCV_H | |||
| #define LAYER_CLIP_RISCV_H | |||
| #include "clip.h" | |||
| namespace ncnn { | |||
| class Clip_riscv : virtual public Clip | |||
| { | |||
| public: | |||
| Clip_riscv(); | |||
| virtual int forward_inplace(Mat& bottom_top_blob, const Option& opt) const; | |||
| }; | |||
| } // namespace ncnn | |||
| #endif // LAYER_CLIP_RISCV_H | |||
| @@ -19,6 +19,7 @@ | |||
| #cmakedefine01 NCNN_STRING | |||
| #cmakedefine01 NCNN_OPENCV | |||
| #cmakedefine01 NCNN_SIMPLESTL | |||
| #cmakedefine01 NCNN_THREADS | |||
| #cmakedefine01 NCNN_BENCHMARK | |||
| #cmakedefine01 NCNN_PIXEL | |||
| #cmakedefine01 NCNN_PIXEL_ROTATE | |||
| @@ -27,6 +28,7 @@ | |||
| #cmakedefine01 NCNN_REQUANT | |||
| #cmakedefine01 NCNN_AVX2 | |||
| #if NCNN_THREADS | |||
| #if (defined _WIN32 && !(defined __MINGW32__)) | |||
| #define WIN32_LEAN_AND_MEAN | |||
| #include <windows.h> | |||
| @@ -34,6 +36,7 @@ | |||
| #else | |||
| #include <pthread.h> | |||
| #endif | |||
| #endif // NCNN_THREADS | |||
| #if __ANDROID_API__ >= 26 | |||
| #define VK_USE_PLATFORM_ANDROID_KHR | |||
| @@ -41,6 +44,7 @@ | |||
| namespace ncnn { | |||
| #if NCNN_THREADS | |||
| #if (defined _WIN32 && !(defined __MINGW32__)) | |||
| class Mutex | |||
| { | |||
| @@ -134,6 +138,34 @@ private: | |||
| pthread_t t; | |||
| }; | |||
| #endif // _WIN32 | |||
| #else // NCNN_THREADS | |||
| class Mutex | |||
| { | |||
| public: | |||
| Mutex() {} | |||
| ~Mutex() {} | |||
| void lock() {} | |||
| void unlock() {} | |||
| }; | |||
| class ConditionVariable | |||
| { | |||
| public: | |||
| ConditionVariable() {} | |||
| ~ConditionVariable() {} | |||
| void wait(Mutex& /*mutex*/) {} | |||
| void broadcast() {} | |||
| void signal() {} | |||
| }; | |||
| class Thread | |||
| { | |||
| public: | |||
| Thread(void* (*/*start*/)(void*), void* /*args*/ = 0) {} | |||
| ~Thread() {} | |||
| void join() {} | |||
| }; | |||
| #endif // NCNN_THREADS | |||
| } // namespace ncnn | |||
| @@ -2,7 +2,8 @@ | |||
| macro(ncnn_add_test name) | |||
| add_executable(test_${name} test_${name}.cpp) | |||
| target_link_libraries(test_${name} PRIVATE ncnn) | |||
| add_test(test_${name} test_${name}) | |||
| add_test(NAME test_${name} COMMAND ${CMAKE_COMMAND} -DTEST_EXECUTABLE=$<TARGET_FILE:test_${name}> -P ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/run_test.cmake) | |||
| # add test to a virtual project group | |||
| set_property(TARGET test_${name} PROPERTY FOLDER "tests") | |||
| @@ -282,29 +282,29 @@ int main() | |||
| for (op_type = 0; op_type < OP_TYPE_MAX; op_type++) | |||
| { | |||
| int ret = 0 | |||
| || test_binaryop_1() | |||
| || test_binaryop_2() | |||
| || test_binaryop_3() | |||
| || test_binaryop_4() | |||
| || test_binaryop_5() | |||
| || test_binaryop_6() | |||
| || test_binaryop_7() | |||
| || test_binaryop_8() | |||
| || test_binaryop_9() | |||
| || test_binaryop_10() | |||
| || test_binaryop_11() | |||
| || test_binaryop_12() | |||
| || test_binaryop_13() | |||
| || test_binaryop_14() | |||
| || test_binaryop_15() | |||
| || test_binaryop_16() | |||
| || test_binaryop_17() | |||
| || test_binaryop_18() | |||
| || test_binaryop_19() | |||
| || test_binaryop_s1() | |||
| || test_binaryop_s2() | |||
| || test_binaryop_s3() | |||
| || test_binaryop_s4(); | |||
| || test_binaryop_1() | |||
| || test_binaryop_2() | |||
| || test_binaryop_3() | |||
| || test_binaryop_4() | |||
| || test_binaryop_5() | |||
| || test_binaryop_6() | |||
| || test_binaryop_7() | |||
| || test_binaryop_8() | |||
| || test_binaryop_9() | |||
| || test_binaryop_10() | |||
| || test_binaryop_11() | |||
| || test_binaryop_12() | |||
| || test_binaryop_13() | |||
| || test_binaryop_14() | |||
| || test_binaryop_15() | |||
| || test_binaryop_16() | |||
| || test_binaryop_17() | |||
| || test_binaryop_18() | |||
| || test_binaryop_19() | |||
| || test_binaryop_s1() | |||
| || test_binaryop_s2() | |||
| || test_binaryop_s3() | |||
| || test_binaryop_s4(); | |||
| if (ret != 0) | |||
| return ret; | |||
| @@ -0,0 +1,19 @@ | |||
| set(CMAKE_SYSTEM_NAME Generic) | |||
| set(CMAKE_SYSTEM_PROCESSOR riscv64) | |||
| if(DEFINED ENV{RISCV_ROOT_PATH}) | |||
| file(TO_CMAKE_PATH $ENV{RISCV_ROOT_PATH} RISCV_ROOT_PATH) | |||
| else() | |||
| message(FATAL_ERROR "RISCV_ROOT_PATH env must be defined") | |||
| endif() | |||
| set(RISCV_ROOT_PATH ${RISCV_ROOT_PATH} CACHE STRING "root path to riscv toolchain") | |||
| set(CMAKE_C_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-elf-gcc") | |||
| set(CMAKE_CXX_COMPILER "${RISCV_ROOT_PATH}/bin/riscv64-unknown-elf-g++") | |||
| set(CMAKE_FIND_ROOT_PATH "${RISCV_ROOT_PATH}/riscv64-unknown-elf") | |||
| set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | |||
| set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | |||
| set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | |||