From nobody Thu Aug 3 22:55:51 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RH42J2gRYz4V9Bt; Thu, 3 Aug 2023 22:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RH42J1d1Qz3gY7; Thu, 3 Aug 2023 22:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691103352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wWmB5schb2nhe0+3jYFTItVqLpoF4y4Cp9lgi9lwB68=; b=oz925CnWC0bGRTiFCtWkJVqsvfwgL0S/g3JZGEoerXtkQ7OSf+uGJXSbXM5TRggkORJDqg 1vlw6aHme9V2+fVBFHEOQzRHA86cGspTqeXZerpRdoy3I2ZzWxRU10CEqA1peqqcUw/+6b JXaBGaaSNcWTkCSqVVmNUfK+AW/ow+eDhBR1edu2yeyf4Qqbh7wgsjyARUwsQL2rjbCdMW XVgmJh0Qwb+pMI7zxfeB8AV4/puuqIVG7mOkcWfr8QQ/kp/fx/tdD60Aa8tnt1Q2CVeyzJ EzSoo6OKlxyiSfsHWGC+bOTPPShQmrMkK+AKUvYjlUHrg0t+fe59wjpeCXE/8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1691103352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wWmB5schb2nhe0+3jYFTItVqLpoF4y4Cp9lgi9lwB68=; b=HFpvryuYmA8SJmFCuwt491FYNLBb2NcZRUGGj6jHMsO5L9tEqbDRP9EZltxqtZYaWQ/BmH IOLI6Thg7n41pJwZpPTOZ7jHBTw4uh26Nc+PFlZCYScGm5WE1i0cTv1FWp7yAJqcD0SU+4 4LI7v6LFNtT5/8ipEYMaApbYfFJn5C0VEyjKOHI9h/ygjqX58TMbAGz2yb2SM3zooFKzJs uR10tk9hMjHtxY9UeCT1cfxoVO6NHjainHb+gfoIXfQt9I4bBPiBi8aAwtril0cyqXMF1z qiNxUP4zIm6lMmUbzSgzT59OaBSbrT0YK7mve4ylv1kgn6/KEvUen6Hs7QAcmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1691103352; a=rsa-sha256; cv=none; b=oY7GK7XnF5p8TNqzoM/5gfJHCXCK1tuYyhX/y6AtJAVVjOofRNEi4daWLtVdxr6tO/yH51 2UFugL4QRFwrgHB2xu+3TC/FIxHvRAZ8zM4U31Pn6Ejm05KfrUr7fJVdGW5pDpKBDnelBy KOrZJhu829fSHpRuEi1PjyjG7sx271V8xN0xaN/oMSaXo5TKXGdXUoYvJf56EzmAWuVDAA S50DxP1HGxVVCBiC47ZtvR91RPK2AlwES7BVHMeAEk1thoDbRn6fGB33bVqb9QcRujA+Sd 5sDDRC9xKL1B2a89uYEJDMsLt7fl18uTsu34a3eo6Sn3j+Zg6p/PETVUsvZ4sA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RH42J0RwbzfmY; Thu, 3 Aug 2023 22:55:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 373MtpTB072053; Thu, 3 Aug 2023 22:55:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 373Mtp3i072052; Thu, 3 Aug 2023 22:55:51 GMT (envelope-from git) Date: Thu, 3 Aug 2023 22:55:51 GMT Message-Id: <202308032255.373Mtp3i072052@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Clausecker Subject: git: 0588819779cd - main - share/man/man7: document libc simd usage in new man page simd(7) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fuz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0588819779cd82dc8fd9a1b63bcb531b296986eb Auto-Submitted: auto-generated The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=0588819779cd82dc8fd9a1b63bcb531b296986eb commit 0588819779cd82dc8fd9a1b63bcb531b296986eb Author: Robert Clausecker AuthorDate: 2023-08-03 22:51:31 +0000 Commit: Robert Clausecker CommitDate: 2023-08-03 22:54:44 +0000 share/man/man7: document libc simd usage in new man page simd(7) This documents SIMD usage in libc for all architectures with specific details on the new amd64 SIMD dispatch framework. Sponsored by: The FreeBSD Foundation Approved by: kib Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D40693 --- share/man/man7/Makefile | 1 + share/man/man7/simd.7 | 226 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 227 insertions(+) diff --git a/share/man/man7/Makefile b/share/man/man7/Makefile index f50e31cdeb11..56ade5092275 100644 --- a/share/man/man7/Makefile +++ b/share/man/man7/Makefile @@ -26,6 +26,7 @@ MAN= arch.7 \ release.7 \ sdoc.7 \ security.7 \ + simd.7 \ sizeof.7 \ sprog.7 \ stats.7 \ diff --git a/share/man/man7/simd.7 b/share/man/man7/simd.7 new file mode 100644 index 000000000000..c8e17cb9e0ef --- /dev/null +++ b/share/man/man7/simd.7 @@ -0,0 +1,226 @@ +.\" Copyright (c) 2023 The FreeBSD Foundation +. +.\" This documentation was written by Robert Clausecker +.\" under sponsorship from the FreeBSD Foundation. +. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +. +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ''AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE +. +.Dd July 3, 2023 +.Dt SIMD 7 +.Os +.Sh NAME +.Nm simd +.Nd SIMD enhancements +. +.Sh DESCRIPTION +On some architectures, the +.Fx +.Em libc +provides enhanced implementations of commonly used functions, replacing +the architecture-independent implementations used otherwise. +Depending on architecture and function, an enhanced +implementation of a function may either always be used or the +.Em libc +detects at runtime which SIMD instruction set extensions are +supported and picks the most suitable implementation automatically. +On +.Cm amd64 , +the environment variable +.Ev ARCHLEVEL +can be used to override this mechanism. +.Pp +Enhanced functions are present in the following architectures: +.Bl -column FUNCTION_ aarch64_ arm_ amd64_ i386_ ppc64_ -offset indent +.It Em FUNCTION Ta Em AARCH64 Ta Em ARM Ta Em AMD64 Ta Em I386 Ta Em PPC64 +.It bcmp Ta Ta Ta S Ta S +.It bcopy Ta Ta S Ta S Ta S Ta SV +.It bzero Ta Ta S Ta S Ta S +.It div Ta Ta Ta S Ta S +.It index Ta S +.It ldiv Ta Ta Ta S Ta S +.It lldiv Ta Ta Ta S +.It memcmp Ta Ta S Ta S Ta S +.It memcpy Ta S Ta S Ta S Ta S Ta SV +.It memmove Ta S Ta S Ta S Ta S Ta SV +.It memset Ta Ta S Ta S Ta S +.It rindex Ta S +.It stpcpy Ta Ta Ta S +.It strcat Ta Ta Ta S Ta S +.It strchr Ta S Ta Ta Ta S +.It strcmp Ta Ta S Ta S Ta S +.It strcpy Ta Ta Ta S Ta S Ta S2 +.It strlen Ta Ta S Ta S134 +.It strncmp Ta Ta S Ta Ta S +.It strncpy Ta Ta Ta Ta Ta S2 +.It strrchr Ta S Ta Ta Ta S +.It swab Ta Ta Ta Ta S +.It wcschr Ta Ta Ta Ta S +.It wcscmp Ta Ta Ta Ta S +.It wcslen Ta Ta Ta Ta S +.It wmemchr Ta Ta Ta Ta S +.El +.Pp +.Sy S Ns :\ scalar (non-SIMD), +.Sy 1 Ns :\ amd64 baseline, +.Sy 2 Ns :\ x86-64-v2 +or PowerPC\ 2.05, +.Sy 3 Ns :\ x86-64-v3, +.Sy 4 Ns :\ x86-64-v4, +.Sy V Ns :\ PowerPC\ VSX. +. +.Sh ENVIRONMENT +.Bl -tag +.It Ev ARCHLEVEL +On +.Em amd64 , +controls the level of SIMD enhancements used. +If this variable is set to an architecture level from the list below +and that architecture level is supported by the processor, SIMD +enhancements up to +.Ev ARCHLEVEL +are used. +If +.Ev ARCHLEVEL +is unset, not recognised, or not supported by the processor, the highest +level of SIMD enhancements supported by the processor is used. +.Pp +A suffix beginning with +.Sq ":" +or +.Sq "+" +in +.Ev ARCHLEVEL +is ignored and may be used for future extensions. +The architecture level can be prefixed with a +.Sq "!" +character to force use of the requested architecture level, even if the +processor does not advertise that it is supported. +This usually causes applications to crash and should only be used for +testing purposes or if architecture level detection yields incorrect +results. +.Pp +The architecture levels follow the AMD64 SysV ABI supplement: +.Bl -tag -width x86-64-v2 +.It Cm scalar +scalar enhancements only (no SIMD) +.It Cm baseline +cmov, cx8, x87 FPU, fxsr, MMX, osfxsr, SSE, SSE2 +.It Cm x86-64-v2 +cx16, lahf/sahf, popcnt, SSE3, SSSE3, SSE4.1, SSE4.2 +.It Cm x86-64-v3 +AVX, AVX2, BMI1, BMI2, F16C, FMA, lzcnt, movbe, osxsave +.It Cm x86-64-v4 +AVX-512F/BW/CD/DQ/VL +.El +.El +. +.Sh DIAGNOSTICS +.Bl -diag +.It "Illegal Instruction" +Printed by +.Xr sh 1 +if a command is terminated through delivery of a +.Dv SIGILL +signal, see +.Xr signal 3 . +.Pp +Use of an unsupported architecture level was forced by setting +.Ev ARCHLEVEL +to a string beginning with a +.Sq "!" +character, causing a process to crash due to use of an unsupported +instruction. +Unset +.Ev ARCHLEVEL , +remove the +.Sq "!" +prefix or select a supported architecture level. +.Pp +Message may also appear for unrelated reasons. +.El +. +.Sh SEE ALSO +.Xr string 3 , +.Xr arch 7 +.Rs +.%A H. J. Lu +.%A Michael Matz +.%A Milind Girkar +.%A Jan Hubi\[u010D]ka \" \(vc +.%A Andreas Jaeger +.%A Mark Mitchell +.%B System V Application Binary Interface +.%D May 23, 2023 +.%T AMD64 Architecture Processor Supplement +.%O Version 1.0 +.Re +. +.Sh HISTORY +Architecture-specific enhanced +.Em libc +functions were added starting +with +.Fx 2.0 +for +.Cm i386 , +.Fx 6.0 +for +.Cm arm , +.Fx 6.1 +for +.Cm amd64 , +.Fx 11.0 +for +.Cm aarch64 , +and +.Fx 12.0 +for +.Cm powerpc64 . +SIMD-enhanced functions were first added with +.Fx 13.0 +for +.Cm powerpc64 +and with +.Fx 14.0 +for +.Cm amd64 . +.Pp +A +.Nm +manual page appeared in +.Fx 14.0 . +. +.Sh AUTHOR +.An Robert Clausecker Aq Mt fuz@FreeBSD.org +. +.Sh CAVEATS +Other parts of +.Fx +such as cryptographic routines in the kernel or in +OpenSSL may also use SIMD enhancements. +These enhancements are not subject to the +.Ev ARCHLEVEL +variable and may have their own configuration +mechanism. +. +.Sh BUGS +Use of SIMD enhancements cannot be configured on powerpc64.