| Message ID | 20260204181533.1498013-1-pincheng.plct@isrc.iscas.ac.cn |
|---|---|
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 27C2C4BA23C7 for <patchwork@sourceware.org>; Wed, 4 Feb 2026 18:15:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 27C2C4BA23C7 X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) by sourceware.org (Postfix) with ESMTPS id 2B2904BA2E08 for <newlib@sourceware.org>; Wed, 4 Feb 2026 18:15:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B2904BA2E08 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2B2904BA2E08 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=159.226.251.25 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770228942; cv=none; b=p5VO8ncpCHJQEQAMsylPHuEsx5is1Uc+WPeFglmZMM74f1BS4UyEshAnMLp7Dtp00VitUuTDY4exbjDllNLVKDXbLdeTlweP8hGA4YZpj0XUYS2fexjNfFAyY/0nrA7k5c0U2FY59XGw2J9UzfwNUUy41DyAh2Ta416EMNFfS2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770228942; c=relaxed/simple; bh=Em4zk5IoxUTOG+iFms7u4Ns8oUk5sZ0qBmJzP9iN2Dk=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Z9v3qtIgHPFRRtwVu7l3J7hEWwH1F4SV4NY8xjPb1V/IWTTolT1udilBL9Bugyv6OMMpeyB7L/XZ19FvhY2cHq2PkR+hr1mfLSit4xxZDThobgd8flFJbV4eVV0KiLqBBo8Wagq7fOljfVk6xqNX84xrZgbYRnzTYDn6SKpjNvc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B2904BA2E08 Received: from ROG.lan (unknown [118.251.177.185]) by APP-05 (Coremail) with SMTP id zQCowABX7A_GjINp+yx9Bw--.30190S2; Thu, 05 Feb 2026 02:15:35 +0800 (CST) From: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn> To: newlib@sourceware.org Cc: pincheng.plct@isrc.iscas.ac.cn Subject: [RFC PATCH 0/2] Add RISC-V vector math library support Date: Thu, 5 Feb 2026 02:15:31 +0800 Message-Id: <20260204181533.1498013-1-pincheng.plct@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: zQCowABX7A_GjINp+yx9Bw--.30190S2 X-Coremail-Antispam: 1UD129KBjvJXoWxXFW7GrWxKryDKry3WF4kJFb_yoW5WF18pF 4fGryrGw48Jr1fXrnrX3y0vr15Jas5G3W3Gr13Ja15Z3ykWw1vqFWqyw1rZa47Ja4UCFy7 XasrGr1ruw43ZrJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyq14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j 6r4UM28EF7xvwVC2z280aVAFwI0_Jr0_Gr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r1j6r 4UM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAKI48J MxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwV AFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUXVWUAwCIc40Y0x0EwIxGrwCI42IY6xIIjxv2 0xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4 v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AK xVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfU5WlkUUUUU X-Originating-IP: [118.251.177.185] X-CM-SenderInfo: pslquxhhqjh1xofwqxxvufhxpvfd2hldfou0/ X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
Add RISC-V vector math library support
|
|
Message
Pincheng Wang
Feb. 4, 2026, 6:15 p.m. UTC
Hi all, This RFC patch series propose adding RISC-V Vector Extension (RVV) optimized math functions to newlib, starting with a vectorized implementation of sin(). The motivation is to enable automatic vectorization of math functions on RISC-V platforms with vector extensions, which can provide significant performance improvements for numerical applications. After applying the gcc vecmath patch[1], compiler supports automatic vectorzation using the vector ABI[2](also in RFC). When compiling with auto-vectorization enabled (-O3 -ffast-math), the compiler can replace scalar math function calls with vector variants if they are available in the math library. This patch series adds infrastructure support for building vector math functions conditionally via a newly added "--enable-vecmath" configure option (disabled by default), and a vectorized sin() implementation for RISC-V using intrinsics from the RISC-V Vector Extension. While adding the above option, I encountered an automake compatibility issue during math object copying. Therefore, commit 1 is dedicated to fixing that issue and does not involve any vector math changes. The vector sin implementation is derived from the SLEEF library (Boost licensed) and adapted for newlib's RISC-V target. It uses RVV 1.0 intrinsics and provides performance-optimized computation with proper handling of edge cases. To configure and build, use below command. configure --target=riscv64-unknown-elf \ --prefix=/opt/vecmath-newlib \ CFLAGS_FOR_TARGET="-O2 -march=rv64gcv -mabi=lp64d" \ --enable-vecmath To compile a program that can take benefit of this patch, use the patched[1] gcc and run command like below. /opt/vecmath-gcc/bin/riscv64-unknown-elf-gcc \ -O3 -ffast-math -march=rv64gcv \ --sysroot=/opt/vecmath-newlib \ -L/opt/vecmath-newlib/riscv64-unknown-elf/lib \ -I/opt/vecmath-newlib/riscv64-unknown-elf/include \ test_sin.c -o test_sin -lm Comments and suggestions are welcome! [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-November/667352.html [2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455 Thanks, Pincheng Wang Pincheng Wang (2): newlib: Fix automake 1.16 compatibility for math object copying newlib: Add RISC-V vector math library support newlib/Makefile.am | 26 +- newlib/configure.ac | 10 + newlib/libc/include/math.h | 1 + newlib/libm/machine/riscv/Makefile.inc | 5 + newlib/libm/machine/riscv/riscv-vec-math.h | 1461 ++++++++++++++++++++ newlib/libm/machine/riscv/vec_sin.c | 79 ++ 6 files changed, 1569 insertions(+), 13 deletions(-) create mode 100644 newlib/libm/machine/riscv/riscv-vec-math.h create mode 100644 newlib/libm/machine/riscv/vec_sin.c
Comments
Benefits? - Performance? Accuracy? - numbers to back that up? On 2026-02-04 11:15, Pincheng Wang wrote: > This RFC patch series propose adding RISC-V Vector Extension (RVV) > optimized math functions to newlib, starting with a vectorized > implementation of sin(). > > The motivation is to enable automatic vectorization of math functions on > RISC-V platforms with vector extensions, which can provide significant > performance improvements for numerical applications. > > After applying the gcc vecmath patch[1], compiler supports automatic > vectorzation using the vector ABI[2](also in RFC). When compiling with > auto-vectorization enabled (-O3 -ffast-math), the compiler can replace > scalar math function calls with vector variants if they are available in > the math library. > > This patch series adds infrastructure support for building vector math > functions conditionally via a newly added "--enable-vecmath" configure > option (disabled by default), and a vectorized sin() implementation for > RISC-V using intrinsics from the RISC-V Vector Extension. > > While adding the above option, I encountered an automake compatibility > issue during math object copying. Therefore, commit 1 is dedicated to > fixing that issue and does not involve any vector math changes. > > The vector sin implementation is derived from the SLEEF library (Boost > licensed) and adapted for newlib's RISC-V target. It uses RVV 1.0 > intrinsics and provides performance-optimized computation with proper > handling of edge cases. > > To configure and build, use below command. > configure --target=riscv64-unknown-elf \ > --prefix=/opt/vecmath-newlib \ > CFLAGS_FOR_TARGET="-O2 -march=rv64gcv -mabi=lp64d" \ > --enable-vecmath > > To compile a program that can take > benefit of this patch, use the patched[1] gcc and run command like > below. > /opt/vecmath-gcc/bin/riscv64-unknown-elf-gcc \ > -O3 -ffast-math -march=rv64gcv \ > --sysroot=/opt/vecmath-newlib \ > -L/opt/vecmath-newlib/riscv64-unknown-elf/lib \ > -I/opt/vecmath-newlib/riscv64-unknown-elf/include \ > test_sin.c -o test_sin -lm > > Comments and suggestions are welcome! > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-November/667352.html > [2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455 > > Thanks, > Pincheng Wang > > Pincheng Wang (2): > newlib: Fix automake 1.16 compatibility for math object copying > newlib: Add RISC-V vector math library support > > newlib/Makefile.am | 26 +- > newlib/configure.ac | 10 + > newlib/libc/include/math.h | 1 + > newlib/libm/machine/riscv/Makefile.inc | 5 + > newlib/libm/machine/riscv/riscv-vec-math.h | 1461 ++++++++++++++++++++ > newlib/libm/machine/riscv/vec_sin.c | 79 ++ > 6 files changed, 1569 insertions(+), 13 deletions(-) > create mode 100644 newlib/libm/machine/riscv/riscv-vec-math.h > create mode 100644 newlib/libm/machine/riscv/vec_sin.c >
On Thu, Feb 5, 2026, 3:53 AM Brian Inglis <Brian.Inglis@systematicsw.ab.ca> wrote: > Benefits? - Performance? Accuracy? - numbers to back that up? > Are the vector extensions enabled by any multilib variant? At least for RTEMS, we do not build single variant tool chains. Our risc-v tool chain supports 32 and 64 variants. The OS source uses the compiler predefines to tailor to which cpu variant is being compiled to. What multilib variant would your configuration correspond to? When did GCC start having the builtins used? --joel RTEMS > > > On 2026-02-04 11:15, Pincheng Wang wrote: > > This RFC patch series propose adding RISC-V Vector Extension (RVV) > > optimized math functions to newlib, starting with a vectorized > > implementation of sin(). > > > > The motivation is to enable automatic vectorization of math functions on > > RISC-V platforms with vector extensions, which can provide significant > > performance improvements for numerical applications. > > > > After applying the gcc vecmath patch[1], compiler supports automatic > > vectorzation using the vector ABI[2](also in RFC). When compiling with > > auto-vectorization enabled (-O3 -ffast-math), the compiler can replace > > scalar math function calls with vector variants if they are available in > > the math library. > > > > This patch series adds infrastructure support for building vector math > > functions conditionally via a newly added "--enable-vecmath" configure > > option (disabled by default), and a vectorized sin() implementation for > > RISC-V using intrinsics from the RISC-V Vector Extension. > > > > While adding the above option, I encountered an automake compatibility > > issue during math object copying. Therefore, commit 1 is dedicated to > > fixing that issue and does not involve any vector math changes. > > > > The vector sin implementation is derived from the SLEEF library (Boost > > licensed) and adapted for newlib's RISC-V target. It uses RVV 1.0 > > intrinsics and provides performance-optimized computation with proper > > handling of edge cases. > > > > To configure and build, use below command. > > configure --target=riscv64-unknown-elf \ > > --prefix=/opt/vecmath-newlib \ > > CFLAGS_FOR_TARGET="-O2 -march=rv64gcv -mabi=lp64d" \ > > --enable-vecmath > > > > To compile a program that can take > > benefit of this patch, use the patched[1] gcc and run command like > > below. > > /opt/vecmath-gcc/bin/riscv64-unknown-elf-gcc \ > > -O3 -ffast-math -march=rv64gcv \ > > --sysroot=/opt/vecmath-newlib \ > > -L/opt/vecmath-newlib/riscv64-unknown-elf/lib \ > > -I/opt/vecmath-newlib/riscv64-unknown-elf/include \ > > test_sin.c -o test_sin -lm > > > > Comments and suggestions are welcome! > > > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-November/667352.html > > [2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455 > > > > Thanks, > > Pincheng Wang > > > > Pincheng Wang (2): > > newlib: Fix automake 1.16 compatibility for math object copying > > newlib: Add RISC-V vector math library support > > > > newlib/Makefile.am | 26 +- > > newlib/configure.ac | 10 + > > newlib/libc/include/math.h | 1 + > > newlib/libm/machine/riscv/Makefile.inc | 5 + > > newlib/libm/machine/riscv/riscv-vec-math.h | 1461 ++++++++++++++++++++ > > newlib/libm/machine/riscv/vec_sin.c | 79 ++ > > 6 files changed, 1569 insertions(+), 13 deletions(-) > > create mode 100644 newlib/libm/machine/riscv/riscv-vec-math.h > > create mode 100644 newlib/libm/machine/riscv/vec_sin.c > > > > > -- > Take care. Thanks, Brian Inglis Calgary, Alberta, Canada > > La perfection est atteinte Perfection is achieved > non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to > add > mais lorsqu'il n'y a plus rien à retrancher but when there is no more to > cut > -- Antoine de Saint-Exupéry >
Hi Brian, Apologies for the delayed response. This email somehow didn't appear in my inbox, and I only came across it while browsing the mailing list archive. Regarding benefits and performance, the primary benefit of this patch manifests when code contains loops (or similar patterns recognizable by the compiler for auto-vectorization, e.g, consecutive math function calls within a basic block. Please see the gcc patch logic for details) that invoke math functions. In such cases, multiple scalar function calls can be consolidated into a single vectorized call, resulting measurable performance gains. On the Spacemit X60 CPU, our benchmarks for functions like sin() and cos() showed up to 5.40x speedup compared to the scalar implementation. For Accuracy, the vectorized implementations are adapted from the SLEEF project with target-specifir tuning for RISC-V. Through extensive random sampling tests, we have verified that the error remains within 1ULP across the tests. For reference, glibc's vector math library on x86 targets typically guarantees accuracy within 3ULP. While nelib primarily targets embedded systems, we believe this optimization benefits with less friction. First, applications can benefit automatically with the patched gcc toolchain and appropriate flags without rewriting application codes. If vector math is not applicable or desired, the disabled by default configure option ensures no unintended side effects. Second, certail embedded workloads such as signal processing and sensor fusion do involve high throughput math computations, where vectorized math functions can meaningfully improve efficiency. Thank you very much for your questions. We welcome any further feedback or suggestions from the community! Best regards, Pincheng Wang On 2026/2/5 17:52, Brian Inglis wrote: > Benefits? - Performance? Accuracy? - numbers to back that up? > > On 2026-02-04 11:15, Pincheng Wang wrote: >> This RFC patch series propose adding RISC-V Vector Extension (RVV) >> optimized math functions to newlib, starting with a vectorized >> implementation of sin(). >> >> The motivation is to enable automatic vectorization of math functions on >> RISC-V platforms with vector extensions, which can provide significant >> performance improvements for numerical applications. >> >> After applying the gcc vecmath patch[1], compiler supports automatic >> vectorzation using the vector ABI[2](also in RFC). When compiling with >> auto-vectorization enabled (-O3 -ffast-math), the compiler can replace >> scalar math function calls with vector variants if they are available in >> the math library. >> >> This patch series adds infrastructure support for building vector math >> functions conditionally via a newly added "--enable-vecmath" configure >> option (disabled by default), and a vectorized sin() implementation for >> RISC-V using intrinsics from the RISC-V Vector Extension. >> >> While adding the above option, I encountered an automake compatibility >> issue during math object copying. Therefore, commit 1 is dedicated to >> fixing that issue and does not involve any vector math changes. >> >> The vector sin implementation is derived from the SLEEF library (Boost >> licensed) and adapted for newlib's RISC-V target. It uses RVV 1.0 >> intrinsics and provides performance-optimized computation with proper >> handling of edge cases. >> >> To configure and build, use below command. >> configure --target=riscv64-unknown-elf \ >> --prefix=/opt/vecmath-newlib \ >> CFLAGS_FOR_TARGET="-O2 -march=rv64gcv -mabi=lp64d" \ >> --enable-vecmath >> >> To compile a program that can take >> benefit of this patch, use the patched[1] gcc and run command like >> below. >> /opt/vecmath-gcc/bin/riscv64-unknown-elf-gcc \ >> -O3 -ffast-math -march=rv64gcv \ >> --sysroot=/opt/vecmath-newlib \ >> -L/opt/vecmath-newlib/riscv64-unknown-elf/lib \ >> -I/opt/vecmath-newlib/riscv64-unknown-elf/include \ >> test_sin.c -o test_sin -lm >> >> Comments and suggestions are welcome! >> >> [1] https://gcc.gnu.org/pipermail/gcc-patches/2024-November/667352.html >> [2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455 >> >> Thanks, >> Pincheng Wang >> >> Pincheng Wang (2): >> newlib: Fix automake 1.16 compatibility for math object copying >> newlib: Add RISC-V vector math library support >> >> newlib/Makefile.am | 26 +- >> newlib/configure.ac | 10 + >> newlib/libc/include/math.h | 1 + >> newlib/libm/machine/riscv/Makefile.inc | 5 + >> newlib/libm/machine/riscv/riscv-vec-math.h | 1461 ++++++++++++++++++++ >> newlib/libm/machine/riscv/vec_sin.c | 79 ++ >> 6 files changed, 1569 insertions(+), 13 deletions(-) >> create mode 100644 newlib/libm/machine/riscv/riscv-vec-math.h >> create mode 100644 newlib/libm/machine/riscv/vec_sin.c >> > >
Hi Joel, Thank you for the thoughtful questions regarding multilib configureation and gcc builtins. I apologies for the delayed response. This email somehow didn't appear in my inbox, and I only came across it while browsing the mailing list archive. For multilib variants, currently, neither gcc nor newlib defines a dedicated multilib variant solely for RISC-V vector extension (e.g a seperate rv64gcv). As noted in the cover letter, the current workflow requires both --enable-vecmath at configure time and -march=rv64gcv at compile time to enable vector math support. This may indeed an area that may benefit from upstream toolchain coordination, especially given that the vector extension has now become a mandatory extension of the RVA23 profile. If the community sees value in introducing RVV-aware multilib vairiants like rv64gcv_lp64d, I would be happy to collaborate on adapting the build infrasturcture accordingly. Regarding gcc builtins. If you refers to RVV intrinsics: intrinsics based on the v0.11 spec have been supported since gcc 13 and clang 16; Ratified v1.0 intrinsics became available starting with gcc 14 and clang 19. Our implementation uses v1.0 intrinsics, so gcc 14+ is required. If you refers to vectorized math function symbols: The naming convention and ABI for these vector math functions are currently under review in the RISC-V psABI document [1]. The corresponding gcc patch to recognize and emit these calls has not yet been merged upstream. This is also why this patch series is send as an RFC to gather feedback before the ABI solidifies. Thank you again for valubale insights from a practical application and development perspective. I look forward to further discussion and suggestions from the community. Best regards, Pincheng Wang [1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455 On 2026/2/5 22:31, Joel Sherrill wrote: > > > On Thu, Feb 5, 2026, 3:53 AM Brian Inglis > <Brian.Inglis@systematicsw.ab.ca > <mailto:Brian.Inglis@systematicsw.ab.ca>> wrote: > > Benefits? - Performance? Accuracy? - numbers to back that up? > > > Are the vector extensions enabled by any multilib variant? > > At least for RTEMS, we do not build single variant tool chains. Our > risc-v tool chain supports 32 and 64 variants. The OS source uses the > compiler predefines to tailor to which cpu variant is being compiled to. > What multilib variant would your configuration correspond to? > > When did GCC start having the builtins used? > > --joel > RTEMS > > > > On 2026-02-04 11:15, Pincheng Wang wrote: > > This RFC patch series propose adding RISC-V Vector Extension (RVV) > > optimized math functions to newlib, starting with a vectorized > > implementation of sin(). > > > > The motivation is to enable automatic vectorization of math > functions on > > RISC-V platforms with vector extensions, which can provide > significant > > performance improvements for numerical applications. > > > > After applying the gcc vecmath patch[1], compiler supports automatic > > vectorzation using the vector ABI[2](also in RFC). When compiling > with > > auto-vectorization enabled (-O3 -ffast-math), the compiler can > replace > > scalar math function calls with vector variants if they are > available in > > the math library. > > > > This patch series adds infrastructure support for building vector > math > > functions conditionally via a newly added "--enable-vecmath" > configure > > option (disabled by default), and a vectorized sin() > implementation for > > RISC-V using intrinsics from the RISC-V Vector Extension. > > > > While adding the above option, I encountered an automake > compatibility > > issue during math object copying. Therefore, commit 1 is dedicated to > > fixing that issue and does not involve any vector math changes. > > > > The vector sin implementation is derived from the SLEEF library > (Boost > > licensed) and adapted for newlib's RISC-V target. It uses RVV 1.0 > > intrinsics and provides performance-optimized computation with proper > > handling of edge cases. > > > > To configure and build, use below command. > > configure --target=riscv64-unknown-elf \ > > --prefix=/opt/vecmath-newlib \ > > CFLAGS_FOR_TARGET="-O2 -march=rv64gcv -mabi=lp64d" \ > > --enable-vecmath > > > > To compile a program that can take > > benefit of this patch, use the patched[1] gcc and run command like > > below. > > /opt/vecmath-gcc/bin/riscv64-unknown-elf-gcc \ > > -O3 -ffast-math -march=rv64gcv \ > > --sysroot=/opt/vecmath-newlib \ > > -L/opt/vecmath-newlib/riscv64-unknown-elf/lib \ > > -I/opt/vecmath-newlib/riscv64-unknown-elf/include \ > > test_sin.c -o test_sin -lm > > > > Comments and suggestions are welcome! > > > > [1] https://gcc.gnu.org/pipermail/gcc-patches/2024- > November/667352.html <https://gcc.gnu.org/pipermail/gcc- > patches/2024-November/667352.html> > > [2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455 > <https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/455> > > > > Thanks, > > Pincheng Wang > > > > Pincheng Wang (2): > > newlib: Fix automake 1.16 compatibility for math object copying > > newlib: Add RISC-V vector math library support > > > > newlib/Makefile.am | 26 +- > > newlib/configure.ac <http://configure.ac> > | 10 + > > newlib/libc/include/math.h | 1 + > > newlib/libm/machine/riscv/Makefile.inc | 5 + > > newlib/libm/machine/riscv/riscv-vec-math.h | 1461 +++++++++++++ > +++++++ > > newlib/libm/machine/riscv/vec_sin.c | 79 ++ > > 6 files changed, 1569 insertions(+), 13 deletions(-) > > create mode 100644 newlib/libm/machine/riscv/riscv-vec-math.h > > create mode 100644 newlib/libm/machine/riscv/vec_sin.c > > > > > -- > Take care. Thanks, Brian Inglis Calgary, Alberta, Canada > > La perfection est atteinte Perfection is achieved > non pas lorsqu'il n'y a plus rien à ajouter not when there is no > more to add > mais lorsqu'il n'y a plus rien à retrancher but when there is no > more to cut > -- Antoine de Saint-Exupéry >