xref: /freebsd/contrib/arm-optimized-routines/math/README.contributors (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1STYLE REQUIREMENTS
2==================
3
41. Most code in this sub-directory is expected to be upstreamed into glibc so
5   the GNU Coding Standard and glibc specific conventions should be followed
6   to ease upstreaming.
7
82. ABI and symbols: the code should be written so it is suitable for inclusion
9   into a libc with minimal changes. This e.g. means that internal symbols
10   should be hidden and in the implementation reserved namespace according to
11   ISO C and POSIX rules. If possible the built shared libraries and static
12   library archives should be usable to override libc symbols at link time (or
13   at runtime via LD_PRELOAD). This requires the symbols to follow the glibc ABI
14   (other than symbol versioning), this cannot be done reliably for static
15   linking so this is a best effort requirement.
16
173. API: include headers should be suitable for benchmarking and testing code
18   and should not conflict with libc headers.
19
20
21CONTRIBUTION GUIDELINES FOR math SUB-DIRECTORY
22==============================================
23
241. Math functions have quality and performance requirements.
25
262. Quality:
27   - Worst-case ULP error should be small in the entire input domain (for most
28     common double precision scalar functions the target is < 0.66 ULP error,
29     and < 1 ULP for single precision, even performance optimized function
30     variant should not have > 5 ULP error if the goal is to be a drop in
31     replacement for a standard math function), this should be tested
32     statistically (or on all inputs if possible in reasonable amount of time).
33     The ulp tool is for this and runulp.sh should be updated for new functions.
34
35   - All standard rounding modes need to be supported but in non-default rounding
36     modes the quality requirement can be relaxed. (Non-nearest rounded
37     computation can be slow and inaccurate but has to be correct for conformance
38     reasons.)
39
40   - Special cases and error handling need to follow ISO C Annex F requirements,
41     POSIX requirements, IEEE 754-2008 requirements and Glibc requiremnts:
42     https://www.gnu.org/software/libc/manual/html_mono/libc.html#Errors-in-Math-Functions
43     this should be tested by direct tests (glibc test system may be used for it).
44
45   - Error handling code should be decoupled from the approximation code as much
46     as possible. (There are helper functions, these take care of errno as well
47     as exception raising.)
48
49   - Vector math code does not need to work in non-nearest rounding mode and error
50     handling side effects need not happen (fenv exceptions and errno), but the
51     result should be correct (within quality requirements, which are lower for
52     vector code than for scalar code).
53
54   - Error bounds of the approximation should be clearly documented.
55
56   - The code should build and pass tests on arm, aarch64 and x86_64 GNU linux
57     systems. (Routines and features can be disabled on specific targets, but
58     the build must complete). On aarch64, both little- and big-endian targets
59     are supported as well as valid combinations of architecture extensions.
60     The configurations that should be tested depend on the contribution.
61
623. Performance:
63   - Common math code should be benchmarked on modern aarch64 microarchitectures
64     over typical inputs.
65
66   - Performance improvements should be documented (relative numbers can be
67     published; it is enough to use the mathbench microbenchmark tool which should
68     be updated for new functions).
69
70   - Attention should be paid to the compilation flags: for aarch64 fma
71     contraction should be on and math errno turned off so some builtins can be
72     inlined.
73
74   - The code should be reasonably performant on x86_64 too, e.g. some rounding
75     instructions and fma may not be available on x86_64, such builtins turn into
76     libc calls with slow code. Such slowdown is not acceptable, a faster fallback
77     should be present: glibc and bionic use the same code on all targets. (This
78     does not apply to vector math code).
79