diff options
-rw-r--r-- | benchtests/bench-malloc-simple.c | 2 | ||||
-rw-r--r-- | elf/Makefile | 21 | ||||
-rw-r--r-- | malloc/arena.c | 13 | ||||
-rw-r--r-- | malloc/malloc.c | 2 | ||||
-rw-r--r-- | sysdeps/aarch64/fpu/coshf_sve.c | 6 | ||||
-rw-r--r-- | sysdeps/aarch64/fpu/expf_sve.c | 6 | ||||
-rw-r--r-- | sysdeps/aarch64/fpu/sv_expf_inline.h | 30 |
7 files changed, 34 insertions, 46 deletions
diff --git a/benchtests/bench-malloc-simple.c b/benchtests/bench-malloc-simple.c index f93d76e..1d7989e 100644 --- a/benchtests/bench-malloc-simple.c +++ b/benchtests/bench-malloc-simple.c @@ -35,7 +35,7 @@ multi-threaded using thread-arena, and main arena with SINGLE_THREAD_P false. */ -#define NUM_ITERS 200000 +#define NUM_ITERS 5000000 #define NUM_ALLOCS 4 #define MAX_ALLOCS 1600 diff --git a/elf/Makefile b/elf/Makefile index 2bce1ed..3d60000 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -456,6 +456,7 @@ tests += \ tst-noload \ tst-non-directory-path \ tst-null-argv \ + tst-origin \ tst-p_align1 \ tst-p_align2 \ tst-p_align3 \ @@ -763,6 +764,7 @@ modules-names += \ libmarkermod5-3 \ libmarkermod5-4 \ libmarkermod5-5 \ + liborigin-mod \ libtracemod1-1 \ libtracemod2-1 \ libtracemod3-1 \ @@ -1421,6 +1423,10 @@ $(objpfx)tst-_dl_addr_inside_object: $(objpfx)dl-addr-obj.os CFLAGS-tst-_dl_addr_inside_object.c += $(PIE-ccflag) endif +ifeq ($(run-built-tests),yes) +tests-special += $(objpfx)tst-origin.out +endif + include ../Rules ifeq (yes,$(build-shared)) @@ -3443,19 +3449,10 @@ $(objpfx)tst-dlopen-constructor-null: \ $(objpfx)tst-dlopen-constructor-null-mod2.so: \ $(objpfx)tst-dlopen-constructor-null-mod1.so -ifeq ($(run-built-tests),yes) -tests-special += $(objpfx)tst-origin.out -endif CFLAGS-tst-origin.c += $(no-stack-protector) -$(objpfx)tst-origin: $(objpfx)tst-origin.o $(objpfx)liborigin-mod.so - $(LINK.o) -o $@ -B$(csu-objpfx) $(LDFLAGS.so) $< \ - -Wl,-rpath,\$$ORIGIN \ - -L$(subst :, -L,$(rpath-link)) -Wl,--no-as-needed -lorigin-mod -$(objpfx)liborigin-mod.so: $(objpfx)liborigin-mod.os - $(LINK.o) -shared -o $@ -B$(csu-objpfx) $(LDFLAGS.so) \ - $(LDFLAGS-soname-fname) \ - $< -$(objpfx)tst-origin.out: tst-origin.sh $(objpfx)tst-origin +CFLAGS-liborigin-mod.c += $(no-stack-protector) +LDFLAGS-tst-origin += -Wl,-rpath,\$$ORIGIN -L$(subst :, -L,$(rpath-link)) -lorigin-mod +$(objpfx)tst-origin.out: tst-origin.sh $(objpfx)liborigin-mod.so $(objpfx)tst-origin $(SHELL) \ $< \ '$(common-objpfx)' \ diff --git a/malloc/arena.c b/malloc/arena.c index 353b634..405ae82 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -40,19 +40,20 @@ mmap threshold, so that requests with a size just below that threshold can be fulfilled without creating too many heaps. */ -/* When huge pages are used to create new arenas, the maximum and minimum - size are based on the runtime defined huge page size. */ +/* HEAP_MAX_SIZE should be larger than the huge page size, otherwise heaps will + use not huge pages. It is a constant so arena_for_chunk() is efficient. */ static inline size_t heap_min_size (void) { - return mp_.hp_pagesize == 0 ? HEAP_MIN_SIZE : mp_.hp_pagesize; + return mp_.hp_pagesize == 0 || mp_.hp_pagesize > HEAP_MAX_SIZE + ? HEAP_MIN_SIZE : mp_.hp_pagesize; } static inline size_t heap_max_size (void) { - return mp_.hp_pagesize == 0 ? HEAP_MAX_SIZE : mp_.hp_pagesize * 4; + return HEAP_MAX_SIZE; } /***************************************************************************/ @@ -313,7 +314,7 @@ ptmalloc_init (void) TUNABLE_GET (mxfast, size_t, TUNABLE_CALLBACK (set_mxfast)); TUNABLE_GET (hugetlb, size_t, TUNABLE_CALLBACK (set_hugetlb)); - if (mp_.hp_pagesize > 0) + if (mp_.hp_pagesize > 0 && mp_.hp_pagesize <= heap_max_size ()) { /* Force mmap for main arena instead of sbrk, so MAP_HUGETLB is always tried. Also tune the mmap threshold, so allocation smaller than the @@ -460,7 +461,7 @@ alloc_new_heap (size_t size, size_t top_pad, size_t pagesize, static heap_info * new_heap (size_t size, size_t top_pad) { - if (__glibc_unlikely (mp_.hp_pagesize != 0)) + if (mp_.hp_pagesize != 0 && mp_.hp_pagesize <= heap_max_size ()) { heap_info *h = alloc_new_heap (size, top_pad, mp_.hp_pagesize, mp_.hp_flags); diff --git a/malloc/malloc.c b/malloc/malloc.c index 931ca48..55fb2ab 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -298,7 +298,7 @@ # define tidx2usize(idx) (((size_t) idx) * MALLOC_ALIGNMENT + MINSIZE - SIZE_SZ) /* When "x" is from chunksize(). */ -# define csize2tidx(x) (((x) - MINSIZE + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENT) +# define csize2tidx(x) (((x) - MINSIZE) / MALLOC_ALIGNMENT) /* When "x" is a user-provided size. */ # define usize2tidx(x) csize2tidx (request2size (x)) diff --git a/sysdeps/aarch64/fpu/coshf_sve.c b/sysdeps/aarch64/fpu/coshf_sve.c index fb8e06c..8056055 100644 --- a/sysdeps/aarch64/fpu/coshf_sve.c +++ b/sysdeps/aarch64/fpu/coshf_sve.c @@ -39,9 +39,9 @@ special_case (svfloat32_t x, svfloat32_t half_e, svfloat32_t half_over_e, } /* Single-precision vector cosh, using vector expf. - Maximum error is 2.77 ULP: - _ZGVsMxv_coshf(-0x1.5b38f4p+1) got 0x1.e45946p+2 - want 0x1.e4594cp+2. */ + Maximum error is 2.56 +0.5 ULP: + _ZGVsMxv_coshf(-0x1.5b40f4p+1) got 0x1.e47748p+2 + want 0x1.e4774ep+2. */ svfloat32_t SV_NAME_F1 (cosh) (svfloat32_t x, svbool_t pg) { const struct data *d = ptr_barrier (&data); diff --git a/sysdeps/aarch64/fpu/expf_sve.c b/sysdeps/aarch64/fpu/expf_sve.c index f9249db..c361997 100644 --- a/sysdeps/aarch64/fpu/expf_sve.c +++ b/sysdeps/aarch64/fpu/expf_sve.c @@ -40,9 +40,9 @@ special_case (svfloat32_t x, svbool_t special, const struct sv_expf_data *d) } /* Optimised single-precision SVE exp function. - Worst-case error is 1.04 ulp: - SV_NAME_F1 (exp)(0x1.a8eda4p+1) got 0x1.ba74bcp+4 - want 0x1.ba74bap+4. */ + Worst-case error is 0.88 +0.50 ULP: + _ZGVsMxv_expf(-0x1.bba276p-6) got 0x1.f25288p-1 + want 0x1.f2528ap-1. */ svfloat32_t SV_NAME_F1 (exp) (svfloat32_t x, const svbool_t pg) { const struct data *d = ptr_barrier (&data); diff --git a/sysdeps/aarch64/fpu/sv_expf_inline.h b/sysdeps/aarch64/fpu/sv_expf_inline.h index 16b81fc..e2d2e90 100644 --- a/sysdeps/aarch64/fpu/sv_expf_inline.h +++ b/sysdeps/aarch64/fpu/sv_expf_inline.h @@ -24,50 +24,40 @@ struct sv_expf_data { - float c1, c3, inv_ln2; - float ln2_lo, c0, c2, c4; - float ln2_hi, shift; + float ln2_hi, ln2_lo, c1, null; + float inv_ln2, shift; }; -/* Coefficients copied from the polynomial in AdvSIMD variant, reversed for - compatibility with polynomial helpers. Shift is 1.5*2^17 + 127. */ +/* Shift is 1.5*2^17 + 127. */ #define SV_EXPF_DATA \ { \ - /* Coefficients copied from the polynomial in AdvSIMD variant. */ \ - .c0 = 0x1.ffffecp-1f, .c1 = 0x1.fffdb6p-2f, .c2 = 0x1.555e66p-3f, \ - .c3 = 0x1.573e2ep-5f, .c4 = 0x1.0e4020p-7f, .inv_ln2 = 0x1.715476p+0f, \ - .ln2_hi = 0x1.62e4p-1f, .ln2_lo = 0x1.7f7d1cp-20f, \ - .shift = 0x1.803f8p17f, \ + .c1 = 0.5f, .inv_ln2 = 0x1.715476p+0f, .ln2_hi = 0x1.62e4p-1f, \ + .ln2_lo = 0x1.7f7d1cp-20f, .shift = 0x1.803f8p17f, \ } -#define C(i) sv_f32 (d->poly[i]) - static inline svfloat32_t expf_inline (svfloat32_t x, const svbool_t pg, const struct sv_expf_data *d) { /* exp(x) = 2^n (1 + poly(r)), with 1 + poly(r) in [1/sqrt(2),sqrt(2)] x = ln2*n + r, with r in [-ln2/2, ln2/2]. */ - svfloat32_t lane_consts = svld1rq (svptrue_b32 (), &d->ln2_lo); + svfloat32_t lane_consts = svld1rq (svptrue_b32 (), &d->ln2_hi); /* n = round(x/(ln2/N)). */ svfloat32_t z = svmad_x (pg, sv_f32 (d->inv_ln2), x, d->shift); svfloat32_t n = svsub_x (pg, z, d->shift); /* r = x - n*ln2/N. */ - svfloat32_t r = svmsb_x (pg, sv_f32 (d->ln2_hi), n, x); + svfloat32_t r = x; r = svmls_lane (r, n, lane_consts, 0); + r = svmls_lane (r, n, lane_consts, 1); /* scale = 2^(n/N). */ svfloat32_t scale = svexpa (svreinterpret_u32 (z)); - /* poly(r) = exp(r) - 1 ~= C0 r + C1 r^2 + C2 r^3 + C3 r^4 + C4 r^5. */ - svfloat32_t p12 = svmla_lane (sv_f32 (d->c1), r, lane_consts, 2); - svfloat32_t p34 = svmla_lane (sv_f32 (d->c3), r, lane_consts, 3); + /* poly(r) = exp(r) - 1 ~= r + 0.5 r^2. */ svfloat32_t r2 = svmul_x (svptrue_b32 (), r, r); - svfloat32_t p14 = svmla_x (pg, p12, p34, r2); - svfloat32_t p0 = svmul_lane (r, lane_consts, 1); - svfloat32_t poly = svmla_x (pg, p0, r2, p14); + svfloat32_t poly = svmla_lane (r, r2, lane_consts, 2); return svmla_x (pg, scale, scale, poly); } |