mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-07 00:50:50 +00:00
Update the Arm Optimized Routines
Import the v23.01 release of the Arm Optimized Routines [1]. This updates the license to MIT OR Apache-2.0 WITH LLVM-exception. [1] https://github.com/ARM-software/optimized-routines/tree/v23.01 Approved by: core (License change) Sponsored by: Arm Ltd
This commit is contained in:
parent
01c4cb317e
commit
29866ecb89
232
LICENSE
232
LICENSE
|
@ -1,6 +1,11 @@
|
|||
MIT License
|
||||
MIT OR Apache-2.0 WITH LLVM-exception
|
||||
=====================================
|
||||
|
||||
Copyright (c) 1999-2019, Arm Limited.
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
Copyright (c) 1999-2022, Arm Limited.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -19,3 +24,226 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
Apache-2.0 WITH LLVM-exception
|
||||
------------------------------
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
|
||||
--- LLVM Exceptions to the Apache 2.0 License ----
|
||||
|
||||
As an exception, if, as a result of your compiling your source code, portions
|
||||
of this Software are embedded into an Object form of such source code, you
|
||||
may redistribute such embedded portions in such Object form without complying
|
||||
with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
|
||||
|
||||
In addition, if you combine or link compiled forms of this Software with
|
||||
software that is licensed under the GPLv2 ("Combined Software") and if a
|
||||
court of competent jurisdiction determines that the patent provision (Section
|
||||
3), the indemnity provision (Section 9) or other Section of the License
|
||||
conflicts with the conditions of the GPLv2, you may retroactively and
|
||||
prospectively choose to deem waived or otherwise exclude such Section(s) of
|
||||
the License, but only in their entirety and only with respect to the Combined
|
||||
Software.
|
||||
|
|
12
MAINTAINERS
Normal file
12
MAINTAINERS
Normal file
|
@ -0,0 +1,12 @@
|
|||
/
|
||||
Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
math/
|
||||
Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
networking/
|
||||
Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
pl/
|
||||
Pierre Blanchard <pierre.blanchard@arm.com>
|
||||
Joe Ramsay <joe.ramsay@arm.com>
|
||||
string/
|
||||
Szabolcs Nagy <szabolcs.nagy@arm.com>
|
||||
Wilco Dijkstra <wilco.dijkstra@arm.com>
|
7
Makefile
7
Makefile
|
@ -1,7 +1,7 @@
|
|||
# Makefile - requires GNU make
|
||||
#
|
||||
# Copyright (c) 2018-2020, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2022, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
srcdir = .
|
||||
prefix = /usr
|
||||
|
@ -11,6 +11,7 @@ includedir = $(prefix)/include
|
|||
|
||||
# Configure these in config.mk, do not make changes in this file.
|
||||
SUBS = math string networking
|
||||
PLSUBS = math
|
||||
HOST_CC = cc
|
||||
HOST_CFLAGS = -std=c99 -O2
|
||||
HOST_LDFLAGS =
|
||||
|
@ -20,6 +21,7 @@ CPPFLAGS =
|
|||
CFLAGS = -std=c99 -O2
|
||||
CFLAGS_SHARED = -fPIC
|
||||
CFLAGS_ALL = -Ibuild/include $(CPPFLAGS) $(CFLAGS)
|
||||
CFLAGS_PL = -Ibuild/pl/include $(CPPFLAGS) $(CFLAGS) -DPL
|
||||
LDFLAGS =
|
||||
LDLIBS =
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
|
@ -51,6 +53,7 @@ $(DIRS):
|
|||
mkdir -p $@
|
||||
|
||||
$(filter %.os,$(ALL_FILES)): CFLAGS_ALL += $(CFLAGS_SHARED)
|
||||
$(filter %.os,$(ALL_FILES)): CFLAGS_PL += $(CFLAGS_SHARED)
|
||||
|
||||
build/%.o: $(srcdir)/%.S
|
||||
$(CC) $(CFLAGS_ALL) -c -o $@ $<
|
||||
|
|
14
README
14
README
|
@ -2,14 +2,17 @@ Arm Optimized Routines
|
|||
----------------------
|
||||
|
||||
This repository contains implementations of library functions
|
||||
provided by Arm under MIT License (See LICENSE). Contributions
|
||||
to this project are accepted, but Contributors have to sign an
|
||||
Assignment Agreement, please follow the instructions in
|
||||
provided by Arm. The outbound license is available under a dual
|
||||
license, at the user’s election, as reflected in the LICENSE file.
|
||||
Contributions to this project are accepted, but Contributors have
|
||||
to sign an Assignment Agreement, please follow the instructions in
|
||||
contributor-agreement.pdf. This is needed so upstreaming code
|
||||
to projects that require copyright assignment is possible.
|
||||
to projects that require copyright assignment is possible. Further
|
||||
contribution requirements are documented in README.contributors of
|
||||
the appropriate subdirectory.
|
||||
|
||||
Regular quarterly releases are tagged as vYY.MM, the latest
|
||||
release is v21.02.
|
||||
release is v23.01.
|
||||
|
||||
Source code layout:
|
||||
|
||||
|
@ -24,6 +27,7 @@ networking/test/ - networking test and benchmark related sources.
|
|||
string/ - string routines subproject sources.
|
||||
string/include/ - string library public headers.
|
||||
string/test/ - string test and benchmark related sources.
|
||||
pl/... - separately maintained performance library code.
|
||||
|
||||
The steps to build the target libraries and run the tests:
|
||||
|
||||
|
|
44
README.contributors
Normal file
44
README.contributors
Normal file
|
@ -0,0 +1,44 @@
|
|||
GENERIC CONTRIBUTION GUIDELINES
|
||||
===============================
|
||||
|
||||
1. Sub-projects are maintained independently and thus have independent
|
||||
contribution rules. If there exists a README.contributors in the
|
||||
sub-directory to which the contribution is made, it must be followed.
|
||||
|
||||
2. Legal:
|
||||
- Contributors who are not employed by Arm must sign an Assignment Agreement.
|
||||
See contributor-agreement.pdf.
|
||||
- All code must be copyright owned by Arm Limited and the appropriate
|
||||
copyright notice and license identifier must be present in every source
|
||||
file.
|
||||
|
||||
3. Build:
|
||||
- Build should only depend on GNU make and posix utilities (shell, awk, sed,
|
||||
etc) and on a C toolchain.
|
||||
- Build should pass with the default configuration (see config.mk.dist)
|
||||
and other supported configurations, with both gcc and clang based
|
||||
toolchains. (The build should not depend on a recent toolchain, the use
|
||||
of a new feature should be possible to disable.)
|
||||
- Currently there is no automated configuration, target specific configuration
|
||||
should be done via make variables in config.mk. This is the user interface
|
||||
to the build system, so it should be documented in sufficient detail and
|
||||
kept reasonably stable.
|
||||
|
||||
4. Testing:
|
||||
- On aarch64 the tests must pass. If the code may behave differently under
|
||||
some supported configurations (e.g. CFLAGS) those should be tested.
|
||||
- New symbols are expected to have new associated test code and ideally
|
||||
benchmark code too.
|
||||
|
||||
4. Commits:
|
||||
- Commit message should be descriptive and should not refer to Arm internal
|
||||
information (such as Jira tickets, or internal discussions). Non-obvious
|
||||
decisions should be recorded or explained in the commit message if they are
|
||||
not explained in source comments.
|
||||
- Ideally tools and scripts used to write the code should be added to the
|
||||
repository or at least mentioned in the commit.
|
||||
- Logically independent changes should not be mixed into the same commit.
|
||||
|
||||
5. Style:
|
||||
- Unless otherwise required differently by the sub-project, follow the
|
||||
clang-format tool using the style from the gcc contrib/ directory.
|
|
@ -1,11 +1,14 @@
|
|||
# Example config.mk
|
||||
#
|
||||
# Copyright (c) 2018-2020, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2018-2022, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Subprojects to build
|
||||
SUBS = math string networking
|
||||
|
||||
# Subsubprojects to build if subproject pl is built
|
||||
PLSUBS = math
|
||||
|
||||
# Target architecture: aarch64, arm or x86_64
|
||||
ARCH = aarch64
|
||||
|
||||
|
@ -59,6 +62,23 @@ math-cflags += -ffp-contract=fast -fno-math-errno
|
|||
# Disable vector math code
|
||||
#math-cflags += -DWANT_VMATH=0
|
||||
|
||||
# Disable/enable SVE vector math code and tests
|
||||
WANT_SVE_MATH = 0
|
||||
ifeq ($(WANT_SVE_MATH), 1)
|
||||
math-cflags += -march=armv8.2-a+sve
|
||||
endif
|
||||
math-cflags += -DWANT_SVE_MATH=$(WANT_SVE_MATH)
|
||||
|
||||
# If defined to 1, set errno in math functions according to ISO C. Many math
|
||||
# libraries do not set errno, so this is 0 by default. It may need to be
|
||||
# set to 1 if math.h has (math_errhandling & MATH_ERRNO) != 0.
|
||||
WANT_ERRNO = 0
|
||||
math-cflags += -DWANT_ERRNO=$(WANT_ERRNO)
|
||||
|
||||
# If set to 1, set fenv in vector math routines.
|
||||
WANT_SIMD_EXCEPT = 0
|
||||
math-cflags += -DWANT_SIMD_EXCEPT=$(WANT_SIMD_EXCEPT)
|
||||
|
||||
# Disable fenv checks
|
||||
#math-ulpflags = -q -f
|
||||
#math-testflags = -nostatus
|
||||
|
|
15
math/Dir.mk
15
math/Dir.mk
|
@ -1,7 +1,7 @@
|
|||
# Makefile fragment - requires GNU make
|
||||
#
|
||||
# Copyright (c) 2019, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2019-2022, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
S := $(srcdir)/math
|
||||
B := build/math
|
||||
|
@ -15,6 +15,7 @@ math-test-srcs := \
|
|||
math-test-host-srcs := $(wildcard $(S)/test/rtest/*.[cS])
|
||||
|
||||
math-includes := $(patsubst $(S)/%,build/%,$(wildcard $(S)/include/*.h))
|
||||
math-test-includes := $(patsubst $(S)/%,build/include/%,$(wildcard $(S)/test/*.h))
|
||||
|
||||
math-libs := \
|
||||
build/lib/libmathlib.so \
|
||||
|
@ -42,10 +43,11 @@ math-files := \
|
|||
$(math-tools) \
|
||||
$(math-host-tools) \
|
||||
$(math-includes) \
|
||||
$(math-test-includes) \
|
||||
|
||||
all-math: $(math-libs) $(math-tools) $(math-includes)
|
||||
all-math: $(math-libs) $(math-tools) $(math-includes) $(math-test-includes)
|
||||
|
||||
$(math-objs): $(math-includes)
|
||||
$(math-objs): $(math-includes) $(math-test-includes)
|
||||
$(math-objs): CFLAGS_ALL += $(math-cflags)
|
||||
$(B)/test/mathtest.o: CFLAGS_ALL += -fmath-errno
|
||||
$(math-host-objs): CC = $(HOST_CC)
|
||||
|
@ -83,6 +85,9 @@ build/bin/ulp: $(B)/test/ulp.o build/lib/libmathlib.a
|
|||
build/include/%.h: $(S)/include/%.h
|
||||
cp $< $@
|
||||
|
||||
build/include/test/%.h: $(S)/test/%.h
|
||||
cp $< $@
|
||||
|
||||
build/bin/%.sh: $(S)/test/%.sh
|
||||
cp $< $@
|
||||
|
||||
|
@ -96,7 +101,7 @@ check-math-rtest: $(math-host-tools) $(math-tools)
|
|||
cat $(math-rtests) | build/bin/rtest | $(EMULATOR) build/bin/mathtest $(math-testflags)
|
||||
|
||||
check-math-ulp: $(math-tools)
|
||||
ULPFLAGS="$(math-ulpflags)" build/bin/runulp.sh $(EMULATOR)
|
||||
ULPFLAGS="$(math-ulpflags)" WANT_SIMD_EXCEPT="$(WANT_SIMD_EXCEPT)" build/bin/runulp.sh $(EMULATOR)
|
||||
|
||||
check-math: check-math-test check-math-rtest check-math-ulp
|
||||
|
||||
|
|
78
math/README.contributors
Normal file
78
math/README.contributors
Normal file
|
@ -0,0 +1,78 @@
|
|||
STYLE REQUIREMENTS
|
||||
==================
|
||||
|
||||
1. Most code in this sub-directory is expected to be upstreamed into glibc so
|
||||
the GNU Coding Standard and glibc specific conventions should be followed
|
||||
to ease upstreaming.
|
||||
|
||||
2. ABI and symbols: the code should be written so it is suitable for inclusion
|
||||
into a libc with minimal changes. This e.g. means that internal symbols
|
||||
should be hidden and in the implementation reserved namespace according to
|
||||
ISO C and POSIX rules. If possible the built shared libraries and static
|
||||
library archives should be usable to override libc symbols at link time (or
|
||||
at runtime via LD_PRELOAD). This requires the symbols to follow the glibc ABI
|
||||
(other than symbol versioning), this cannot be done reliably for static
|
||||
linking so this is a best effort requirement.
|
||||
|
||||
3. API: include headers should be suitable for benchmarking and testing code
|
||||
and should not conflict with libc headers.
|
||||
|
||||
|
||||
CONTRIBUTION GUIDELINES FOR math SUB-DIRECTORY
|
||||
==============================================
|
||||
|
||||
1. Math functions have quality and performance requirements.
|
||||
|
||||
2. Quality:
|
||||
- Worst-case ULP error should be small in the entire input domain (for most
|
||||
common double precision scalar functions the target is < 0.66 ULP error,
|
||||
and < 1 ULP for single precision, even performance optimized function
|
||||
variant should not have > 5 ULP error if the goal is to be a drop in
|
||||
replacement for a standard math function), this should be tested
|
||||
statistically (or on all inputs if possible in reasonable amount of time).
|
||||
The ulp tool is for this and runulp.sh should be updated for new functions.
|
||||
|
||||
- All standard rounding modes need to be supported but in non-default rounding
|
||||
modes the quality requirement can be relaxed. (Non-nearest rounded
|
||||
computation can be slow and inaccurate but has to be correct for conformance
|
||||
reasons.)
|
||||
|
||||
- Special cases and error handling need to follow ISO C Annex F requirements,
|
||||
POSIX requirements, IEEE 754-2008 requirements and Glibc requiremnts:
|
||||
https://www.gnu.org/software/libc/manual/html_mono/libc.html#Errors-in-Math-Functions
|
||||
this should be tested by direct tests (glibc test system may be used for it).
|
||||
|
||||
- Error handling code should be decoupled from the approximation code as much
|
||||
as possible. (There are helper functions, these take care of errno as well
|
||||
as exception raising.)
|
||||
|
||||
- Vector math code does not need to work in non-nearest rounding mode and error
|
||||
handling side effects need not happen (fenv exceptions and errno), but the
|
||||
result should be correct (within quality requirements, which are lower for
|
||||
vector code than for scalar code).
|
||||
|
||||
- Error bounds of the approximation should be clearly documented.
|
||||
|
||||
- The code should build and pass tests on arm, aarch64 and x86_64 GNU linux
|
||||
systems. (Routines and features can be disabled on specific targets, but
|
||||
the build must complete). On aarch64, both little- and big-endian targets
|
||||
are supported as well as valid combinations of architecture extensions.
|
||||
The configurations that should be tested depend on the contribution.
|
||||
|
||||
3. Performance:
|
||||
- Common math code should be benchmarked on modern aarch64 microarchitectures
|
||||
over typical inputs.
|
||||
|
||||
- Performance improvements should be documented (relative numbers can be
|
||||
published; it is enough to use the mathbench microbenchmark tool which should
|
||||
be updated for new functions).
|
||||
|
||||
- Attention should be paid to the compilation flags: for aarch64 fma
|
||||
contraction should be on and math errno turned off so some builtins can be
|
||||
inlined.
|
||||
|
||||
- The code should be reasonably performant on x86_64 too, e.g. some rounding
|
||||
instructions and fma may not be available on x86_64, such builtins turn into
|
||||
libc calls with slow code. Such slowdown is not acceptable, a faster fallback
|
||||
should be present: glibc and bionic use the same code on all targets. (This
|
||||
does not apply to vector math code).
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Single-precision cos function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2018-2021, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision erf(x) function.
|
||||
*
|
||||
* Copyright (c) 2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Shared data between erf and erfc.
|
||||
*
|
||||
* Copyright (c) 2019-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Single-precision erf(x) function.
|
||||
*
|
||||
* Copyright (c) 2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data for approximation of erff.
|
||||
*
|
||||
* Copyright (c) 2019-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision e^x function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision 2^x function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Single-precision 2^x function.
|
||||
*
|
||||
* Copyright (c) 2017-2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Shared data between expf, exp2f and powf.
|
||||
*
|
||||
* Copyright (c) 2017-2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Shared data between exp, exp2 and pow.
|
||||
*
|
||||
* Copyright (c) 2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Single-precision e^x function.
|
||||
*
|
||||
* Copyright (c) 2017-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Public API.
|
||||
*
|
||||
* Copyright (c) 2015-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _MATHLIB_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision log(x) function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision log2(x) function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data for log2.
|
||||
*
|
||||
* Copyright (c) 2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Single-precision log2 function.
|
||||
*
|
||||
* Copyright (c) 2017-2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data definition for log2f.
|
||||
*
|
||||
* Copyright (c) 2017-2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data for log.
|
||||
*
|
||||
* Copyright (c) 2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Single-precision log function.
|
||||
*
|
||||
* Copyright (c) 2017-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2017-2023, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
@ -57,7 +57,7 @@ logf (float x)
|
|||
tmp = ix - OFF;
|
||||
i = (tmp >> (23 - LOGF_TABLE_BITS)) % N;
|
||||
k = (int32_t) tmp >> 23; /* arithmetic shift */
|
||||
iz = ix - (tmp & 0x1ff << 23);
|
||||
iz = ix - (tmp & 0xff800000);
|
||||
invc = T[i].invc;
|
||||
logc = T[i].logc;
|
||||
z = (double_t) asfloat (iz);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data definition for logf.
|
||||
*
|
||||
* Copyright (c) 2017-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Configuration for math routines.
|
||||
*
|
||||
* Copyright (c) 2017-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef _MATH_CONFIG_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision math error handling.
|
||||
*
|
||||
* Copyright (c) 2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Single-precision math error handling.
|
||||
*
|
||||
* Copyright (c) 2017-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Double-precision x^y function.
|
||||
*
|
||||
* Copyright (c) 2018-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data for the log part of pow.
|
||||
*
|
||||
* Copyright (c) 2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Single-precision pow function.
|
||||
*
|
||||
* Copyright (c) 2017-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data definition for powf.
|
||||
*
|
||||
* Copyright (c) 2017-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "math_config.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_cos.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_cosf.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_exp.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_exp2f.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_exp2f_1u.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_expf.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_expf_1u.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_log.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_logf.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_pow.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_powf.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_sin.c"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#define SCALAR 1
|
||||
#include "v_sinf.c"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Single-precision sin/cos function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2018-2021, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Header for sinf, cosf and sincosf.
|
||||
*
|
||||
* Copyright (c) 2018, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2018-2021, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Data definition for sinf, cosf and sincosf.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Single-precision sin function.
|
||||
*
|
||||
* Copyright (c) 2018-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2018-2021, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* Microbenchmark for math functions.
|
||||
*
|
||||
* Copyright (c) 2018-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2018-2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#undef _GNU_SOURCE
|
||||
|
@ -66,6 +66,43 @@ v_float_dup (float x)
|
|||
{
|
||||
return (v_float){x, x, x, x};
|
||||
}
|
||||
#if WANT_SVE_MATH
|
||||
#include <arm_sve.h>
|
||||
typedef svbool_t sv_bool;
|
||||
typedef svfloat64_t sv_double;
|
||||
|
||||
#define sv_double_len() svcntd()
|
||||
|
||||
static inline sv_double
|
||||
sv_double_load (const double *p)
|
||||
{
|
||||
svbool_t pg = svptrue_b64();
|
||||
return svld1(pg, p);
|
||||
}
|
||||
|
||||
static inline sv_double
|
||||
sv_double_dup (double x)
|
||||
{
|
||||
return svdup_n_f64(x);
|
||||
}
|
||||
|
||||
typedef svfloat32_t sv_float;
|
||||
|
||||
#define sv_float_len() svcntw()
|
||||
|
||||
static inline sv_float
|
||||
sv_float_load (const float *p)
|
||||
{
|
||||
svbool_t pg = svptrue_b32();
|
||||
return svld1(pg, p);
|
||||
}
|
||||
|
||||
static inline sv_float
|
||||
sv_float_dup (float x)
|
||||
{
|
||||
return svdup_n_f32(x);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
/* dummy definitions to make things compile. */
|
||||
typedef double v_double;
|
||||
|
@ -89,7 +126,6 @@ dummyf (float x)
|
|||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
#if WANT_VMATH
|
||||
#if __aarch64__
|
||||
static v_double
|
||||
|
@ -116,101 +152,25 @@ __vn_dummyf (v_float x)
|
|||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
__vpcs static v_float
|
||||
xy__vn_powf (v_float x)
|
||||
#endif
|
||||
#if WANT_SVE_MATH
|
||||
static sv_double
|
||||
__sv_dummy (sv_double x, sv_bool pg)
|
||||
{
|
||||
return __vn_powf (x, x);
|
||||
return x;
|
||||
}
|
||||
|
||||
__vpcs static v_float
|
||||
xy_Z_powf (v_float x)
|
||||
static sv_float
|
||||
__sv_dummyf (sv_float x, sv_bool pg)
|
||||
{
|
||||
return _ZGVnN4vv_powf (x, x);
|
||||
return x;
|
||||
}
|
||||
|
||||
__vpcs static v_double
|
||||
xy__vn_pow (v_double x)
|
||||
{
|
||||
return __vn_pow (x, x);
|
||||
}
|
||||
|
||||
__vpcs static v_double
|
||||
xy_Z_pow (v_double x)
|
||||
{
|
||||
return _ZGVnN2vv_pow (x, x);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static v_float
|
||||
xy__v_powf (v_float x)
|
||||
{
|
||||
return __v_powf (x, x);
|
||||
}
|
||||
|
||||
static v_double
|
||||
xy__v_pow (v_double x)
|
||||
{
|
||||
return __v_pow (x, x);
|
||||
}
|
||||
#endif
|
||||
|
||||
static float
|
||||
xy__s_powf (float x)
|
||||
{
|
||||
return __s_powf (x, x);
|
||||
}
|
||||
|
||||
static double
|
||||
xy__s_pow (double x)
|
||||
{
|
||||
return __s_pow (x, x);
|
||||
}
|
||||
#endif
|
||||
|
||||
static double
|
||||
xypow (double x)
|
||||
{
|
||||
return pow (x, x);
|
||||
}
|
||||
|
||||
static float
|
||||
xypowf (float x)
|
||||
{
|
||||
return powf (x, x);
|
||||
}
|
||||
|
||||
static double
|
||||
xpow (double x)
|
||||
{
|
||||
return pow (x, 23.4);
|
||||
}
|
||||
|
||||
static float
|
||||
xpowf (float x)
|
||||
{
|
||||
return powf (x, 23.4f);
|
||||
}
|
||||
|
||||
static double
|
||||
ypow (double x)
|
||||
{
|
||||
return pow (2.34, x);
|
||||
}
|
||||
|
||||
static float
|
||||
ypowf (float x)
|
||||
{
|
||||
return powf (2.34f, x);
|
||||
}
|
||||
|
||||
static float
|
||||
sincosf_wrap (float x)
|
||||
{
|
||||
float s, c;
|
||||
sincosf (x, &s, &c);
|
||||
return s + c;
|
||||
}
|
||||
#include "test/mathbench_wrappers.h"
|
||||
|
||||
static const struct fun
|
||||
{
|
||||
|
@ -228,6 +188,10 @@ static const struct fun
|
|||
#ifdef __vpcs
|
||||
__vpcs v_double (*vnd) (v_double);
|
||||
__vpcs v_float (*vnf) (v_float);
|
||||
#endif
|
||||
#if WANT_SVE_MATH
|
||||
sv_double (*svd) (sv_double, sv_bool);
|
||||
sv_float (*svf) (sv_float, sv_bool);
|
||||
#endif
|
||||
} fun;
|
||||
} funtab[] = {
|
||||
|
@ -237,106 +201,25 @@ static const struct fun
|
|||
#define VF(func, lo, hi) {#func, 'f', 'v', lo, hi, {.vf = func}},
|
||||
#define VND(func, lo, hi) {#func, 'd', 'n', lo, hi, {.vnd = func}},
|
||||
#define VNF(func, lo, hi) {#func, 'f', 'n', lo, hi, {.vnf = func}},
|
||||
#define SVD(func, lo, hi) {#func, 'd', 's', lo, hi, {.svd = func}},
|
||||
#define SVF(func, lo, hi) {#func, 'f', 's', lo, hi, {.svf = func}},
|
||||
D (dummy, 1.0, 2.0)
|
||||
D (exp, -9.9, 9.9)
|
||||
D (exp, 0.5, 1.0)
|
||||
D (exp2, -9.9, 9.9)
|
||||
D (log, 0.01, 11.1)
|
||||
D (log, 0.999, 1.001)
|
||||
D (log2, 0.01, 11.1)
|
||||
D (log2, 0.999, 1.001)
|
||||
{"pow", 'd', 0, 0.01, 11.1, {.d = xypow}},
|
||||
D (xpow, 0.01, 11.1)
|
||||
D (ypow, -9.9, 9.9)
|
||||
D (erf, -6.0, 6.0)
|
||||
|
||||
F (dummyf, 1.0, 2.0)
|
||||
F (expf, -9.9, 9.9)
|
||||
F (exp2f, -9.9, 9.9)
|
||||
F (logf, 0.01, 11.1)
|
||||
F (log2f, 0.01, 11.1)
|
||||
{"powf", 'f', 0, 0.01, 11.1, {.f = xypowf}},
|
||||
F (xpowf, 0.01, 11.1)
|
||||
F (ypowf, -9.9, 9.9)
|
||||
{"sincosf", 'f', 0, 0.1, 0.7, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 0.8, 3.1, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, -3.1, 3.1, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 3.3, 33.3, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 100, 1000, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 1e6, 1e32, {.f = sincosf_wrap}},
|
||||
F (sinf, 0.1, 0.7)
|
||||
F (sinf, 0.8, 3.1)
|
||||
F (sinf, -3.1, 3.1)
|
||||
F (sinf, 3.3, 33.3)
|
||||
F (sinf, 100, 1000)
|
||||
F (sinf, 1e6, 1e32)
|
||||
F (cosf, 0.1, 0.7)
|
||||
F (cosf, 0.8, 3.1)
|
||||
F (cosf, -3.1, 3.1)
|
||||
F (cosf, 3.3, 33.3)
|
||||
F (cosf, 100, 1000)
|
||||
F (cosf, 1e6, 1e32)
|
||||
F (erff, -4.0, 4.0)
|
||||
#if WANT_VMATH
|
||||
D (__s_sin, -3.1, 3.1)
|
||||
D (__s_cos, -3.1, 3.1)
|
||||
D (__s_exp, -9.9, 9.9)
|
||||
D (__s_log, 0.01, 11.1)
|
||||
{"__s_pow", 'd', 0, 0.01, 11.1, {.d = xy__s_pow}},
|
||||
F (__s_expf, -9.9, 9.9)
|
||||
F (__s_expf_1u, -9.9, 9.9)
|
||||
F (__s_exp2f, -9.9, 9.9)
|
||||
F (__s_exp2f_1u, -9.9, 9.9)
|
||||
F (__s_logf, 0.01, 11.1)
|
||||
{"__s_powf", 'f', 0, 0.01, 11.1, {.f = xy__s_powf}},
|
||||
F (__s_sinf, -3.1, 3.1)
|
||||
F (__s_cosf, -3.1, 3.1)
|
||||
#if __aarch64__
|
||||
VD (__v_dummy, 1.0, 2.0)
|
||||
VD (__v_sin, -3.1, 3.1)
|
||||
VD (__v_cos, -3.1, 3.1)
|
||||
VD (__v_exp, -9.9, 9.9)
|
||||
VD (__v_log, 0.01, 11.1)
|
||||
{"__v_pow", 'd', 'v', 0.01, 11.1, {.vd = xy__v_pow}},
|
||||
VF (__v_dummyf, 1.0, 2.0)
|
||||
VF (__v_expf, -9.9, 9.9)
|
||||
VF (__v_expf_1u, -9.9, 9.9)
|
||||
VF (__v_exp2f, -9.9, 9.9)
|
||||
VF (__v_exp2f_1u, -9.9, 9.9)
|
||||
VF (__v_logf, 0.01, 11.1)
|
||||
{"__v_powf", 'f', 'v', 0.01, 11.1, {.vf = xy__v_powf}},
|
||||
VF (__v_sinf, -3.1, 3.1)
|
||||
VF (__v_cosf, -3.1, 3.1)
|
||||
#ifdef __vpcs
|
||||
VND (__vn_dummy, 1.0, 2.0)
|
||||
VND (__vn_exp, -9.9, 9.9)
|
||||
VND (_ZGVnN2v_exp, -9.9, 9.9)
|
||||
VND (__vn_log, 0.01, 11.1)
|
||||
VND (_ZGVnN2v_log, 0.01, 11.1)
|
||||
{"__vn_pow", 'd', 'n', 0.01, 11.1, {.vnd = xy__vn_pow}},
|
||||
{"_ZGVnN2vv_pow", 'd', 'n', 0.01, 11.1, {.vnd = xy_Z_pow}},
|
||||
VND (__vn_sin, -3.1, 3.1)
|
||||
VND (_ZGVnN2v_sin, -3.1, 3.1)
|
||||
VND (__vn_cos, -3.1, 3.1)
|
||||
VND (_ZGVnN2v_cos, -3.1, 3.1)
|
||||
VNF (__vn_dummyf, 1.0, 2.0)
|
||||
VNF (__vn_expf, -9.9, 9.9)
|
||||
VNF (_ZGVnN4v_expf, -9.9, 9.9)
|
||||
VNF (__vn_expf_1u, -9.9, 9.9)
|
||||
VNF (__vn_exp2f, -9.9, 9.9)
|
||||
VNF (_ZGVnN4v_exp2f, -9.9, 9.9)
|
||||
VNF (__vn_exp2f_1u, -9.9, 9.9)
|
||||
VNF (__vn_logf, 0.01, 11.1)
|
||||
VNF (_ZGVnN4v_logf, 0.01, 11.1)
|
||||
{"__vn_powf", 'f', 'n', 0.01, 11.1, {.vnf = xy__vn_powf}},
|
||||
{"_ZGVnN4vv_powf", 'f', 'n', 0.01, 11.1, {.vnf = xy_Z_powf}},
|
||||
VNF (__vn_sinf, -3.1, 3.1)
|
||||
VNF (_ZGVnN4v_sinf, -3.1, 3.1)
|
||||
VNF (__vn_cosf, -3.1, 3.1)
|
||||
VNF (_ZGVnN4v_cosf, -3.1, 3.1)
|
||||
#endif
|
||||
#if WANT_SVE_MATH
|
||||
SVD (__sv_dummy, 1.0, 2.0)
|
||||
SVF (__sv_dummyf, 1.0, 2.0)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#include "test/mathbench_funcs.h"
|
||||
{0},
|
||||
#undef F
|
||||
#undef D
|
||||
|
@ -344,6 +227,8 @@ VNF (_ZGVnN4v_cosf, -3.1, 3.1)
|
|||
#undef VD
|
||||
#undef VNF
|
||||
#undef VND
|
||||
#undef SVF
|
||||
#undef SVD
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -508,6 +393,40 @@ runf_vn_latency (__vpcs v_float f (v_float))
|
|||
}
|
||||
#endif
|
||||
|
||||
#if WANT_SVE_MATH
|
||||
static void
|
||||
run_sv_thruput (sv_double f (sv_double, sv_bool))
|
||||
{
|
||||
for (int i = 0; i < N; i += sv_double_len ())
|
||||
f (sv_double_load (A+i), svptrue_b64 ());
|
||||
}
|
||||
|
||||
static void
|
||||
runf_sv_thruput (sv_float f (sv_float, sv_bool))
|
||||
{
|
||||
for (int i = 0; i < N; i += sv_float_len ())
|
||||
f (sv_float_load (Af+i), svptrue_b32 ());
|
||||
}
|
||||
|
||||
static void
|
||||
run_sv_latency (sv_double f (sv_double, sv_bool))
|
||||
{
|
||||
sv_double z = sv_double_dup (zero);
|
||||
sv_double prev = z;
|
||||
for (int i = 0; i < N; i += sv_double_len ())
|
||||
prev = f (svmad_f64_x (svptrue_b64 (), prev, z, sv_double_load (A+i)), svptrue_b64 ());
|
||||
}
|
||||
|
||||
static void
|
||||
runf_sv_latency (sv_float f (sv_float, sv_bool))
|
||||
{
|
||||
sv_float z = sv_float_dup (zero);
|
||||
sv_float prev = z;
|
||||
for (int i = 0; i < N; i += sv_float_len ())
|
||||
prev = f (svmad_f32_x (svptrue_b32 (), prev, z, sv_float_load (Af+i)), svptrue_b32 ());
|
||||
}
|
||||
#endif
|
||||
|
||||
static uint64_t
|
||||
tic (void)
|
||||
{
|
||||
|
@ -570,6 +489,16 @@ bench1 (const struct fun *f, int type, double lo, double hi)
|
|||
else if (f->prec == 'f' && type == 'l' && f->vec == 'n')
|
||||
TIMEIT (runf_vn_latency, f->fun.vnf);
|
||||
#endif
|
||||
#if WANT_SVE_MATH
|
||||
else if (f->prec == 'd' && type == 't' && f->vec == 's')
|
||||
TIMEIT (run_sv_thruput, f->fun.svd);
|
||||
else if (f->prec == 'd' && type == 'l' && f->vec == 's')
|
||||
TIMEIT (run_sv_latency, f->fun.svd);
|
||||
else if (f->prec == 'f' && type == 't' && f->vec == 's')
|
||||
TIMEIT (runf_sv_thruput, f->fun.svf);
|
||||
else if (f->prec == 'f' && type == 'l' && f->vec == 's')
|
||||
TIMEIT (runf_sv_latency, f->fun.svf);
|
||||
#endif
|
||||
|
||||
if (type == 't')
|
||||
{
|
||||
|
|
100
math/test/mathbench_funcs.h
Normal file
100
math/test/mathbench_funcs.h
Normal file
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* Function entries for mathbench.
|
||||
*
|
||||
* Copyright (c) 2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
D (exp, -9.9, 9.9)
|
||||
D (exp, 0.5, 1.0)
|
||||
D (exp2, -9.9, 9.9)
|
||||
D (log, 0.01, 11.1)
|
||||
D (log, 0.999, 1.001)
|
||||
D (log2, 0.01, 11.1)
|
||||
D (log2, 0.999, 1.001)
|
||||
{"pow", 'd', 0, 0.01, 11.1, {.d = xypow}},
|
||||
D (xpow, 0.01, 11.1)
|
||||
D (ypow, -9.9, 9.9)
|
||||
D (erf, -6.0, 6.0)
|
||||
|
||||
F (expf, -9.9, 9.9)
|
||||
F (exp2f, -9.9, 9.9)
|
||||
F (logf, 0.01, 11.1)
|
||||
F (log2f, 0.01, 11.1)
|
||||
{"powf", 'f', 0, 0.01, 11.1, {.f = xypowf}},
|
||||
F (xpowf, 0.01, 11.1)
|
||||
F (ypowf, -9.9, 9.9)
|
||||
{"sincosf", 'f', 0, 0.1, 0.7, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 0.8, 3.1, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, -3.1, 3.1, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 3.3, 33.3, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 100, 1000, {.f = sincosf_wrap}},
|
||||
{"sincosf", 'f', 0, 1e6, 1e32, {.f = sincosf_wrap}},
|
||||
F (sinf, 0.1, 0.7)
|
||||
F (sinf, 0.8, 3.1)
|
||||
F (sinf, -3.1, 3.1)
|
||||
F (sinf, 3.3, 33.3)
|
||||
F (sinf, 100, 1000)
|
||||
F (sinf, 1e6, 1e32)
|
||||
F (cosf, 0.1, 0.7)
|
||||
F (cosf, 0.8, 3.1)
|
||||
F (cosf, -3.1, 3.1)
|
||||
F (cosf, 3.3, 33.3)
|
||||
F (cosf, 100, 1000)
|
||||
F (cosf, 1e6, 1e32)
|
||||
F (erff, -4.0, 4.0)
|
||||
#if WANT_VMATH
|
||||
D (__s_sin, -3.1, 3.1)
|
||||
D (__s_cos, -3.1, 3.1)
|
||||
D (__s_exp, -9.9, 9.9)
|
||||
D (__s_log, 0.01, 11.1)
|
||||
{"__s_pow", 'd', 0, 0.01, 11.1, {.d = xy__s_pow}},
|
||||
F (__s_expf, -9.9, 9.9)
|
||||
F (__s_expf_1u, -9.9, 9.9)
|
||||
F (__s_exp2f, -9.9, 9.9)
|
||||
F (__s_exp2f_1u, -9.9, 9.9)
|
||||
F (__s_logf, 0.01, 11.1)
|
||||
{"__s_powf", 'f', 0, 0.01, 11.1, {.f = xy__s_powf}},
|
||||
F (__s_sinf, -3.1, 3.1)
|
||||
F (__s_cosf, -3.1, 3.1)
|
||||
#if __aarch64__
|
||||
VD (__v_sin, -3.1, 3.1)
|
||||
VD (__v_cos, -3.1, 3.1)
|
||||
VD (__v_exp, -9.9, 9.9)
|
||||
VD (__v_log, 0.01, 11.1)
|
||||
{"__v_pow", 'd', 'v', 0.01, 11.1, {.vd = xy__v_pow}},
|
||||
VF (__v_expf, -9.9, 9.9)
|
||||
VF (__v_expf_1u, -9.9, 9.9)
|
||||
VF (__v_exp2f, -9.9, 9.9)
|
||||
VF (__v_exp2f_1u, -9.9, 9.9)
|
||||
VF (__v_logf, 0.01, 11.1)
|
||||
{"__v_powf", 'f', 'v', 0.01, 11.1, {.vf = xy__v_powf}},
|
||||
VF (__v_sinf, -3.1, 3.1)
|
||||
VF (__v_cosf, -3.1, 3.1)
|
||||
#ifdef __vpcs
|
||||
VND (__vn_exp, -9.9, 9.9)
|
||||
VND (_ZGVnN2v_exp, -9.9, 9.9)
|
||||
VND (__vn_log, 0.01, 11.1)
|
||||
VND (_ZGVnN2v_log, 0.01, 11.1)
|
||||
{"__vn_pow", 'd', 'n', 0.01, 11.1, {.vnd = xy__vn_pow}},
|
||||
{"_ZGVnN2vv_pow", 'd', 'n', 0.01, 11.1, {.vnd = xy_Z_pow}},
|
||||
VND (__vn_sin, -3.1, 3.1)
|
||||
VND (_ZGVnN2v_sin, -3.1, 3.1)
|
||||
VND (__vn_cos, -3.1, 3.1)
|
||||
VND (_ZGVnN2v_cos, -3.1, 3.1)
|
||||
VNF (__vn_expf, -9.9, 9.9)
|
||||
VNF (_ZGVnN4v_expf, -9.9, 9.9)
|
||||
VNF (__vn_expf_1u, -9.9, 9.9)
|
||||
VNF (__vn_exp2f, -9.9, 9.9)
|
||||
VNF (_ZGVnN4v_exp2f, -9.9, 9.9)
|
||||
VNF (__vn_exp2f_1u, -9.9, 9.9)
|
||||
VNF (__vn_logf, 0.01, 11.1)
|
||||
VNF (_ZGVnN4v_logf, 0.01, 11.1)
|
||||
{"__vn_powf", 'f', 'n', 0.01, 11.1, {.vnf = xy__vn_powf}},
|
||||
{"_ZGVnN4vv_powf", 'f', 'n', 0.01, 11.1, {.vnf = xy_Z_powf}},
|
||||
VNF (__vn_sinf, -3.1, 3.1)
|
||||
VNF (_ZGVnN4v_sinf, -3.1, 3.1)
|
||||
VNF (__vn_cosf, -3.1, 3.1)
|
||||
VNF (_ZGVnN4v_cosf, -3.1, 3.1)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
104
math/test/mathbench_wrappers.h
Normal file
104
math/test/mathbench_wrappers.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* Function wrappers for mathbench.
|
||||
*
|
||||
* Copyright (c) 2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
#if WANT_VMATH
|
||||
#if __aarch64__
|
||||
|
||||
#ifdef __vpcs
|
||||
__vpcs static v_float
|
||||
xy__vn_powf (v_float x)
|
||||
{
|
||||
return __vn_powf (x, x);
|
||||
}
|
||||
|
||||
__vpcs static v_float
|
||||
xy_Z_powf (v_float x)
|
||||
{
|
||||
return _ZGVnN4vv_powf (x, x);
|
||||
}
|
||||
|
||||
__vpcs static v_double
|
||||
xy__vn_pow (v_double x)
|
||||
{
|
||||
return __vn_pow (x, x);
|
||||
}
|
||||
|
||||
__vpcs static v_double
|
||||
xy_Z_pow (v_double x)
|
||||
{
|
||||
return _ZGVnN2vv_pow (x, x);
|
||||
}
|
||||
#endif // __vpcs
|
||||
|
||||
static v_float
|
||||
xy__v_powf (v_float x)
|
||||
{
|
||||
return __v_powf (x, x);
|
||||
}
|
||||
|
||||
static v_double
|
||||
xy__v_pow (v_double x)
|
||||
{
|
||||
return __v_pow (x, x);
|
||||
}
|
||||
#endif // __aarch64__
|
||||
|
||||
static float
|
||||
xy__s_powf (float x)
|
||||
{
|
||||
return __s_powf (x, x);
|
||||
}
|
||||
|
||||
static double
|
||||
xy__s_pow (double x)
|
||||
{
|
||||
return __s_pow (x, x);
|
||||
}
|
||||
#endif // WANT_VMATH
|
||||
|
||||
static double
|
||||
xypow (double x)
|
||||
{
|
||||
return pow (x, x);
|
||||
}
|
||||
|
||||
static float
|
||||
xypowf (float x)
|
||||
{
|
||||
return powf (x, x);
|
||||
}
|
||||
|
||||
static double
|
||||
xpow (double x)
|
||||
{
|
||||
return pow (x, 23.4);
|
||||
}
|
||||
|
||||
static float
|
||||
xpowf (float x)
|
||||
{
|
||||
return powf (x, 23.4f);
|
||||
}
|
||||
|
||||
static double
|
||||
ypow (double x)
|
||||
{
|
||||
return pow (2.34, x);
|
||||
}
|
||||
|
||||
static float
|
||||
ypowf (float x)
|
||||
{
|
||||
return powf (2.34f, x);
|
||||
}
|
||||
|
||||
static float
|
||||
sincosf_wrap (float x)
|
||||
{
|
||||
float s, c;
|
||||
sincosf (x, &s, &c);
|
||||
return s + c;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* mathtest.c - test rig for mathlib
|
||||
*
|
||||
* Copyright (c) 1998-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 1998-2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -196,9 +196,11 @@ int is_complex_rettype(int rettype) {
|
|||
#define TFUNCARM(arg,ret,name,tolerance) { t_func, arg, ret, (void*)& ARM_PREFIX(name), m_none, tolerance, #name }
|
||||
#define MFUNC(arg,ret,name,tolerance) { t_macro, arg, ret, NULL, m_##name, tolerance, #name }
|
||||
|
||||
#ifndef PL
|
||||
/* sincosf wrappers for easier testing. */
|
||||
static float sincosf_sinf(float x) { float s,c; sincosf(x, &s, &c); return s; }
|
||||
static float sincosf_cosf(float x) { float s,c; sincosf(x, &s, &c); return c; }
|
||||
#endif
|
||||
|
||||
test_func tfuncs[] = {
|
||||
/* trigonometric */
|
||||
|
@ -218,9 +220,10 @@ test_func tfuncs[] = {
|
|||
TFUNCARM(at_s,rt_s, tanf, 4*ULPUNIT),
|
||||
TFUNCARM(at_s,rt_s, sinf, 3*ULPUNIT/4),
|
||||
TFUNCARM(at_s,rt_s, cosf, 3*ULPUNIT/4),
|
||||
#ifndef PL
|
||||
TFUNCARM(at_s,rt_s, sincosf_sinf, 3*ULPUNIT/4),
|
||||
TFUNCARM(at_s,rt_s, sincosf_cosf, 3*ULPUNIT/4),
|
||||
|
||||
#endif
|
||||
/* hyperbolic */
|
||||
TFUNC(at_d, rt_d, atanh, 4*ULPUNIT),
|
||||
TFUNC(at_d, rt_d, asinh, 4*ULPUNIT),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* dotest.c - actually generate mathlib test cases
|
||||
*
|
||||
* Copyright (c) 1999-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* intern.h
|
||||
*
|
||||
* Copyright (c) 1999-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef mathtest_intern_h
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* main.c
|
||||
*
|
||||
* Copyright (c) 1999-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* random.c - random number generator for producing mathlib test cases
|
||||
*
|
||||
* Copyright (c) 1998-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* random.h - header for random.c
|
||||
*
|
||||
* Copyright (c) 2009-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include "types.h"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* semi.c: test implementations of mathlib seminumerical functions
|
||||
*
|
||||
* Copyright (c) 1999-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* semi.h: header for semi.c
|
||||
*
|
||||
* Copyright (c) 1999-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef test_semi_h
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* types.h
|
||||
*
|
||||
* Copyright (c) 2005-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#ifndef mathtest_types_h
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* wrappers.c - wrappers to modify output of MPFR/MPC test functions
|
||||
*
|
||||
* Copyright (c) 2014-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* wrappers.h - wrappers to modify output of MPFR/MPC test functions
|
||||
*
|
||||
* Copyright (c) 2014-2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
# ULP error check script.
|
||||
#
|
||||
# Copyright (c) 2019-2020, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Copyright (c) 2019-2022, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#set -x
|
||||
set -eu
|
||||
|
@ -145,7 +145,7 @@ done
|
|||
# vector functions
|
||||
Ldir=0.5
|
||||
r='n'
|
||||
flags="${ULPFLAGS:--q} -f"
|
||||
flags="${ULPFLAGS:--q}"
|
||||
runs=
|
||||
check __s_exp 1 && runs=1
|
||||
runv=
|
||||
|
@ -229,7 +229,7 @@ L_sinf=1.4
|
|||
L_cosf=1.4
|
||||
L_powf=2.1
|
||||
|
||||
while read G F R
|
||||
while read G F R D
|
||||
do
|
||||
[ "$R" = 1 ] || continue
|
||||
case "$G" in \#*) continue ;; esac
|
||||
|
@ -239,7 +239,16 @@ do
|
|||
do
|
||||
[ -n "$X" ] || continue
|
||||
case "$X" in \#*) continue ;; esac
|
||||
t $F $X
|
||||
disable_fenv=""
|
||||
if [ -z "$WANT_SIMD_EXCEPT" ] || [ $WANT_SIMD_EXCEPT -eq 0 ]; then
|
||||
# If library was built with SIMD exceptions
|
||||
# disabled, disable fenv checking in ulp
|
||||
# tool. Otherwise, fenv checking may still be
|
||||
# disabled by adding -f to the end of the run
|
||||
# line.
|
||||
disable_fenv="-f"
|
||||
fi
|
||||
t $D $disable_fenv $F $X
|
||||
done << EOF
|
||||
$range
|
||||
EOF
|
||||
|
@ -255,10 +264,10 @@ log __v_log $runv
|
|||
log __vn_log $runvn
|
||||
log _ZGVnN2v_log $runvn
|
||||
|
||||
pow __s_pow $runs
|
||||
pow __v_pow $runv
|
||||
pow __vn_pow $runvn
|
||||
pow _ZGVnN2vv_pow $runvn
|
||||
pow __s_pow $runs -f
|
||||
pow __v_pow $runv -f
|
||||
pow __vn_pow $runvn -f
|
||||
pow _ZGVnN2vv_pow $runvn -f
|
||||
|
||||
sin __s_sin $runs
|
||||
sin __v_sin $runv
|
||||
|
@ -275,18 +284,18 @@ expf __v_expf $runv
|
|||
expf __vn_expf $runvn
|
||||
expf _ZGVnN4v_expf $runvn
|
||||
|
||||
expf_1u __s_expf_1u $runs
|
||||
expf_1u __v_expf_1u $runv
|
||||
expf_1u __vn_expf_1u $runvn
|
||||
expf_1u __s_expf_1u $runs -f
|
||||
expf_1u __v_expf_1u $runv -f
|
||||
expf_1u __vn_expf_1u $runvn -f
|
||||
|
||||
exp2f __s_exp2f $runs
|
||||
exp2f __v_exp2f $runv
|
||||
exp2f __vn_exp2f $runvn
|
||||
exp2f _ZGVnN4v_exp2f $runvn
|
||||
|
||||
exp2f_1u __s_exp2f_1u $runs
|
||||
exp2f_1u __v_exp2f_1u $runv
|
||||
exp2f_1u __vn_exp2f_1u $runvn
|
||||
exp2f_1u __s_exp2f_1u $runs -f
|
||||
exp2f_1u __v_exp2f_1u $runv -f
|
||||
exp2f_1u __vn_exp2f_1u $runvn -f
|
||||
|
||||
logf __s_logf $runs
|
||||
logf __v_logf $runv
|
||||
|
@ -303,10 +312,10 @@ cosf __v_cosf $runv
|
|||
cosf __vn_cosf $runvn
|
||||
cosf _ZGVnN4v_cosf $runvn
|
||||
|
||||
powf __s_powf $runs
|
||||
powf __v_powf $runv
|
||||
powf __vn_powf $runvn
|
||||
powf _ZGVnN4vv_powf $runvn
|
||||
powf __s_powf $runs -f
|
||||
powf __v_powf $runv -f
|
||||
powf __vn_powf $runvn -f
|
||||
powf _ZGVnN4vv_powf $runvn -f
|
||||
EOF
|
||||
|
||||
[ 0 -eq $FAIL ] || {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; cosf.tst - Directed test cases for SP cosine
|
||||
;
|
||||
; Copyright (c) 2007-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=cosf op1=7fc00001 result=7fc00001 errno=0
|
||||
func=cosf op1=ffc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; erf.tst - Directed test cases for erf
|
||||
;
|
||||
; Copyright (c) 2007-2020, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=erf op1=7ff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
func=erf op1=fff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; erff.tst
|
||||
;
|
||||
; Copyright (c) 2007-2020, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=erff op1=7fc00001 result=7fc00001 errno=0
|
||||
func=erff op1=ffc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Directed test cases for exp
|
||||
;
|
||||
; Copyright (c) 2018-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=exp op1=7ff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
func=exp op1=fff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Directed test cases for exp2
|
||||
;
|
||||
; Copyright (c) 2018-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=exp2 op1=7ff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
func=exp2 op1=fff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; exp2f.tst - Directed test cases for exp2f
|
||||
;
|
||||
; Copyright (c) 2017-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=exp2f op1=7fc00001 result=7fc00001 errno=0
|
||||
func=exp2f op1=ffc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; expf.tst - Directed test cases for expf
|
||||
;
|
||||
; Copyright (c) 2007-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=expf op1=7fc00001 result=7fc00001 errno=0
|
||||
func=expf op1=ffc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Directed test cases for log
|
||||
;
|
||||
; Copyright (c) 2018-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=log op1=7ff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
func=log op1=fff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Directed test cases for log2
|
||||
;
|
||||
; Copyright (c) 2018-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=log2 op1=7ff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
func=log2 op1=fff80000.00000001 result=7ff80000.00000001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; log2f.tst - Directed test cases for log2f
|
||||
;
|
||||
; Copyright (c) 2017-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=log2f op1=7fc00001 result=7fc00001 errno=0
|
||||
func=log2f op1=ffc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; logf.tst - Directed test cases for logf
|
||||
;
|
||||
; Copyright (c) 2007-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=logf op1=7fc00001 result=7fc00001 errno=0
|
||||
func=logf op1=ffc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Directed test cases for pow
|
||||
;
|
||||
; Copyright (c) 2018-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=pow op1=00000000.00000000 op2=00000000.00000000 result=3ff00000.00000000 errno=0
|
||||
func=pow op1=00000000.00000000 op2=00000000.00000001 result=00000000.00000000 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; powf.tst - Directed test cases for powf
|
||||
;
|
||||
; Copyright (c) 2007-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
func=powf op1=7f800001 op2=7f800001 result=7fc00001 errno=0 status=i
|
||||
func=powf op1=7f800001 op2=ff800001 result=7fc00001 errno=0 status=i
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; Directed test cases for SP sincos
|
||||
;
|
||||
; Copyright (c) 2007-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
|
||||
func=sincosf_sinf op1=7fc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; sinf.tst - Directed test cases for SP sine
|
||||
;
|
||||
; Copyright (c) 2007-2019, Arm Limited.
|
||||
; SPDX-License-Identifier: MIT
|
||||
; SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
|
||||
func=sinf op1=7fc00001 result=7fc00001 errno=0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
!! double.tst - Random test case specification for DP functions
|
||||
!!
|
||||
!! Copyright (c) 1999-2019, Arm Limited.
|
||||
!! SPDX-License-Identifier: MIT
|
||||
!! SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
test exp 10000
|
||||
test exp2 10000
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
!! single.tst - Random test case specification for SP functions
|
||||
!!
|
||||
!! Copyright (c) 1999-2019, Arm Limited.
|
||||
!! SPDX-License-Identifier: MIT
|
||||
!! SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
test sinf 10000
|
||||
test cosf 10000
|
||||
|
|
248
math/test/ulp.c
248
math/test/ulp.c
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* ULP error checking tool for math functions.
|
||||
*
|
||||
* Copyright (c) 2019-2020, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* Copyright (c) 2019-2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -214,16 +214,6 @@ struct conf
|
|||
double errlim;
|
||||
};
|
||||
|
||||
/* Wrappers for sincos. */
|
||||
static float sincosf_sinf(float x) {(void)cosf(x); return sinf(x);}
|
||||
static float sincosf_cosf(float x) {(void)sinf(x); return cosf(x);}
|
||||
static double sincos_sin(double x) {(void)cos(x); return sin(x);}
|
||||
static double sincos_cos(double x) {(void)sin(x); return cos(x);}
|
||||
#if USE_MPFR
|
||||
static int sincos_mpfr_sin(mpfr_t y, const mpfr_t x, mpfr_rnd_t r) { mpfr_cos(y,x,r); return mpfr_sin(y,x,r); }
|
||||
static int sincos_mpfr_cos(mpfr_t y, const mpfr_t x, mpfr_rnd_t r) { mpfr_sin(y,x,r); return mpfr_cos(y,x,r); }
|
||||
#endif
|
||||
|
||||
/* A bit of a hack: call vector functions twice with the same
|
||||
input in lane 0 but a different value in other lanes: once
|
||||
with an in-range value and then with a special case value. */
|
||||
|
@ -233,52 +223,81 @@ static int secondcall;
|
|||
#if __aarch64__ && WANT_VMATH
|
||||
typedef __f32x4_t v_float;
|
||||
typedef __f64x2_t v_double;
|
||||
static const float fv[2] = {1.0f, -INFINITY};
|
||||
static const double dv[2] = {1.0, -INFINITY};
|
||||
/* First element of fv and dv may be changed by -c argument. */
|
||||
static float fv[2] = {1.0f, -INFINITY};
|
||||
static double dv[2] = {1.0, -INFINITY};
|
||||
static inline v_float argf(float x) { return (v_float){x,x,x,fv[secondcall]}; }
|
||||
static inline v_double argd(double x) { return (v_double){x,dv[secondcall]}; }
|
||||
#if WANT_SVE_MATH
|
||||
#include <arm_sve.h>
|
||||
typedef __SVFloat32_t sv_float;
|
||||
typedef __SVFloat64_t sv_double;
|
||||
|
||||
static float v_sinf(float x) { return __v_sinf(argf(x))[0]; }
|
||||
static float v_cosf(float x) { return __v_cosf(argf(x))[0]; }
|
||||
static float v_expf_1u(float x) { return __v_expf_1u(argf(x))[0]; }
|
||||
static float v_expf(float x) { return __v_expf(argf(x))[0]; }
|
||||
static float v_exp2f_1u(float x) { return __v_exp2f_1u(argf(x))[0]; }
|
||||
static float v_exp2f(float x) { return __v_exp2f(argf(x))[0]; }
|
||||
static float v_logf(float x) { return __v_logf(argf(x))[0]; }
|
||||
static float v_powf(float x, float y) { return __v_powf(argf(x),argf(y))[0]; }
|
||||
static double v_sin(double x) { return __v_sin(argd(x))[0]; }
|
||||
static double v_cos(double x) { return __v_cos(argd(x))[0]; }
|
||||
static double v_exp(double x) { return __v_exp(argd(x))[0]; }
|
||||
static double v_log(double x) { return __v_log(argd(x))[0]; }
|
||||
static double v_pow(double x, double y) { return __v_pow(argd(x),argd(y))[0]; }
|
||||
#ifdef __vpcs
|
||||
static float vn_sinf(float x) { return __vn_sinf(argf(x))[0]; }
|
||||
static float vn_cosf(float x) { return __vn_cosf(argf(x))[0]; }
|
||||
static float vn_expf_1u(float x) { return __vn_expf_1u(argf(x))[0]; }
|
||||
static float vn_expf(float x) { return __vn_expf(argf(x))[0]; }
|
||||
static float vn_exp2f_1u(float x) { return __vn_exp2f_1u(argf(x))[0]; }
|
||||
static float vn_exp2f(float x) { return __vn_exp2f(argf(x))[0]; }
|
||||
static float vn_logf(float x) { return __vn_logf(argf(x))[0]; }
|
||||
static float vn_powf(float x, float y) { return __vn_powf(argf(x),argf(y))[0]; }
|
||||
static double vn_sin(double x) { return __vn_sin(argd(x))[0]; }
|
||||
static double vn_cos(double x) { return __vn_cos(argd(x))[0]; }
|
||||
static double vn_exp(double x) { return __vn_exp(argd(x))[0]; }
|
||||
static double vn_log(double x) { return __vn_log(argd(x))[0]; }
|
||||
static double vn_pow(double x, double y) { return __vn_pow(argd(x),argd(y))[0]; }
|
||||
static float Z_sinf(float x) { return _ZGVnN4v_sinf(argf(x))[0]; }
|
||||
static float Z_cosf(float x) { return _ZGVnN4v_cosf(argf(x))[0]; }
|
||||
static float Z_expf(float x) { return _ZGVnN4v_expf(argf(x))[0]; }
|
||||
static float Z_exp2f(float x) { return _ZGVnN4v_exp2f(argf(x))[0]; }
|
||||
static float Z_logf(float x) { return _ZGVnN4v_logf(argf(x))[0]; }
|
||||
static float Z_powf(float x, float y) { return _ZGVnN4vv_powf(argf(x),argf(y))[0]; }
|
||||
static double Z_sin(double x) { return _ZGVnN2v_sin(argd(x))[0]; }
|
||||
static double Z_cos(double x) { return _ZGVnN2v_cos(argd(x))[0]; }
|
||||
static double Z_exp(double x) { return _ZGVnN2v_exp(argd(x))[0]; }
|
||||
static double Z_log(double x) { return _ZGVnN2v_log(argd(x))[0]; }
|
||||
static double Z_pow(double x, double y) { return _ZGVnN2vv_pow(argd(x),argd(y))[0]; }
|
||||
static inline sv_float svargf(float x) {
|
||||
int n = svcntw();
|
||||
float base[n];
|
||||
for (int i=0; i<n; i++)
|
||||
base[i] = (float)x;
|
||||
base[n-1] = (float) fv[secondcall];
|
||||
return svld1(svptrue_b32(), base);
|
||||
}
|
||||
static inline sv_double svargd(double x) {
|
||||
int n = svcntd();
|
||||
double base[n];
|
||||
for (int i=0; i<n; i++)
|
||||
base[i] = x;
|
||||
base[n-1] = dv[secondcall];
|
||||
return svld1(svptrue_b64(), base);
|
||||
}
|
||||
static inline float svretf(sv_float vec) {
|
||||
int n = svcntw();
|
||||
float res[n];
|
||||
svst1(svptrue_b32(), res, vec);
|
||||
return res[0];
|
||||
}
|
||||
static inline double svretd(sv_double vec) {
|
||||
int n = svcntd();
|
||||
double res[n];
|
||||
svst1(svptrue_b64(), res, vec);
|
||||
return res[0];
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if WANT_SVE_MATH
|
||||
long double
|
||||
dummyl (long double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
double
|
||||
dummy (double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
static sv_double
|
||||
__sv_dummy (sv_double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
static sv_float
|
||||
__sv_dummyf (sv_float x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "test/ulp_wrappers.h"
|
||||
|
||||
/* Wrappers for SVE functions. */
|
||||
#if WANT_SVE_MATH
|
||||
static double sv_dummy (double x) { return svretd (__sv_dummy (svargd (x))); }
|
||||
static float sv_dummyf (float x) { return svretf (__sv_dummyf (svargf (x))); }
|
||||
#endif
|
||||
|
||||
struct fun
|
||||
{
|
||||
const char *name;
|
||||
|
@ -322,83 +341,53 @@ static const struct fun fun[] = {
|
|||
#define F2(x) F (x##f, x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define D1(x) F (x, x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define D2(x) F (x, x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
F1 (sin)
|
||||
F1 (cos)
|
||||
F (sincosf_sinf, sincosf_sinf, sincos_sin, sincos_mpfr_sin, 1, 1, f1, 0)
|
||||
F (sincosf_cosf, sincosf_cosf, sincos_cos, sincos_mpfr_cos, 1, 1, f1, 0)
|
||||
F1 (exp)
|
||||
F1 (exp2)
|
||||
F1 (log)
|
||||
F1 (log2)
|
||||
F2 (pow)
|
||||
F1 (erf)
|
||||
D1 (exp)
|
||||
D1 (exp2)
|
||||
D1 (log)
|
||||
D1 (log2)
|
||||
D2 (pow)
|
||||
D1 (erf)
|
||||
#if WANT_VMATH
|
||||
F (__s_sinf, __s_sinf, sin, mpfr_sin, 1, 1, f1, 0)
|
||||
F (__s_cosf, __s_cosf, cos, mpfr_cos, 1, 1, f1, 0)
|
||||
F (__s_expf_1u, __s_expf_1u, exp, mpfr_exp, 1, 1, f1, 0)
|
||||
F (__s_expf, __s_expf, exp, mpfr_exp, 1, 1, f1, 0)
|
||||
F (__s_exp2f_1u, __s_exp2f_1u, exp2, mpfr_exp2, 1, 1, f1, 0)
|
||||
F (__s_exp2f, __s_exp2f, exp2, mpfr_exp2, 1, 1, f1, 0)
|
||||
F (__s_powf, __s_powf, pow, mpfr_pow, 2, 1, f2, 0)
|
||||
F (__s_logf, __s_logf, log, mpfr_log, 1, 1, f1, 0)
|
||||
F (__s_sin, __s_sin, sinl, mpfr_sin, 1, 0, d1, 0)
|
||||
F (__s_cos, __s_cos, cosl, mpfr_cos, 1, 0, d1, 0)
|
||||
F (__s_exp, __s_exp, expl, mpfr_exp, 1, 0, d1, 0)
|
||||
F (__s_log, __s_log, logl, mpfr_log, 1, 0, d1, 0)
|
||||
F (__s_pow, __s_pow, powl, mpfr_pow, 2, 0, d2, 0)
|
||||
#if __aarch64__
|
||||
F (__v_sinf, v_sinf, sin, mpfr_sin, 1, 1, f1, 1)
|
||||
F (__v_cosf, v_cosf, cos, mpfr_cos, 1, 1, f1, 1)
|
||||
F (__v_expf_1u, v_expf_1u, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__v_expf, v_expf, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__v_exp2f_1u, v_exp2f_1u, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__v_exp2f, v_exp2f, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__v_logf, v_logf, log, mpfr_log, 1, 1, f1, 1)
|
||||
F (__v_powf, v_powf, pow, mpfr_pow, 2, 1, f2, 1)
|
||||
F (__v_sin, v_sin, sinl, mpfr_sin, 1, 0, d1, 1)
|
||||
F (__v_cos, v_cos, cosl, mpfr_cos, 1, 0, d1, 1)
|
||||
F (__v_exp, v_exp, expl, mpfr_exp, 1, 0, d1, 1)
|
||||
F (__v_log, v_log, logl, mpfr_log, 1, 0, d1, 1)
|
||||
F (__v_pow, v_pow, powl, mpfr_pow, 2, 0, d2, 1)
|
||||
#ifdef __vpcs
|
||||
F (__vn_sinf, vn_sinf, sin, mpfr_sin, 1, 1, f1, 1)
|
||||
F (__vn_cosf, vn_cosf, cos, mpfr_cos, 1, 1, f1, 1)
|
||||
F (__vn_expf_1u, vn_expf_1u, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__vn_expf, vn_expf, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__vn_exp2f_1u, vn_exp2f_1u, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__vn_exp2f, vn_exp2f, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__vn_logf, vn_logf, log, mpfr_log, 1, 1, f1, 1)
|
||||
F (__vn_powf, vn_powf, pow, mpfr_pow, 2, 1, f2, 1)
|
||||
F (__vn_sin, vn_sin, sinl, mpfr_sin, 1, 0, d1, 1)
|
||||
F (__vn_cos, vn_cos, cosl, mpfr_cos, 1, 0, d1, 1)
|
||||
F (__vn_exp, vn_exp, expl, mpfr_exp, 1, 0, d1, 1)
|
||||
F (__vn_log, vn_log, logl, mpfr_log, 1, 0, d1, 1)
|
||||
F (__vn_pow, vn_pow, powl, mpfr_pow, 2, 0, d2, 1)
|
||||
F (_ZGVnN4v_sinf, Z_sinf, sin, mpfr_sin, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_cosf, Z_cosf, cos, mpfr_cos, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_expf, Z_expf, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_exp2f, Z_exp2f, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_logf, Z_logf, log, mpfr_log, 1, 1, f1, 1)
|
||||
F (_ZGVnN4vv_powf, Z_powf, pow, mpfr_pow, 2, 1, f2, 1)
|
||||
F (_ZGVnN2v_sin, Z_sin, sinl, mpfr_sin, 1, 0, d1, 1)
|
||||
F (_ZGVnN2v_cos, Z_cos, cosl, mpfr_cos, 1, 0, d1, 1)
|
||||
F (_ZGVnN2v_exp, Z_exp, expl, mpfr_exp, 1, 0, d1, 1)
|
||||
F (_ZGVnN2v_log, Z_log, logl, mpfr_log, 1, 0, d1, 1)
|
||||
F (_ZGVnN2vv_pow, Z_pow, powl, mpfr_pow, 2, 0, d2, 1)
|
||||
#endif
|
||||
#endif
|
||||
/* Neon routines. */
|
||||
#define VF1(x) F (__v_##x##f, v_##x##f, x, mpfr_##x, 1, 1, f1, 0)
|
||||
#define VF2(x) F (__v_##x##f, v_##x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define VD1(x) F (__v_##x, v_##x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define VD2(x) F (__v_##x, v_##x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
#define VNF1(x) F (__vn_##x##f, vn_##x##f, x, mpfr_##x, 1, 1, f1, 0)
|
||||
#define VNF2(x) F (__vn_##x##f, vn_##x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define VND1(x) F (__vn_##x, vn_##x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define VND2(x) F (__vn_##x, vn_##x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
#define ZVF1(x) F (_ZGVnN4v_##x##f, Z_##x##f, x, mpfr_##x, 1, 1, f1, 0)
|
||||
#define ZVF2(x) F (_ZGVnN4vv_##x##f, Z_##x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define ZVD1(x) F (_ZGVnN2v_##x, Z_##x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define ZVD2(x) F (_ZGVnN2vv_##x, Z_##x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
#define ZVNF1(x) VNF1 (x) ZVF1 (x)
|
||||
#define ZVNF2(x) VNF2 (x) ZVF2 (x)
|
||||
#define ZVND1(x) VND1 (x) ZVD1 (x)
|
||||
#define ZVND2(x) VND2 (x) ZVD2 (x)
|
||||
#define SF1(x) F (__s_##x##f, __s_##x##f, x, mpfr_##x, 1, 1, f1, 0)
|
||||
#define SF2(x) F (__s_##x##f, __s_##x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define SD1(x) F (__s_##x, __s_##x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define SD2(x) F (__s_##x, __s_##x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
/* SVE routines. */
|
||||
#define SVF1(x) F (__sv_##x##f, sv_##x##f, x, mpfr_##x, 1, 1, f1, 0)
|
||||
#define SVF2(x) F (__sv_##x##f, sv_##x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define SVD1(x) F (__sv_##x, sv_##x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define SVD2(x) F (__sv_##x, sv_##x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
#define ZSVF1(x) F (_ZGVsMxv_##x##f, Z_sv_##x##f, x, mpfr_##x, 1, 1, f1, 0)
|
||||
#define ZSVF2(x) F (_ZGVsMxvv_##x##f, Z_sv_##x##f, x, mpfr_##x, 2, 1, f2, 0)
|
||||
#define ZSVD1(x) F (_ZGVsMxv_##x, Z_sv_##x, x##l, mpfr_##x, 1, 0, d1, 0)
|
||||
#define ZSVD2(x) F (_ZGVsMxvv_##x, Z_sv_##x, x##l, mpfr_##x, 2, 0, d2, 0)
|
||||
|
||||
#include "test/ulp_funcs.h"
|
||||
|
||||
#if WANT_SVE_MATH
|
||||
SVD1 (dummy)
|
||||
SVF1 (dummy)
|
||||
#endif
|
||||
|
||||
#undef F
|
||||
#undef F1
|
||||
#undef F2
|
||||
#undef D1
|
||||
#undef D2
|
||||
#undef SVF1
|
||||
#undef SVF2
|
||||
#undef SVD1
|
||||
#undef SVD2
|
||||
{0}};
|
||||
|
||||
/* Boilerplate for generic calls. */
|
||||
|
@ -645,6 +634,11 @@ usage (void)
|
|||
puts ("-q: quiet.");
|
||||
puts ("-m: use mpfr even if faster method is available.");
|
||||
puts ("-f: disable fenv testing (rounding modes and exceptions).");
|
||||
#if __aarch64__ && WANT_VMATH
|
||||
puts ("-c: neutral 'control value' to test behaviour when one lane can affect another. \n"
|
||||
" This should be different from tested input in other lanes, and non-special \n"
|
||||
" (i.e. should not trigger fenv exceptions). Default is 1.");
|
||||
#endif
|
||||
puts ("Supported func:");
|
||||
for (const struct fun *f = fun; f->name; f++)
|
||||
printf ("\t%s\n", f->name);
|
||||
|
@ -812,6 +806,14 @@ main (int argc, char *argv[])
|
|||
conf.rc = argv[0][0];
|
||||
}
|
||||
break;
|
||||
#if __aarch64__ && WANT_VMATH
|
||||
case 'c':
|
||||
argc--;
|
||||
argv++;
|
||||
fv[0] = strtof(argv[0], 0);
|
||||
dv[0] = strtod(argv[0], 0);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
usage ();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Generic functions for ULP error estimation.
|
||||
*
|
||||
* Copyright (c) 2019, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
/* For each different math function type,
|
||||
|
|
78
math/test/ulp_funcs.h
Normal file
78
math/test/ulp_funcs.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Function entries for ulp.
|
||||
*
|
||||
* Copyright (c) 2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
F1 (sin)
|
||||
F1 (cos)
|
||||
F (sincosf_sinf, sincosf_sinf, sincos_sin, sincos_mpfr_sin, 1, 1, f1, 0)
|
||||
F (sincosf_cosf, sincosf_cosf, sincos_cos, sincos_mpfr_cos, 1, 1, f1, 0)
|
||||
F1 (exp)
|
||||
F1 (exp2)
|
||||
F1 (log)
|
||||
F1 (log2)
|
||||
F2 (pow)
|
||||
F1 (erf)
|
||||
D1 (exp)
|
||||
D1 (exp2)
|
||||
D1 (log)
|
||||
D1 (log2)
|
||||
D2 (pow)
|
||||
D1 (erf)
|
||||
#if WANT_VMATH
|
||||
F (__s_sinf, __s_sinf, sin, mpfr_sin, 1, 1, f1, 0)
|
||||
F (__s_cosf, __s_cosf, cos, mpfr_cos, 1, 1, f1, 0)
|
||||
F (__s_expf_1u, __s_expf_1u, exp, mpfr_exp, 1, 1, f1, 0)
|
||||
F (__s_expf, __s_expf, exp, mpfr_exp, 1, 1, f1, 0)
|
||||
F (__s_exp2f_1u, __s_exp2f_1u, exp2, mpfr_exp2, 1, 1, f1, 0)
|
||||
F (__s_exp2f, __s_exp2f, exp2, mpfr_exp2, 1, 1, f1, 0)
|
||||
F (__s_powf, __s_powf, pow, mpfr_pow, 2, 1, f2, 0)
|
||||
F (__s_logf, __s_logf, log, mpfr_log, 1, 1, f1, 0)
|
||||
F (__s_sin, __s_sin, sinl, mpfr_sin, 1, 0, d1, 0)
|
||||
F (__s_cos, __s_cos, cosl, mpfr_cos, 1, 0, d1, 0)
|
||||
F (__s_exp, __s_exp, expl, mpfr_exp, 1, 0, d1, 0)
|
||||
F (__s_log, __s_log, logl, mpfr_log, 1, 0, d1, 0)
|
||||
F (__s_pow, __s_pow, powl, mpfr_pow, 2, 0, d2, 0)
|
||||
#if __aarch64__
|
||||
F (__v_sinf, v_sinf, sin, mpfr_sin, 1, 1, f1, 1)
|
||||
F (__v_cosf, v_cosf, cos, mpfr_cos, 1, 1, f1, 1)
|
||||
F (__v_expf_1u, v_expf_1u, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__v_expf, v_expf, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__v_exp2f_1u, v_exp2f_1u, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__v_exp2f, v_exp2f, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__v_logf, v_logf, log, mpfr_log, 1, 1, f1, 1)
|
||||
F (__v_powf, v_powf, pow, mpfr_pow, 2, 1, f2, 1)
|
||||
F (__v_sin, v_sin, sinl, mpfr_sin, 1, 0, d1, 1)
|
||||
F (__v_cos, v_cos, cosl, mpfr_cos, 1, 0, d1, 1)
|
||||
F (__v_exp, v_exp, expl, mpfr_exp, 1, 0, d1, 1)
|
||||
F (__v_log, v_log, logl, mpfr_log, 1, 0, d1, 1)
|
||||
F (__v_pow, v_pow, powl, mpfr_pow, 2, 0, d2, 1)
|
||||
#ifdef __vpcs
|
||||
F (__vn_sinf, vn_sinf, sin, mpfr_sin, 1, 1, f1, 1)
|
||||
F (__vn_cosf, vn_cosf, cos, mpfr_cos, 1, 1, f1, 1)
|
||||
F (__vn_expf_1u, vn_expf_1u, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__vn_expf, vn_expf, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (__vn_exp2f_1u, vn_exp2f_1u, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__vn_exp2f, vn_exp2f, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (__vn_logf, vn_logf, log, mpfr_log, 1, 1, f1, 1)
|
||||
F (__vn_powf, vn_powf, pow, mpfr_pow, 2, 1, f2, 1)
|
||||
F (__vn_sin, vn_sin, sinl, mpfr_sin, 1, 0, d1, 1)
|
||||
F (__vn_cos, vn_cos, cosl, mpfr_cos, 1, 0, d1, 1)
|
||||
F (__vn_exp, vn_exp, expl, mpfr_exp, 1, 0, d1, 1)
|
||||
F (__vn_log, vn_log, logl, mpfr_log, 1, 0, d1, 1)
|
||||
F (__vn_pow, vn_pow, powl, mpfr_pow, 2, 0, d2, 1)
|
||||
F (_ZGVnN4v_sinf, Z_sinf, sin, mpfr_sin, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_cosf, Z_cosf, cos, mpfr_cos, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_expf, Z_expf, exp, mpfr_exp, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_exp2f, Z_exp2f, exp2, mpfr_exp2, 1, 1, f1, 1)
|
||||
F (_ZGVnN4v_logf, Z_logf, log, mpfr_log, 1, 1, f1, 1)
|
||||
F (_ZGVnN4vv_powf, Z_powf, pow, mpfr_pow, 2, 1, f2, 1)
|
||||
F (_ZGVnN2v_sin, Z_sin, sinl, mpfr_sin, 1, 0, d1, 1)
|
||||
F (_ZGVnN2v_cos, Z_cos, cosl, mpfr_cos, 1, 0, d1, 1)
|
||||
F (_ZGVnN2v_exp, Z_exp, expl, mpfr_exp, 1, 0, d1, 1)
|
||||
F (_ZGVnN2v_log, Z_log, logl, mpfr_log, 1, 0, d1, 1)
|
||||
F (_ZGVnN2vv_pow, Z_pow, powl, mpfr_pow, 2, 0, d2, 1)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
59
math/test/ulp_wrappers.h
Normal file
59
math/test/ulp_wrappers.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Function wrappers for ulp.
|
||||
*
|
||||
* Copyright (c) 2022, Arm Limited.
|
||||
* SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
/* Wrappers for sincos. */
|
||||
static float sincosf_sinf(float x) {(void)cosf(x); return sinf(x);}
|
||||
static float sincosf_cosf(float x) {(void)sinf(x); return cosf(x);}
|
||||
static double sincos_sin(double x) {(void)cos(x); return sin(x);}
|
||||
static double sincos_cos(double x) {(void)sin(x); return cos(x);}
|
||||
#if USE_MPFR
|
||||
static int sincos_mpfr_sin(mpfr_t y, const mpfr_t x, mpfr_rnd_t r) { mpfr_cos(y,x,r); return mpfr_sin(y,x,r); }
|
||||
static int sincos_mpfr_cos(mpfr_t y, const mpfr_t x, mpfr_rnd_t r) { mpfr_sin(y,x,r); return mpfr_cos(y,x,r); }
|
||||
#endif
|
||||
|
||||
/* Wrappers for vector functions. */
|
||||
#if __aarch64__ && WANT_VMATH
|
||||
static float v_sinf(float x) { return __v_sinf(argf(x))[0]; }
|
||||
static float v_cosf(float x) { return __v_cosf(argf(x))[0]; }
|
||||
static float v_expf_1u(float x) { return __v_expf_1u(argf(x))[0]; }
|
||||
static float v_expf(float x) { return __v_expf(argf(x))[0]; }
|
||||
static float v_exp2f_1u(float x) { return __v_exp2f_1u(argf(x))[0]; }
|
||||
static float v_exp2f(float x) { return __v_exp2f(argf(x))[0]; }
|
||||
static float v_logf(float x) { return __v_logf(argf(x))[0]; }
|
||||
static float v_powf(float x, float y) { return __v_powf(argf(x),argf(y))[0]; }
|
||||
static double v_sin(double x) { return __v_sin(argd(x))[0]; }
|
||||
static double v_cos(double x) { return __v_cos(argd(x))[0]; }
|
||||
static double v_exp(double x) { return __v_exp(argd(x))[0]; }
|
||||
static double v_log(double x) { return __v_log(argd(x))[0]; }
|
||||
static double v_pow(double x, double y) { return __v_pow(argd(x),argd(y))[0]; }
|
||||
#ifdef __vpcs
|
||||
static float vn_sinf(float x) { return __vn_sinf(argf(x))[0]; }
|
||||
static float vn_cosf(float x) { return __vn_cosf(argf(x))[0]; }
|
||||
static float vn_expf_1u(float x) { return __vn_expf_1u(argf(x))[0]; }
|
||||
static float vn_expf(float x) { return __vn_expf(argf(x))[0]; }
|
||||
static float vn_exp2f_1u(float x) { return __vn_exp2f_1u(argf(x))[0]; }
|
||||
static float vn_exp2f(float x) { return __vn_exp2f(argf(x))[0]; }
|
||||
static float vn_logf(float x) { return __vn_logf(argf(x))[0]; }
|
||||
static float vn_powf(float x, float y) { return __vn_powf(argf(x),argf(y))[0]; }
|
||||
static double vn_sin(double x) { return __vn_sin(argd(x))[0]; }
|
||||
static double vn_cos(double x) { return __vn_cos(argd(x))[0]; }
|
||||
static double vn_exp(double x) { return __vn_exp(argd(x))[0]; }
|
||||
static double vn_log(double x) { return __vn_log(argd(x))[0]; }
|
||||
static double vn_pow(double x, double y) { return __vn_pow(argd(x),argd(y))[0]; }
|
||||
static float Z_sinf(float x) { return _ZGVnN4v_sinf(argf(x))[0]; }
|
||||
static float Z_cosf(float x) { return _ZGVnN4v_cosf(argf(x))[0]; }
|
||||
static float Z_expf(float x) { return _ZGVnN4v_expf(argf(x))[0]; }
|
||||
static float Z_exp2f(float x) { return _ZGVnN4v_exp2f(argf(x))[0]; }
|
||||
static float Z_logf(float x) { return _ZGVnN4v_logf(argf(x))[0]; }
|
||||
static float Z_powf(float x, float y) { return _ZGVnN4vv_powf(argf(x),argf(y))[0]; }
|
||||
static double Z_sin(double x) { return _ZGVnN2v_sin(argd(x))[0]; }
|
||||
static double Z_cos(double x) { return _ZGVnN2v_cos(argd(x))[0]; }
|
||||
static double Z_exp(double x) { return _ZGVnN2v_exp(argd(x))[0]; }
|
||||
static double Z_log(double x) { return _ZGVnN2v_log(argd(x))[0]; }
|
||||
static double Z_pow(double x, double y) { return _ZGVnN2vv_pow(argd(x),argd(y))[0]; }
|
||||
#endif
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating cos(x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 8; // polynomial degree
|
||||
a = -pi/4; // interval
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating e^x
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 5; // poly degree
|
||||
N = 128; // table entries
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating 2^x
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
// exp2f parameters
|
||||
deg = 3; // poly degree
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating log(1+x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 12; // poly degree
|
||||
// |log(1+x)| > 0x1p-4 outside the interval
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating log2(1+x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 11; // poly degree
|
||||
// |log2(1+x)| > 0x1p-4 outside the interval
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating log2(1+x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 7; // poly degree
|
||||
// interval ~= 1/(2*N), where N is the table entries
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating log(1+x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 6; // poly degree
|
||||
// interval ~= 1/(2*N), where N is the table entries
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# ULP error plot tool.
|
||||
#
|
||||
# Copyright (c) 2019, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT
|
||||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# remez.jl - implementation of the Remez algorithm for polynomial approximation
|
||||
#
|
||||
# Copyright (c) 2015-2019, Arm Limited.
|
||||
# SPDX-License-Identifier: MIT
|
||||
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
import Base.\
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating sin(x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 7; // polynomial degree
|
||||
a = -pi/4; // interval
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial for approximating e^x
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 4; // poly degree
|
||||
N = 128; // table entries
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// polynomial used for __v_log(x)
|
||||
//
|
||||
// Copyright (c) 2019, Arm Limited.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
|
||||
|
||||
deg = 6; // poly degree
|
||||
a = -0x1.fc1p-9;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue