383 Commits

Author SHA1 Message Date
Sunil K Pandey
bcd4cf9d5f x86_64: Add atanh with FMA
On SPR, it improves atanh bench performance by:

			Before		After		Improvement
reciprocal-throughput	15.1715		14.8628		2%
latency			57.1941		56.1883		2%

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit c7c4a5906f326f1290b1c2413a83c530564ec4b8)
2025-03-18 10:01:25 -07:00
Sunil K Pandey
7e72fa7577 x86_64: Add sinh with FMA
On SPR, it improves sinh bench performance by:

			Before		After		Improvement
reciprocal-throughput	14.2017		11.815		17%
latency			36.4917		35.2114		4%

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
(cherry picked from commit dded0d20f67ba1925ccbcb9cf28f0c75febe0dbe)
2025-03-18 09:58:14 -07:00
Florian Weimer
0b795abd62 benchtests: Add dummy in put files cospi, cospif, sinpi, sinpif, tanpi, tanpif
This fixes an AArch64 build failure:

python3 -B ../sysdeps/aarch64/fpu/scripts/bench_libmvec_advsimd.py bench-float-advsimd-cospi > …/benchtests/bench-float-advsimd-cospi.c
Traceback (most recent call last):
  File "…/sysdeps/aarch64/fpu/scripts/bench_libmvec_advsimd.py", line 106, in <module>
    main(sys.argv[1])
    ~~~~^^^^^^^^^^^^^
  File "…/sysdeps/aarch64/fpu/scripts/bench_libmvec_advsimd.py", line 81, in main
    with open(f"../benchtests/libmvec/{input_filename}") as f:
         ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

FileNotFoundError: [Errno 2] No such file or directory: '../benchtests/libmvec/cospif-inputs'
2025-01-16 19:59:58 +01:00
Paul Eggert
2642002380 Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
Adhemerval Zanella
a2b0ff98a0 include/sys/cdefs.h: Add __attribute_optimization_barrier__
Add __attribute_optimization_barrier__ to disable inlining and cloning on a
function.  For Clang, expand it to

__attribute__ ((optnone))

Otherwise, expand it to

__attribute__ ((noinline, clone))

Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-23 06:28:55 +08:00
Adhemerval Zanella
042ed4b28a benchtests: Add tanhf benchmark
Random inputs in the range [-10,10].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
b76b90a809 benchtests: Add sinhf benchmark
Random inputs in the range [-10,10].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
7b7a3fa121 benchtests: Add coshf benchmark
Random inputs in the range [-10,10].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
4f1e26ba47 benchtests: Add atanhf benchmark
The input is based on acosf one (random inputs in [-1,1]).

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
fa857e6c7b benchtests: Add atan2f benchmark
Random inputs in the range [-10,10].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
74a275d244 benchtests: Add atanf benchmark
Random inputs in the range [-10,10].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
275d4d479b benchtests: Add asinhf benchmark
Random inputs in the range [-10,10].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
1da8a3707c benchtests: Add asinf benchmark
The input is based on acosf one (random inputs in [-1,1]).

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
fa145f3784 benchtests: Add acoshf benchmark
Random inputs in the range [1,21].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Adhemerval Zanella
647e464374 benchtests: Add acosf benchmark
The input is based on acos one (random inputs in [-1,1]).

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Kuan-Wei Chiu
dce846c789 benchtests: Add benchmark test for bsearch
Introduce a benchmark test for the bsearch function to evaluate its
performance.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-11 17:04:42 -05:00
Wangyang Guo
2d6427a63c benchtests: Add calloc test
Two new benchmarks related to calloc added:
- bench-calloc-simple
- bench-calloc-thread
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-11-29 19:04:28 +08:00
Adhemerval Zanella
2234b08763 benchtests: Add tanf benchmark
Random inputs in [-pi, pi].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-22 10:01:03 -03:00
Adhemerval Zanella
ce4122ff97 benchtests: Add lgammaf benchmark
Random inputs in the range [-20.0,20.0].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-22 10:01:03 -03:00
Adhemerval Zanella
d7612d04e4 benchtests: Add erfcf benchmark
It is based on binary64 erfc-inputs, with random inputs in
[0,b=0x1.41bbf6p+3] where b in the smallest number such that
erfcf(b) rounds to 0 (to nearest).

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-22 10:01:03 -03:00
Adhemerval Zanella
50657965da benchtests: Add erff benchmark
It is based on binary64 erf-inputs, with random inputs in [0,b=0x1.f5a888p+1]
where b in the smallest number such that erff(b) rounds to 1 (to nearest).

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-22 10:01:03 -03:00
Adhemerval Zanella
53c80be8da benchtests: Add cbrtf benchmark
Based on binary64 benchtests, with random inputs in [1,8].
2024-11-22 10:01:03 -03:00
Adhemerval Zanella
48767cbb76 benchtests: Add log10p1f benchmark
It is based on log2f data.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:20 -03:00
Adhemerval Zanella
ef2485c5fe benchtests: Add log1p benchmark
Random inputs x*2^e where x is random in [1/2,1] and e in [-29,127].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:19 -03:00
Adhemerval Zanella
acc2137382 benchtests: Add log2p1f benchmark
It is based on log2f data.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:18 -03:00
Adhemerval Zanella
1e262f80dd benchtests: Add log10f benchmark
The inputs are random numbers in the form x*2^e where x is random
in [0x1p-1,0x1p+0] and e in [-126,127].

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:16 -03:00
Adhemerval Zanella
2dbf7c4bf1 benchtests: Add expm1f benchmark
The inputs are modeled based on expm1-inputs, with the range
adapted to binary32 range.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:15 -03:00
Adhemerval Zanella
19ab8bbd71 benchtests: Add exp2m1f benchmark
The input is based on exp2f benchmark.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:13 -03:00
Adhemerval Zanella
ad53c12798 benchtests: Add exp10m1f benchmark
The input is based on exp10f benchmark.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-01 11:17:09 -03:00
Paul Zimmermann
392b3f0971 replace tgammaf by the CORE-MATH implementation
The CORE-MATH implementation is correctly rounded (for any rounding mode).
This can be checked by exhaustive tests in a few minutes since there are
less than 2^32 values to check against for example GNU MPFR.
This patch also adds some bench values for tgammaf.

Tested on x86_64 and x86 (cfarm26).

With the initial GNU libc code it gave on an Intel(R) Core(TM) i7-8700:

      "tgammaf": {
       "": {
        "duration": 3.50188e+09,
        "iterations": 2e+07,
        "max": 602.891,
        "min": 65.1415,
        "mean": 175.094
       }
      }

With the new code:

      "tgammaf": {
       "": {
        "duration": 3.30825e+09,
        "iterations": 5e+07,
        "max": 211.592,
        "min": 32.0325,
        "mean": 66.1649
       }
      }

With the initial GNU libc code it gave on cfarm26 (i686):

  "tgammaf": {
   "": {
    "duration": 3.70505e+09,
    "iterations": 6e+06,
    "max": 2420.23,
    "min": 243.154,
    "mean": 617.509
   }
  }

With the new code:

  "tgammaf": {
   "": {
    "duration": 3.24497e+09,
    "iterations": 1.8e+07,
    "max": 1238.15,
    "min": 101.155,
    "mean": 180.276
   }
  }

Signed-off-by: Alexei Sibidanov <sibid@uvic.ca>
Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>

Changes in v2:
    - include <math.h> (fix the linknamespace failures)
    - restored original benchtests/strcoll-inputs/filelist#en_US.UTF-8 file
    - restored original wrapper code (math/w_tgammaf_compat.c),
      except for the dealing with the sign
    - removed the tgammaf/float entries in all libm-test-ulps files
    - address other comments from Joseph Myers
      (https://sourceware.org/pipermail/libc-alpha/2024-July/158736.html)

Changes in v3:
    - pass NULL argument for signgam from w_tgammaf_compat.c
    - use of math_narrow_eval
    - added more comments

Changes in v4:
    - initialize local_signgam to 0 in math/w_tgamma_template.c
    - replace sysdeps/ieee754/dbl-64/gamma_productf.c by dummy file

Changes in v5:
    - do not mention local_signgam any more in math/w_tgammaf_compat.c
    - initialize local_signgam to 1 instead of 0 in w_tgamma_template.c
      and added comment

Changes in v6:
    - pass NULL as 2nd argument of __ieee754_gammaf_r in
      w_tgammaf_compat.c, and check for NULL in e_gammaf_r.c

Changes in v7:
    - added Signed-off-by line for Alexei Sibidanov (author of the code)

Changes in v8:
    - added Signed-off-by line for Paul Zimmermann (submitted of the patch)

Changes in v9:
    - address comments from review by Adhemerval Zanella
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-10-11 11:12:32 +02:00
Wilco Dijkstra
79e472f0f8 benchtests: Add random memset benchmark
Add a new randomized memset test similar to bench-random-memcpy.  Instead of
repeating the same call to memset over and over again, it times a large number
of different inputs.  The distribution of memset length and alignment is based
on SPEC2017 (length up to 4096 and alignment up to 64).

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-08-07 14:58:46 +01:00
Wilco Dijkstra
5aa2f79691 Benchtests: Remove broken walk benchmarks
The walk benchmarks don't measure anything useful - memory is not initialized
properly so doing a single walk in 32MB just measures reading the 4KB zero
page for reads and clear_page overhead for writes.  The memset variants don't
even manage to do a walk in the 32MB region due to using incorrect pointer
increments...  Neither is it clear why it is walking backwards since this
won't confuse modern prefetchers.  If you fix the benchmark and print the
bandwidth, the results are identical for all sizes larger than ~1KB since it
is just testing memory bandwidth of a single 32MB block.  This case is already
tested by the large benchmark, so overall it doesn't seem useful to keep these.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-06-21 14:41:42 +01:00
Paul Eggert
ee768a30fe Modernize and fix doc’s “Date and Time” (BZ 31876)
POSIX.1-2024 (now official) specifies tm_gmtoff and tm_zone.
This is a good time to update the manual’s “Date and Time”
chapter so I went through it, fixed some outdated
stuff that had been in there for decades, and improved it to match
POSIX.1-2024 better and to clarify some implementation-defined
behavior.  Glibc already conforms to POSIX.1-2024 in these matters, so
this is merely a documentation change.

* manual/examples/strftim.c: Use snprintf instead of now-deprecated
  function asctime.  Check for localtime failure.  Simplify by using
  puts instead of fputs.  Prefer ‘buf, sizeof buf’ to less-obvious
  ‘buffer, SIZE’.

* manual/examples/timespec_subtract.c: Modernize to use struct
  timespec not struct timeval, and rename from timeval_subtract.c.
  All uses changed.  Check for overflow.  Do not check for negative
  return value, which ought to be OK since negative time_t is OK.
  Use GNU indenting style.

* manual/time.texi:

  Document CLOCKS_PER_SEC, TIME_UTC, timespec_get, timespec_getres,
  strftime_l.

  Document the storage lifetime of tm_zone and of tzname.

  Caution against use of tzname, timezone and daylight, saying that
  these variables have unspecified values when TZ is geographic.
  This is what glibc actually does (contrary to what the manual said
  before this patch), and POSIX is planned to say the same thing
  <https://austingroupbugs.net/view.php?id=1816>.
  Also say that directly accessing the variables is not thread-safe.

  Say that localtime_r and ctime_r don’t necessarily set time zone
  state.  Similarly, in the tzset documentation, say that it is called
  by ctime, localtime, mktime, strftime, not that it is called by all
  time conversion functions that depend on the time zone.

  Say that tm_isdst is useful mostly just for mktime, and that
  other uses should prefer tm_gmtoff and tm_zone instead.

  Do not say that strftime ignores tm_gmtoff and tm_zone, because
  it doesn’t do that.

  Document what gmtime does to tm_gmtoff and tm_zone.

  Say that the asctime, asctime_r, ctime, and ctime_r are now deprecated
  and/or obsolescent, and that behavior is undefined if the year is <
  1000 or > 9999.  Document strftime before these now-obsolescent
  functions, so that readers see the useful function first.

  Coin the terms “geographical format” and “proleptic format” for the
  two main formats of TZ settings, to simplify exposition.  Use this
  wording consistently.

  Update top-level proleptic syntax to match POSIX.1-2024, which glibc
  already implements.  Document the angle-bracket quoted forms of time
  zone abbreviations in proleptic TZ.  Say that time zone abbreviations
  can contain only ASCII alphanumerics, ‘+’, and ‘-’.

  Document what happens if the proleptic form specifies a DST
  abbreviation and offset but omits the rules.  POSIX says this is
  implementation-defined so we need to document it.  Although this
  documentation mentions ‘posixrules’ tersely, we need to rethink
  ‘posixrules’ since I think it stops working after 2038.

  Clarify wording about TZ settings beginning with ‘;’.

  Say that timegm is in ISO C (as of C23).

  Say that POSIX.1-2024 removed gettimeofday.

  Say that tm_gmtoff and tm_zone are extensions to ISO C, which is
  clearer than saying they are invisible in a struct ISO C enviroment,
  and gives us more wiggle room if we want to make them visible in
  strict ISO C, something that ISO C allows.

  Drop mention of old standards like POSIX.1c and POSIX.2-1992 in the
  text when the history is so old that it’s no longer useful in a
  general-purpose manual.

  Define Coordinated Universal Time (UTC), time zone, time zone ruleset,
  and POSIX Epoch, and use these phrases more consistently.

  Improve TZ examples to show more variety, and to reflect current
  practice and timestamps.  Remove obsolete example about Argentina.
  Add an example for Ireland.

  Don’t rely on GCC extensions when explaining ctime_r.

  Do not say that difftime produces the mathematically correct result,
  since it might be inexact.

  For clock_t don’t say “as in the example above” when there is no
  such example, and don’t say that casting to double works “properly
  and consistently no matter what”, as it suffers from rounding and
  overflow.

  Don’t say broken-down time is not useful for calculations; it’s
  merely painful.

  Say that UTC is not defined before 1960.

  Rename Time Zone Functions to Time Zone State.  All uses changed.

  Update Internet RFC 822 → 5322, 1305 → 5905.  Drop specific years of
  ISO 8601 as they don’t matter.

  Minor style changes: @code{"..."} → @t{"..."} to avoid overquoting in
  info files, @code → @env for environment variables, Daylight Saving
  Time → daylight saving time, white space → whitespace, prime meridian
  → Prime Meridian.
2024-06-15 08:53:50 -07:00
H.J. Lu
fa9aecc045 benchtests: Add fclose benchmark
Measure duration of 100 fclose calls after opening 1 million FILEs.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-05-16 08:12:59 -07:00
Wilco Dijkstra
f262fce616 benchtests: Add difficult strstr needle for bruteforce algorithms
Add another difficult needle to strstr that clearly shows the quadratic
complexity of bruteforce algorithms.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-04-24 18:25:46 +01:00
Wilco Dijkstra
0997c3d0c8 benchtests: Add random() benchmark
Add a simple benchmark to measure the overhead of internal libc locks in
the random() implementation on both single- and multi-threaded cases.
This relies on the implementation of random using internal locks to
access shared global data, and that the runtime uses multi-threaded
locking once a thread has been created (even after it finishes).

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-04-18 14:30:21 +01:00
Adhemerval Zanella
a0698a5e92 benchtests: Improve benchtests for strstr
Use same strategy as bench-strstr.c (93eebae5168e5cf2 and 80b2bfb53504)
and use json_ctx for output to help standardize format across all
benchtests.
Reviewed-by: Arjun Shankar <arjun@redhat.com>
2024-04-01 13:52:00 -03:00
Junxian Zhu
0a4d6c8254 benchtests: Add more benchtests for rounding functions.
This patch adds more benchtests for rounding functions.
The double inputs are copied from trunc-inputs, the float inputs are copied from truncf-inputs. and the rintf is copied from rint-inputs.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-02-23 08:50:00 -03:00
Wilco Dijkstra
7c14d8a985 Benchtests: Increase benchmark iterations
Increase benchmark iterations for math and vector math functions to improve
timing accuracy.  Vector math benchmarks now take 1-3 seconds on a modern CPU.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-01-12 16:00:28 +00:00
Paul Eggert
dff8da6b3e Update copyright dates with scripts/update-copyrights 2024-01-01 10:53:40 -08:00
Frederic Berat
99f9ae4ed0 benchtests: fix warn unused result
Few tests needed to properly check for asprintf and system calls return
values with _FORTIFY_SOURCE enabled.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2023-06-22 00:21:19 -04:00
Paul Pluzhnikov
7f0d9e61f4 Fix all the remaining misspellings -- BZ 25337 2023-06-02 01:39:48 +00:00
Carlos O'Donell
85c3569cf4 benchtests: Reformat Makefile.
Reflow all long lines adding comment terminators.
Sort all reflowed text using scripts/sort-makefile-lines.py.

No regressions running microbenchmarks.
No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
2023-05-18 13:11:48 -04:00
Joe Ramsay
cd94326a13 Enable libmvec support for AArch64
This patch enables libmvec on AArch64. The proposed change is mainly
implementing build infrastructure to add the new routines to ABI,
tests and benchmarks. I have demonstrated how this all fits together
by adding implementations for vector cos, in both single and double
precision, targeting both Advanced SIMD and SVE.

The implementations of the routines themselves are just loops over the
scalar routine from libm for now, as we are more concerned with
getting the plumbing right at this point. We plan to contribute vector
routines from the Arm Optimized Routines repo that are compliant with
requirements described in the libmvec wiki.

Building libmvec requires minimum GCC 10 for SVE ACLE. To avoid raising
the minimum GCC by such a big jump, we allow users to disable libmvec
if their compiler is too old.

Note that at this point users have to manually call the vector math
functions. This seems to be acceptable to some downstream users.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2023-05-03 12:09:49 +01:00
Wilco Dijkstra
2623479105 Benchtests: Adjust timing
Adjust iteration counts so benchmarks don't run too slowly or quickly.
Ensure benchmarks take less than 10 seconds on older, slower cores and
more than 0.5 seconds on fast cores.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-04-17 13:00:38 +01:00
Nisha Menon
51a121eb36 compare_strings.py : Add --gmean flag
To calculate geometric mean for string benchmark results.

Signed-off-by: Nisha Poyarekar <nisha.s.menon@gmail.com>
2023-04-04 13:51:45 -05:00
Adhemerval Zanella Netto
5c11701c51 benchtests: Add fmodf benchmark
1. Subnormals: 128 inputs.
2. Normal numbers with large exponent difference (|x/y| > 2^8):
   1024 inputs between FLT_MIN and FLT_MAX;
3. Close exponents (ey >= -103 and |x/y| < 2^8): 1024 inputs with
   exponents between -10 and 10.
Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2023-04-03 16:13:55 -03:00
Adhemerval Zanella Netto
3ba0c9593f benchtests: Add fmod benchmark
Add three different dataset, from random floating point numbers:

1. Subnormals: 128 inputs.
2. Normal numbers with large exponent difference (|x/y| > 2^52):
   1024 inputs between DBL_MIN and DBL_MAX;
3. Close exponents (ey >= -907 and |x/y| < 2^52): 1024 inputs with
   exponents between -10 and 10.
Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2023-04-03 16:13:55 -03:00
Joe Ramsay
e4d336f1ac benchtests: Move libmvec benchtest inputs to benchtests directory
This allows other targets to use the same inputs for their own libmvec
microbenchmarks without having to duplicate them in their own
subdirectory.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2023-03-27 17:04:03 +01:00
Wilco Dijkstra
10f980d31e Benchtests: Remove simple_str(r)chr
Instead of benchmarking slow byte oriented loops, include the optimized generic
strchr and strrchr implementation.  Adjust iteration count to reduce benchmark
time.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-03-08 18:36:48 +00:00