From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id AF84448BF0 for ; Fri, 10 May 2024 16:40:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 102EF68D557; Fri, 10 May 2024 19:39:54 +0300 (EEST) Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6313868D4EC for ; Fri, 10 May 2024 19:39:45 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 11A25C018E for ; Fri, 10 May 2024 19:39:44 +0300 (EEST) From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 May 2024 19:39:42 +0300 Message-ID: <20240510163943.109471-2-remi@remlab.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240510163943.109471-1-remi@remlab.net> References: <20240510163943.109471-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] lavu/riscv: add ff_rv_vlen_least() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This inline function checks that the vector length is at least a given value. With this, most run-time VLEN checks can be optimised away. --- libavutil/riscv/cpu.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libavutil/riscv/cpu.h b/libavutil/riscv/cpu.h index 56035f8556..af1440f626 100644 --- a/libavutil/riscv/cpu.h +++ b/libavutil/riscv/cpu.h @@ -22,6 +22,7 @@ #define AVUTIL_RISCV_CPU_H #include "config.h" +#include #include #include "libavutil/cpu.h" @@ -42,4 +43,24 @@ static inline size_t ff_get_rv_vlenb(void) return vlenb; } #endif + +/** + * Checks that the vector bit-size is at least the given value. + * This is potentially undefined behaviour if vectors are not implemented. + */ +static inline bool ff_rv_vlen_least(unsigned int bits) +{ +#ifdef __riscv_v_min_vlen + if (bits <= __riscv_min_vlen) + return true; +#else + /* + * Vector lengths smaller than 128 bits are only possible in embedded cases + * and cannot be run-time detected, so we can assume 128 bits at least. + */ + if (bits <= 128) + return true; +#endif + return bits <= (8 * ff_get_rv_vlenb()); +} #endif -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".