├── .clang-format ├── .clang-tidy ├── .github └── workflows │ ├── build_and_test.yml │ ├── clang-format.yml │ └── reuse.yml ├── .gitignore ├── .pre-commit-config.yaml ├── CMakeLists.txt ├── CMakeToolchain └── riscv.clang.cross.cmake ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md ├── include ├── rvvlm.h ├── rvvlm_acoshD.inc.h ├── rvvlm_asincosD.inc.h ├── rvvlm_asinhcoshD.inc.h ├── rvvlm_atan2D.inc.h ├── rvvlm_atanD.inc.h ├── rvvlm_atanhD.inc.h ├── rvvlm_cbrtD.inc.h ├── rvvlm_cdfnorminvD.inc.h ├── rvvlm_erfD.inc.h ├── rvvlm_erfcD.inc.h ├── rvvlm_erfcinvD.inc.h ├── rvvlm_erfinvD.inc.h ├── rvvlm_errorfuncsD.h ├── rvvlm_expD.h ├── rvvlm_expD.inc.h ├── rvvlm_expint1D.inc.h ├── rvvlm_expm1D.inc.h ├── rvvlm_fp.inc.h ├── rvvlm_fp64m1.h ├── rvvlm_fp64m2.h ├── rvvlm_fp64m4.h ├── rvvlm_gammafuncsD.h ├── rvvlm_hyperbolicsD.h ├── rvvlm_inverrorfuncsD.h ├── rvvlm_invhyperD.h ├── rvvlm_lgammaD.inc.h ├── rvvlm_log1pD.inc.h ├── rvvlm_logD.inc.h ├── rvvlm_powD.inc.h ├── rvvlm_sinandcosD.inc.h ├── rvvlm_sincosD.inc.h ├── rvvlm_sinhcoshD.inc.h ├── rvvlm_tanD.inc.h ├── rvvlm_tanhD.inc.h ├── rvvlm_tgammaD.inc.h └── rvvlm_trigD.h ├── src ├── rvvlm_2ovpi_tbl.c ├── rvvlm_acosD.c ├── rvvlm_acosDI.c ├── rvvlm_acoshD.c ├── rvvlm_acoshDI.c ├── rvvlm_acospiD.c ├── rvvlm_acospiDI.c ├── rvvlm_asinD.c ├── rvvlm_asinDI.c ├── rvvlm_asinhD.c ├── rvvlm_asinhDI.c ├── rvvlm_asinpiD.c ├── rvvlm_asinpiDI.c ├── rvvlm_atan2D.c ├── rvvlm_atan2DI.c ├── rvvlm_atan2piD.c ├── rvvlm_atan2piDI.c ├── rvvlm_atanD.c ├── rvvlm_atanDI.c ├── rvvlm_atanhD.c ├── rvvlm_atanhDI.c ├── rvvlm_atanpiD.c ├── rvvlm_atanpiDI.c ├── rvvlm_cbrtD.c ├── rvvlm_cbrtDI.c ├── rvvlm_cdfnormD.c ├── rvvlm_cdfnormDI.c ├── rvvlm_cdfnorminvD.c ├── rvvlm_cdfnorminvDI.c ├── rvvlm_cosD.c ├── rvvlm_cosDI.c ├── rvvlm_coshD.c ├── rvvlm_coshDI.c ├── rvvlm_cospiD.c ├── rvvlm_cospiDI.c ├── rvvlm_erfD.c ├── rvvlm_erfDI.c ├── rvvlm_erfcD.c ├── rvvlm_erfcDI.c ├── rvvlm_erfcinvD.c ├── rvvlm_erfcinvDI.c ├── rvvlm_erfinvD.c ├── rvvlm_erfinvDI.c ├── rvvlm_exp10D.c ├── rvvlm_exp10DI.c ├── rvvlm_exp2D.c ├── rvvlm_exp2DI.c ├── rvvlm_expD.c ├── rvvlm_expDI.c ├── rvvlm_expD_tbl.c ├── rvvlm_expint1D.c ├── rvvlm_expint1DI.c ├── rvvlm_expm1D.c ├── rvvlm_expm1DI.c ├── rvvlm_lgammaD.c ├── rvvlm_lgammaDI.c ├── rvvlm_log10D.c ├── rvvlm_log10DI.c ├── rvvlm_log1pD.c ├── rvvlm_log1pDI.c ├── rvvlm_log2D.c ├── rvvlm_log2DI.c ├── rvvlm_logD.c ├── rvvlm_logDI.c ├── rvvlm_logD_tbl.c ├── rvvlm_powD.c ├── rvvlm_powDI.c ├── rvvlm_powD_tbl.c ├── rvvlm_sinD.c ├── rvvlm_sinDI.c ├── rvvlm_sincosD.c ├── rvvlm_sincosDI.c ├── rvvlm_sincospiD.c ├── rvvlm_sincospiDI.c ├── rvvlm_sinhD.c ├── rvvlm_sinhDI.c ├── rvvlm_sinpiD.c ├── rvvlm_sinpiDI.c ├── rvvlm_tanD.c ├── rvvlm_tanDI.c ├── rvvlm_tanhD.c ├── rvvlm_tanhDI.c ├── rvvlm_tanpiD.c ├── rvvlm_tanpiDI.c ├── rvvlm_tgammaD.c └── rvvlm_tgammaDI.c ├── test ├── CMakeLists.txt ├── include │ ├── near_NPiby2_tbl.h │ └── test_infra.h └── src │ ├── test_acos.cpp │ ├── test_acosI.cpp │ ├── test_acosh.cpp │ ├── test_acoshI.cpp │ ├── test_acospi.cpp │ ├── test_acospiI.cpp │ ├── test_asin.cpp │ ├── test_asinI.cpp │ ├── test_asinh.cpp │ ├── test_asinhI.cpp │ ├── test_asinpi.cpp │ ├── test_asinpiI.cpp │ ├── test_atan.cpp │ ├── test_atan2.cpp │ ├── test_atan2I.cpp │ ├── test_atan2pi.cpp │ ├── test_atan2piI.cpp │ ├── test_atanI.cpp │ ├── test_atanh.cpp │ ├── test_atanhI.cpp │ ├── test_atanpi.cpp │ ├── test_atanpiI.cpp │ ├── test_cbrt.cpp │ ├── test_cbrtI.cpp │ ├── test_cdfnorm.cpp │ ├── test_cdfnormI.cpp │ ├── test_cdfnorminv.cpp │ ├── test_cdfnorminvI.cpp │ ├── test_cos.cpp │ ├── test_cosI.cpp │ ├── test_cosh.cpp │ ├── test_coshI.cpp │ ├── test_cospi.cpp │ ├── test_cospiI.cpp │ ├── test_erf.cpp │ ├── test_erfI.cpp │ ├── test_erfc.cpp │ ├── test_erfcI.cpp │ ├── test_erfcinv.cpp │ ├── test_erfcinvI.cpp │ ├── test_erfinv.cpp │ ├── test_erfinvI.cpp │ ├── test_exp.cpp │ ├── test_exp10.cpp │ ├── test_exp10I.cpp │ ├── test_exp2.cpp │ ├── test_exp2I.cpp │ ├── test_expI.cpp │ ├── test_expint1.cpp │ ├── test_expint1I.cpp │ ├── test_expm1.cpp │ ├── test_expm1I.cpp │ ├── test_infra.cpp │ ├── test_lgamma.cpp │ ├── test_lgammaI.cpp │ ├── test_log.cpp │ ├── test_log10.cpp │ ├── test_log10I.cpp │ ├── test_log1p.cpp │ ├── test_log1pI.cpp │ ├── test_log2.cpp │ ├── test_log2I.cpp │ ├── test_logI.cpp │ ├── test_pow.cpp │ ├── test_powI.cpp │ ├── test_sin.cpp │ ├── test_sinI.cpp │ ├── test_sincos.cpp │ ├── test_sincosI.cpp │ ├── test_sincospi.cpp │ ├── test_sincospiI.cpp │ ├── test_sinh.cpp │ ├── test_sinhI.cpp │ ├── test_sinpi.cpp │ ├── test_sinpiI.cpp │ ├── test_tan.cpp │ ├── test_tanI.cpp │ ├── test_tanh.cpp │ ├── test_tanhI.cpp │ ├── test_tanpi.cpp │ ├── test_tgamma.cpp │ └── test_tgammaI.cpp └── tools └── run-clang-format.py /.clang-format: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | BasedOnStyle: LLVM 6 | -------------------------------------------------------------------------------- /.clang-tidy: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming' 6 | CheckOptions: 7 | - key: readability-identifier-naming.ClassCase 8 | value: CamelCase 9 | - key: readability-identifier-naming.EnumCase 10 | value: CamelCase 11 | - key: readability-identifier-naming.FunctionCase 12 | value: snake_case 13 | - key: readability-identifier-naming.MemberCase 14 | value: snake_case 15 | - key: readability-identifier-naming.ParameterCase 16 | value: snake_case 17 | - key: readability-identifier-naming.UnionCase 18 | value: snake_case 19 | - key: readability-identifier-naming.VariableCase 20 | value: snake_case 21 | - key: readability-identifier-naming.IgnoreMainLikeFunctions 22 | value: 1 23 | - key: readability-redundant-member-init.IgnoreBaseInCopyConstructors 24 | value: 1 25 | - key: modernize-use-default-member-init.UseAssignment 26 | value: 1 27 | -------------------------------------------------------------------------------- /.github/workflows/build_and_test.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2024 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | name: "Build & Test" 6 | 7 | on: 8 | # allow direct trigger 9 | workflow_dispatch: 10 | push: 11 | pull_request: 12 | 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.ref }} 15 | cancel-in-progress: true 16 | 17 | permissions: 18 | contents: read 19 | 20 | env: 21 | GCC_VERSION: "12" 22 | LLVM_VERSION: "18" 23 | 24 | jobs: 25 | build: 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - uses: actions/checkout@v4.1.1 30 | with: 31 | persist-credentials: false 32 | 33 | - name: Install dependencies 34 | run: | 35 | sudo apt-get update -y -qq 36 | sudo apt-get install -y -qq build-essential curl ninja-build debootstrap 37 | 38 | # Needed for some target toolchains like ld 39 | - name: Install gcc 40 | run: | 41 | sudo apt-get install -y -qq gcc-${GCC_VERSION} gcc-${GCC_VERSION}-riscv64-linux-gnu g++-${GCC_VERSION} g++-${GCC_VERSION}-riscv64-linux-gnu 42 | 43 | - name: Install llvm 44 | run: | 45 | curl -o llvm.sh https://apt.llvm.org/llvm.sh 46 | chmod u+x llvm.sh 47 | sudo ./llvm.sh ${LLVM_VERSION} 48 | rm llvm.sh 49 | 50 | - name: Setup QEMU 51 | uses: docker/setup-qemu-action@v3.0.0 52 | 53 | - name: Check sysroot cache 54 | id: check-sysroot-cache 55 | uses: actions/cache@v4 56 | with: 57 | path: sysroot 58 | key: sysroot-${{ hashFiles('./.github/workflows/build_and_test.yml') }} 59 | 60 | - name: Create sysroot 61 | run: | 62 | sudo debootstrap --arch=riscv64 --verbose --include=fakeroot,symlinks,googletest --resolve-deps --variant=minbase --components=main,universe jammy sysroot 63 | # Remove unused files to minimize cache 64 | sudo chroot sysroot symlinks -cr . 65 | sudo chown ${USER} -R sysroot 66 | rm -rf sysroot/{dev,proc,run,sys,var} 67 | rm -rf sysroot/usr/{sbin,bin,share} 68 | rm -rf sysroot/usr/lib/{apt,gcc,udev,systemd} 69 | rm -rf sysroot/usr/libexec/gcc 70 | if: steps.check-sysroot-cache.outputs.cache-hit != 'true' 71 | 72 | - name: Build 73 | shell: bash -ex -o pipefail {0} 74 | run: | 75 | export QEMU_LD_PREFIX=$(pwd)/sysroot 76 | cmake -S . -B build -GNinja \ 77 | -DCMAKE_INSTALL_PREFIX="$(pwd)/install" \ 78 | -DCMAKE_TOOLCHAIN_FILE=$(pwd)/CMakeToolchain/riscv.clang.cross.cmake \ 79 | -DCMAKE_SYSROOT=$(pwd)/sysroot 80 | cmake --build build 81 | cmake --install build 82 | 83 | - name: Upload build artifacts 84 | uses: actions/upload-artifact@v4 85 | with: 86 | name: build 87 | path: | 88 | build 89 | install 90 | if: always() 91 | 92 | test: 93 | runs-on: ubuntu-latest 94 | needs: [build] 95 | strategy: 96 | fail-fast: false 97 | matrix: 98 | include: 99 | - qemu_cpu: "rv64,zba=true,zbb=true,zbs=true,v=true,vlen=128,elen=64,vext_spec=v1.0" 100 | - qemu_cpu: "rv64,zba=true,zbb=true,zbs=true,v=true,vlen=256,elen=64,vext_spec=v1.0" 101 | - qemu_cpu: "rv64,zba=true,zbb=true,zbs=true,v=true,vlen=512,elen=64,vext_spec=v1.0" 102 | 103 | name: "test (qemu_cpu: \"${{ matrix.qemu_cpu }}\")" 104 | steps: 105 | - uses: actions/checkout@v4.1.1 106 | with: 107 | persist-credentials: false 108 | 109 | - name: Setup QEMU 110 | uses: docker/setup-qemu-action@v3.0.0 111 | 112 | - name: Check sysroot cache 113 | id: check-sysroot-cache 114 | uses: actions/cache@v4 115 | with: 116 | path: sysroot 117 | key: sysroot-${{ hashFiles('./.github/workflows/build_and_test.yml') }} 118 | 119 | - name: Download build artifacts 120 | uses: actions/download-artifact@v4 121 | with: 122 | name: build 123 | 124 | - name: Fix build permissions 125 | run: | 126 | chmod +x build/test/test_* 127 | 128 | - name: Test 129 | env: 130 | CTEST_OUTPUT_ON_FAILURE: "TRUE" 131 | run: | 132 | export QEMU_CPU="${{ matrix.qemu_cpu }}" 133 | export QEMU_LD_PREFIX=$(pwd)/sysroot 134 | cd build 135 | ctest -j$(nproc) --output-on-failure 136 | 137 | - name: Upload test-${{ strategy.job-index }} artifacts 138 | uses: actions/upload-artifact@v4 139 | with: 140 | name: test-${{ strategy.job-index }} 141 | path: | 142 | build/Testing 143 | if: always() 144 | -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | name: Format checking 6 | 7 | on: [push, pull_request] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | clang_formatting: 14 | name: check_clang_format 15 | runs-on: ubuntu-22.04 16 | strategy: 17 | matrix: 18 | python-version: ['3.11'] 19 | steps: 20 | - uses: actions/checkout@v4 21 | with: 22 | fetch-depth: 0 23 | show-progress: true 24 | 25 | - name: Setup Python 26 | uses: actions/setup-python@v4 27 | with: 28 | python-version: ${{ matrix.python-version }} 29 | 30 | - name: Install Packages 31 | run: | 32 | sudo apt update 33 | sudo apt install -y clang-format 34 | python -m pip install click 35 | 36 | - name: Check Clang Format 37 | run: | 38 | set -euo pipefail 39 | python tools/run-clang-format.py check 40 | 41 | -------------------------------------------------------------------------------- /.github/workflows/reuse.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | name: reuse 6 | 7 | on: [push, pull_request] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - name: reuse Compliance Check 15 | uses: fsfe/reuse-action@v1 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | build/ 6 | install/ 7 | sysroot/ 8 | compile_commands.json 9 | LOCAL 10 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | repos: 6 | # pull mirror of https://github.com/fsfe/reuse-tool 7 | - repo: https://github.com/rivosinc/reuse-tool 8 | rev: 'd95c0e946ee0448420fb1417a0f98fc2eb87d94a' 9 | hooks: 10 | # Check compliance 11 | - id: reuse 12 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | cmake_minimum_required(VERSION 3.22) 6 | project(veclibm C CXX) 7 | 8 | option(VECLIBM_BUILD_TESTS "Build tests" ON) 9 | 10 | if (VECLIBM_BUILD_TESTS) 11 | # Adds a test target 12 | include(CTest) 13 | 14 | include(GoogleTest) 15 | 16 | set(GTest_ROOT ${CMAKE_SYSROOT}/usr/src/googletest/googletest) 17 | add_subdirectory(${GTest_ROOT} "${CMAKE_CURRENT_BINARY_DIR}/googletest" EXCLUDE_FROM_ALL) 18 | endif() 19 | 20 | set(PROJECT_SOURCES 21 | src/rvvlm_acosD.c 22 | src/rvvlm_acosDI.c 23 | src/rvvlm_acospiD.c 24 | src/rvvlm_acospiDI.c 25 | src/rvvlm_asinD.c 26 | src/rvvlm_asinDI.c 27 | src/rvvlm_asinpiD.c 28 | src/rvvlm_asinpiDI.c 29 | src/rvvlm_atanD.c 30 | src/rvvlm_atanDI.c 31 | src/rvvlm_atanpiD.c 32 | src/rvvlm_atanpiDI.c 33 | src/rvvlm_atan2D.c 34 | src/rvvlm_atan2DI.c 35 | src/rvvlm_atan2piD.c 36 | src/rvvlm_atan2piDI.c 37 | src/rvvlm_acoshD.c 38 | src/rvvlm_acoshDI.c 39 | src/rvvlm_asinhD.c 40 | src/rvvlm_asinhDI.c 41 | src/rvvlm_atanhD.c 42 | src/rvvlm_atanhDI.c 43 | src/rvvlm_cbrtD.c 44 | src/rvvlm_cbrtDI.c 45 | src/rvvlm_cdfnormD.c 46 | src/rvvlm_cdfnormDI.c 47 | src/rvvlm_cdfnorminvD.c 48 | src/rvvlm_cdfnorminvDI.c 49 | src/rvvlm_erfD.c 50 | src/rvvlm_erfDI.c 51 | src/rvvlm_erfcD.c 52 | src/rvvlm_erfcDI.c 53 | src/rvvlm_erfcinvD.c 54 | src/rvvlm_erfcinvDI.c 55 | src/rvvlm_erfinvD.c 56 | src/rvvlm_erfinvDI.c 57 | src/rvvlm_expD_tbl.c 58 | src/rvvlm_expD.c 59 | src/rvvlm_expDI.c 60 | src/rvvlm_exp2D.c 61 | src/rvvlm_exp2DI.c 62 | src/rvvlm_exp10D.c 63 | src/rvvlm_exp10DI.c 64 | src/rvvlm_expm1D.c 65 | src/rvvlm_expm1DI.c 66 | src/rvvlm_expint1D.c 67 | src/rvvlm_expint1DI.c 68 | src/rvvlm_logD_tbl.c 69 | src/rvvlm_logD.c 70 | src/rvvlm_logDI.c 71 | src/rvvlm_log2D.c 72 | src/rvvlm_log2DI.c 73 | src/rvvlm_log10D.c 74 | src/rvvlm_log10DI.c 75 | src/rvvlm_log1pD.c 76 | src/rvvlm_log1pDI.c 77 | src/rvvlm_powD_tbl.c 78 | src/rvvlm_powD.c 79 | src/rvvlm_powDI.c 80 | src/rvvlm_2ovpi_tbl.c 81 | src/rvvlm_cosD.c 82 | src/rvvlm_cosDI.c 83 | src/rvvlm_cospiD.c 84 | src/rvvlm_cospiDI.c 85 | src/rvvlm_sinD.c 86 | src/rvvlm_sinDI.c 87 | src/rvvlm_sinpiD.c 88 | src/rvvlm_sinpiDI.c 89 | src/rvvlm_sincosD.c 90 | src/rvvlm_sincosDI.c 91 | src/rvvlm_sincospiD.c 92 | src/rvvlm_sincospiDI.c 93 | src/rvvlm_tanD.c 94 | src/rvvlm_tanDI.c 95 | src/rvvlm_tanpiD.c 96 | src/rvvlm_tanpiDI.c 97 | src/rvvlm_coshD.c 98 | src/rvvlm_coshDI.c 99 | src/rvvlm_sinhD.c 100 | src/rvvlm_sinhDI.c 101 | src/rvvlm_tanhD.c 102 | src/rvvlm_tanhDI.c 103 | src/rvvlm_lgammaD.c 104 | src/rvvlm_lgammaDI.c 105 | src/rvvlm_tgammaD.c 106 | src/rvvlm_tgammaDI.c 107 | ) 108 | 109 | add_library(vecm 110 | ${PROJECT_SOURCES} 111 | ) 112 | 113 | target_include_directories(vecm 114 | PUBLIC 115 | include 116 | ) 117 | 118 | target_compile_options(vecm 119 | PUBLIC 120 | $<$:-std=c11> 121 | ) 122 | 123 | if (VECLIBM_BUILD_TESTS) 124 | # Add tests as well. Split this out into its own file. This means that the tests 125 | # are in a 'test' subdirectory of the current build directory 126 | add_subdirectory(test) 127 | endif() 128 | -------------------------------------------------------------------------------- /CMakeToolchain/riscv.clang.cross.cmake: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | SET (CMAKE_CROSSCOMPILING TRUE) 6 | SET (CMAKE_SYSTEM_NAME "Linux") 7 | SET (CMAKE_SYSTEM_PROCESSOR "riscv64") 8 | 9 | SET(CMAKE_FIND_ROOT_PATH /usr/riscv64-linux-gnu /usr/include/riscv64-linux-gnu /usr/lib/riscv64-linux-gnu /lib/riscv64-linux-gnu) 10 | 11 | find_program(CMAKE_C_COMPILER NAMES clang-18 clang) 12 | set(CMAKE_C_COMPILER_TARGET riscv64-linux-gnu) 13 | set(CMAKE_C_FLAGS "-march=rv64gcv_zba_zbb_zbs") 14 | 15 | find_program(CMAKE_CXX_COMPILER NAMES clang++-18 clang++) 16 | set(CMAKE_CXX_COMPILER_TARGET riscv64-linux-gnu) 17 | set(CMAKE_CXX_FLAGS "-march=rv64gcv_zba_zbb_zbs") 18 | 19 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 20 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) 21 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 22 | -------------------------------------------------------------------------------- /LICENSES/Apache-2.0.txt: -------------------------------------------------------------------------------- 1 | ../LICENSE -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # veclibm 8 | 9 | [![REUSE status](https://api.reuse.software/badge/github.com/rivosinc/veclibm)](https://api.reuse.software/info/github.com/rivosinc/veclibm) 10 | 11 | A vector math library using RISC-V vector ISA via C intrinsic. 12 | 13 | WORK IN PROGRESS... 14 | 15 | The basic structure is that each function, such as exp, is contained in one file. 16 | The file includes a sequence of header files. Typically these three headers are present in this order 17 | 1. rvvlm.h (Risc-V Vector Libm). Commonly used macros and function declaration (more detail below) 18 | 2. rvvlm_fp64m1.h (or rvvlm_fp64m2.h, etc) which defines the LMUL choice for each function. 19 | 3. function-specific header file, e.g. rvvlm_expD.h (for double precision exp function) 20 | 21 | We sometimes provide multiple implementations for a single function as each may perform differently on different hardware implementations of the Risc-V vector ISA. Thus the function implementation use a macro for its name; and these macros are defined in the header file rvvlm.h. One can manually define one (and only one) of these macros to be the standard function name. Obviously, the "manual" process can be automated, allowing one to determine the highest performing choice experimentally. 22 | 23 | A simple test program test_funcs.c uses the existing long double function as a reference. At this point we only aim to develop double-precision (and perhaps single-precision) functions, thus testing their accuracy with long-double function is deemed sufficient. 24 | 25 | # Building & Testing 26 | 27 | The veclibm project is built and tested on GitHub Actions. See `.github/workflows/build_and_test.yml` for reference. 28 | 29 | ## Cross-compiling 30 | 31 | First, a sysroot is required with appropriate dependencies installed in it. For veclibm the following command will set up a sysroot: 32 | ``` 33 | sudo debootstrap --arch=riscv64 --verbose --include=fakeroot,symlinks,googletest --resolve-deps --variant=minbase --components=main,universe jammy sysroot 34 | ``` 35 | 36 | Then, assuming you've the necessary toolchains installed (refer to the [GHA workflow file](https://github.com/rivosinc/veclibm/blob/main/.github/workflows/build_and_test.yml) for versions and steps), veclibm is built with the following command: 37 | ``` 38 | cmake -S . -B build -DCMAKE_INSTALL_PREFIX="$(pwd)/install" -DCMAKE_TOOLCHAIN_FILE=$(pwd)/CMakeToolchain/riscv.clang.cross.cmake -DCMAKE_SYSROOT=$(pwd)/sysroot 39 | ``` 40 | 41 | Finally, veclibm is built with: 42 | ``` 43 | cmake --build build 44 | ``` 45 | 46 | This will build the `libvecm.so` library as well as the tests. 47 | 48 | ## Testing 49 | 50 | _The following steps take the assumption the user is cross-compiling and using QEMU to execute the riscv64 binary on your host machine._ 51 | 52 | The easiest is to simply run `test/test_veclibm`: 53 | ``` 54 | QEMU_CPU=rv64,zba=true,zbb=true,zbs=true,v=true QEMU_LD_PREFIX=$(pwd)/sysroot build/test/test_veclibm 55 | ``` 56 | 57 | To run only a specific test, for example the `erf.test`, the user can filter with: 58 | ``` 59 | QEMU_CPU=rv64,zba=true,zbb=true,zbs=true,v=true QEMU_LD_PREFIX=$(pwd)/sysroot build/test/test_veclibm --gtest_filter=erf.test 60 | ``` 61 | 62 | Refer to the help for more options: 63 | ``` 64 | QEMU_CPU=rv64,zba=true,zbb=true,zbs=true,v=true QEMU_LD_PREFIX=$(pwd)/sysroot build/test/test_veclibm --help 65 | ``` 66 | -------------------------------------------------------------------------------- /include/rvvlm_acoshD.inc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include "rvvlm_invhyperD.h" 6 | 7 | #if (STRIDE == UNIT_STRIDE) 8 | #define F_VER1 RVVLM_ACOSHD_STD 9 | #else 10 | #define F_VER1 RVVLM_ACOSHDI_STD 11 | #endif 12 | 13 | // Acosh(x) is defined for x >= 1 by the formula log(x + sqrt(x*x - 1)) 14 | // and for the log function log(2^n z), we uses the expansion in terms of atanh 15 | // n log(2) + 2 atanh((z-1)/(z+1)) 16 | // This algorithm obtains this scale factor 2^n from the input x, and computes 17 | // the expression x' + sqrt(x'*x' - 2^(-2n)) thus avoiding possible overflow or 18 | // excess computation such as computing sqrt(x*x - 1) by x * sqrt(1 - 1/(x*x)) 19 | // which needs a division on top of a sqrt. 20 | void F_VER1(API) { 21 | size_t vlen; 22 | VFLOAT vx, vx_orig, vy, vy_special; 23 | VBOOL special_args; 24 | 25 | SET_ROUNDTONEAREST; 26 | // stripmining over input arguments 27 | for (; _inarg_n > 0; _inarg_n -= vlen) { 28 | vlen = VSET(_inarg_n); 29 | vx = VFLOAD_INARG1(vlen); 30 | #if defined(COMPILE_FOR_ASINH) 31 | vx_orig = vx; 32 | #endif 33 | 34 | #if defined(COMPILE_FOR_ACOSH) 35 | // Handle Inf and NaN and input <= 1.0 36 | EXCEPTION_HANDLING_ACOSH(vx, special_args, vy_special, vlen); 37 | #else 38 | // Handle Inf and NaN and |input} < 2^(-30) 39 | EXCEPTION_HANDLING_ASINH(vx, special_args, vy_special, vlen); 40 | vx = __riscv_vfsgnj(vx, fp_posOne, vlen); 41 | #endif 42 | 43 | // Need to scale x so that x + sqrt(x*x +/- 1) doesn't overflow 44 | // Since x >= 1, we scale x down by 2^(-550) if x >= 2^500 and set 1 to 0 45 | VINT n; 46 | VFLOAT u; 47 | SCALE_X(vx, n, u, vlen); 48 | // n is 0 or 500; and u is +/-1.0 or 0.0 49 | 50 | // sqrt(x*x + u) extra precisely 51 | VFLOAT A, a; 52 | #if defined(COMPILE_FOR_ACOSH) 53 | XSQ_PLUS_U_ACOSH(vx, u, A, a, vlen); 54 | #else 55 | XSQ_PLUS_U_ASINH(vx, u, A, a, vlen); 56 | #endif 57 | // A + a is x*x + u 58 | 59 | VFLOAT B, b; 60 | SQRT2_X2(A, a, B, b, vlen); 61 | // B + b is sqrt(x*x + u) to about 7 extra bits 62 | 63 | // x dominants B for acosh 64 | VFLOAT S, s; 65 | #if defined(COMPILE_FOR_ACOSH) 66 | FAST2SUM(vx, B, S, s, vlen); 67 | s = __riscv_vfadd(s, b, vlen); 68 | #else 69 | FAST2SUM(B, vx, S, s, vlen); 70 | s = __riscv_vfadd(s, b, vlen); 71 | #endif 72 | 73 | // x + sqrt(x*x + u) is accurately represented as S + s 74 | // We first scale S, s so that it falls roughly in [1/rt2, rt2] 75 | SCALE_4_LOG(S, s, n, vlen); 76 | 77 | // log(x + sqrt(x*x + u)) = n * log(2) + log(y); y = S + s 78 | // since log(y) = 2 atanh( (y-1)/(y+1) ) to be approximated 79 | // by t + t^3 * poly(t^2), t = 2 (y-1)/(y+1) 80 | // We now compute the numerator and denominator and its quotient 81 | // to extra precision 82 | VFLOAT numer, delta_numer, denom, delta_denom; 83 | TRANSFORM_2_ATANH(S, s, numer, delta_numer, denom, delta_denom, vlen); 84 | 85 | VFLOAT r_hi, r_lo, r; 86 | DIV2_N2D2(numer, delta_numer, denom, delta_denom, r_hi, r_lo, vlen); 87 | r = __riscv_vfadd(r_hi, r_lo, vlen); 88 | 89 | VFLOAT n_flt = __riscv_vfcvt_f(n, vlen); 90 | 91 | VFLOAT poly; 92 | LOG_POLY(r, r_lo, poly, vlen); 93 | // At this point r_hi + poly approximates log(X) 94 | 95 | // Reconstruction: logB(in_arg) = n logB(2) + log(X) * logB(e), computed as 96 | // n*(logB_2_hi + logB_2_lo) + r * (logB_e_hi + logB_e_lo) + poly * 97 | // logB_e_hi It is best to compute n * logB_2_hi + r * logB_e_hi in extra 98 | // precision 99 | 100 | A = __riscv_vfmul(n_flt, LOG2_HI, vlen); 101 | FAST2SUM(A, r_hi, S, s, vlen); 102 | s = __riscv_vfmacc(s, LOG2_LO, n_flt, vlen); 103 | s = __riscv_vfadd(s, poly, vlen); 104 | 105 | vy = __riscv_vfadd(S, s, vlen); 106 | #if defined(COMPILE_FOR_ASINH) 107 | vy = __riscv_vfsgnj(vy, vx_orig, vlen); 108 | #endif 109 | vy = __riscv_vmerge(vy, vy_special, special_args, vlen); 110 | 111 | // copy vy into y and increment addr pointers 112 | VFSTORE_OUTARG1(vy, vlen); 113 | 114 | INCREMENT_INARG1(vlen); 115 | INCREMENT_OUTARG1(vlen); 116 | } 117 | RESTORE_FRM; 118 | } 119 | -------------------------------------------------------------------------------- /include/rvvlm_asinhcoshD.inc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include "rvvlm_invhyperD.h" 6 | 7 | #if defined(COMPILE_FOR_ACOSH) 8 | #if (STRIDE == UNIT_STRIDE) 9 | #define F_VER1 RVVLM_ACOSHD_STD 10 | #else 11 | #define F_VER1 RVVLM_ACOSHDI_STD 12 | #endif 13 | #else 14 | #if (STRIDE == UNIT_STRIDE) 15 | #define F_VER1 RVVLM_ASINHD_STD 16 | #else 17 | #define F_VER1 RVVLM_ASINHDI_STD 18 | #endif 19 | #endif 20 | 21 | // Acosh(x) is defined for x >= 1 by the formula log(x + sqrt(x*x - 1)) 22 | // Asinh(x) is defined for all finite x by the formula log(x + sqrt(x*x + 1)) 23 | // Acosh is always positive, and Asinh(-x) = -Asinh(x). Thus we in general 24 | // work with |x| and restore the sign (if necessary) in the end. 25 | // For the log function log(2^n z), we uses the expansion in terms of atanh: 26 | // n log(2) + 2 atanh((z-1)/(z+1)) 27 | // The algorithm here first scales down x by 2^(-550) when |x| >= 2^500. 28 | // And for such large x, both acosh and asinh equals log(2x) to very high 29 | // precision. We safely ignore the +/- 1 when this is the case. 30 | // 31 | // A power 2^n is determined by the value of x + sqrt(x*x +/- 1) so that 32 | // scaling the expression by 2^(-n) transforms it to the range [0.71, 1.42]. 33 | // Log(t) for t in this region is computed by 2 atanh((t-1)/(t+1)) 34 | // More precisely, we use s = 2(t-1)/(t+1) and approximate the function 35 | // 2 atanh(s/2) by s + s^3 * polynomial(s^2). 36 | // The final result is n * log(2) + s + s^3 * polynomial(s^2) 37 | // which is computed with care. 38 | void F_VER1(API) { 39 | size_t vlen; 40 | VFLOAT vx, vy, vy_special; 41 | VBOOL special_args; 42 | 43 | SET_ROUNDTONEAREST; 44 | // stripmining over input arguments 45 | for (; _inarg_n > 0; _inarg_n -= vlen) { 46 | vlen = VSET(_inarg_n); 47 | vx = VFLOAD_INARG1(vlen); 48 | #if defined(COMPILE_FOR_ASINH) 49 | VFLOAT vx_orig = vx; 50 | #endif 51 | 52 | #if defined(COMPILE_FOR_ACOSH) 53 | // Handle Inf and NaN and input <= 1.0 54 | EXCEPTION_HANDLING_ACOSH(vx, special_args, vy_special, vlen); 55 | #else 56 | // Handle Inf and NaN and |input| < 2^(-30) 57 | EXCEPTION_HANDLING_ASINH(vx, special_args, vy_special, vlen); 58 | vx = __riscv_vfsgnj(vx, fp_posOne, vlen); 59 | #endif 60 | 61 | // Need to scale x so that x + sqrt(x*x +/- 1) doesn't overflow 62 | // We scale x down by 2^(-550) if x >= 2^500 and set the "+/- 1" to 0 63 | VINT n; 64 | VFLOAT u; 65 | SCALE_X(vx, n, u, vlen); 66 | // n is 0 or 500; and u is +/-1.0 or 0.0 67 | 68 | // sqrt(x*x + u) extra precisely 69 | VFLOAT A, a; 70 | #if defined(COMPILE_FOR_ACOSH) 71 | XSQ_PLUS_U_ACOSH(vx, u, A, a, vlen); 72 | #else 73 | XSQ_PLUS_U_ASINH(vx, u, A, a, vlen); 74 | #endif 75 | // A + a is x*x + u 76 | 77 | VFLOAT B, b; 78 | #if defined(COMPILE_FOR_ACOSH) 79 | SQRT2_X2(A, a, B, b, vlen); 80 | // B + b is sqrt(x*x + u) to about 7 extra bits 81 | #else 82 | // For asinh, we need the sqrt to double-double precision 83 | VFLOAT recip = __riscv_vfrdiv(A, fp_posOne, vlen); 84 | B = __riscv_vfsqrt(A, vlen); 85 | b = __riscv_vfnmsub(B, B, A, vlen); 86 | b = __riscv_vfadd(b, a, vlen); 87 | VFLOAT B_recip = __riscv_vfmul(B, recip, vlen); 88 | b = __riscv_vfmul(b, 0x1.0p-1, vlen); 89 | b = __riscv_vfmul(b, B_recip, vlen); 90 | #endif 91 | 92 | VFLOAT S, s; 93 | #if defined(COMPILE_FOR_ACOSH) 94 | // x dominantes B for acosh 95 | FAST2SUM(vx, B, S, s, vlen); 96 | s = __riscv_vfadd(s, b, vlen); 97 | #else 98 | // B dominates x for asinh 99 | FAST2SUM(B, vx, S, s, vlen); 100 | s = __riscv_vfadd(s, b, vlen); 101 | #endif 102 | 103 | // x + sqrt(x*x + u) is accurately represented as S + s 104 | // We first scale S, s by 2^(-n) so that the scaled value 105 | // falls roughly in [1/rt2, rt2] 106 | SCALE_4_LOG(S, s, n, vlen); 107 | 108 | // log(x + sqrt(x*x + u)) = n * log(2) + log(y); y = S + s 109 | // We use log(y) = 2 atanh( (y-1)/(y+1) ) and approximate the latter 110 | // by t + t^3 * poly(t^2), t = 2 (y-1)/(y+1) 111 | 112 | // We now compute the numerator 2(y-1) and denominator y+1 and their 113 | // quotient to extra precision 114 | VFLOAT numer, delta_numer, denom, delta_denom; 115 | TRANSFORM_2_ATANH(S, s, numer, delta_numer, denom, delta_denom, vlen); 116 | 117 | VFLOAT r_hi, r_lo, r; 118 | DIV2_N2D2(numer, delta_numer, denom, delta_denom, r_hi, r_lo, vlen); 119 | r = __riscv_vfadd(r_hi, r_lo, vlen); 120 | 121 | VFLOAT poly; 122 | LOG_POLY(r, r_lo, poly, vlen); 123 | // At this point r_hi + poly approximates log(X) 124 | 125 | // Compose the final result: n * log(2) + r_hi + poly 126 | VFLOAT n_flt = __riscv_vfcvt_f(n, vlen); 127 | A = __riscv_vfmul(n_flt, LOG2_HI, vlen); 128 | FAST2SUM(A, r_hi, S, s, vlen); 129 | s = __riscv_vfmacc(s, LOG2_LO, n_flt, vlen); 130 | s = __riscv_vfadd(s, poly, vlen); 131 | 132 | vy = __riscv_vfadd(S, s, vlen); 133 | #if defined(COMPILE_FOR_ASINH) 134 | vy = __riscv_vfsgnj(vy, vx_orig, vlen); 135 | #endif 136 | vy = __riscv_vmerge(vy, vy_special, special_args, vlen); 137 | 138 | // copy vy into y and increment addr pointers 139 | VFSTORE_OUTARG1(vy, vlen); 140 | 141 | INCREMENT_INARG1(vlen); 142 | INCREMENT_OUTARG1(vlen); 143 | } 144 | RESTORE_FRM; 145 | } 146 | -------------------------------------------------------------------------------- /include/rvvlm_atanhD.inc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include "rvvlm_invhyperD.h" 6 | 7 | #if (STRIDE == UNIT_STRIDE) 8 | #define F_VER1 RVVLM_ATANHD_MIXED 9 | #else 10 | #define F_VER1 RVVLM_ATANHDI_MIXED 11 | #endif 12 | 13 | // Atanh(x) is defined only for |x| <= 1. As atanh(-x) = -atanh(x), the 14 | // main computation works with |x|. 15 | // For |x| > 1 and x being a sNaN, the invalid signal has to be generated 16 | // together with a returned valued of NaN. For a qNaN input, no signal is 17 | // generated. And atan(+/- 1) yiedls +/- Inf, but a div-by-zero signal has 18 | // to be generated. 19 | // 20 | // For 0 < x < 1, we use the formula atan(x) = (1/2) log( (1+x)/(1-x) ). 21 | // The usual technique is to find a scale s = 2^(-n) so that 22 | // r = s * (1+x)/(1-x) falls roughly in the region [1/sqrt(2), sqrt(2)]. 23 | // Thus the desired result is (1/2)(n * log(2) + log(r)). 24 | // Somewhat ironically, log(r) is usually approximated in terms of atanh, 25 | // as its Taylor series around 0 converges much faster than that of log(r) 26 | // around 1. log(r) = 2 atanh( (r-1)/(r+1) ). 27 | // Hence, atan(x) = (n/2)log(2) + atan([(1+x)-(1-x)/s]/[(1+x)+(1-x)/s]). 28 | // 29 | // This implementation obtains s=2^(-n) using the approximate reciprocal 30 | // instruction rather than computing (1+x)/(1-x) to extra precision. 31 | // It then combines the two transformations into 32 | // atanh( [(1+x) - (1-x)/s] / [(1+x) + (1-x)/s] ) requiring only 33 | // one division, instead of two. 34 | // We further observe that instead of using multiple extra-precise 35 | // simulations to obtain both the numerator and denominator accurately, 36 | // we can use fixed-point computations. 37 | // As long as the original input |x| >= 0.248, a scale of 60 allows 38 | // both numerator and denominator to maintain high precision without overflow, 39 | // elminating many double-double like simulations. For |x| < 0.248, the 40 | // core polynomial evaluated at x yields the result. 41 | // 42 | void F_VER1(API) { 43 | size_t vlen; 44 | VFLOAT vx, vx_orig, vy, vy_special; 45 | VBOOL special_args; 46 | 47 | SET_ROUNDTONEAREST; 48 | // stripmining over input arguments 49 | for (; _inarg_n > 0; _inarg_n -= vlen) { 50 | vlen = VSET(_inarg_n); 51 | vx = VFLOAD_INARG1(vlen); 52 | vx_orig = vx; 53 | 54 | // Handle Inf, NaN, |input| >= 1, and |input| < 2^(-30) 55 | EXCEPTION_HANDLING_ATANH(vx, special_args, vy_special, vlen); 56 | vx = __riscv_vfsgnj(vx, fp_posOne, vlen); 57 | 58 | // At this point vx are positive number, either 0, or 2^(-30) <= x < 1. 59 | 60 | // Get n so that 2^(-n) * (1+x)/(1-x) is in roughly in the range [1/rt2, 61 | // rt2] 62 | VUINT n; 63 | VFLOAT one_plus_x, one_minus_x; 64 | one_plus_x = __riscv_vfadd(vx, fp_posOne, vlen); 65 | one_minus_x = __riscv_vfrsub(vx, fp_posOne, vlen); 66 | // note one_minus_x >= 2^(-53) is never 0 67 | VFLOAT ratio = 68 | __riscv_vfmul(one_plus_x, __riscv_vfrec7(one_minus_x, vlen), vlen); 69 | n = __riscv_vadd(__riscv_vsrl(F_AS_U(ratio), MAN_LEN - 8, vlen), 0x96, 70 | vlen); 71 | n = __riscv_vsub(__riscv_vsrl(n, 8, vlen), EXP_BIAS, vlen); 72 | 73 | VINT X = __riscv_vfcvt_x(__riscv_vfmul(vx, 0x1.0p60, vlen), vlen); 74 | VINT Numer, Denom; 75 | // no overflow, so it does not matter if we use the saturating add or not 76 | VINT One_plus_X = __riscv_vadd(X, ONE_Q60, vlen); 77 | VINT One_minus_X = __riscv_vrsub(X, ONE_Q60, vlen); 78 | One_minus_X = __riscv_vsll(One_minus_X, n, vlen); 79 | Numer = __riscv_vsub(One_plus_X, One_minus_X, vlen); 80 | Denom = __riscv_vadd(One_plus_X, One_minus_X, vlen); 81 | VFLOAT numer, delta_numer, denom, delta_denom; 82 | numer = __riscv_vfcvt_f(Numer, vlen); 83 | VINT Tail = __riscv_vsub(Numer, __riscv_vfcvt_x(numer, vlen), vlen); 84 | delta_numer = __riscv_vfcvt_f(Tail, vlen); 85 | denom = __riscv_vfcvt_f(Denom, vlen); 86 | Tail = __riscv_vsub(Denom, __riscv_vfcvt_x(denom, vlen), vlen); 87 | delta_denom = __riscv_vfcvt_f(Tail, vlen); 88 | 89 | VFLOAT r_hi, r_lo, r; 90 | DIV2_N2D2(numer, delta_numer, denom, delta_denom, r_hi, r_lo, vlen); 91 | VBOOL x_in_range = __riscv_vmflt(vx, 0x1.0p-8, vlen); 92 | r_hi = __riscv_vmerge(r_hi, vx, x_in_range, vlen); 93 | r_lo = __riscv_vfmerge(r_lo, fp_posZero, x_in_range, vlen); 94 | n = __riscv_vmerge(n, 0, x_in_range, vlen); 95 | 96 | r = __riscv_vfadd(r_hi, r_lo, vlen); 97 | VFLOAT rsq = __riscv_vfmul(r, r, vlen); 98 | VFLOAT rcube = __riscv_vfmul(rsq, r, vlen); 99 | VFLOAT r6 = __riscv_vfmul(rcube, rcube, vlen); 100 | 101 | VFLOAT poly_right = PSTEP( 102 | 0x1.c71c4a9aa397dp-4, rsq, 103 | PSTEP(0x1.7467d1711e0d8p-4, rsq, 104 | PSTEP(0x1.397813e4ac2d0p-4, 0x1.30b2960ceaa62p-4, rsq, vlen), 105 | vlen), 106 | vlen); 107 | 108 | VFLOAT poly_left = PSTEP( 109 | 0x1.55555555555aep-2, rsq, 110 | PSTEP(0x1.999999997646fp-3, 0x1.2492494ac4a16p-3, rsq, vlen), vlen); 111 | 112 | VFLOAT poly = __riscv_vfmadd(poly_right, r6, poly_left, vlen); 113 | poly = __riscv_vfmadd(poly, rcube, r_lo, vlen); 114 | // At this point r_hi + poly approximates atanh(r) 115 | 116 | // Compose the final answer (n/2)*log(2) + atanh(r) 117 | VFLOAT n_flt = __riscv_vfcvt_f(n, vlen); 118 | VFLOAT A = __riscv_vfmul(n_flt, LOG2_BY2_HI, vlen); 119 | VFLOAT S, s; 120 | FAST2SUM(A, r_hi, S, s, vlen); 121 | s = __riscv_vfmacc(s, LOG2_BY2_LO, n_flt, vlen); 122 | s = __riscv_vfadd(s, poly, vlen); 123 | vy = __riscv_vfadd(S, s, vlen); 124 | 125 | vy = __riscv_vfsgnj(vy, vx_orig, vlen); 126 | 127 | vy = __riscv_vmerge(vy, vy_special, special_args, vlen); 128 | 129 | // copy vy into y and increment addr pointers 130 | VFSTORE_OUTARG1(vy, vlen); 131 | 132 | INCREMENT_INARG1(vlen); 133 | INCREMENT_OUTARG1(vlen); 134 | } 135 | RESTORE_FRM; 136 | } 137 | -------------------------------------------------------------------------------- /include/rvvlm_cbrtD.inc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #if (STRIDE == UNIT_STRIDE) 6 | #define F_VER1 RVVLM_CBRTD_ITER 7 | #else 8 | #define F_VER1 RVVLM_CBRTDI_ITER 9 | #endif 10 | 11 | #define EXCEPTION_HANDLING_CBRT(vx, special_args, vy_special, n_adjust, vlen) \ 12 | do { \ 13 | VUINT vclass = __riscv_vfclass((vx), (vlen)); \ 14 | /* special handling NaN, +-Inf, +-0 */ \ 15 | IDENTIFY(vclass, 0x399, (special_args), (vlen)); \ 16 | VBOOL denorm; \ 17 | IDENTIFY(vclass, 0x24, denorm, (vlen)); \ 18 | VBOOL special_n_denorm = __riscv_vmor((special_args), denorm, (vlen)); \ 19 | (n_adjust) = __riscv_vxor((n_adjust), (n_adjust), (vlen)); \ 20 | if (__riscv_vcpop(special_n_denorm, (vlen)) > 0) { \ 21 | /* normalize denormal numbers */ \ 22 | VFLOAT vx_normal = __riscv_vfmul(denorm, vx, 0x1.0p60, (vlen)); \ 23 | (vx) = __riscv_vmerge((vx), vx_normal, denorm, (vlen)); \ 24 | (n_adjust) = __riscv_vmerge((n_adjust), -20, denorm, (vlen)); \ 25 | (vy_special) = __riscv_vfadd((special_args), (vx), (vx), (vlen)); \ 26 | (vx) = __riscv_vfmerge((vx), fp_posOne, (special_args), (vlen)); \ 27 | } \ 28 | } while (0) 29 | 30 | #define ONE_OV_3 0x1.5555555555555p-2 31 | #define THIRD_Q62 0x1555555555555555 32 | #define ONE_Q62 0x4000000000000000 33 | #define CBRT_2_Q62 0x50a28be635ca2b89 34 | #define CBRT_4_Q62 0x6597fa94f5b8f20b 35 | 36 | // This version uses a short polynomial to approximate x^(-1/3) to 14+ bits 37 | // It then iterates to improve the accuracy. Finally x * (x^(-1/3))^2 gives 38 | // x^(1/3) 39 | void F_VER1(API) { 40 | size_t vlen; 41 | VFLOAT vx_orig, vx, vy, vy_special; 42 | VBOOL special_args; 43 | VINT n_adjust; 44 | 45 | SET_ROUNDTONEAREST; 46 | // stripmining over input arguments 47 | for (; _inarg_n > 0; _inarg_n -= vlen) { 48 | vlen = VSET(_inarg_n); 49 | vx_orig = VFLOAD_INARG1(vlen); 50 | 51 | // Set results for input of NaN, +-Inf, +-0, and normalize denormals 52 | EXCEPTION_HANDLING_CBRT(vx_orig, special_args, vy_special, n_adjust, vlen); 53 | vx = __riscv_vfsgnj(vx_orig, fp_posOne, vlen); 54 | 55 | VINT N = __riscv_vsra(F_AS_I(vx), MAN_LEN, vlen); 56 | N = __riscv_vsub(N, EXP_BIAS, vlen); 57 | vx = I_AS_F(__riscv_vsub(F_AS_I(vx), __riscv_vsll(N, MAN_LEN, vlen), vlen)); 58 | // vx are now in [1, 2), the original argument is 2^N * vx 59 | // cube root is 2^M * 2^(J/3) * vx^(1/3) where N = 3 * M + J, 0 <= J <= 2 60 | 61 | VFLOAT poly_left = PSTEP( 62 | 0x1.c7feaf5d6cc3bp+0, vx, 63 | PSTEP(-0x1.910e22c54a1eap+0, 0x1.3e9d3512b6a5ap+0, vx, vlen), vlen); 64 | 65 | VFLOAT xcube = __riscv_vfmul(vx, vx, vlen); 66 | xcube = __riscv_vfmul(xcube, vx, vlen); 67 | 68 | VFLOAT poly_right = PSTEP( 69 | -0x1.3261c716ecf2dp-1, vx, 70 | PSTEP(0x1.3ffc61ff0985dp-3, -0x1.173278cb4b00fp-6, vx, vlen), vlen); 71 | 72 | VFLOAT z = __riscv_vfmadd(poly_right, xcube, poly_left, vlen); 73 | // z ~=~ x^(-1/3) to relatitve error 2^(-17.3) 74 | // iteration is z <-- z + delta * z where delta = 1/3 - 1/3 * x * z^3 75 | 76 | // work on decomposing N = 3 * M + J 77 | // M = N // 3; it is a well known trick that one can get 78 | // integer quotient by multiplication of an "inverse" 79 | // but this works only for non-negative (or non-positive) dividends 80 | // So we add 1023 to N to make it non-negative 81 | VINT L = __riscv_vadd(N, 1023, vlen); 82 | VINT M = __riscv_vsra(__riscv_vmul(L, 1366, vlen), 12, vlen); 83 | ; 84 | // 0 <= L <= 2046; 1366 is ceil(2^12/3); M = L // 3 85 | VINT J = __riscv_vadd(__riscv_vsll(M, 1, vlen), M, vlen); 86 | J = __riscv_vsub(L, J, vlen); // J is N mod 3 87 | M = __riscv_vsub(M, 341, vlen); // 341 is 1023/3 88 | // At this point, N = 3 * M + J 89 | 90 | VINT R = VMVI_VX(ONE_Q62, vlen); 91 | VBOOL J_is_1 = __riscv_vmseq(J, 1, vlen); 92 | VBOOL J_is_2 = __riscv_vmseq(J, 2, vlen); 93 | R = __riscv_vmerge(R, CBRT_2_Q62, J_is_1, vlen); 94 | R = __riscv_vmerge(R, CBRT_4_Q62, J_is_2, vlen); 95 | 96 | // two iterations of z <-- z + delta * z 97 | // rounding error in the first iteration is immaterial 98 | VFLOAT a = __riscv_vfmul(z, z, vlen); 99 | VFLOAT b = __riscv_vfmul(vx, z, vlen); 100 | b = __riscv_vfmul(b, a, vlen); 101 | VFLOAT c = VFMV_VF(ONE_OV_3, vlen); 102 | VFLOAT delta = __riscv_vfnmsub(b, ONE_OV_3, c, vlen); 103 | z = __riscv_vfmacc(z, delta, z, vlen); 104 | 105 | // the second iteration we perform in fixed point 106 | // as the rounding errors need to be controlled 107 | double two_to_62 = 0x1.0p62; 108 | VINT Z_Q62 = __riscv_vfcvt_x(__riscv_vfmul(z, two_to_62, vlen), vlen); 109 | VINT X_Q62 = __riscv_vfcvt_x(__riscv_vfmul(vx, two_to_62, vlen), vlen); 110 | VINT A = __riscv_vsll(__riscv_vsmul(Z_Q62, Z_Q62, 1, vlen), 1, vlen); 111 | VINT B = __riscv_vsll(__riscv_vsmul(X_Q62, Z_Q62, 1, vlen), 1, vlen); 112 | B = __riscv_vsll(__riscv_vsmul(A, B, 1, vlen), 1, vlen); 113 | B = __riscv_vsll(__riscv_vsmul(B, THIRD_Q62, 1, vlen), 1, vlen); 114 | VINT DELTA = __riscv_vrsub(B, THIRD_Q62, vlen); 115 | A = __riscv_vsll(__riscv_vsmul(DELTA, Z_Q62, 1, vlen), 1, vlen); 116 | Z_Q62 = __riscv_vadd(Z_Q62, A, vlen); 117 | 118 | // X * Z * Z is cube root of x in [1, 2) 119 | // then we need to multiply with 2^(1/3) or 4^(1/3) as needed 120 | // together with multiplication with 2^m 121 | Z_Q62 = __riscv_vsll(__riscv_vsmul(Z_Q62, Z_Q62, 1, vlen), 1, vlen); 122 | Z_Q62 = __riscv_vsll(__riscv_vsmul(Z_Q62, X_Q62, 1, vlen), 1, vlen); 123 | R = __riscv_vsmul(R, Z_Q62, 1, vlen); // scale is 61 now 124 | 125 | M = __riscv_vadd(M, EXP_BIAS - 61, vlen); 126 | M = __riscv_vadd(M, n_adjust, vlen); 127 | VFLOAT scale = I_AS_F(__riscv_vsll(M, MAN_LEN, vlen)); 128 | vy = __riscv_vfcvt_f(R, vlen); 129 | vy = __riscv_vfmul(vy, scale, vlen); 130 | vy = __riscv_vfsgnj(vy, vx_orig, vlen); 131 | vy = __riscv_vmerge(vy, vy_special, special_args, vlen); 132 | 133 | // copy vy into y and increment addr pointers 134 | VFSTORE_OUTARG1(vy, vlen); 135 | 136 | INCREMENT_INARG1(vlen); 137 | INCREMENT_OUTARG1(vlen); 138 | } 139 | RESTORE_FRM; 140 | } 141 | -------------------------------------------------------------------------------- /include/rvvlm_expD.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // Macros for common small-block codes 6 | #define EXCEPTION_HANDLING_EXP(vx, special_args, vy_special, vlen) \ 7 | { \ 8 | VUINT vclass = __riscv_vfclass((vx), (vlen)); \ 9 | IDENTIFY(vclass, class_NaN | class_Inf, (special_args), (vlen)) \ 10 | UINT nb_special_args = __riscv_vcpop((special_args), (vlen)); \ 11 | if (nb_special_args > 0) { \ 12 | /* Substitute -Inf with +0 */ \ 13 | VBOOL id_mask; \ 14 | IDENTIFY(vclass, class_negInf, id_mask, (vlen)) \ 15 | vx = __riscv_vfmerge(vx, fp_posZero, id_mask, (vlen)); \ 16 | vy_special = __riscv_vfadd((special_args), (vx), (vx), (vlen)); \ 17 | vx = __riscv_vfmerge((vx), fp_posZero, (special_args), (vlen)); \ 18 | } \ 19 | } 20 | 21 | #define LOG2_INV 0x1.71547652b82fep+0 22 | #define LOG2_HI 0x1.62e42fefa39efp-1 23 | #define LOG2_LO 0x1.abc9e3b39803fp-56 24 | 25 | #define LOG2_INV_64 0x1.71547652b82fep+6 26 | #define LOG2_BY64_HI 0x1.62e42fefa39efp-7 27 | #define LOG2_BY64_LO 0x1.abc9e3b39803fp-62 28 | 29 | #define X_MAX 0x1.65p+9 30 | #define X_MIN -0x1.77p+9 31 | -------------------------------------------------------------------------------- /include/rvvlm_expm1D.inc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // Macros for common small-block codes 6 | #define EXCEPTION_HANDLING_EXPM1(vx, special_args, vy_special, vlen) \ 7 | do { \ 8 | VUINT vclass = __riscv_vfclass((vx), (vlen)); \ 9 | IDENTIFY(vclass, class_NaN | class_Inf, (special_args), (vlen)); \ 10 | UINT nb_special_args = __riscv_vcpop((special_args), (vlen)); \ 11 | if (nb_special_args > 0) { \ 12 | /* Substitute -Inf with -1 */ \ 13 | VBOOL id_mask; \ 14 | IDENTIFY(vclass, class_negInf, id_mask, (vlen)); \ 15 | vx = __riscv_vfmerge((vx), fp_negOne, id_mask, (vlen)); \ 16 | vy_special = __riscv_vfmul((special_args), (vx), fp_posOne, (vlen)); \ 17 | vx = __riscv_vfmerge((vx), fp_posZero, (special_args), (vlen)); \ 18 | } \ 19 | } while (0) 20 | 21 | #if (STRIDE == UNIT_STRIDE) 22 | #define F_VER1 RVVLM_EXPM1D_STD_EPSIM 23 | #else 24 | #define F_VER1 RVVLM_EXPM1DI_STD_EPSIM 25 | #endif 26 | #define P_INV_STD 0x1.71547652b82fep+0 27 | #define P_HI_STD 0x1.62e42fefa39efp-1 28 | #define P_LO_STD 0x1.abc9e3b39803fp-56 29 | #define P_INV_TBL 0x1.71547652b82fep+6 30 | #define P_HI_TBL 0x1.62e42fefa39efp-7 31 | #define P_LO_TBL 0x1.abc9e3b39803fp-62 32 | #define X_MAX 0x1.65p+9 33 | #define X_MIN -0x1.5p+5 34 | 35 | // We use the EPsim version of expD to compute expm1 36 | void F_VER1(API) { 37 | size_t vlen; 38 | VFLOAT vx, vy, vy_special; 39 | VBOOL special_args; 40 | 41 | SET_ROUNDTONEAREST; 42 | // stripmining over input arguments 43 | for (; _inarg_n > 0; _inarg_n -= vlen) { 44 | vlen = VSET(_inarg_n); 45 | vx = VFLOAD_INARG1(vlen); 46 | 47 | EXCEPTION_HANDLING_EXPM1(vx, special_args, vy_special, vlen); 48 | 49 | // Clip 50 | vx = FCLIP(vx, X_MIN, X_MAX, vlen); 51 | 52 | // Argument reduction 53 | VFLOAT flt_n = __riscv_vfmul(vx, P_INV_STD, vlen); 54 | VINT n = __riscv_vfcvt_x(flt_n, vlen); 55 | flt_n = __riscv_vfcvt_f(n, vlen); 56 | 57 | VFLOAT r_tmp = __riscv_vfnmsac(vx, P_HI_STD, flt_n, vlen); 58 | VFLOAT r = __riscv_vfnmsub(flt_n, P_LO_STD, r_tmp, vlen); 59 | VFLOAT r_lo = __riscv_vfsub(r_tmp, r, vlen); 60 | r_lo = __riscv_vfnmsac(r_lo, P_LO_STD, flt_n, vlen); 61 | // r is the reduced argument in working precision; but r + r_lo is extra 62 | // precise exp(r+r_lo) is 1 + (r+r_lo) + (r+r_lo)^2/2 + r^3 * polynomial(r) 63 | // 1 + r + r^2/2 + (r_lo + r * r_lo) + r^3 * polynomial(r) 64 | r_lo = __riscv_vfmacc(r_lo, r, r_lo, vlen); 65 | // 1 + r + r^2/2 + r_lo + r^3 * polynomial(r) 66 | 67 | // Compute P_head + P_tail as r + r^2/2 accurately 68 | VFLOAT r_prime = __riscv_vfmul(r, 0x1.0p-1, vlen); // this coeff is 1/2 69 | VFLOAT P_head = __riscv_vfmadd(r, r_prime, r, vlen); 70 | VFLOAT P_tail = __riscv_vfsub(r, P_head, vlen); 71 | P_tail = __riscv_vfmacc(P_tail, r, r_prime, vlen); 72 | 73 | // Polynomial computation, we have a degree 11 polynomial 74 | VFLOAT poly_right = PSTEP( 75 | 0x1.71ddf7aef0679p-19, r, 76 | PSTEP(0x1.27e4e210af311p-22, r, 77 | PSTEP(0x1.af5ff637cd647p-26, 0x1.1f6562eae5ba9p-29, r, vlen), 78 | vlen), 79 | vlen); 80 | 81 | VFLOAT poly_mid = PSTEP( 82 | 0x1.6c16c16c166f3p-10, r, 83 | PSTEP(0x1.a01a01b0207e3p-13, 0x1.a01a01a4af90ap-16, r, vlen), vlen); 84 | 85 | VFLOAT poly_left = 86 | PSTEP(0x1.5555555555559p-3, r, 87 | PSTEP(0x1.5555555555556p-5, 0x1.111111110f62ap-7, r, vlen), vlen); 88 | 89 | VFLOAT r_sq = __riscv_vfmul(r, r, vlen); 90 | VFLOAT r_cube = __riscv_vfmul(r_sq, r, vlen); 91 | 92 | VFLOAT poly = __riscv_vfmadd(poly_right, r_cube, poly_mid, vlen); 93 | poly = __riscv_vfmadd(poly, r_cube, poly_left, vlen); 94 | // At this point, exp(r) is 1 + P_head + P_tail + r_lo + r^3 * poly 95 | // expm1(x) = 2^n ( 1 - 2^(-n) + P_head + P_tail + r_lo + r^3 * poly ) 96 | 97 | // Compute 1 - 2^(-n) accurately 98 | // Note that n >= -61 because the input argument was clipped because 99 | // expm1(x) = 1 as long as x <= -54 log(2). 100 | // For the purpose of 1 - 2^(-n), n can be clipped to n <= 64 as well 101 | // Then 1 - 2^(-n) = A + a, where A := 1 - 2^(-n), and 102 | // a = 1.0 for n <= -54; a = -2^(-n) if n >= 54; and a = 0 otherwise 103 | // While it is true we can use a KNUTH2SUM to compute A and a using 6 104 | // floating-point instructions, we can obtain A and a with just one 105 | // floating-point instructions and other simple integer instructions. 106 | // This should be more performant on most hardware implementations as 107 | // integer instructions have lower latency in general and possibly using 108 | // hardware resources different from that for floating point. 109 | VFLOAT One = VFMV_VF(fp_posOne, vlen); 110 | VINT n_clip = __riscv_vmin(n, 64, vlen); 111 | // n_clip <= 64; note that n_clip >= -61 112 | VBOOL n_le53 = __riscv_vmsle(n_clip, 53, vlen); 113 | VBOOL n_le_neg54 = __riscv_vmsle(n_clip, -54, vlen); 114 | VINT I_tail = __riscv_vrsub(n_clip, -(EXP_BIAS + 2), vlen); 115 | // The 12 lsb of I_tail is (sign,expo) of -2^(-n_clip) 116 | VFLOAT u = I_AS_F(__riscv_vsll(I_tail, MAN_LEN, vlen)); // u = -2^(-n_clip) 117 | I_tail = __riscv_vmerge(I_tail, 0, n_le53, vlen); 118 | I_tail = __riscv_vmerge(I_tail, EXP_BIAS, n_le_neg54, vlen); 119 | VFLOAT a = I_AS_F(__riscv_vsll(I_tail, MAN_LEN, vlen)); 120 | // a is 1.0, 0, -2^(-n_clip) 121 | // for n <= -54, -53 <= n <= 53, 54 <= n, respectively 122 | VFLOAT A = __riscv_vfadd(One, u, vlen); 123 | 124 | // Compute A + a + P_head + P_tail + r_lo + r^3 * poly 125 | P_tail = __riscv_vfadd(P_tail, a, vlen); 126 | P_tail = __riscv_vfadd(P_tail, r_lo, vlen); 127 | poly = __riscv_vfmadd(poly, r_cube, P_tail, vlen); 128 | P_head = __riscv_vfadd(P_head, poly, vlen); 129 | 130 | vy = __riscv_vfadd(P_head, A, vlen); 131 | // vy is now exp(r) - 1 accurately. 132 | 133 | // Need to compute 2^n * exp(r). 134 | FAST_LDEXP(vy, n, vlen); 135 | 136 | vy = __riscv_vmerge(vy, vy_special, special_args, vlen); 137 | 138 | // copy vy into y and increment addr pointers 139 | VFSTORE_OUTARG1(vy, vlen); 140 | 141 | INCREMENT_INARG1(vlen); 142 | INCREMENT_OUTARG1(vlen); 143 | } 144 | RESTORE_FRM; 145 | } 146 | -------------------------------------------------------------------------------- /include/rvvlm_fp64m1.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #ifndef __RVVLM_FP64M1_H__ 6 | #define __RVVLM_FP64M1_H__ 7 | #define LMUL 1 8 | #define BIT_WIDTH 64 9 | #include "rvvlm_fp.inc.h" 10 | #endif 11 | -------------------------------------------------------------------------------- /include/rvvlm_fp64m2.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #ifndef __RVVLM_FP64M2_H__ 6 | #define __RVVLM_FP64M2_H__ 7 | #define LMUL 2 8 | #define BIT_WIDTH 64 9 | #include "rvvlm_fp.inc.h" 10 | #endif 11 | -------------------------------------------------------------------------------- /include/rvvlm_fp64m4.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #ifndef __RVVLM_FP64M4_H__ 6 | #define __RVVLM_FP64M4_H__ 7 | #define LMUL 4 8 | #define BIT_WIDTH 64 9 | #include "rvvlm_fp.inc.h" 10 | #endif 11 | -------------------------------------------------------------------------------- /include/rvvlm_gammafuncsD.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // gamma(+inf) = +inf; gamma(-inf/sNaN) is qNaN with invalid 6 | // gamma(qNaN) is qNaN 7 | // gamma(+-0) is +-inf and divide by 0 8 | // gamma(tiny) is 1/tiny 9 | #define EXCEPTION_HANDLING_TGAMMA(vx, special_args, vy_special, vlen) \ 10 | do { \ 11 | VUINT expo_x = __riscv_vand(__riscv_vsrl(F_AS_U((vx)), MAN_LEN, (vlen)), \ 12 | 0x7FF, (vlen)); \ 13 | VBOOL x_small = __riscv_vmsltu(expo_x, EXP_BIAS - 60, (vlen)); \ 14 | VBOOL x_InfNaN = __riscv_vmseq(expo_x, 0x7FF, (vlen)); \ 15 | (special_args) = __riscv_vmor(x_small, x_InfNaN, (vlen)); \ 16 | if (__riscv_vcpop((special_args), (vlen)) > 0) { \ 17 | VUINT vclass = __riscv_vfclass((vx), (vlen)); \ 18 | VBOOL x_negInf; \ 19 | IDENTIFY(vclass, class_negInf, x_negInf, (vlen)); \ 20 | (vx) = __riscv_vfmerge((vx), fp_sNaN, x_negInf, (vlen)); \ 21 | VFLOAT y_tmp = __riscv_vfadd(x_InfNaN, (vx), (vx), (vlen)); \ 22 | (vy_special) = __riscv_vmerge((vy_special), y_tmp, x_InfNaN, (vlen)); \ 23 | y_tmp = __riscv_vfrdiv(x_small, (vx), fp_posOne, (vlen)); \ 24 | (vy_special) = __riscv_vmerge((vy_special), y_tmp, x_small, (vlen)); \ 25 | (vx) = __riscv_vfmerge((vx), fp_posOne, (special_args), (vlen)); \ 26 | } \ 27 | } while (0) 28 | -------------------------------------------------------------------------------- /include/rvvlm_hyperbolicsD.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #if defined(COMPILE_FOR_SINH) || defined(COMPILE_FOR_TANH) 6 | #define GEN_EXCEPTIONS(special_args, vx, vlen) \ 7 | __riscv_vfmadd((special_args), (vx), 0x1.0p-60, (vx), (vlen)) 8 | #else 9 | #define GEN_EXCEPTIONS(special_args, vx, vlen) \ 10 | __riscv_vfmadd((special_args), (vx), (vx), VFMV_VF(0x1.0p0, (vlen)), (vlen)) 11 | #endif 12 | 13 | #if defined(COMPILE_FOR_SINH) || defined(COMPILE_FOR_COSH) 14 | #define EXCEPTION_HANDLING_HYPER(vx, expo_x, special_args, vy_special, vlen) \ 15 | do { \ 16 | VUINT vclass = __riscv_vfclass((vx), (vlen)); \ 17 | VBOOL NaN_Inf; \ 18 | IDENTIFY(vclass, class_NaN | class_Inf, NaN_Inf, (vlen)); \ 19 | VBOOL small_x = __riscv_vmsleu((expo_x), EXP_BIAS - MAN_LEN - 5, (vlen)); \ 20 | (special_args) = __riscv_vmor(NaN_Inf, small_x, (vlen)); \ 21 | UINT nb_special_args = __riscv_vcpop((special_args), (vlen)); \ 22 | if (nb_special_args > 0) { \ 23 | (vy_special) = GEN_EXCEPTIONS((special_args), (vx), (vlen)); \ 24 | (vx) = __riscv_vfmerge((vx), fp_posZero, (special_args), (vlen)); \ 25 | } \ 26 | } while (0) 27 | #else 28 | #define EXCEPTION_HANDLING_HYPER(vx, expo_x, special_args, vy_special, vlen) \ 29 | do { \ 30 | VUINT vclass = __riscv_vfclass((vx), (vlen)); \ 31 | VBOOL NaN_Inf; \ 32 | IDENTIFY(vclass, class_NaN | class_Inf, NaN_Inf, (vlen)); \ 33 | VBOOL small_x = __riscv_vmsleu((expo_x), EXP_BIAS - MAN_LEN - 5, (vlen)); \ 34 | (special_args) = __riscv_vmor(NaN_Inf, small_x, (vlen)); \ 35 | UINT nb_special_args = __riscv_vcpop((special_args), (vlen)); \ 36 | if (nb_special_args > 0) { \ 37 | (vy_special) = GEN_EXCEPTIONS((special_args), (vx), (vlen)); \ 38 | VBOOL Inf; \ 39 | IDENTIFY(vclass, class_Inf, Inf, (vlen)); \ 40 | VFLOAT one = VFMV_VF(fp_posOne, (vlen)); \ 41 | one = __riscv_vfsgnj(one, (vx), (vlen)); \ 42 | (vy_special) = __riscv_vmerge((vy_special), one, Inf, (vlen)); \ 43 | (vx) = __riscv_vfmerge((vx), fp_posZero, (special_args), (vlen)); \ 44 | } \ 45 | } while (0) 46 | #endif 47 | 48 | #define LOG2_INV 0x1.71547652b82fep+0 49 | #define LOG2_HI 0x1.62e42fefa39efp-1 50 | #define LOG2_LO 0x1.abc9e3b39803fp-56 51 | 52 | #define ARGUMENT_REDUCTION(vx, n, r, r_delta, vlen) \ 53 | do { \ 54 | VFLOAT n_flt = __riscv_vfmul((vx), LOG2_INV, (vlen)); \ 55 | (n) = __riscv_vfcvt_x(n_flt, (vlen)); \ 56 | n_flt = __riscv_vfcvt_f((n), (vlen)); \ 57 | (r_delta) = __riscv_vfnmsac((vx), LOG2_HI, n_flt, (vlen)); \ 58 | (r) = __riscv_vfnmsac((r_delta), LOG2_LO, n_flt, (vlen)); \ 59 | (r_delta) = __riscv_vfsub((r_delta), (r), (vlen)); \ 60 | (r_delta) = __riscv_vfnmsac((r_delta), LOG2_LO, n_flt, (vlen)); \ 61 | } while (0) 62 | -------------------------------------------------------------------------------- /include/rvvlm_tanhD.inc.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include "rvvlm_hyperbolicsD.h" 6 | 7 | #if (STRIDE == UNIT_STRIDE) 8 | #define F_VER1 RVVLM_TANHD_STD 9 | #else 10 | #define F_VER1 RVVLM_TANHDI_STD 11 | #endif 12 | 13 | // This versions reduces argument to [-log2/2, log2/2] 14 | // Exploit common expressions exp(R) and exp(-R), 15 | // and uses purely floating-point computation 16 | void F_VER1(API) { 17 | size_t vlen; 18 | VFLOAT vx_orig, vx, vy, vy_special; 19 | VBOOL special_args; 20 | VUINT expo_x; 21 | 22 | SET_ROUNDTONEAREST; 23 | // stripmining over input arguments 24 | for (; _inarg_n > 0; _inarg_n -= vlen) { 25 | vlen = VSET(_inarg_n); 26 | vx_orig = VFLOAD_INARG1(vlen); 27 | expo_x = 28 | __riscv_vand(__riscv_vsrl(F_AS_U(vx_orig), MAN_LEN, vlen), 0x7FF, vlen); 29 | 30 | // Set results for input of NaN and Inf and also for |x| very small 31 | EXCEPTION_HANDLING_HYPER(vx_orig, expo_x, special_args, vy_special, vlen); 32 | 33 | // tanh(x) = sign(x) * tanh(|x|); suffices to work on |x| for the main part 34 | vx = __riscv_vfsgnj(vx_orig, fp_posOne, vlen); 35 | 36 | // Suffices to clip |x| to 20, which is bigger than 28 log(2) 37 | vx = __riscv_vfmin(vx, 0x1.4p4, vlen); 38 | VINT n; 39 | VFLOAT r, r_delta; 40 | // tanh(x) = (1 - exp(-2x)) / (1 + exp(-2x)); so we compute exp(-2x) 41 | // by replacing x by -2x 42 | vx = __riscv_vfmul(vx, -0x1.0p1, vlen); 43 | ARGUMENT_REDUCTION(vx, n, r, r_delta, vlen); 44 | //////////////////// 45 | 46 | // exp(x) = 2^n exp(r'), r' = r + r_delta and thus we compute 1 +/- exp(x) 47 | // as 1 +/- 2^(n)(1 + r' + (r')^2/2 + r^3 p(r)) (1 +/- s) +/- s(r' + 48 | // (r')^2/2) +/- s r^3 p(r) To maintain good precision, 1 +/- s and r' + 49 | // (r')^2/2 are computed to extra precision in a leading term and a 50 | // correctional term. This leads to representing 1 +/- exp(x) in a leading 51 | // and correctional term. 52 | 53 | VFLOAT s = 54 | I_AS_F(__riscv_vsll(__riscv_vadd(n, EXP_BIAS, vlen), MAN_LEN, vlen)); 55 | VBOOL s_is_small = __riscv_vmsle(n, -(MAN_LEN + 1), vlen); 56 | VBOOL s_not_small = __riscv_vmnot(s_is_small, vlen); 57 | // 1 +/- s is exact when s is not small 58 | VFLOAT s_head = __riscv_vfmerge(s, fp_posZero, s_is_small, vlen); 59 | VFLOAT s_tail = __riscv_vfmerge(s, fp_posZero, s_not_small, vlen); 60 | // s_head + s_tail = s; and 1 +/- s is (1 +/- s_head) +/- s_tail 61 | 62 | // exp(r') is approximated by 1 + r' + (r')^2/2 + r^3(p_even(r^2) + 63 | // r*p_odd(r^2)) using r without delta_r sufficies from the third order 64 | // onwards 65 | VFLOAT rsq = __riscv_vfmul(r, r, vlen); 66 | VFLOAT rcube = __riscv_vfmul(rsq, r, vlen); 67 | 68 | VFLOAT p_even = PSTEP(0x1.555555555555ap-3, rsq, 69 | PSTEP(0x1.111111110ef6ap-7, rsq, 70 | PSTEP(0x1.a01a01b32b633p-13, rsq, 71 | PSTEP(0x1.71ddef82f4beep-19, 72 | 0x1.af6eacd796f0bp-26, rsq, vlen), 73 | vlen), 74 | vlen), 75 | vlen); 76 | 77 | VFLOAT p_odd = PSTEP( 78 | 0x1.5555555553aefp-5, rsq, 79 | PSTEP(0x1.6c16c17a09506p-10, rsq, 80 | PSTEP(0x1.a019b37a2b3dfp-16, 0x1.289788d8bdadfp-22, rsq, vlen), 81 | vlen), 82 | vlen); 83 | 84 | VFLOAT poly = __riscv_vfmadd(p_odd, r, p_even, vlen); 85 | // r^3 * poly will be r^3(...) 86 | // we delay this multiplication with r^3 for now 87 | 88 | // Compute r' + (r')^2/2 extra precisely 89 | VFLOAT r_prime = __riscv_vfmul(r, 0x1.0p-1, vlen); 90 | VFLOAT B = __riscv_vfmadd(r, r_prime, r, vlen); 91 | VFLOAT b = __riscv_vfsub(r, B, vlen); 92 | b = __riscv_vfmacc(b, r, r_prime, vlen); 93 | // B + b is r' + (r')^2/2 extra precisely 94 | // incoporate r_delta in R + R^2/2 95 | VFLOAT c = __riscv_vfmadd(r, r_delta, r_delta, vlen); 96 | b = __riscv_vfadd(b, c, vlen); 97 | poly = __riscv_vfmadd(poly, rcube, b, vlen); 98 | // B + poly is r' + (r')^2/2 + r^3(.....) 99 | // and exp(r') is well approximated by s*(1 + B + poly) 100 | 101 | // We compute the denominator 1 + exp(R) first as 102 | // we will need to recipricate afterwards, the latency of which 103 | // can be hidden somewhat by proceeding with the numerator 104 | // at that time 105 | VFLOAT Z = __riscv_vfadd(s_head, fp_posOne, vlen); 106 | VFLOAT D_tmp = __riscv_vfmadd(B, s, Z, vlen); 107 | VFLOAT d_tmp = __riscv_vfsub(Z, D_tmp, vlen); 108 | d_tmp = __riscv_vfmacc(d_tmp, s, B, vlen); 109 | d_tmp = __riscv_vfadd(d_tmp, s_tail, vlen); 110 | d_tmp = __riscv_vfmacc(d_tmp, s, poly, vlen); 111 | // D_tmp + d_tmp is 1 + exp(R) to high precision, but we have to 112 | // normalize this representation so that the leading term 113 | // has full FP64 precision of this sum 114 | VFLOAT D, d; 115 | FAST2SUM(D_tmp, d_tmp, D, d, vlen); 116 | // VFLOAT D = __riscv_vfadd(D_tmp, d, vlen); 117 | // Z = __riscv_vfsub(D_tmp, D, vlen); 118 | // d = __riscv_vfadd(Z, d, vlen); 119 | 120 | // Now start to compute 1/(D+d) as E + e 121 | VFLOAT One = VFMV_VF(fp_posOne, vlen); 122 | VFLOAT E, e; 123 | DIV_N1D2(One, D, d, E, e, vlen); 124 | // E + e is 1/(D+d) to extra precision 125 | 126 | // Overlap much of the 1/(D+d) computation with 127 | // computing 1 - s(1 + B + poly) 128 | Z = __riscv_vfrsub(s_head, fp_posOne, vlen); 129 | 130 | VFLOAT Numer = __riscv_vfnmsub(B, s, Z, vlen); 131 | VFLOAT numer = __riscv_vfsub(Z, Numer, vlen); 132 | numer = __riscv_vfnmsac(numer, s, B, vlen); 133 | 134 | // Numer + numer = Z - s * B accurately 135 | numer = __riscv_vfsub(numer, s_tail, vlen); 136 | numer = __riscv_vfnmsac(numer, s, poly, vlen); 137 | 138 | // (Numer + numer) * (E + e) 139 | // Numer * E + ( numer * E + (Numer * e + (e*numer)) ) 140 | vy = __riscv_vfmul(e, numer, vlen); 141 | vy = __riscv_vfmacc(vy, Numer, e, vlen); 142 | vy = __riscv_vfmacc(vy, numer, E, vlen); 143 | vy = __riscv_vfmacc(vy, Numer, E, vlen); 144 | 145 | vy = __riscv_vfsgnj(vy, vx_orig, vlen); 146 | vy = __riscv_vmerge(vy, vy_special, special_args, vlen); 147 | 148 | // copy vy into y and increment addr pointers 149 | VFSTORE_OUTARG1(vy, vlen); 150 | 151 | INCREMENT_INARG1(vlen); 152 | INCREMENT_OUTARG1(vlen); 153 | } 154 | RESTORE_FRM; 155 | } 156 | -------------------------------------------------------------------------------- /src/rvvlm_2ovpi_tbl.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // This table is used my different functions of the log and exponential family 6 | #include 7 | 8 | // This is 2^500 * (2/pi) and the lsb of dbl_2ovpi_tbl[j] is 2^(500-(j+1)*52), 9 | // j=0,1,...,27 10 | const double dbl_2ovpi_tbl[28] = { 11 | 0x1.45f306dc9c882p+499, 0x1.4a7f09d5f47d4p+446, 0x1.a6ee06db14ad0p+393, 12 | -0x1.b0ef1bef806bcp+342, 0x1.8eaf7aef1586cp+290, 0x1.c91b8e909374cp+238, 13 | -0x1.ff9b6d115f630p+184, 0x1.921cfe1deb1d0p+132, -0x1.3b5963045df74p+82, 14 | 0x1.7d4baed1213a8p+30, -0x1.8e3f652e82070p-22, 0x1.3991d63983530p-76, 15 | 0x1.cfa4e422fc5e0p-127, -0x1.036be27003b40p-179, -0x1.0fd33f8086800p-239, 16 | -0x1.dce94beb25c20p-285, 0x1.b4d9fb3c9f2c4p-334, -0x1.922c2e7026588p-386, 17 | 0x1.7fa8b5d49eeb0p-438, 0x1.faf97c5ecf41cp-490, 0x1.cfbc529497538p-543, 18 | -0x1.012813b81ca8cp-594, 0x1.0ac06608df900p-649, -0x1.251503cc10f7cp-698, 19 | -0x1.942f27895871cp-750, 0x1.615ee61b08660p-804, -0x1.99ea83ad7e5f0p-854, 20 | 0x1.1bffb1009ae60p-909}; 21 | -------------------------------------------------------------------------------- /src/rvvlm_acosD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ACOSD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ACOS 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_acosDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ACOSDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ACOS 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_acoshD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ACOSHD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ACOSH 14 | 15 | #include "rvvlm_asinhcoshD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_acoshDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ACOSHDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ACOSH 14 | 15 | #include "rvvlm_asinhcoshD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_acospiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ACOSPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ACOSPI 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_acospiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ACOSPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ACOSPI 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_asinD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ASIND_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ASIN 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_asinDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ASINDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ASIN 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_asinhD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ASINHD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ASINH 14 | 15 | #include "rvvlm_asinhcoshD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_asinhDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ASINHDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ASINH 14 | 15 | #include "rvvlm_asinhcoshD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_asinpiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ASINPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ASINPI 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_asinpiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ASINPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ASINPI 14 | 15 | #include "rvvlm_asincosD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atan2D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_21 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ATAN2D_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATAN2 14 | 15 | #include "rvvlm_atan2D.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atan2DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_21 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ATAN2DI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATAN2 14 | 15 | #include "rvvlm_atan2D.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atan2piD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_21 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ATAN2PID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATAN2PI 14 | 15 | #include "rvvlm_atan2D.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atan2piDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_21 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ATAN2PIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATAN2PI 14 | 15 | #include "rvvlm_atan2D.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atanD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ATAND_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATAN 14 | 15 | #include "rvvlm_atanD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atanDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ATANDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATAN 14 | 15 | #include "rvvlm_atanD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atanhD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ATANHD_VSET_CONFIG 12 | 13 | #include "rvvlm_atanhD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_atanhDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ATANHDI_VSET_CONFIG 12 | 13 | #include "rvvlm_atanhD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_atanpiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ATANPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATANPI 14 | 15 | #include "rvvlm_atanD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_atanpiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ATANPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ATANPI 14 | 15 | #include "rvvlm_atanD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_cbrtD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_CBRTD_VSET_CONFIG 12 | 13 | #include "rvvlm_cbrtD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_cbrtDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_CBRTDI_VSET_CONFIG 12 | 13 | #include "rvvlm_cbrtD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_cdfnormD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_CDFNORMD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_CDFNORM 14 | #include "rvvlm_errorfuncsD.h" 15 | 16 | #include "rvvlm_erfcD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cdfnormDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_CDFNORMDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_CDFNORM 14 | #include "rvvlm_errorfuncsD.h" 15 | 16 | #include "rvvlm_erfcD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cdfnorminvD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_CDFNORMINVD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_CDFNORMINV 14 | #include "rvvlm_inverrorfuncsD.h" 15 | 16 | #include "rvvlm_cdfnorminvD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cdfnorminvDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_CDFNORMINVDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_CDFNORMINV 14 | #include "rvvlm_inverrorfuncsD.h" 15 | 16 | #include "rvvlm_cdfnorminvD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cosD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_COSD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_COS 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cosDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_COSDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_COS 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_coshD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_COSHD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_COSH 14 | #include "rvvlm_hyperbolicsD.h" 15 | 16 | #include "rvvlm_sinhcoshD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_coshDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_COSHDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_COSH 14 | #include "rvvlm_hyperbolicsD.h" 15 | 16 | #include "rvvlm_sinhcoshD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cospiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_COSPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_COSPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_cospiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_COSPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_COSPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ERFD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERF 14 | #include "rvvlm_errorfuncsD.h" 15 | 16 | #include "rvvlm_erfD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ERFDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERF 14 | #include "rvvlm_errorfuncsD.h" 15 | 16 | #include "rvvlm_erfD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfcD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ERFCD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERFC 14 | #include "rvvlm_errorfuncsD.h" 15 | 16 | #include "rvvlm_erfcD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfcDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ERFCDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERFC 14 | #include "rvvlm_errorfuncsD.h" 15 | 16 | #include "rvvlm_erfcD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfcinvD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ERFCINVD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERFCINV 14 | #include "rvvlm_inverrorfuncsD.h" 15 | 16 | #include "rvvlm_erfcinvD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfcinvDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ERFCINVDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERFCINV 14 | #include "rvvlm_inverrorfuncsD.h" 15 | 16 | #include "rvvlm_erfcinvD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfinvD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_ERFINVD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERFINV 14 | #include "rvvlm_inverrorfuncsD.h" 15 | 16 | #include "rvvlm_erfinvD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_erfinvDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_ERFINVDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_ERFINV 14 | #include "rvvlm_inverrorfuncsD.h" 15 | 16 | #include "rvvlm_erfinvD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_exp10D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_EXP10D_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_EXP10 14 | #include "rvvlm_expD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_exp10DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_EXPDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_EXP10 14 | #include "rvvlm_expD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_exp2D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_EXP2D_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_EXP2 14 | #include "rvvlm_expD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_exp2DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_EXPDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_EXP2 14 | #include "rvvlm_expD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_expD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_EXPD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_EXP 14 | #include "rvvlm_expD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_expDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_EXPDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_EXP 14 | #include "rvvlm_expD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_expD_tbl.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | // This table is used my different functions of the exp and exponential family 6 | #include 7 | 8 | // The following contains exp(j/64) for j = 0, 1, ..., 63 9 | // We need these values to more than FP64 precision. We do this 10 | // by exploiting fixed-point computation supported by RISC-V 11 | // This table contains round-to-int(2^62 * exp(j/64)) 12 | const int64_t expD_tbl64_fixedpt[64] = { 13 | 0x4000000000000000, 0x40b268f9de0183ba, 0x4166c34c5615d0ec, 14 | 0x421d1461d66f2023, 0x42d561b3e6243d8a, 0x438fb0cb4f468808, 15 | 0x444c0740496d4294, 0x450a6abaa4b77ecd, 0x45cae0f1f545eb73, 16 | 0x468d6fadbf2dd4f3, 0x47521cc5a2e6a9e0, 0x4818ee218a3358ee, 17 | 0x48e1e9b9d588e19b, 0x49ad159789f37496, 0x4a7a77d47f7b84b1, 18 | 0x4b4a169b900c2d00, 0x4c1bf828c6dc54b8, 0x4cf022c9905bfd32, 19 | 0x4dc69cdceaa72a9c, 0x4e9f6cd3967fdba8, 0x4f7a993048d088d7, 20 | 0x50582887dcb8a7e1, 0x513821818624b40c, 0x521a8ad704f3404f, 21 | 0x52ff6b54d8a89c75, 0x53e6c9da74b29ab5, 0x54d0ad5a753e077c, 22 | 0x55bd1cdad49f699c, 0x56ac1f752150a563, 0x579dbc56b48521ba, 23 | 0x5891fac0e95612c8, 0x5988e20954889245, 0x5a827999fcef3242, 24 | 0x5b7ec8f19468bbc9, 0x5c7dd7a3b17dcf75, 0x5d7fad59099f22fe, 25 | 0x5e8451cfac061b5f, 0x5f8bccdb3d398841, 0x6096266533384a2b, 26 | 0x61a3666d124bb204, 0x62b39508aa836d6f, 0x63c6ba6455dcd8ae, 27 | 0x64dcdec3371793d1, 0x65f60a7f79393e2e, 0x6712460a8fc24072, 28 | 0x683199ed779592ca, 0x69540ec8f895722d, 0x6a79ad55e7f6fd10, 29 | 0x6ba27e656b4eb57a, 0x6cce8ae13c57ebdb, 0x6dfddbcbed791bab, 30 | 0x6f307a412f074892, 0x70666f76154a7089, 0x719fc4b95f452d29, 31 | 0x72dc8373be41a454, 0x741cb5281e25ee34, 0x75606373ee921c97, 32 | 0x76a7980f6cca15c2, 0x77f25ccdee6d7ae6, 0x7940bb9e2cffd89d, 33 | 0x7a92be8a92436616, 0x7be86fb985689ddc, 0x7d41d96db915019d, 34 | 0x7e9f06067a4360ba, 35 | }; 36 | -------------------------------------------------------------------------------- /src/rvvlm_expint1D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_EXPINT1D_VSET_CONFIG 12 | 13 | #include "rvvlm_expint1D.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_expint1DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_EXPINT1DI_VSET_CONFIG 12 | 13 | #include "rvvlm_expint1D.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_expm1D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_EXPM1D_VSET_CONFIG 12 | 13 | #include "rvvlm_expm1D.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_expm1DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_EXPM1DI_VSET_CONFIG 12 | 13 | #include "rvvlm_expm1D.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_lgammaD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_LGAMMAD_VSET_CONFIG 12 | 13 | #include "rvvlm_gammafuncsD.h" 14 | 15 | #include "rvvlm_lgammaD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_lgammaDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_LGAMMADI_VSET_CONFIG 12 | 13 | #include "rvvlm_gammafuncsD.h" 14 | 15 | #include "rvvlm_lgammaD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_log10D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_LOG10D_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_LOG10 14 | #include "rvvlm_logD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_log10DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_LOG10DI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_LOG10 14 | #include "rvvlm_logD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_log1pD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_LOG1PD_VSET_CONFIG 12 | 13 | #include "rvvlm_log1pD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_log1pDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_LOG1PDI_VSET_CONFIG 12 | 13 | #include "rvvlm_log1pD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_log2D.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_LOG2D_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_LOG2 14 | #include "rvvlm_logD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_log2DI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_LOG2DI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_LOG2 14 | #include "rvvlm_logD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_logD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_LOGD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_LOG 14 | #include "rvvlm_logD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_logDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_LOGDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_LOG 14 | #include "rvvlm_logD.inc.h" 15 | -------------------------------------------------------------------------------- /src/rvvlm_powD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_21 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_POWD_VSET_CONFIG 12 | 13 | #include "rvvlm_powD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_powDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_21 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_POWDI_VSET_CONFIG 12 | 13 | #include "rvvlm_powD.inc.h" 14 | -------------------------------------------------------------------------------- /src/rvvlm_sinD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_SIND_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SIN 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sinDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_SINDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SIN 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sincosD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_12 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_SINCOSD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINCOS 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sinandcosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sincosDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_12 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_SINCOSDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINCOS 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sinandcosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sincospiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_12 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_SINCOSPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINCOSPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sinandcosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sincospiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_12 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_SINCOSPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINCOSPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sinandcosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sinhD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_SINHD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINH 14 | #include "rvvlm_hyperbolicsD.h" 15 | 16 | #include "rvvlm_sinhcoshD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sinhDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_SINHDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINH 14 | #include "rvvlm_hyperbolicsD.h" 15 | 16 | #include "rvvlm_sinhcoshD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sinpiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_SINPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_sinpiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_SINPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_SINPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_sincosD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tanD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_TAND_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_TAN 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_tanD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tanDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_TANDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_TAN 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_tanD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tanhD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_TANHD_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_TANH 14 | #include "rvvlm_hyperbolicsD.h" 15 | 16 | #include "rvvlm_tanhD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tanhDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_TANHDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_TANH 14 | #include "rvvlm_hyperbolicsD.h" 15 | 16 | #include "rvvlm_tanhD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tanpiD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_TANPID_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_TANPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_tanD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tanpiDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_TANPIDI_VSET_CONFIG 12 | 13 | #define COMPILE_FOR_TANPI 14 | #include "rvvlm_trigD.h" 15 | 16 | #include "rvvlm_tanD.inc.h" 17 | -------------------------------------------------------------------------------- /src/rvvlm_tgammaD.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE UNIT_STRIDE 10 | 11 | #include RVVLM_TGAMMAD_VSET_CONFIG 12 | 13 | #include "rvvlm_gammafuncsD.h" 14 | 15 | #include "rvvlm_tgammaD.inc.h" 16 | -------------------------------------------------------------------------------- /src/rvvlm_tgammaDI.c: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | 7 | #include "rvvlm.h" 8 | #define API_SIGNATURE API_SIGNATURE_11 9 | #define STRIDE GENERAL_STRIDE 10 | 11 | #include RVVLM_TGAMMADI_VSET_CONFIG 12 | 13 | #include "rvvlm_gammafuncsD.h" 14 | 15 | #include "rvvlm_tgammaD.inc.h" 16 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | # 3 | # SPDX-License-Identifier: Apache-2.0 4 | 5 | set(TEST_SOURCES 6 | src/test_infra.cpp 7 | src/test_acos.cpp 8 | src/test_acosI.cpp 9 | src/test_acospi.cpp 10 | src/test_acospiI.cpp 11 | src/test_asin.cpp 12 | src/test_asinI.cpp 13 | src/test_asinpi.cpp 14 | src/test_asinpiI.cpp 15 | src/test_atan.cpp 16 | src/test_atanI.cpp 17 | src/test_atanpi.cpp 18 | src/test_atanpiI.cpp 19 | src/test_atan2.cpp 20 | src/test_atan2I.cpp 21 | src/test_atan2pi.cpp 22 | src/test_atan2piI.cpp 23 | src/test_acosh.cpp 24 | src/test_acoshI.cpp 25 | src/test_asinh.cpp 26 | src/test_asinhI.cpp 27 | src/test_atanh.cpp 28 | src/test_atanhI.cpp 29 | src/test_cbrt.cpp 30 | src/test_cbrtI.cpp 31 | src/test_cdfnorm.cpp 32 | src/test_cdfnormI.cpp 33 | src/test_cdfnorminv.cpp 34 | src/test_cdfnorminvI.cpp 35 | src/test_erf.cpp 36 | src/test_erfI.cpp 37 | src/test_erfc.cpp 38 | src/test_erfcI.cpp 39 | src/test_erfinv.cpp 40 | src/test_erfinvI.cpp 41 | src/test_erfcinv.cpp 42 | src/test_erfcinvI.cpp 43 | src/test_exp.cpp 44 | src/test_expI.cpp 45 | src/test_exp2.cpp 46 | src/test_exp2I.cpp 47 | src/test_exp10.cpp 48 | src/test_exp10I.cpp 49 | src/test_expm1.cpp 50 | src/test_expm1I.cpp 51 | src/test_expint1.cpp 52 | src/test_expint1I.cpp 53 | src/test_log.cpp 54 | src/test_logI.cpp 55 | src/test_log2.cpp 56 | src/test_log2I.cpp 57 | src/test_log10.cpp 58 | src/test_log10I.cpp 59 | src/test_log1p.cpp 60 | src/test_log1pI.cpp 61 | src/test_pow.cpp 62 | src/test_powI.cpp 63 | src/test_cos.cpp 64 | src/test_cosI.cpp 65 | src/test_sin.cpp 66 | src/test_sinI.cpp 67 | src/test_cospi.cpp 68 | src/test_cospiI.cpp 69 | src/test_sinpi.cpp 70 | src/test_sinpiI.cpp 71 | src/test_sincos.cpp 72 | src/test_sincosI.cpp 73 | src/test_sincospi.cpp 74 | src/test_sincospiI.cpp 75 | src/test_tan.cpp 76 | src/test_tanI.cpp 77 | src/test_tanpi.cpp 78 | src/test_cosh.cpp 79 | src/test_coshI.cpp 80 | src/test_sinh.cpp 81 | src/test_sinhI.cpp 82 | src/test_tanh.cpp 83 | src/test_tanhI.cpp 84 | src/test_lgamma.cpp 85 | src/test_lgammaI.cpp 86 | src/test_tgamma.cpp 87 | src/test_tgammaI.cpp 88 | ) 89 | 90 | add_executable(test_veclibm ${TEST_SOURCES}) 91 | 92 | target_include_directories(test_veclibm 93 | PRIVATE 94 | include 95 | ) 96 | 97 | target_link_libraries(test_veclibm 98 | vecm 99 | GTest::gtest_main 100 | ) 101 | 102 | target_compile_options(test_veclibm 103 | PRIVATE 104 | $<$:-std=c11> 105 | $<$:-std=c++17> 106 | ) 107 | 108 | gtest_discover_tests(test_veclibm) 109 | -------------------------------------------------------------------------------- /test/include/near_NPiby2_tbl.h: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2024 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #define NB_TEST_ARGS 63 * 3 6 | static const double dbl_near_NPiby2_tbl[NB_TEST_ARGS] = { 7 | 0x1.6c6cbc45dc8dep+9, 0x1.6c6cbc45dc8dep+10, 0x1.6c6cbc45dc8dep+11, 8 | 0x1.6c6cbc45dc8dep+12, 0x1.635e3d74befcap+14, 0x1.67e57cdd4dc54p+15, 9 | 0x1.65a1dd290660fp+16, 0x1.bf9b3c6059d24p+17, 0x1.39c6fd67805a7p+18, 10 | 0x1.39c6fd67805a7p+19, 0x1.9eb7148f354d6p+20, 0x1.9eb7148f354d6p+20, 11 | 0x1.d3ecce1f28274p+22, 0x1.b951f1572eba5p+23, 0x1.b951f1572eba5p+24, 12 | 0x1.b951f1572eba5p+25, 0x1.b951f1572eba5p+26, 0x1.b951f1572eba5p+27, 13 | 0x1.b951f1572eba5p+28, 0x1.b951f1572eba5p+29, 0x1.b951f1572eba5p+30, 14 | 0x1.b951f1572eba5p+31, 0x1.5c9508c58aafap+32, 0x1.5c9508c58aafap+32, 15 | 0x1.de5e5054e921bp+34, 0x1.46546a5bd73ccp+35, 0x1.46546a5bd73ccp+35, 16 | 0x1.46546a5bd73ccp+35, 0x1.bb23eaa3db16dp+38, 0x1.065c829d68730p+39, 17 | 0x1.065c829d68730p+39, 0x1.065c829d68730p+39, 0x1.065c829d68730p+39, 18 | 0x1.065c829d68730p+39, 0x1.065c829d68730p+40, 0x1.065c829d68730p+41, 19 | 0x1.f42d52c35675dp+46, 0x1.7512069b7430dp+47, 0x1.7512069b7430dp+48, 20 | 0x1.7512069b7430dp+49, 0x1.44630cc2cad9dp+50, 0x1.5cba89af1f855p+51, 21 | 0x1.5cba89af1f855p+52, 0x1.56a4aa740a5a7p+53, 0x1.59af9a1194efep+54, 22 | 0x1.59af9a1194efep+54, 0x1.ae9608c734e12p+56, 0x1.ae9608c734e12p+56, 23 | 0x1.c3cfa4749cdd7p+58, 0x1.c3cfa4749cdd7p+59, 0x1.c3cfa4749cdd7p+60, 24 | 0x1.c3cfa4749cdd7p+61, 0x1.ed814f0220525p+62, 0x1.ed814f0220525p+63, 25 | 0x1.a7f3bc5a7ed9ep+64, 0x1.a7f3bc5a7ed9ep+64, 0x1.a7f3bc5a7ed9ep+65, 26 | 0x1.782b7a20df6d4p+67, 0x1.782b7a20df6d4p+67, 0x1.782b7a20df6d4p+67, 27 | 0x1.782b7a20df6d4p+68, 0x1.782b7a20df6d4p+69, 0x1.782b7a20df6d4p+70, 28 | 0x1.782b7a20df6d4p+71, 0x1.a4ffb379a019cp+74, 0x1.308ab84507e83p+75, 29 | 0x1.99caa5236feeap+76, 0x1.99caa5236feeap+76, 0x1.99caa5236feeap+77, 30 | 0x1.99caa5236feeap+78, 0x1.99caa5236feeap+79, 0x1.e0664dbedfec5p+81, 31 | 0x1.e0664dbedfec5p+82, 0x1.e0664dbedfec5p+83, 0x1.e0664dbedfec5p+84, 32 | 0x1.f19e5d71b26bap+85, 0x1.f19e5d71b26bap+85, 0x1.f19e5d71b26bap+86, 33 | 0x1.f19e5d71b26bap+87, 0x1.d4ab7990f194dp+89, 0x1.66bd5424e5655p+90, 34 | 0x1.66bd5424e5655p+91, 0x1.66bd5424e5655p+92, 0x1.66bd5424e5655p+93, 35 | 0x1.66bd5424e5655p+94, 0x1.c3dc1a597f202p+95, 0x1.c3dc1a597f202p+95, 36 | 0x1.c3dc1a597f202p+96, 0x1.e50fec1788957p+98, 0x1.e50fec1788957p+99, 37 | 0x1.e50fec1788957p+100, 0x1.e50fec1788957p+101, 0x1.77d794c891d1cp+102, 38 | 0x1.dae3a00451b5fp+103, 0x1.dae3a00451b5fp+104, 0x1.1c6cc29b3b153p+105, 39 | 0x1.d99e1681eada0p+106, 0x1.d99e1681eada0p+106, 0x1.d99e1681eada0p+106, 40 | 0x1.d99e1681eada0p+106, 0x1.d99e1681eada0p+106, 0x1.d99e1681eada0p+106, 41 | 0x1.f8d36a8915598p+112, 0x1.ae04fdb542be8p+113, 0x1.ae04fdb542be8p+113, 42 | 0x1.ae04fdb542be8p+113, 0x1.ae04fdb542be8p+113, 0x1.ae04fdb542be8p+114, 43 | 0x1.ed82892c91569p+118, 0x1.47623428452f0p+119, 0x1.47623428452f0p+119, 44 | 0x1.47623428452f0p+119, 0x1.f7e7a76e07787p+122, 0x1.f7e7a76e07787p+123, 45 | 0x1.e7426933f5760p+124, 0x1.e7426933f5760p+124, 0x1.e7426933f5760p+124, 46 | 0x1.e7426933f5760p+124, 0x1.e7426933f5760p+124, 0x1.e7426933f5760p+124, 47 | 0x1.f91a847a07755p+130, 0x1.504cac51f1eafp+131, 0x1.504cac51f1eafp+132, 48 | 0x1.504cac51f1eafp+133, 0x1.504cac51f1eafp+134, 0x1.504cac51f1eafp+135, 49 | 0x1.504cac51f1eafp+136, 0x1.8a56c23d2dfe0p+137, 0x1.8a56c23d2dfe0p+137, 50 | 0x1.b2e25ce13d6a7p+139, 0x1.e42d3528e32a3p+140, 0x1.fcd2a14cb60a1p+141, 51 | 0x1.fcd2a14cb60a1p+142, 0x1.5ad5a62cb1cc9p+143, 0x1.5ad5a62cb1cc9p+144, 52 | 0x1.5ad5a62cb1cc9p+145, 0x1.5ad5a62cb1cc9p+146, 0x1.f1cdf37f20ff1p+147, 53 | 0x1.a651ccd5e965dp+148, 0x1.a651ccd5e965dp+149, 0x1.b930d680374c2p+150, 54 | 0x1.b930d680374c2p+150, 0x1.b930d680374c2p+151, 0x1.b930d680374c2p+152, 55 | 0x1.641bcd12e3311p+154, 0x1.205a1c297f6b9p+155, 0x1.205a1c297f6b9p+156, 56 | 0x1.205a1c297f6b9p+157, 0x1.17e1e60c52f2ep+158, 0x1.17e1e60c52f2ep+158, 57 | 0x1.ee076da427656p+160, 0x1.82f4a9d83d2c2p+161, 0x1.82f4a9d83d2c2p+161, 58 | 0x1.682ff8e5429ddp+163, 0x1.682ff8e5429ddp+164, 0x1.682ff8e5429ddp+165, 59 | 0x1.682ff8e5429ddp+166, 0x1.cca7515e2585cp+167, 0x1.cca7515e2585cp+167, 60 | 0x1.bdf4d57f7f0c4p+169, 0x1.c54e136ed2490p+170, 0x1.c54e136ed2490p+170, 61 | 0x1.c54e136ed2490p+170, 0x1.fc218660d7c2fp+173, 0x1.fc218660d7c2fp+174, 62 | 0x1.d28d5c4c5e73bp+175, 0x1.d28d5c4c5e73bp+176, 0x1.d28d5c4c5e73bp+177, 63 | 0x1.2722f5d698acep+178, 0x1.2722f5d698acep+178, 0x1.2722f5d698acep+179, 64 | 0x1.76e1ee2edd343p+181, 0x1.0539b48d14c55p+182, 0x1.0539b48d14c55p+183, 65 | 0x1.0539b48d14c55p+184, 0x1.0539b48d14c55p+185, 0x1.6014d4a7e0086p+186, 66 | 0x1.b5441ee104c98p+187, 0x1.b5441ee104c98p+187, 0x1.f7fd817cb39b5p+189, 67 | 0x1.f7fd817cb39b5p+190, 0x1.bb4c8e40cbe5dp+191, 0x1.bb4c8e40cbe5dp+192, 68 | 0x1.3ecf49b990c61p+193, 0x1.0090a775f3363p+194, 0x1.1faff897c1fe2p+195, 69 | 0x1.1faff897c1fe2p+195, 0x1.e7e44a78ac18cp+197, 0x1.e7e44a78ac18cp+197}; 70 | -------------------------------------------------------------------------------- /test/src/test_acos.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(acos, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("acos: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_acos, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p-40; 20 | x_end = 0x1.0p-40; 21 | ; 22 | nb_tests = 10000; 23 | report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); 24 | 25 | x_start = -0.5; 26 | x_end = 0.5; 27 | nb_tests = 10000; 28 | report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); 29 | 30 | x_start = 0.5; 31 | x_end = 1.0; 32 | nb_tests = 10000; 33 | report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); 34 | 35 | x_start = -1.0; 36 | x_end = -0.5; 37 | nb_tests = 10000; 38 | report_err_fp64(rvvlm_acos, acosl, x_start, x_end, nb_tests); 39 | } 40 | -------------------------------------------------------------------------------- /test/src/test_acosI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(acosI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("acosI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_acosI, acosl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_acosh.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(acosh, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("acosh: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_acosh, "Special Value handling of this function"); 18 | 19 | x_start = 0x1.0p0 + 0x1.0p-52; 20 | x_end = 0x1.0p0 + 0x1.0p-10; 21 | nb_tests = 40000; 22 | report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); 23 | 24 | x_start = 0x1.0p0; 25 | x_end = 0x1.0p2; 26 | nb_tests = 40000; 27 | report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p490; 30 | x_end = 0x1.0p520; 31 | nb_tests = 40000; 32 | report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); 33 | 34 | x_start = 0x1.0p1020; 35 | x_end = 0x1.FFFFFFFFFFp1023; 36 | nb_tests = 40000; 37 | report_err_fp64(rvvlm_acosh, acoshl, x_start, x_end, nb_tests); 38 | } 39 | -------------------------------------------------------------------------------- /test/src/test_acoshI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(acoshI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("acoshI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 1.2; 18 | x_end = 10.0; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_acoshI, acoshl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_acospi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(acospi, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("acospi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_acospi, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p-40; 20 | x_end = 0x1.0p-40; 21 | nb_tests = 10000; 22 | report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); 23 | 24 | x_start = -0.5; 25 | x_end = 0.5; 26 | nb_tests = 10000; 27 | report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); 28 | 29 | x_start = 0.5; 30 | x_end = 1.0; 31 | nb_tests = 10000; 32 | report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); 33 | 34 | x_start = -1.0; 35 | x_end = -0.5; 36 | nb_tests = 10000; 37 | report_err_fp64(rvvlm_acospi, acospil, x_start, x_end, nb_tests); 38 | } 39 | -------------------------------------------------------------------------------- /test/src/test_acospiI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(acospiI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("acospiI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_acospiI, acospil, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_asin.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(asin, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("asin: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_asin, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p-40; 20 | x_end = 0x1.0p-40; 21 | ; 22 | nb_tests = 40000; 23 | report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); 24 | 25 | x_start = 0.0; 26 | x_end = 0.5; 27 | nb_tests = 40000; 28 | report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); 29 | 30 | x_start = 0.5; 31 | x_end = 1.0; 32 | nb_tests = 40000; 33 | report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); 34 | 35 | x_start = -1.0; 36 | x_end = 1.0; 37 | nb_tests = 40000; 38 | report_err_fp64(rvvlm_asin, asinl, x_start, x_end, nb_tests); 39 | } 40 | -------------------------------------------------------------------------------- /test/src/test_asinI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(asinI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("asinI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_asinI, asinl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_asinh.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(asinh, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("asinh: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_asinh, "Special Value handling of this function"); 18 | 19 | x_start = 0x1.0p-40; 20 | x_end = 0x1.0p-35; 21 | nb_tests = 20000; 22 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 23 | 24 | x_start = -0x1.0p-35; 25 | x_end = -0x1.0p-40; 26 | nb_tests = 20000; 27 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p-20; 30 | x_end = 0x1.0p-10; 31 | nb_tests = 20000; 32 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 33 | 34 | x_start = 0x1.0p-6; 35 | x_end = 0x1.0p0; 36 | nb_tests = 20000; 37 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 38 | 39 | x_start = 0x1.0p0; 40 | x_end = 0x1.0p2; 41 | nb_tests = 20000; 42 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 43 | 44 | x_start = -0x1.0p0; 45 | x_end = -0x1.0p2; 46 | nb_tests = 20000; 47 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 48 | 49 | x_start = 0x1.0p490; 50 | x_end = 0x1.0p520; 51 | nb_tests = 20000; 52 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 53 | 54 | x_start = 0x1.0p1020; 55 | x_end = 0x1.FFFFFFFFFFp1023; 56 | nb_tests = 20000; 57 | report_err_fp64(rvvlm_asinh, asinhl, x_start, x_end, nb_tests); 58 | } 59 | -------------------------------------------------------------------------------- /test/src/test_asinhI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(asinhI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("asinhI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 1.2; 18 | x_end = 10.0; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_asinhI, asinhl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_asinpi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(asinpI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("asinpi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_asinpi, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p-40; 20 | x_end = 0x1.0p-40; 21 | nb_tests = 40000; 22 | report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); 23 | 24 | x_start = 0.0; 25 | x_end = 0.5; 26 | nb_tests = 40000; 27 | report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); 28 | 29 | x_start = 0.5; 30 | x_end = 1.0; 31 | nb_tests = 40000; 32 | report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); 33 | 34 | x_start = -1.0; 35 | x_end = 1.0; 36 | nb_tests = 40000; 37 | report_err_fp64(rvvlm_asinpi, asinpil, x_start, x_end, nb_tests); 38 | } 39 | -------------------------------------------------------------------------------- /test/src/test_asinpiI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(asinpiI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("asinpiI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_asinpiI, asinpil, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_atan.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atan, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("atan: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_atan, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p-40; 20 | x_end = 0x1.0p-40; 21 | ; 22 | nb_tests = 40000; 23 | report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); 24 | 25 | x_start = 0.0; 26 | x_end = 1.0; 27 | nb_tests = 40000; 28 | report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); 29 | 30 | x_start = 1.0; 31 | x_end = 100.0; 32 | nb_tests = 40000; 33 | report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); 34 | 35 | x_start = -10.0; 36 | x_end = 10.0; 37 | nb_tests = 40000; 38 | report_err_fp64(rvvlm_atan, atanl, x_start, x_end, nb_tests); 39 | } 40 | -------------------------------------------------------------------------------- /test/src/test_atan2.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atan2, test) { 12 | unsigned long nb_x, nb_y; 13 | double x_start, x_end, y_start, y_end; 14 | int swap_xy = 1; 15 | 16 | COMMENT("atan2: current chosen algorithm; reduced argument in FP64 only") 17 | 18 | show_special2_fp64(rvvlm_atan2, swap_xy, 19 | "Special Value handling of this function"); 20 | 21 | x_start = 0x1.000000001p0; 22 | x_end = 0x1.ffffffffffp0; 23 | 24 | nb_x = 8; 25 | y_start = 0x1.01p0; 26 | y_end = 0x1.fffp0; 27 | nb_y = 2000; 28 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 29 | nb_y, swap_xy); 30 | 31 | x_start = 0x1.000000001p0; 32 | x_end = 0x1.ffffffffffp0; 33 | 34 | nb_x = 8; 35 | y_start = 0x1.01p1020; 36 | y_end = 0x1.ffffffffp1020; 37 | nb_y = 2000; 38 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 39 | nb_y, swap_xy); 40 | 41 | x_start = 0x1.000000001p0; 42 | x_end = 0x1.ffffffffffp0; 43 | ; 44 | nb_x = 8; 45 | y_start = 0x1.01p-1020; 46 | y_end = 0x1.ffffffffp-1020; 47 | nb_y = 2000; 48 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 49 | nb_y, swap_xy); 50 | 51 | x_start = -0x1.000000001p0; 52 | x_end = -0x1.ffffffffffp0; 53 | ; 54 | nb_x = 8; 55 | y_start = 0x1.01p0; 56 | y_end = 0x1.fffp0; 57 | nb_y = 2000; 58 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 59 | nb_y, swap_xy); 60 | 61 | x_start = -0x1.000000001p0; 62 | x_end = -0x1.ffffffffffp0; 63 | ; 64 | nb_x = 8; 65 | y_start = 0x1.01p1020; 66 | y_end = 0x1.ffffffffp1020; 67 | nb_y = 2000; 68 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 69 | nb_y, swap_xy); 70 | 71 | x_start = -0x1.000000001p0; 72 | x_end = -0x1.ffffffffffp0; 73 | ; 74 | nb_x = 8; 75 | y_start = 0x1.01p-1020; 76 | y_end = 0x1.ffffffffp-1020; 77 | nb_y = 2000; 78 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 79 | nb_y, swap_xy); 80 | 81 | x_start = 0x1.000000001p0; 82 | x_end = 0x1.ffffffffffp0; 83 | ; 84 | nb_x = 8; 85 | y_start = -0x1.01p0; 86 | y_end = -0x1.fffp0; 87 | nb_y = 2000; 88 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 89 | nb_y, swap_xy); 90 | 91 | x_start = 0x1.000000001p0; 92 | x_end = 0x1.ffffffffffp0; 93 | ; 94 | nb_x = 8; 95 | y_start = -0x1.01p1020; 96 | y_end = -0x1.ffffffffp1020; 97 | nb_y = 2000; 98 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 99 | nb_y, swap_xy); 100 | 101 | x_start = 0x1.000000001p0; 102 | x_end = 0x1.ffffffffffp0; 103 | ; 104 | nb_x = 8; 105 | y_start = -0x1.01p-1020; 106 | y_end = -0x1.ffffffffp-1020; 107 | nb_y = 2000; 108 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 109 | nb_y, swap_xy); 110 | 111 | x_start = -0x1.000000001p0; 112 | x_end = -0x1.ffffffffffp0; 113 | ; 114 | nb_x = 8; 115 | y_start = -0x1.01p0; 116 | y_end = -0x1.fffp0; 117 | nb_y = 2000; 118 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 119 | nb_y, swap_xy); 120 | 121 | x_start = -0x1.000000001p0; 122 | x_end = -0x1.ffffffffffp0; 123 | ; 124 | nb_x = 8; 125 | y_start = -0x1.01p1020; 126 | y_end = -0x1.ffffffffp1020; 127 | nb_y = 2000; 128 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 129 | nb_y, swap_xy); 130 | 131 | x_start = -0x1.000000001p0; 132 | x_end = -0x1.ffffffffffp0; 133 | ; 134 | nb_x = 8; 135 | y_start = -0x1.01p-1020; 136 | y_end = -0x1.ffffffffp-1020; 137 | nb_y = 2000; 138 | report_err2_fp64(rvvlm_atan2, atan2l, x_start, x_end, nb_x, y_start, y_end, 139 | nb_y, swap_xy); 140 | } 141 | -------------------------------------------------------------------------------- /test/src/test_atan2I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atan2I, test) { 12 | unsigned long nb_x, nb_y; 13 | double x_start, x_end, y_start, y_end; 14 | int swap_xy = 1; 15 | 16 | COMMENT("atan2I: current chosen algorithm; reduced argument in FP64 only") 17 | 18 | x_start = -11.0; 19 | x_end = 20.0; 20 | nb_x = 8; 21 | y_start = 0.8; 22 | y_end = 10.4; 23 | nb_y = 10; 24 | 25 | int stride_x = 21; 26 | int stride_y = 39; 27 | int stride_z = 17; 28 | 29 | report_err2_fp64(rvvlm_atan2I, atan2l, x_start, x_end, nb_x, y_start, y_end, 30 | nb_y, stride_x, stride_y, stride_z, swap_xy); 31 | } 32 | -------------------------------------------------------------------------------- /test/src/test_atan2pi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atan2pi, test) { 12 | unsigned long nb_x, nb_y; 13 | double x_start, x_end, y_start, y_end; 14 | int swap_xy = 1; 15 | 16 | COMMENT("atan2pi: current chosen algorithm; reduced argument in FP64 only") 17 | 18 | show_special2_fp64(rvvlm_atan2pi, swap_xy, 19 | "Special Value handling of this function"); 20 | 21 | x_start = 0x1.000000001p0; 22 | x_end = 0x1.ffffffffffp0; 23 | nb_x = 4; 24 | y_start = 0x1.01p0; 25 | y_end = 0x1.fffp0; 26 | nb_y = 5000; 27 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 28 | y_end, nb_y, swap_xy); 29 | 30 | x_start = 0x1.000000001p0; 31 | x_end = 0x1.ffffffffffp0; 32 | nb_x = 4; 33 | y_start = 0x1.01p1020; 34 | y_end = 0x1.ffffffffp1020; 35 | nb_y = 5000; 36 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 37 | y_end, nb_y, swap_xy); 38 | 39 | x_start = 0x1.000000001p0; 40 | x_end = 0x1.ffffffffffp0; 41 | nb_x = 4; 42 | y_start = 0x1.01p-1020; 43 | y_end = 0x1.ffffffffp-1020; 44 | nb_y = 5000; 45 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 46 | y_end, nb_y, swap_xy); 47 | 48 | x_start = -0x1.000000001p0; 49 | x_end = -0x1.ffffffffffp0; 50 | nb_x = 4; 51 | y_start = 0x1.01p0; 52 | y_end = 0x1.fffp0; 53 | nb_y = 5000; 54 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 55 | y_end, nb_y, swap_xy); 56 | 57 | x_start = -0x1.000000001p0; 58 | x_end = -0x1.ffffffffffp0; 59 | nb_x = 4; 60 | y_start = 0x1.01p1020; 61 | y_end = 0x1.ffffffffp1020; 62 | nb_y = 5000; 63 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 64 | y_end, nb_y, swap_xy); 65 | 66 | x_start = -0x1.000000001p0; 67 | x_end = -0x1.ffffffffffp0; 68 | nb_x = 4; 69 | y_start = 0x1.01p-1020; 70 | y_end = 0x1.ffffffffp-1020; 71 | nb_y = 5000; 72 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 73 | y_end, nb_y, swap_xy); 74 | 75 | x_start = 0x1.000000001p0; 76 | x_end = 0x1.ffffffffffp0; 77 | nb_x = 4; 78 | y_start = -0x1.01p0; 79 | y_end = -0x1.fffp0; 80 | nb_y = 5000; 81 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 82 | y_end, nb_y, swap_xy); 83 | 84 | x_start = 0x1.000000001p0; 85 | x_end = 0x1.ffffffffffp0; 86 | nb_x = 4; 87 | y_start = -0x1.01p1020; 88 | y_end = -0x1.ffffffffp1020; 89 | nb_y = 5000; 90 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 91 | y_end, nb_y, swap_xy); 92 | 93 | x_start = 0x1.000000001p0; 94 | x_end = 0x1.ffffffffffp0; 95 | nb_x = 4; 96 | y_start = -0x1.01p-1020; 97 | y_end = -0x1.ffffffffp-1020; 98 | nb_y = 5000; 99 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 100 | y_end, nb_y, swap_xy); 101 | 102 | x_start = -0x1.000000001p0; 103 | x_end = -0x1.ffffffffffp0; 104 | nb_x = 4; 105 | y_start = -0x1.01p0; 106 | y_end = -0x1.fffp0; 107 | nb_y = 5000; 108 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 109 | y_end, nb_y, swap_xy); 110 | 111 | x_start = -0x1.000000001p0; 112 | x_end = -0x1.ffffffffffp0; 113 | nb_x = 4; 114 | y_start = -0x1.01p1020; 115 | y_end = -0x1.ffffffffp1020; 116 | nb_y = 5000; 117 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 118 | y_end, nb_y, swap_xy); 119 | 120 | x_start = -0x1.000000001p0; 121 | x_end = -0x1.ffffffffffp0; 122 | nb_x = 4; 123 | y_start = -0x1.01p-1020; 124 | y_end = -0x1.ffffffffp-1020; 125 | nb_y = 5000; 126 | report_err2_fp64(rvvlm_atan2pi, atan2pil, x_start, x_end, nb_x, y_start, 127 | y_end, nb_y, swap_xy); 128 | } 129 | -------------------------------------------------------------------------------- /test/src/test_atan2piI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atan2piI, test) { 12 | unsigned long nb_x, nb_y; 13 | double x_start, x_end, y_start, y_end; 14 | int swap_xy = 1; 15 | 16 | COMMENT("atan2piI: current chosen algorithm; reduced argument in FP64 only") 17 | 18 | x_start = -11.0; 19 | x_end = 20.0; 20 | nb_x = 8; 21 | y_start = 0.8; 22 | y_end = 10.4; 23 | nb_y = 10; 24 | 25 | int stride_x = 21; 26 | int stride_y = 39; 27 | int stride_z = 17; 28 | 29 | report_err2_fp64(rvvlm_atan2piI, atan2pil, x_start, x_end, nb_x, y_start, 30 | y_end, nb_y, stride_x, stride_y, stride_z, swap_xy); 31 | } 32 | -------------------------------------------------------------------------------- /test/src/test_atanI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atanI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("atanI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_atanI, atanl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_atanh.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atanh, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("atanh: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | // show_special_fp64(rvvlm_atanh, "Special Value handling of this function"); 18 | 19 | x_start = 0x1.0p-40; 20 | x_end = 0x1.0p-35; 21 | nb_tests = 10000; 22 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 23 | 24 | x_start = -0x1.0p-35; 25 | x_end = -0x1.0p-40; 26 | nb_tests = 10000; 27 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p-20; 30 | x_end = 0x1.0p-10; 31 | nb_tests = 10000; 32 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 33 | 34 | x_start = 0x1.0p-10; 35 | x_end = 0x1.ffp-3; 36 | nb_tests = 10000; 37 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 38 | 39 | x_start = 0x1.00p-9; 40 | x_end = 0x1.0p-2; 41 | nb_tests = 10000; 42 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 43 | 44 | x_start = 0x1.0p-1; 45 | x_end = 0x1.0p0 - 0x1.0p-51; 46 | nb_tests = 10000; 47 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 48 | 49 | x_start = -0x1.0p-1; 50 | x_end = -(0x1.0p0 - 0x1.0p-51); 51 | nb_tests = 10000; 52 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 53 | 54 | x_start = -1.0 + 0x1.0p-53; 55 | x_end = 1.0 - 0x1.0p-51; 56 | nb_tests = 10000; 57 | report_err_fp64(rvvlm_atanh, atanhl, x_start, x_end, nb_tests); 58 | } 59 | -------------------------------------------------------------------------------- /test/src/test_atanhI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atanhI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("atanhI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0.1; 18 | x_end = 0.9; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_atanhI, atanhl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_atanpi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atanpi, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("atanpi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_atanpi, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p-40; 20 | x_end = 0x1.0p-40; 21 | ; 22 | nb_tests = 40000; 23 | report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); 24 | 25 | x_start = 0.0; 26 | x_end = 1.0; 27 | nb_tests = 40000; 28 | report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); 29 | 30 | x_start = 1.0; 31 | x_end = 100.0; 32 | nb_tests = 40000; 33 | report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); 34 | 35 | x_start = -10.0; 36 | x_end = 10.0; 37 | nb_tests = 40000; 38 | report_err_fp64(rvvlm_atanpi, atanpil, x_start, x_end, nb_tests); 39 | } 40 | -------------------------------------------------------------------------------- /test/src/test_atanpiI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(atanpiI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("atanpiI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_atanpiI, atanpil, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_cbrt.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cbrt, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cbrt: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_cbrt, "Special Value handling of this function"); 18 | 19 | x_start = 0x1.0p-1074; 20 | x_end = 0x1.0p-1064; 21 | nb_tests = 40000; 22 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 23 | 24 | x_start = -0x1.0p-1064; 25 | x_end = -0x1.0p-1074; 26 | nb_tests = 40000; 27 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p0; 30 | x_end = 0x1.0p8; 31 | nb_tests = 40000; 32 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 33 | 34 | x_start = 0x1.0p-8; 35 | x_end = 0x1.0p-4; 36 | nb_tests = 40000; 37 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 38 | 39 | x_start = -0x1.0p0; 40 | x_end = -0x1.0p8; 41 | nb_tests = 40000; 42 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 43 | 44 | x_start = -0x1.0p-8; 45 | x_end = -0x1.0p-4; 46 | nb_tests = 40000; 47 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 48 | 49 | x_start = 0x1.0p1020; 50 | x_end = 0x1.fffffp1023; 51 | nb_tests = 40000; 52 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 53 | 54 | x_start = -0x1.0p1020; 55 | x_end = -0x1.fffffp1023; 56 | nb_tests = 40000; 57 | report_err_fp64(rvvlm_cbrt, cbrtl, x_start, x_end, nb_tests); 58 | } 59 | -------------------------------------------------------------------------------- /test/src/test_cbrtI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cbrtI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cbrtI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0.1; 18 | x_end = 0.9; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_cbrtI, cbrtl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_cdfnorm.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cdfnorm, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cdfnorm: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_cdfnorm, "Special Value handling of this function"); 18 | 19 | x_start = -0x1.0p0; 20 | x_end = 0x1.0p0; 21 | nb_tests = 10000; 22 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); 23 | 24 | x_start = 0x1.0p-2; 25 | x_end = 0x1.0p0; 26 | nb_tests = 10000; 27 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); 28 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); 29 | 30 | x_start = 0x1.0p0; 31 | x_end = 0x1.0p3; 32 | nb_tests = 10000; 33 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); 34 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); 35 | 36 | x_start = 0x1.0p3; 37 | x_end = 30.0; 38 | nb_tests = 10000; 39 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); 40 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); 41 | 42 | x_start = 0x1.0p-80; 43 | x_end = 0x1.0p-50; 44 | nb_tests = 10000; 45 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); 46 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); 47 | 48 | x_start = 0x1.0p-50; 49 | x_end = 0x1.0p-10; 50 | nb_tests = 10000; 51 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, x_start, x_end, nb_tests); 52 | report_err_fp64(rvvlm_cdfnorm, cdfnorml, -x_start, -x_end, nb_tests); 53 | } 54 | -------------------------------------------------------------------------------- /test/src/test_cdfnormI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cdfnormI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cdfnormI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 1.2; 18 | x_end = 10.0; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_cdfnormI, cdfnorml, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_cdfnorminv.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cdfnorminv, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cdfnorminv: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_cdfnorminv, 18 | "Special Value handling of this function"); 19 | } 20 | 21 | TEST(cdfnorminv, tiny_args) { 22 | unsigned long nb_tests; 23 | double x_start, x_end; 24 | 25 | COMMENT("cdfnorminv: current chosen algorithm; reduced argument in FP64 only") 26 | 27 | x_start = 0x1.0p-1074; 28 | x_end = 0x1.0p-1000; 29 | nb_tests = 10000; 30 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 31 | x_end, nb_tests); 32 | 33 | x_start = 0x1.0p-1000; 34 | x_end = 0x1.0p-500; 35 | nb_tests = 10000; 36 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 37 | x_end, nb_tests); 38 | 39 | x_start = 0x1.0p-55; 40 | x_end = 0x1.0p-53; 41 | nb_tests = 10000; 42 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 43 | x_end, nb_tests); 44 | } 45 | 46 | TEST(cdfnorminv, small_args) { 47 | unsigned long nb_tests; 48 | double x_start, x_end; 49 | 50 | COMMENT("cdfnorminv: current chosen algorithm; reduced argument in FP64 only") 51 | 52 | x_start = 0x1.0p-50; 53 | x_end = 0x1.0p-20; 54 | nb_tests = 10000; 55 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 56 | x_end, nb_tests); 57 | 58 | x_start = 0x1.0p-20; 59 | x_end = 0x1.0p-4; 60 | nb_tests = 10000; 61 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 62 | x_end, nb_tests); 63 | } 64 | 65 | TEST(cdfnorminv, medium_args) { 66 | unsigned long nb_tests; 67 | double x_start, x_end; 68 | 69 | COMMENT("cdfnorminv: current chosen algorithm; reduced argument in FP64 only") 70 | 71 | x_start = 0x1.0p-5; 72 | x_end = 0x1.0p-2; 73 | nb_tests = 10000; 74 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 75 | x_end, nb_tests); 76 | 77 | x_start = 0x1.0p-2; 78 | x_end = 0x1.8p-1; 79 | nb_tests = 10000; 80 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 81 | x_end, nb_tests); 82 | 83 | x_start = 1.0 - 0x1.0p-53; 84 | x_end = 0x1.8p-1; 85 | nb_tests = 10000; 86 | report_err_byinv_fp64(rvvlm_cdfnorminv, cdfnorml, cdfnorml_prime, x_start, 87 | x_end, nb_tests); 88 | } 89 | -------------------------------------------------------------------------------- /test/src/test_cdfnorminvI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cdfnorminvI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT( 16 | "cdfnorminvI: current chosen algorithm; reduced argument in FP64 only") 17 | 18 | x_start = 0.25; 19 | x_end = 0.75; 20 | nb_tests = 30; 21 | int stride_x = 21; 22 | int stride_y = 30; 23 | report_err_byinv_fp64(rvvlm_cdfnorminvI, cdfnorml, cdfnorml_prime, x_start, 24 | x_end, nb_tests, stride_x, stride_y); 25 | } 26 | -------------------------------------------------------------------------------- /test/src/test_cos.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cos, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_TRIG)] = TV_FOR_TRIG; 14 | 15 | nb_tv = NB_TV_FOR_TRIG; 16 | 17 | test_vectors_fp64(rvvlm_cos, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(cos, near_NPiby2) { 21 | #include "near_NPiby2_tbl.h" 22 | unsigned long nb_tests; 23 | 24 | COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | nb_tests = (NB_TEST_ARGS); 27 | report_err_fp64(rvvlm_cos, cosl, dbl_near_NPiby2_tbl, nb_tests); 28 | } 29 | 30 | TEST(cos, small_args) { 31 | unsigned long nb_tests; 32 | double x_start, x_end; 33 | 34 | COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") 35 | 36 | x_start = -0.78; 37 | x_end = 0.78; 38 | nb_tests = 100000; 39 | report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); 40 | 41 | x_start = -6.0; 42 | x_end = 6.0; 43 | nb_tests = 100000; 44 | report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); 45 | } 46 | 47 | TEST(cos, medium_args) { 48 | unsigned long nb_tests; 49 | double x_start, x_end; 50 | 51 | COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") 52 | 53 | x_start = 1.0; 54 | x_end = 0x1.0p23; 55 | nb_tests = 100000; 56 | report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); 57 | 58 | x_start = 0x1.0p25; 59 | x_end = 0x1.0p100; 60 | nb_tests = 100000; 61 | report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); 62 | } 63 | 64 | TEST(cos, large_args) { 65 | unsigned long nb_tests; 66 | double x_start, x_end; 67 | 68 | COMMENT("cos: current chosen algorithm; reduced argument in FP64 only") 69 | 70 | x_start = 1.0; 71 | x_end = 0x1.0p23; 72 | nb_tests = 100000; 73 | report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); 74 | 75 | x_start = 0x1.0p25; 76 | x_end = 0x1.0p100; 77 | nb_tests = 100000; 78 | report_err_fp64(rvvlm_cos, cosl, x_start, x_end, nb_tests); 79 | } 80 | -------------------------------------------------------------------------------- /test/src/test_cosI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cosI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cosI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_cosI, cosl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_cosh.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cosh, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_cosh, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(cosh, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.346; 27 | x_end = 0.346; 28 | nb_tests = 40000; 29 | report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); 30 | 31 | x_start = -6.0; 32 | x_end = 6.0; 33 | nb_tests = 40000; 34 | report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(cosh, medium_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = 30.0; 44 | x_end = 40.0; 45 | nb_tests = 40000; 46 | report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); 47 | 48 | x_start = 50.0; 49 | x_end = 60.0; 50 | nb_tests = 40000; 51 | report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); 52 | } 53 | 54 | TEST(cosh, large_args) { 55 | unsigned long nb_tests; 56 | double x_start, x_end; 57 | 58 | COMMENT("cosh: current chosen algorithm; reduced argument in FP64 only") 59 | 60 | x_start = 60.0; 61 | x_end = 70.0; 62 | nb_tests = 40000; 63 | report_err_fp64(rvvlm_cosh, coshl, x_start, x_end, nb_tests); 64 | } 65 | -------------------------------------------------------------------------------- /test/src/test_coshI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(coshI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("coshI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_coshI, coshl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_cospi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cospi, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cospi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_cospi, "Special Value handling of this function"); 18 | 19 | x_start = -0.5; 20 | x_end = 0.5; 21 | nb_tests = 100000; 22 | report_err_fp64(rvvlm_cospi, cospil, x_start, x_end, nb_tests); 23 | 24 | x_start = -0x1.0p3; 25 | x_end = 0x1.0p3; 26 | nb_tests = 100000; 27 | report_err_fp64(rvvlm_cospi, cospil, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p3; 30 | x_end = 0x1.0p60; 31 | nb_tests = 100000; 32 | report_err_fp64(rvvlm_cospi, cospil, x_start, x_end, nb_tests); 33 | } 34 | -------------------------------------------------------------------------------- /test/src/test_cospiI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(cospiI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("cosI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.5; 18 | x_end = 0.5; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_cospiI, cospil, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_erf.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erf, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erf: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_erf, "Special Value handling of this function"); 18 | 19 | x_start = 0x1.0p-40; 20 | x_end = 0x1.0p-20; 21 | nb_tests = 10000; 22 | report_err_fp64(rvvlm_erf, erfl, x_start, x_end, nb_tests); 23 | 24 | x_start = 0x1.0p-20; 25 | x_end = 0x1.0p1; 26 | nb_tests = 10000; 27 | report_err_fp64(rvvlm_erf, erfl, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p1; 30 | x_end = 0x1.0p2; 31 | nb_tests = 10000; 32 | report_err_fp64(rvvlm_erf, erfl, x_start, x_end, nb_tests); 33 | 34 | x_start = 0x1.0p2; 35 | x_end = 7.0; 36 | nb_tests = 10000; 37 | report_err_fp64(rvvlm_erf, erfl, x_start, x_end, nb_tests); 38 | 39 | x_start = -6.5; 40 | x_end = 6.5; 41 | nb_tests = 10000; 42 | report_err_fp64(rvvlm_erf, erfl, x_start, x_end, nb_tests); 43 | } 44 | -------------------------------------------------------------------------------- /test/src/test_erfI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 1.2; 18 | x_end = 10.0; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_erfI, erfl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_erfc.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfc, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfc: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_erfc, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(erfc, medium_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("erfc: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0x1.0p0; 27 | x_end = 0x1.0p0; 28 | nb_tests = 40000; 29 | report_err_fp64(rvvlm_erfc, erfcl, x_start, x_end, nb_tests); 30 | } 31 | 32 | TEST(erfc, around_one) { 33 | unsigned long nb_tests; 34 | double x_start, x_end; 35 | 36 | COMMENT("erfc: current chosen algorithm; reduced argument in FP64 only") 37 | 38 | x_start = 0x1.0p-1; 39 | x_end = 0x1.0p1; 40 | nb_tests = 40000; 41 | report_err_fp64(rvvlm_erfc, erfcl, x_start, x_end, nb_tests); 42 | report_err_fp64(rvvlm_erfc, erfcl, -x_start, -x_end, nb_tests); 43 | } 44 | 45 | TEST(erfc, large) { 46 | unsigned long nb_tests; 47 | double x_start, x_end; 48 | 49 | COMMENT("erfc: current chosen algorithm; reduced argument in FP64 only") 50 | 51 | x_start = 0x1.0p1; 52 | x_end = 0x1.0p3; 53 | nb_tests = 40000; 54 | report_err_fp64(rvvlm_erfc, erfcl, x_start, x_end, nb_tests); 55 | report_err_fp64(rvvlm_erfc, erfcl, -x_start, -x_end, nb_tests); 56 | } 57 | -------------------------------------------------------------------------------- /test/src/test_erfcI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfcI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfcI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 1.2; 18 | x_end = 10.0; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_erfcI, erfcl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_erfcinv.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfcinv, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfcinv: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_erfcinv, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(erfcinv, tiny_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("erfcinv: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = 0x1.0p-1074; 27 | x_end = 0x1.0p-1000; 28 | nb_tests = 10000; 29 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 30 | nb_tests); 31 | 32 | x_start = 0x1.0p-1000; 33 | x_end = 0x1.0p-500; 34 | nb_tests = 10000; 35 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 36 | nb_tests); 37 | 38 | x_start = 0x1.0p-55; 39 | x_end = 0x1.0p-53; 40 | nb_tests = 10000; 41 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 42 | nb_tests); 43 | } 44 | 45 | TEST(erfcinv, small_args) { 46 | unsigned long nb_tests; 47 | double x_start, x_end; 48 | 49 | COMMENT("erfcinv: current chosen algorithm; reduced argument in FP64 only") 50 | 51 | x_start = 0x1.0p-50; 52 | ; 53 | x_end = 0x1.0p-20; 54 | nb_tests = 10000; 55 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 56 | nb_tests); 57 | 58 | x_start = 0x1.0p-20; 59 | ; 60 | x_end = 0x1.0p-4; 61 | nb_tests = 10000; 62 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 63 | nb_tests); 64 | } 65 | 66 | TEST(erfcinv, medium_args) { 67 | unsigned long nb_tests; 68 | double x_start, x_end; 69 | 70 | COMMENT("erfcinv: current chosen algorithm; reduced argument in FP64 only") 71 | 72 | x_start = 0x1.0p-4; 73 | ; 74 | x_end = 0x1.0p-1; 75 | nb_tests = 10000; 76 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 77 | nb_tests); 78 | 79 | x_start = 0x1.0p-1; 80 | ; 81 | x_end = 0x1.8p0; 82 | nb_tests = 10000; 83 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 84 | nb_tests); 85 | 86 | x_start = 2.0 - 0x1.0p-52; 87 | x_end = 0x1.8p0; 88 | nb_tests = 10000; 89 | report_err_byinv_fp64(rvvlm_erfcinv, erfcl, erfcl_prime, x_start, x_end, 90 | nb_tests); 91 | } 92 | -------------------------------------------------------------------------------- /test/src/test_erfcinvI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfcinvI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfcinvI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0.5; 18 | x_end = 1.75; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 30; 22 | report_err_byinv_fp64(rvvlm_erfcinvI, erfcl, erfcl_prime, x_start, x_end, 23 | nb_tests, stride_x, stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_erfinv.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfinv, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfinv: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_erfinv, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(erfinv, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("erfinv: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = 0x1.0p-40; 27 | x_end = 0x1.0p-30; 28 | nb_tests = 20000; 29 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 30 | nb_tests); 31 | 32 | x_start = 0x1.0p-30; 33 | x_end = 0x1.0p-10; 34 | nb_tests = 20000; 35 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 36 | nb_tests); 37 | 38 | x_start = 0x1.0p-10; 39 | x_end = 0x1.0p-4; 40 | nb_tests = 20000; 41 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 42 | nb_tests); 43 | } 44 | 45 | TEST(erfinv, middle_args) { 46 | unsigned long nb_tests; 47 | double x_start, x_end; 48 | 49 | COMMENT("erfinv: current chosen algorithm; reduced argument in FP64 only") 50 | 51 | x_start = 0x1.0p-4; 52 | x_end = 0x1.0p-2; 53 | nb_tests = 20000; 54 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 55 | nb_tests); 56 | 57 | x_start = 0x1.0p-2; 58 | x_end = 0x1.0p-1; 59 | nb_tests = 20000; 60 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 61 | nb_tests); 62 | 63 | x_start = 0x1.0p-1; 64 | x_end = 0x1.78p-1; 65 | nb_tests = 20000; 66 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 67 | nb_tests); 68 | 69 | x_start = 0x1.6p-1; 70 | x_end = 0x1.7cp-1; 71 | nb_tests = 20000; 72 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 73 | nb_tests); 74 | 75 | x_start = 0x1.71p-1; 76 | x_end = 0x1.8p-1; 77 | nb_tests = 20000; 78 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 79 | nb_tests); 80 | 81 | x_start = -0.8; 82 | x_end = 0.8; 83 | nb_tests = 20000; 84 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 85 | nb_tests); 86 | 87 | x_start = 0.25; 88 | x_end = 0.9; 89 | nb_tests = 2; 90 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 91 | nb_tests); 92 | } 93 | 94 | TEST(erfinv, close_to_1) { 95 | unsigned long nb_tests; 96 | double x_start, x_end; 97 | 98 | COMMENT("erfinv: current chosen algorithm; reduced argument in FP64 only") 99 | 100 | x_start = 1.0 - 0x1.0p-53; 101 | x_end = 0x1.ffp-1; 102 | nb_tests = 20000; 103 | report_err_byinv_fp64(rvvlm_erfinv, erfl, erfl_prime, x_start, x_end, 104 | nb_tests); 105 | } 106 | -------------------------------------------------------------------------------- /test/src/test_erfinvI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(erfinvI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("erfinvI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.7; 18 | x_end = 0.7; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 30; 22 | report_err_byinv_fp64(rvvlm_erfinvI, erfl, erfl_prime, x_start, x_end, 23 | nb_tests, stride_x, stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_exp.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(exp, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_EXP)] = TV_FOR_EXP; 14 | 15 | nb_tv = NB_TV_FOR_EXP; 16 | 17 | test_vectors_fp64(rvvlm_exp, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(exp, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("exp: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.34; 27 | x_end = 0.34; 28 | nb_tests = 100000; 29 | report_err_fp64(rvvlm_exp, expl, x_start, x_end, nb_tests); 30 | 31 | x_start = -3.0; 32 | x_end = 3.0; 33 | nb_tests = 100000; 34 | report_err_fp64(rvvlm_exp, expl, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(exp, medium_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("exp: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = -15.0; 44 | x_end = -10.0; 45 | nb_tests = 100000; 46 | report_err_fp64(rvvlm_exp, expl, x_start, x_end, nb_tests); 47 | 48 | x_start = 15.0; 49 | x_end = 10.0; 50 | nb_tests = 100000; 51 | report_err_fp64(rvvlm_exp, expl, x_start, x_end, nb_tests); 52 | } 53 | 54 | TEST(exp, large_args) { 55 | unsigned long nb_tests; 56 | double x_start, x_end; 57 | 58 | COMMENT("exp: current chosen algorithm; reduced argument in FP64 only") 59 | 60 | x_start = 700.0; 61 | x_end = 709.0; 62 | nb_tests = 100000; 63 | report_err_fp64(rvvlm_exp, expl, x_start, x_end, nb_tests); 64 | 65 | x_start = -740.0; 66 | x_end = -709.0; 67 | nb_tests = 100000; 68 | report_err_fp64(rvvlm_exp, expl, x_start, x_end, nb_tests); 69 | } 70 | -------------------------------------------------------------------------------- /test/src/test_exp10.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(exp10, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_EXP)] = TV_FOR_EXP; 14 | 15 | nb_tv = NB_TV_FOR_EXP; 16 | 17 | test_vectors_fp64(rvvlm_exp10, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(exp10, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("exp10: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.34; 27 | x_end = 0.34; 28 | nb_tests = 30000; 29 | report_err_fp64(rvvlm_exp10, exp10l, x_start, x_end, nb_tests); 30 | 31 | x_start = -3.0; 32 | x_end = 3.0; 33 | nb_tests = 40000; 34 | report_err_fp64(rvvlm_exp10, exp10l, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(exp10, medium_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("exp10: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = -15.0; 44 | x_end = -10.0; 45 | nb_tests = 40000; 46 | report_err_fp64(rvvlm_exp10, exp10l, x_start, x_end, nb_tests); 47 | 48 | x_start = 10.0; 49 | x_end = 15.0; 50 | nb_tests = 40000; 51 | report_err_fp64(rvvlm_exp10, exp10l, x_start, x_end, nb_tests); 52 | } 53 | 54 | TEST(exp10, large_args) { 55 | unsigned long nb_tests; 56 | double x_start, x_end; 57 | 58 | COMMENT("exp10: current chosen algorithm; reduced argument in FP64 only") 59 | 60 | x_start = 295.0; 61 | x_end = 308.0; 62 | nb_tests = 40000; 63 | report_err_fp64(rvvlm_exp10, exp10l, x_start, x_end, nb_tests); 64 | 65 | x_start = -323.0; 66 | x_end = -300.0; 67 | nb_tests = 40000; 68 | report_err_fp64(rvvlm_exp10, exp10l, x_start, x_end, nb_tests); 69 | } 70 | -------------------------------------------------------------------------------- /test/src/test_exp10I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(exp10I, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("exp10I: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_exp10I, exp10l, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_exp2.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(exp2, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_EXP)] = TV_FOR_EXP; 14 | 15 | nb_tv = NB_TV_FOR_EXP; 16 | 17 | test_vectors_fp64(rvvlm_exp2, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(exp2, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("exp2: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.34; 27 | x_end = 0.34; 28 | nb_tests = 80000; 29 | report_err_fp64(rvvlm_exp2, exp2l, x_start, x_end, nb_tests); 30 | 31 | x_start = -3.0; 32 | x_end = 3.0; 33 | nb_tests = 100000; 34 | report_err_fp64(rvvlm_exp2, exp2l, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(exp2, medium_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("exp2: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = -14.0; 44 | x_end = -10.0; 45 | nb_tests = 100000; 46 | report_err_fp64(rvvlm_exp2, exp2l, x_start, x_end, nb_tests); 47 | 48 | x_start = 10.0; 49 | x_end = 15.0; 50 | nb_tests = 100000; 51 | report_err_fp64(rvvlm_exp2, exp2l, x_start, x_end, nb_tests); 52 | } 53 | 54 | TEST(exp2, large_args) { 55 | unsigned long nb_tests; 56 | double x_start, x_end; 57 | 58 | COMMENT("exp2: current chosen algorithm; reduced argument in FP64 only") 59 | 60 | x_start = 1010.0; 61 | x_end = 1023.0; 62 | nb_tests = 40000; 63 | report_err_fp64(rvvlm_exp2, exp2l, x_start, x_end, nb_tests); 64 | 65 | x_start = -1070.; 66 | x_end = -1020.0; 67 | nb_tests = 40000; 68 | report_err_fp64(rvvlm_exp2, exp2l, x_start, x_end, nb_tests); 69 | } 70 | -------------------------------------------------------------------------------- /test/src/test_exp2I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(exp2I, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("expI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_exp2I, exp2l, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_expI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(expI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("expI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_expI, expl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_expint1.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(expint1, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("expint1: current chosen algorithm") 16 | 17 | show_special_fp64(rvvlm_expint1, "Special Value handling of this function"); 18 | 19 | x_start = 0x1.0p-10; 20 | x_end = 0x1.8p0; 21 | nb_tests = 4; 22 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 23 | 24 | x_start = 0x1.0p-1070; 25 | x_end = 0x1.0p-1060; 26 | nb_tests = 1000; 27 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p-4; 30 | x_end = 0x1.0p-3; 31 | nb_tests = 1000; 32 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 33 | 34 | x_start = 0x1.0p-3; 35 | x_end = 0x1.0p-2; 36 | nb_tests = 1000; 37 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 38 | 39 | x_start = 0.25; 40 | x_end = 0.3; 41 | nb_tests = 1000; 42 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 43 | 44 | x_start = 0.3; 45 | x_end = 0.4; 46 | nb_tests = 1000; 47 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 48 | 49 | x_start = 0.4; 50 | x_end = 0.5; 51 | nb_tests = 1000; 52 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 53 | 54 | x_start = 0.5; 55 | x_end = 0.6; 56 | nb_tests = 16; 57 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 58 | 59 | x_start = 0.6; 60 | x_end = 0.7; 61 | nb_tests = 1000; 62 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 63 | 64 | x_start = 0.7; 65 | x_end = 0.8; 66 | nb_tests = 1000; 67 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 68 | 69 | x_start = 0.8; 70 | x_end = 0.9; 71 | nb_tests = 1000; 72 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 73 | 74 | x_start = 0.9; 75 | x_end = 0x1.ffffffffffffp-1; 76 | nb_tests = 1000; 77 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 78 | 79 | x_start = 0x1.0p0 - 0x1.0p-53; 80 | x_end = 0x1.ffffp-1; 81 | nb_tests = 1000; 82 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 83 | 84 | x_start = 1.0; 85 | x_end = 8.0; 86 | nb_tests = 1000; 87 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 88 | 89 | x_start = 8.0; 90 | x_end = 100.0; 91 | nb_tests = 1000; 92 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 93 | 94 | x_start = 100.0; 95 | x_end = 700.0; 96 | nb_tests = 1000; 97 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 98 | 99 | x_start = 700.; 100 | x_end = 735.0; 101 | nb_tests = 100; 102 | report_err_fp64(rvvlm_expint1, expint1, x_start, x_end, nb_tests); 103 | } 104 | -------------------------------------------------------------------------------- /test/src/test_expint1I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(expint1I, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("expint1I: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0.5; 18 | x_end = 1.75; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 30; 22 | report_err_fp64(rvvlm_expint1I, expint1, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_expm1.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(expm1, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_EXPM1)] = TV_FOR_EXPM1; 14 | 15 | nb_tv = NB_TV_FOR_EXPM1; 16 | 17 | test_vectors_fp64(rvvlm_expm1, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(expm1, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("expm1: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.01; 27 | x_end = 0.01; 28 | nb_tests = 30000; 29 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 30 | 31 | x_start = -.3; 32 | x_end = 0.3; 33 | nb_tests = 10000; 34 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(expm1, medium_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("expm1: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = 1.0; 44 | x_end = 10.0; 45 | nb_tests = 10000; 46 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 47 | 48 | x_start = -10.0; 49 | x_end = -1.0; 50 | nb_tests = 10000; 51 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 52 | 53 | x_start = -40.0; 54 | x_end = -36.0; 55 | nb_tests = 10000; 56 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 57 | 58 | x_start = 36.0; 59 | x_end = 40.0; 60 | nb_tests = 10000; 61 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 62 | } 63 | 64 | TEST(expm1, large_args) { 65 | unsigned long nb_tests; 66 | double x_start, x_end; 67 | 68 | COMMENT("expm1: current chosen algorithm; reduced argument in FP64 only") 69 | 70 | x_start = 700.0; 71 | x_end = 709.0; 72 | nb_tests = 40000; 73 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 74 | 75 | x_start = -50.0; 76 | x_end = -40.0; 77 | nb_tests = 40000; 78 | report_err_fp64(rvvlm_expm1, expm1l, x_start, x_end, nb_tests); 79 | } 80 | -------------------------------------------------------------------------------- /test/src/test_expm1I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(expm1I, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("expm1I: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 300; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_expm1I, expm1l, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_lgamma.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(lgamma, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("lgamma: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_lgamma, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(lgamma, lgamma_neg) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | x_start = -0.999; 25 | x_end = -0.0001; 26 | nb_tests = 5000; 27 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 28 | 29 | x_start = -1.99; 30 | x_end = -1.01; 31 | nb_tests = 5000; 32 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 33 | 34 | x_start = -2.99; 35 | x_end = -2.01; 36 | nb_tests = 5000; 37 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 38 | 39 | x_start = -3.99; 40 | x_end = -3.01; 41 | nb_tests = 5000; 42 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 43 | 44 | x_start = -4.99; 45 | x_end = -4.01; 46 | nb_tests = 5000; 47 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 48 | 49 | x_start = -5.99; 50 | x_end = -5.01; 51 | nb_tests = 5000; 52 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 53 | 54 | x_start = -6.9999; 55 | x_end = -6.00001; 56 | nb_tests = 10000; 57 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 58 | 59 | x_start = -1000.9999; 60 | x_end = -1000.0001; 61 | nb_tests = 10000; 62 | report_mixederr_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 63 | } 64 | TEST(lgamma, lgamma_left) { 65 | unsigned long nb_tests; 66 | double x_start, x_end; 67 | 68 | x_start = 0x1.0p-1070; 69 | x_end = 0x1.0p-1065; 70 | nb_tests = 5000; 71 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 72 | 73 | x_start = 0x1.0p-62; 74 | x_end = 0x1.0p-58; 75 | nb_tests = 5000; 76 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 77 | 78 | x_start = 0x1.0p-58; 79 | x_end = 0x1.0p-40; 80 | nb_tests = 5000; 81 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 82 | 83 | x_start = 0x1.0p-4; 84 | x_end = 0x1.0p-1; 85 | nb_tests = 5000; 86 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 87 | 88 | x_start = 0x1.0p-1; 89 | x_end = 0x1.ffffffffp-1; 90 | nb_tests = 5000; 91 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 92 | 93 | x_start = 1.0; 94 | x_end = 0x1.ffffffffp0; 95 | nb_tests = 5000; 96 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 97 | 98 | x_start = 0x1.0p1; 99 | x_end = 0x1.ffffffffp1; 100 | nb_tests = 5000; 101 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 102 | 103 | x_start = 0x1.0p2; 104 | x_end = 0x1.dfffffffp-1; 105 | nb_tests = 5000; 106 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 107 | } 108 | 109 | TEST(lgamma, lgamma_right) { 110 | unsigned long nb_tests; 111 | double x_start, x_end; 112 | 113 | x_start = 2.25; 114 | x_end = 10.0; 115 | nb_tests = 5000; 116 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 117 | 118 | x_start = 10.0; 119 | x_end = 100.0; 120 | nb_tests = 5000; 121 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 122 | } 123 | 124 | TEST(lgamma, lgamma_large) { 125 | unsigned long nb_tests; 126 | double x_start, x_end; 127 | 128 | x_start = 0x1.0p800; 129 | x_end = 0x1.0p802; 130 | nb_tests = 5000; 131 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 132 | 133 | x_start = 0x1.1p1012; 134 | x_end = 0x1.fffffp1012; 135 | nb_tests = 5000; 136 | report_err_fp64(rvvlm_lgamma, lgammal, x_start, x_end, nb_tests); 137 | } 138 | -------------------------------------------------------------------------------- /test/src/test_lgammaI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(lgammaI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("lgammaI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0.5; 18 | x_end = 1.75; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 30; 22 | report_err_fp64(rvvlm_lgammaI, lgammal, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_log.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_LOG)] = TV_FOR_LOG; 14 | 15 | nb_tv = NB_TV_FOR_LOG; 16 | 17 | test_vectors_fp64(rvvlm_log, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(log, around_1) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("log: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = 0.7; 27 | x_end = 1.5; 28 | nb_tests = 10000; 29 | report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); 30 | 31 | x_start = 1.0; 32 | x_end = 4.0; 33 | nb_tests = 10000; 34 | report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); 35 | 36 | x_start = 0.25; 37 | x_end = 1.0; 38 | nb_tests = 100000; 39 | report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); 40 | } 41 | 42 | TEST(log, extreme_args) { 43 | unsigned long nb_tests; 44 | double x_start, x_end; 45 | 46 | COMMENT("log: current chosen algorithm; reduced argument in FP64 only") 47 | 48 | x_start = 0x1.0p1023; 49 | x_end = 0x1.ffffffp1023; 50 | nb_tests = 100000; 51 | report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); 52 | 53 | x_start = 0x1.0p-1074; 54 | x_end = 0x1.0p-1022; 55 | nb_tests = 100000; 56 | report_err_fp64(rvvlm_log, logl, x_start, x_end, nb_tests); 57 | } 58 | -------------------------------------------------------------------------------- /test/src/test_log10.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log10, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_LOG)] = TV_FOR_LOG; 14 | 15 | nb_tv = NB_TV_FOR_LOG; 16 | 17 | test_vectors_fp64(rvvlm_log10, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(log10, around_1) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("log10: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = 0.7; 27 | x_end = 1.5; 28 | nb_tests = 40000; 29 | report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); 30 | 31 | x_start = 1.0; 32 | x_end = 4.0; 33 | nb_tests = 40000; 34 | report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); 35 | 36 | x_start = 0.25; 37 | x_end = 1.0; 38 | nb_tests = 40000; 39 | report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); 40 | } 41 | 42 | TEST(log10, extreme_args) { 43 | unsigned long nb_tests; 44 | double x_start, x_end; 45 | 46 | COMMENT("log10: current chosen algorithm; reduced argument in FP64 only") 47 | 48 | x_start = 0x1.0p1023; 49 | x_end = 0x1.ffffffp1023; 50 | nb_tests = 40000; 51 | report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); 52 | 53 | x_start = 0x1.0p-1074; 54 | x_end = 0x1.0p-1022; 55 | nb_tests = 40000; 56 | report_err_fp64(rvvlm_log10, log10l, x_start, x_end, nb_tests); 57 | } 58 | -------------------------------------------------------------------------------- /test/src/test_log10I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log10I, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("log10I: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0x1.0p-2; 18 | x_end = 0x1.0p+2; 19 | nb_tests = 300; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_log10I, log10l, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_log1p.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log1p, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_LOG1P)] = TV_FOR_LOG1P; 14 | 15 | nb_tv = NB_TV_FOR_LOG1P; 16 | 17 | test_vectors_fp64(rvvlm_log1p, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(log1p, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("log1p: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0x1.0p-4; 27 | x_end = 0x1.0p-4; 28 | nb_tests = 40000; 29 | report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); 30 | 31 | x_start = -0.999999; 32 | x_end = 0.0; 33 | nb_tests = 40000; 34 | report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(log1p, large_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("log1p: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = 0x1.0p1023; 44 | x_end = 0x1.ffffffp1023; 45 | nb_tests = 40000; 46 | report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); 47 | 48 | x_start = 0x1.0p-1074; 49 | x_end = 0x1.0p-1022; 50 | nb_tests = 40000; 51 | report_err_fp64(rvvlm_log1p, log1pl, x_start, x_end, nb_tests); 52 | } 53 | -------------------------------------------------------------------------------- /test/src/test_log1pI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log1pI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("log1pI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0x1.fffffp-1; 18 | x_end = 0x1.0p+4; 19 | nb_tests = 300; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_log1pI, log1pl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_log2.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log2, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_LOG)] = TV_FOR_LOG; 14 | 15 | nb_tv = NB_TV_FOR_LOG; 16 | 17 | test_vectors_fp64(rvvlm_log2, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(log2, around_1) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("log2: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = 0.7; 27 | x_end = 1.5; 28 | nb_tests = 10000; 29 | report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); 30 | 31 | x_start = 1.0; 32 | x_end = 4.0; 33 | nb_tests = 10000; 34 | report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); 35 | 36 | x_start = 0.25; 37 | x_end = 1.0; 38 | nb_tests = 10000; 39 | report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); 40 | } 41 | 42 | TEST(log2, extreme_args) { 43 | unsigned long nb_tests; 44 | double x_start, x_end; 45 | 46 | COMMENT("log2: current chosen algorithm; reduced argument in FP64 only") 47 | 48 | x_start = 0x1.0p1023; 49 | x_end = 0x1.ffffffp1023; 50 | nb_tests = 10000; 51 | report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); 52 | 53 | x_start = 0x1.0p-1074; 54 | x_end = 0x1.0p-1022; 55 | nb_tests = 10000; 56 | report_err_fp64(rvvlm_log2, log2l, x_start, x_end, nb_tests); 57 | } 58 | -------------------------------------------------------------------------------- /test/src/test_log2I.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(log2I, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("log2I: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0x1.0p-2; 18 | x_end = 0x1.0p+2; 19 | nb_tests = 300; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_log2I, log2l, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_logI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(logI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("logI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0x1.0p-2; 18 | x_end = 0x1.0p+2; 19 | nb_tests = 300; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_logI, logl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_powI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include "rvvlm.h" 10 | #include "test_infra.h" 11 | 12 | TEST(powI, test) { 13 | unsigned long nb_pts_x, nb_pts_y, stride_x, stride_y, stride_z; 14 | double x_start, x_end, y_start, y_end; 15 | bool swap_xy; 16 | 17 | COMMENT("powI: current chosen algorithm; reduced argument in FP64 only") 18 | 19 | x_start = 1.0; 20 | x_end = 10.0; 21 | y_start = -3.0; 22 | y_end = 3.0; 23 | nb_pts_x = 6; 24 | nb_pts_y = 7; 25 | stride_x = 21; 26 | stride_y = 39; 27 | stride_z = 11; 28 | swap_xy = 0; 29 | report_err2_fp64(rvvlm_powI, powl, x_start, x_end, nb_pts_x, stride_x, 30 | y_start, y_end, nb_pts_y, stride_y, stride_z, swap_xy); 31 | } 32 | -------------------------------------------------------------------------------- /test/src/test_sin.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sin, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_TRIG)] = TV_FOR_TRIG; 14 | 15 | nb_tv = NB_TV_FOR_TRIG; 16 | 17 | test_vectors_fp64(rvvlm_sin, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(sin, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.78; 27 | x_end = 0.78; 28 | nb_tests = 100000; 29 | report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); 30 | 31 | x_start = -6.0; 32 | x_end = 6.0; 33 | nb_tests = 100000; 34 | report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(sin, near_NPiby2) { 38 | #include "near_NPiby2_tbl.h" 39 | 40 | unsigned long nb_tests; 41 | 42 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 43 | 44 | nb_tests = (NB_TEST_ARGS); 45 | report_err_fp64(rvvlm_sin, sinl, dbl_near_NPiby2_tbl, nb_tests); 46 | } 47 | 48 | TEST(sin, medium_args) { 49 | unsigned long nb_tests; 50 | double x_start, x_end; 51 | 52 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 53 | 54 | x_start = 1.0; 55 | x_end = 0x1.0p23; 56 | nb_tests = 100000; 57 | report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); 58 | 59 | x_start = 0x1.0p25; 60 | x_end = 0x1.0p100; 61 | nb_tests = 100000; 62 | report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); 63 | } 64 | 65 | TEST(sin, large_args) { 66 | unsigned long nb_tests; 67 | double x_start, x_end; 68 | 69 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 70 | 71 | x_start = 1.0; 72 | x_end = 0x1.0p23; 73 | nb_tests = 100000; 74 | report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); 75 | 76 | x_start = 0x1.0p25; 77 | x_end = 0x1.0p100; 78 | nb_tests = 100000; 79 | report_err_fp64(rvvlm_sin, sinl, x_start, x_end, nb_tests); 80 | } 81 | -------------------------------------------------------------------------------- /test/src/test_sinI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sinI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sinI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_sinI, sinl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_sincos.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sincos, small_args) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.78; 18 | x_end = 0.78; 19 | nb_tests = 40000; 20 | report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); 21 | report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); 22 | 23 | x_start = -6.0; 24 | x_end = 6.0; 25 | nb_tests = 40000; 26 | report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); 27 | report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); 28 | } 29 | 30 | TEST(sincos, large_args) { 31 | unsigned long nb_tests; 32 | double x_start, x_end; 33 | 34 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 35 | 36 | x_start = -0.78; 37 | x_end = 0.78; 38 | nb_tests = 40000; 39 | report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); 40 | report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); 41 | 42 | x_start = -6.0; 43 | x_end = 6.0; 44 | nb_tests = 40000; 45 | report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); 46 | report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); 47 | 48 | x_start = 1.0; 49 | x_end = 0x1.0p23; 50 | nb_tests = 40000; 51 | report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); 52 | report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); 53 | 54 | x_start = 0x1.0p25; 55 | x_end = 0x1.0p100; 56 | nb_tests = 40000; 57 | report_err_fp64(rvvlm_sincos, sinl, 1, x_start, x_end, nb_tests); 58 | report_err_fp64(rvvlm_sincos, cosl, 2, x_start, x_end, nb_tests); 59 | } 60 | 61 | TEST(sincos, near_Npiby2) { 62 | #include "near_NPiby2_tbl.h" 63 | unsigned long nb_tests; 64 | 65 | COMMENT("sin: current chosen algorithm; reduced argument in FP64 only") 66 | 67 | nb_tests = (NB_TEST_ARGS); 68 | report_err_fp64(rvvlm_sincos, sinl, 1, dbl_near_NPiby2_tbl, nb_tests); 69 | report_err_fp64(rvvlm_sincos, cosl, 2, dbl_near_NPiby2_tbl, nb_tests); 70 | } 71 | -------------------------------------------------------------------------------- /test/src/test_sincosI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sincosI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sincosI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 8; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | int stride_z = 17; 23 | 24 | report_err_fp64(rvvlm_sincosI, sinl, 1, x_start, x_end, nb_tests, stride_x, 25 | stride_y, stride_z); 26 | 27 | report_err_fp64(rvvlm_sincosI, cosl, 2, x_start, x_end, nb_tests, stride_x, 28 | stride_y, stride_z); 29 | } 30 | -------------------------------------------------------------------------------- /test/src/test_sincospi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sincospi, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sincospi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special12_fp64(rvvlm_sincospi, 18 | "Special Value handling of this function"); 19 | 20 | x_start = -0.5; 21 | x_end = 0.5; 22 | nb_tests = 40000; 23 | report_err_fp64(rvvlm_sincospi, sinpil, 1, x_start, x_end, nb_tests); 24 | report_err_fp64(rvvlm_sincospi, cospil, 2, x_start, x_end, nb_tests); 25 | 26 | x_start = -0x1.0p3; 27 | x_end = 0x1.0p3; 28 | nb_tests = 40000; 29 | report_err_fp64(rvvlm_sincospi, sinpil, 1, x_start, x_end, nb_tests); 30 | report_err_fp64(rvvlm_sincospi, cospil, 2, x_start, x_end, nb_tests); 31 | 32 | x_start = 0x1.0p3; 33 | x_end = 0x1.0p60; 34 | nb_tests = 40000; 35 | report_err_fp64(rvvlm_sincospi, sinpil, 1, x_start, x_end, nb_tests); 36 | report_err_fp64(rvvlm_sincospi, cospil, 2, x_start, x_end, nb_tests); 37 | } 38 | -------------------------------------------------------------------------------- /test/src/test_sincospiI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sincospiI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sincosI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.5; 18 | x_end = 0.5; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | int stride_z = 17; 23 | 24 | report_err_fp64(rvvlm_sincospiI, sinpil, 1, x_start, x_end, nb_tests, 25 | stride_x, stride_y, stride_z); 26 | 27 | report_err_fp64(rvvlm_sincospiI, cospil, 2, x_start, x_end, nb_tests, 28 | stride_x, stride_y, stride_z); 29 | } 30 | -------------------------------------------------------------------------------- /test/src/test_sinh.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sinh, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_sinh, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(sinh, small_args) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | x_start = -0.346; 27 | x_end = 0.346; 28 | nb_tests = 40000; 29 | report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); 30 | 31 | x_start = -6.0; 32 | x_end = 6.0; 33 | nb_tests = 40000; 34 | report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); 35 | } 36 | 37 | TEST(sinh, medium_args) { 38 | unsigned long nb_tests; 39 | double x_start, x_end; 40 | 41 | COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") 42 | 43 | x_start = 30.0; 44 | x_end = 40.0; 45 | nb_tests = 40000; 46 | report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); 47 | 48 | x_start = 50.0; 49 | x_end = 60.0; 50 | nb_tests = 40000; 51 | report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); 52 | } 53 | 54 | TEST(sinh, large_args) { 55 | unsigned long nb_tests; 56 | double x_start, x_end; 57 | 58 | COMMENT("sinh: current chosen algorithm; reduced argument in FP64 only") 59 | 60 | x_start = 60.0; 61 | x_end = 70.0; 62 | nb_tests = 40000; 63 | report_err_fp64(rvvlm_sinh, sinhl, x_start, x_end, nb_tests); 64 | } 65 | -------------------------------------------------------------------------------- /test/src/test_sinhI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sinhI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sinhI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_sinhI, sinhl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_sinpi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sinpi, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sinpi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_sinpi, "Special Value handling of this function"); 18 | 19 | x_start = -0.5; 20 | x_end = 0.5; 21 | nb_tests = 100000; 22 | report_err_fp64(rvvlm_sinpi, sinpil, x_start, x_end, nb_tests); 23 | 24 | x_start = -0x1.0p3; 25 | x_end = 0x1.0p3; 26 | nb_tests = 100000; 27 | report_err_fp64(rvvlm_sinpi, sinpil, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p3; 30 | x_end = 0x1.0p60; 31 | nb_tests = 100000; 32 | report_err_fp64(rvvlm_sinpi, sinpil, x_start, x_end, nb_tests); 33 | } 34 | -------------------------------------------------------------------------------- /test/src/test_sinpiI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(sinpiI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sinI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.5; 18 | x_end = 0.5; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_sinpiI, sinpil, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_tan.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tan, special) { 12 | int nb_tv; 13 | int64_t tv_in_out[2 * (NB_TV_FOR_TRIG)] = TV_FOR_TRIG; 14 | 15 | nb_tv = NB_TV_FOR_TRIG; 16 | 17 | test_vectors_fp64(rvvlm_tan, tv_in_out, nb_tv); 18 | } 19 | 20 | TEST(tan, near_NPiby2) { 21 | #include "near_NPiby2_tbl.h" 22 | unsigned long nb_tests; 23 | 24 | COMMENT("tan: current chosen algorithm; reduced argument in FP64 only") 25 | 26 | nb_tests = (NB_TEST_ARGS); 27 | report_err_fp64(rvvlm_tan, tanl, dbl_near_NPiby2_tbl, nb_tests); 28 | } 29 | 30 | TEST(tan, small_args) { 31 | unsigned long nb_tests; 32 | double x_start, x_end; 33 | 34 | COMMENT("tan: current chosen algorithm; reduced argument in FP64 only") 35 | 36 | x_start = -0.7; 37 | x_end = 0.7; 38 | nb_tests = 10000; 39 | report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); 40 | 41 | x_start = -6.0; 42 | x_end = 6.0; 43 | nb_tests = 10000; 44 | report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); 45 | } 46 | 47 | TEST(tan, large_args) { 48 | unsigned long nb_tests; 49 | double x_start, x_end; 50 | 51 | COMMENT("tan: current chosen algorithm; reduced argument in FP64 only") 52 | 53 | x_start = 1.0; 54 | x_end = 0x1.0p23; 55 | nb_tests = 30000; 56 | report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); 57 | 58 | x_start = 0x1.0p25; 59 | x_end = 0x1.0p100; 60 | nb_tests = 30000; 61 | report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); 62 | 63 | x_start = 0x1.ffffp1023; 64 | x_end = 0x1.0p1000; 65 | nb_tests = 30000; 66 | report_err_fp64(rvvlm_tan, tanl, x_start, x_end, nb_tests); 67 | } 68 | -------------------------------------------------------------------------------- /test/src/test_tanI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tanI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("sinI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_tanI, tanl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_tanh.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tanh, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("tanh: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_tanh, "Special Value handling of this function"); 18 | 19 | x_start = -0.78; 20 | x_end = 0.78; 21 | nb_tests = 40000; 22 | report_err_fp64(rvvlm_tanh, tanhl, x_start, x_end, nb_tests); 23 | 24 | x_start = -6.0; 25 | x_end = 6.0; 26 | nb_tests = 40000; 27 | report_err_fp64(rvvlm_tanh, tanhl, x_start, x_end, nb_tests); 28 | 29 | x_start = 1.0; 30 | x_end = 0x1.0p3; 31 | nb_tests = 40000; 32 | report_err_fp64(rvvlm_tanh, tanhl, x_start, x_end, nb_tests); 33 | } 34 | -------------------------------------------------------------------------------- /test/src/test_tanhI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tanhI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("tanhI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = -0.34; 18 | x_end = 0.34; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 39; 22 | report_err_fp64(rvvlm_tanhI, tanhl, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /test/src/test_tanpi.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tanpi, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("tanpi: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_tanpi, "Special Value handling of this function"); 18 | 19 | x_start = -0.4999; 20 | x_end = 0.49999; 21 | nb_tests = 100000; 22 | report_err_fp64(rvvlm_tanpi, tanpil, x_start, x_end, nb_tests); 23 | 24 | x_start = -0x1.0p3; 25 | x_end = 0x1.0p3; 26 | nb_tests = 100000; 27 | report_err_fp64(rvvlm_tanpi, tanpil, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p3; 30 | x_end = 0x1.0p60; 31 | nb_tests = 100000; 32 | report_err_fp64(rvvlm_tanpi, tanpil, x_start, x_end, nb_tests); 33 | } 34 | -------------------------------------------------------------------------------- /test/src/test_tgamma.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tgamma, special) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("tgamma: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | show_special_fp64(rvvlm_tgamma, "Special Value handling of this function"); 18 | } 19 | 20 | TEST(tgamma, gamma_tiny) { 21 | unsigned long nb_tests; 22 | double x_start, x_end; 23 | 24 | x_start = 0x1.0p-120; 25 | x_end = 0x1.0p-118; 26 | nb_tests = 1000; 27 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 28 | 29 | x_start = 0x1.0p-50; 30 | x_end = 0x1.0p-40; 31 | nb_tests = 1000; 32 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 33 | 34 | x_start = -0x1.0p-118; 35 | x_end = -0x1.0p-120; 36 | nb_tests = 1000; 37 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 38 | 39 | x_start = -0x1.0p-40; 40 | x_end = -0x1.0p-50; 41 | nb_tests = 1000; 42 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 43 | } 44 | 45 | TEST(tgamma, gamma_moderate) { 46 | unsigned long nb_tests; 47 | double x_start, x_end; 48 | 49 | x_start = 0.5; 50 | x_end = 4.0; 51 | nb_tests = 1000; 52 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 53 | 54 | x_start = 4.0; 55 | x_end = 10.0; 56 | nb_tests = 1000; 57 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 58 | 59 | x_start = -0.9; 60 | x_end = -0.2; 61 | nb_tests = 1000; 62 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 63 | 64 | x_start = -10.1; 65 | x_end = -0.9; 66 | nb_tests = 1231; 67 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 68 | } 69 | 70 | TEST(tgamma, gamma_large) { 71 | unsigned long nb_tests; 72 | double x_start, x_end; 73 | 74 | x_start = 100.0; 75 | x_end = 171.0; 76 | nb_tests = 1000; 77 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 78 | 79 | x_start = -171.1; 80 | x_end = -100.3; 81 | nb_tests = 1317; 82 | report_err_fp64(rvvlm_tgamma, tgammal, x_start, x_end, nb_tests); 83 | } 84 | -------------------------------------------------------------------------------- /test/src/test_tgammaI.cpp: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Rivos Inc. 2 | // 3 | // SPDX-License-Identifier: Apache-2.0 4 | 5 | #include 6 | #include 7 | 8 | #include "rvvlm.h" 9 | #include "test_infra.h" 10 | 11 | TEST(tgammaI, test) { 12 | unsigned long nb_tests; 13 | double x_start, x_end; 14 | 15 | COMMENT("tgammaI: current chosen algorithm; reduced argument in FP64 only") 16 | 17 | x_start = 0.5; 18 | x_end = 1.75; 19 | nb_tests = 30; 20 | int stride_x = 21; 21 | int stride_y = 30; 22 | report_err_fp64(rvvlm_tgammaI, tgammal, x_start, x_end, nb_tests, stride_x, 23 | stride_y); 24 | } 25 | -------------------------------------------------------------------------------- /tools/run-clang-format.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # SPDX-FileCopyrightText: 2023 Rivos Inc. 3 | # 4 | # SPDX-License-Identifier: Apache-2.0 5 | 6 | import click 7 | from pathlib import Path 8 | import subprocess 9 | import sys 10 | 11 | def get_files(git_dir: Path, base_commit: str): 12 | if base_commit is None: 13 | git_command = [ 14 | "git", "-C", str(git_dir.absolute()), "ls-tree", "-r", "--name-only", "HEAD" 15 | ] 16 | else: 17 | git_command = [ 18 | "git", "-C", str(git_dir.absolute()), "diff", "--name-only", "--diff-filter=CAMT", base_commit 19 | ] 20 | git_files = subprocess.run(git_command, check=True, capture_output=True).\ 21 | stdout.decode("utf-8").strip().split("\n") 22 | return git_files 23 | 24 | 25 | def file_filter(fname: str): 26 | extensions = [".c", ".cpp", ".h", ".hpp"] 27 | for extension in extensions: 28 | if fname.endswith(extension): 29 | return True 30 | return False 31 | 32 | 33 | def check_format_changes(git_dir: Path, base_commit: str, clang_format_exe: str): 34 | git_files = get_files(git_dir, base_commit) 35 | files_to_update = [] 36 | for fname in filter(file_filter, git_files): 37 | # Do a dry run, and stop on the first error found 38 | clang_format_dry = [clang_format_exe, "-n", "--ferror-limit=1", str(git_dir.absolute() / fname)] 39 | clang_format_output = ( 40 | subprocess.run(clang_format_dry, check=True, capture_output=True) 41 | .stderr.decode("utf-8").strip() 42 | ) 43 | needs_clang_format = (len(clang_format_output) > 0) 44 | if needs_clang_format: 45 | files_to_update.append(str(git_dir.absolute() / fname)) 46 | if len(files_to_update) > 0: 47 | sep="\n\t" 48 | print(f"Found /usr/bin/clang-format changes in files\n{sep.join(files_to_update)}" 49 | "\nPlease address /usr/bin/clang-format errors and commit the changes") 50 | return 1 51 | print(f"No changes found with '{clang_format_exe}'") 52 | return 0 53 | 54 | 55 | def apply_clang_format(git_dir: Path, base_commit: str, clang_format_exe: str): 56 | git_files = get_files(git_dir, base_commit) 57 | # Apply clang format to all of the files we are interested in 58 | for fname in filter(file_filter, git_files): 59 | clang_format_apply = [clang_format_exe, "-i", str(git_dir.absolute() / fname)] 60 | subprocess.run(clang_format_apply, check=True) 61 | return 0 62 | 63 | 64 | @click.command() 65 | @click.argument( 66 | "run_type", 67 | type=click.Choice(["check", "apply"]), 68 | ) 69 | @click.option( 70 | "--base-commit", 71 | help="Base commit to find files with changes in. " 72 | "If not given, runs clang format on the whole repo" 73 | ) 74 | @click.option( 75 | "--clang-format-exe", 76 | help="Command to use for clang-format. This needs to point to the same " 77 | "version of clang-format as run on the CI, otherwise you may end up " 78 | "with different corrections. At the time of writing (2024/11), this is " 79 | "version 14.0", 80 | default="clang-format" 81 | ) 82 | def main(run_type, base_commit, clang_format_exe): 83 | git_dir = Path(__file__).absolute().parent.parent 84 | 85 | clang_format_func = check_format_changes if (run_type == "check") else apply_clang_format 86 | sys.exit(clang_format_func(git_dir, base_commit, clang_format_exe)) 87 | 88 | 89 | if __name__ == "__main__": 90 | main() 91 | --------------------------------------------------------------------------------