Message ID | 20240422074403.2399529-1-christoph.muellner@vrull.eu |
---|---|
Headers |
Return-Path: <libc-alpha-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 386ED384AB5C for <patchwork@sourceware.org>; Mon, 22 Apr 2024 07:46:37 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id 04E42384AB50 for <libc-alpha@sourceware.org>; Mon, 22 Apr 2024 07:44:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04E42384AB50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 04E42384AB50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713771855; cv=none; b=X69mFw77viUT5wNb47RPoySgrE51DzYOBgikTraxW1HVVKC/OiXlLdbMgGVAfhPs4BjUKEAWjl1brEmBca9qqek6cBbfCh0OFyX5bzjm6EZteE69OLZ7vUnR5v0q7X1yFEuotz1FL317nKTjjqbk4h8a2xJeSvPMMRLkdws3fMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713771855; c=relaxed/simple; bh=mYs4gsqYeOVkXu6eD1RE3OM0ndX3DS77CxStKAqONV0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=m0TMphmHn1hOsR/zGlVaBkS5AXewrpoteDLuNkHqkE75xvfSIEWR1HGckLzJbbds7vIGpSKjl9NffJjdDZTrUc9uRvIHHLbeN88oyop2F5Xb2TfgHv/QL7JxQvwBddeqHmE+kUQAnRGa9J7xun473XK49v+h/WYpLL+TDnuGhkA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-518931f8d23so4137287e87.3 for <libc-alpha@sourceware.org>; Mon, 22 Apr 2024 00:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1713771851; x=1714376651; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sHNWTFOQ7ITIeJwI2hNAlztLMCbLeOMcJKjyZ0GHbyE=; b=AIiD8yuajP8tbpgUC5IA4q3tqfhz0WYyX1QjRf0NVx2WNuhXsKxyXnvPwpvWhBkcLW 0jOJX2LCLzWLNf+E6LCXP655Mdqo6fUljoX9+leASJpD4WJkVWz1HTZL03euy0CDY5pU wBFGuxTFURxEp2xn+ILg0gV5Ok3sBTAkKxscNSzHnQglF4FZoialJZEmxm0OH5/Q54Hq zHSNVMz0mGDqAZdQ574VisqliOE6fsnFntVZ1ONL4U/1uJJMJ42tIHZz1DRI74kLODX2 8otz6gYqbdClBgXAkal78itTDVwHxFzw9xZ3Ec+/B7vDwFzT+bq6BXDILxygBMpsKTV6 Pq9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713771851; x=1714376651; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sHNWTFOQ7ITIeJwI2hNAlztLMCbLeOMcJKjyZ0GHbyE=; b=tlIE0scXimg6b5SkfSA6HbmtjK8z71ADDqSHBcI9veUWdr3qXVRbbfr1ginlboucah GPkngfUoa5H8UyV4rM+DkYpS3tY0wga34cr4Zn0s3P7W1iaj/HLCnSOdj4i2JVwALWud VJI0Sc5BKPDGaILXVUFtmjIzbOHbx8MKoN0bzIWTb/djhkOHsNMK0Zmqr6MJvqBuz1Ar PQi9LKwmy5Mqyd4ms69h9pxsVN1HDDrbOZYnl0wWY2Jvb3rMY9LCOEfbsjFdDhSO5fVY OwmN6CKFTyLcUW10pCk+FEbJBdDmg2hMWfhf63icuwQ6ggJ7VcE/ibv7MBQWLSZqba+9 /XBQ== X-Gm-Message-State: AOJu0Yx++oPSLUqOYj+JA3IkwoKq4YSTi/rUuuhrTjtIV/ajA8kq/Vfh 4jdYpqE9BS2f+1v1S07y2fdELDhn9l39OF0Osx4HNO6x8uI+G8k8SAV1HAwwkHcyPIo3AOw/M/v / X-Google-Smtp-Source: AGHT+IEAnGGUeeq51QTx4t/yW8PjLNAA31K2GFtun4OzlWrkkpFq+UrEjacMFcdk7p1QFst5HCdr4g== X-Received: by 2002:a19:f616:0:b0:515:beef:837f with SMTP id x22-20020a19f616000000b00515beef837fmr5207871lfe.29.1713771850411; Mon, 22 Apr 2024 00:44:10 -0700 (PDT) Received: from beast.fritz.box (static.239.130.217.95.clients.your-server.de. [95.217.130.239]) by smtp.gmail.com with ESMTPSA id v24-20020a197418000000b0051920234d6dsm1656756lfe.273.2024.04.22.00.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:44:09 -0700 (PDT) From: =?utf-8?q?Christoph_M=C3=BCllner?= <christoph.muellner@vrull.eu> To: libc-alpha@sourceware.org, Adhemerval Zanella <adhemerval.zanella@linaro.org>, Palmer Dabbelt <palmer@dabbelt.com>, Darius Rad <darius@bluespec.com>, Andrew Waterman <andrew@sifive.com>, Philipp Tomsich <philipp.tomsich@vrull.eu>, Evan Green <evan@rivosinc.com>, DJ Delorie <dj@redhat.com>, Vineet Gupta <vineetg@rivosinc.com>, Kito Cheng <kito.cheng@sifive.com>, Jeff Law <jeffreyalaw@gmail.com> Cc: =?utf-8?q?Christoph_M=C3=BCllner?= <christoph.muellner@vrull.eu> Subject: [PATCH 0/7] Add ifunc support for existing Zbb optimizations Date: Mon, 22 Apr 2024 09:43:56 +0200 Message-ID: <20240422074403.2399529-1-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_MANYTO, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org |
Series |
Add ifunc support for existing Zbb optimizations
|
|
Message
Christoph Müllner
April 22, 2024, 7:43 a.m. UTC
Glibc recently got hwprobe() support for RISC-V, which allows querying avaiable extensions at runtime. On top of that an optimized memcpy() routine (for fast unaligned accesses) has been merged, which is built by recompiling the generic C code with a different compiler flag. An ifunc resolver then detects which routine should be run using hwprobe(). This patchset follows this idea and recompiles the following functions with the existing Zbb/orc.b optimization in riscv/string-fza.h enabled: memchr, memrchr, strchrnul, strcmp, strlen, strncmp. Recompilation is achieved by defining the `__riscv_zbb` macro, which gates the use of orc.b. As defining this macro on our own is not enough to make GAS accept an 'orc.b' instruction, the first patch changes it into the .insn directive form. This series was tested by writing a simple test program to invoke the libc routines (e.g. strcmp) and a modified QEMU that reports the emulation of orc.b on stderr. With that the QEMU can be used to test if the optimized routines are executed (-cpu "rv64,zbb=[false,true]"). Further, this series was tested with SPEC CPU 2017 intrate with Zbb enabled. Christoph Müllner (7): RISC-V: Use .insn directive form for orc.b RISC-V: Add Zbb optimized memchr as ifunc RISC-V: Add Zbb optimized memrchr as ifunc RISC-V: Add Zbb optimized strchrnul as ifunc RISC-V: Add Zbb optimized strcmp as ifunc RISC-V: Add Zbb optimized strlen as ifunc RISC-V: Add Zbb optimized strncmp as ifunc sysdeps/riscv/multiarch/memchr-generic.c | 26 ++++++++ sysdeps/riscv/multiarch/memchr-zbb.c | 30 +++++++++ sysdeps/riscv/multiarch/memrchr-generic.c | 26 ++++++++ sysdeps/riscv/multiarch/memrchr-zbb.c | 30 +++++++++ sysdeps/riscv/multiarch/strchrnul-generic.c | 26 ++++++++ sysdeps/riscv/multiarch/strchrnul-zbb.c | 30 +++++++++ sysdeps/riscv/multiarch/strcmp-generic.c | 26 ++++++++ sysdeps/riscv/multiarch/strcmp-zbb.c | 30 +++++++++ sysdeps/riscv/multiarch/strlen-generic.c | 26 ++++++++ sysdeps/riscv/multiarch/strlen-zbb.c | 30 +++++++++ sysdeps/riscv/multiarch/strncmp-generic.c | 26 ++++++++ sysdeps/riscv/multiarch/strncmp-zbb.c | 30 +++++++++ sysdeps/riscv/string-fza.h | 3 +- .../unix/sysv/linux/riscv/multiarch/Makefile | 18 ++++++ .../linux/riscv/multiarch/ifunc-impl-list.c | 51 ++++++++++++++-- .../unix/sysv/linux/riscv/multiarch/memchr.c | 57 +++++++++++++++++ .../unix/sysv/linux/riscv/multiarch/memrchr.c | 61 +++++++++++++++++++ .../sysv/linux/riscv/multiarch/strchrnul.c | 61 +++++++++++++++++++ .../unix/sysv/linux/riscv/multiarch/strcmp.c | 57 +++++++++++++++++ .../unix/sysv/linux/riscv/multiarch/strlen.c | 57 +++++++++++++++++ .../unix/sysv/linux/riscv/multiarch/strncmp.c | 57 +++++++++++++++++ 21 files changed, 752 insertions(+), 6 deletions(-) create mode 100644 sysdeps/riscv/multiarch/memchr-generic.c create mode 100644 sysdeps/riscv/multiarch/memchr-zbb.c create mode 100644 sysdeps/riscv/multiarch/memrchr-generic.c create mode 100644 sysdeps/riscv/multiarch/memrchr-zbb.c create mode 100644 sysdeps/riscv/multiarch/strchrnul-generic.c create mode 100644 sysdeps/riscv/multiarch/strchrnul-zbb.c create mode 100644 sysdeps/riscv/multiarch/strcmp-generic.c create mode 100644 sysdeps/riscv/multiarch/strcmp-zbb.c create mode 100644 sysdeps/riscv/multiarch/strlen-generic.c create mode 100644 sysdeps/riscv/multiarch/strlen-zbb.c create mode 100644 sysdeps/riscv/multiarch/strncmp-generic.c create mode 100644 sysdeps/riscv/multiarch/strncmp-zbb.c create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/memchr.c create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/memrchr.c create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/strchrnul.c create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/strcmp.c create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/strlen.c create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/strncmp.c