Commit Graph
700 Commits
Author SHA1 Message Date
Nigel Tao fb769ff82f base: disable SIMD on MSVC x86_64 by default
This recreates the case as of commit f1698226 (tag v0.4.0-alpha.4), in
that, by default (without #define'ing a macro or passing an /arch:ETC
compiler flag), Wuffs does not use SIMD on MSVC x86_64.

Commit b64a7610 (after tag v0.4.0-alpha.4, before tag v0.4.0-alpha.5)
changed the default so that x86_64_v2 (roughly equivalent to SSE4.2) was
enabled by default, since the user from issue #148 was enabling that
anyway (in an unsupported way, by #define'ing a macro that was a private
implementation detail) with no problems (and better performance).

However, another user later reported (in issue #151) that enabling SIMD
on MSVC x86_64 somehow lead to ICEs (Internal Compiler Errors).

This commit restores the default to "no SIMD" and it is up to the MSVC
user to opt in to the SIMD code paths. Clang and GCC are unaffected:
SIMD remains enabled by default.

Updates #148
Updates #151
2024-07-31 17:12:55 +10:00
Nigel Tao ce1f59e9ce base: format token-public.h constants 2024-07-27 09:11:53 +10:00
Nigel Tao 8fe987e0b2 base: add sign_extend_convert_u8_u32 2024-07-09 16:31:58 +10:00
Nigel Tao cc9ee184d0 cgen: omit consecutive Wconversion gcc pragmas 2024-07-09 12:39:16 +10:00
Nigel Tao 495f0280a8 base: add ETC__I_KNOW_THAT_ETC_BEST_WITH_ARCH_AVX2
Updates #148
2024-07-09 10:34:35 +10:00
Nigel Tao b64a761067 base: enable ETC__CPU_ARCH__X86_64_V2 on MSVC
If I understand the https://github.com/google/wuffs/issues/148
discussion correctly, a user overrode WUFFS_BASE__CPU_ARCH__X86_FAMILY
(without also providing /arch:AVX) to enable SSE4.2 code (even though,
technically, x86_64 doesn't guarantee SSE4.2, only SSE2). This seemed to
work fine in practice, but was unsupported by Wuffs and 'broke' by
fixing #145, now looking for WUFFS_BASE__CPU_ARCH__X86_64 instead of
WUFFS_BASE__CPU_ARCH__X86_FAMILY.

WUFFS_BASE__CPU_ARCH__X86_FAMILY has since been renamed to
WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_FAMILY and then removed entirely.

As SSE4.2 (roughly equivalent to x86-64-v2) seems to work fine at
compile time (with the existing cpuid detection at runtime), enable it
by default for MSVC, without need /arch.

Enabling x86-64-v3 too, by default, is held back for now, pending
further confirmation from MSVC users. The #148 user was exercising
Wuffs' PNG codec, which uses SSE4.2 but not AVX or AVX2. Currently, only
Wuffs' JPEG codec (and YCbCr conversion) uses AVX or AVX2.

GCC and Clang don't need this fiddliness, because they support
"__attribute__((target(arg)))".

Updates #148
2024-07-09 10:25:42 +10:00
Nigel Tao 7a57e2b600 base: remove ETC__CPU_ARCH__X86_FAMILY
Updates #148
2024-07-09 09:33:34 +10:00
Nigel Tao 4111785304 base: have MSVC detect AVX2 not AVX
The x86-64-v3 micro-architecture level requires AVX2.

Updates #148
2024-07-09 09:22:23 +10:00
Nigel Tao affa1e02d4 base: add WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
Updates #148
2024-07-09 09:17:09 +10:00
Nigel Tao 97b727a1ae base: warn defining private implementation macros
Updates #148
2024-07-08 21:08:05 +10:00
Nigel Tao 37a3c3ce9b base: rename WUFFS_BASE__CPU_ARCH__ETC
See
https://github.com/google/wuffs/issues/148#issuecomment-2130535812

Updates #148
2024-07-08 18:14:59 +10:00
Nigel Tao 5654506497 base: allow swizzling WebP Lossless to gray 2024-07-08 12:35:40 +10:00
Nigel Tao 09f4500e19 std/webp: add new package (and vp8 placeholder) 2024-05-10 13:52:07 +10:00
Nigel Tao a27a7598f0 base: disable SIMD on 32-bit (not 64-bit) x86
Fixes #145
2024-04-06 15:30:25 +11:00
Nigel Tao 4209264a85 cgen: disable SIMD on 32-bit (not 64-bit) x86
Updates #145
2024-04-06 15:27:44 +11:00
Nigel Tao d8c3deb028 aux: remove DynIOBuffer::allocated
This largely reverts commit 8cfde80759.

Updates #135
2024-04-05 15:54:33 +11:00
Nigel Tao 00a01abc4e base: avoid some (ptr + len) when ptr is NULL
Updates #135
2024-04-05 15:52:40 +11:00
Nigel Tao d7f6b81d31 base: have empty_foo() functions use NULL ptr
This largely reverts commit f81deb6b6e.

Updates #135
2024-04-05 15:29:51 +11:00
Nigel Tao 2142aa65fc cgen: fix iterate's "ptr + len" when ptr is NULL
Updates #135
2024-04-05 13:47:25 +11:00
Nigel Tao a9a6d8ac55 base: make malloc_slice_u8(etc, 0) return empty
Updates #135
2024-04-05 13:30:18 +11:00
Nigel Tao f32bfe95c6 std/crc64: optimize for x86+SSE4.2
name                           old speed      new speed      delta

wuffs_crc64_ecma_10k/clang14   1.78GB/s ± 0%  5.79GB/s ± 0%  +225.48%  (p=0.008 n=5+5)
wuffs_crc64_ecma_100k/clang14  1.78GB/s ± 0%  6.09GB/s ± 0%  +241.67%  (p=0.008 n=5+5)

wuffs_crc64_ecma_10k/gcc12     2.05GB/s ± 1%  5.79GB/s ± 1%  +182.80%  (p=0.008 n=5+5)
wuffs_crc64_ecma_100k/gcc12    2.01GB/s ± 0%  6.09GB/s ± 0%  +202.64%  (p=0.008 n=5+5)

wuffs_xz_decode_100k/clang14   57.9MB/s ± 1%  60.2MB/s ± 0%    +4.11%  (p=0.008 n=5+5)

wuffs_xz_decode_100k/gcc12     57.0MB/s ± 0%  57.8MB/s ± 1%    +1.39%  (p=0.008 n=5+5)

$ time example-mzcat < linux-6.8.2.tar.xz > /dev/null
Before: user 0m8.122s
After:  user 0m8.115s
2024-04-02 00:17:43 +11:00
Nigel Tao b6b0f84187 std/lzma: use 8-byte-copy if applicable
name                            old speed      new speed      delta
wuffs_lzma_decode_100k/clang14  56.2MB/s ± 0%  60.7MB/s ± 0%  +7.96%  (p=0.008 n=5+5)
wuffs_lzma_decode_100k/gcc12    56.4MB/s ± 1%  61.7MB/s ± 1%  +9.44%  (p=0.008 n=5+5)

$ time example-mzcat < linux-6.8.2.tar.xz > /dev/null
Before: user 0m8.396s
After:  user 0m8.392s
2024-03-31 16:02:06 +11:00
Nigel Tao f5bb519320 base: add ETC__DST_PIXEL_FORMAT__ENABLE_ALLOWLIST
Binary size, before:
412128 gen/bin/example-convert-to-nia
 50680 gen/bin/example-gifplayer
449680 gen/bin/example-imageviewer
439000 gen/bin/example-sdl-imageviewer
151848 gen/bin/example-toy-aux-image

After:
302232 gen/bin/example-convert-to-nia
 46144 gen/bin/example-gifplayer
352112 gen/bin/example-imageviewer
329168 gen/bin/example-sdl-imageviewer
138656 gen/bin/example-toy-aux-image

For further data points, if you hard-code define'ing
WUFFS_CONFIG__DST_PIXEL_FORMAT__ENABLE_ALLOWLIST and
WUFFS_CONFIG__DST_PIXEL_FORMAT__ALLOW_BGRA_PREMUL:

Binary size, before:
121368 gen/lib/c/clang-dynamic/wuffs-base-pixconv.lo
121368 gen/lib/c/clang-static/wuffs-base-pixconv.o
181088 gen/lib/c/gcc-dynamic/wuffs-base-pixconv.lo
181136 gen/lib/c/gcc-static/wuffs-base-pixconv.o

After:
 54784 gen/lib/c/clang-dynamic/wuffs-base-pixconv.lo
 54784 gen/lib/c/clang-static/wuffs-base-pixconv.o
 72144 gen/lib/c/gcc-dynamic/wuffs-base-pixconv.lo
 72272 gen/lib/c/gcc-static/wuffs-base-pixconv.o
2024-03-29 22:19:47 +11:00
Nigel Tao b2c7c69227 base: add WUFFS_BASE__FORCE_INLINE 2024-03-29 15:49:41 +11:00
Nigel Tao 3bad76cd2c base: fix -Wtautological-type-limit-compare
Fixes #144
2024-03-28 16:38:45 +11:00
Nigel Tao f1a9d34494 pixconv: fix -Werror=conversion 2024-03-27 22:10:13 +11:00
Nigel Tao da40cdf29f base: re-format ETC__PIXEL_FORMAT__ETC defines 2024-03-27 21:16:32 +11:00
Nigel Tao bdfbdf407e pixconv: add PIXEL_FORMAT__YA_NONPREMUL support
Binary size, before:
115152 gen/lib/c/clang-dynamic/wuffs-base-pixconv.lo
115152 gen/lib/c/clang-static/wuffs-base-pixconv.o
162280 gen/lib/c/gcc-dynamic/wuffs-base-pixconv.lo
165352 gen/lib/c/gcc-static/wuffs-base-pixconv.o

After:
123464 gen/lib/c/clang-dynamic/wuffs-base-pixconv.lo
123464 gen/lib/c/clang-static/wuffs-base-pixconv.o
180768 gen/lib/c/gcc-dynamic/wuffs-base-pixconv.lo
180880 gen/lib/c/gcc-static/wuffs-base-pixconv.o

Updates #143
2024-03-27 19:07:03 +11:00
Nigel Tao 0c9b700df0 base: fix PIXEL_FORMAT__YA_{NON,}PREMUL values
These pixel formats have two channels (gray, alpha), not one.

Updates #143
2024-03-27 16:53:19 +11:00
Nigel Tao a6676851e3 pixconv: sse42-optimize swizzling RGB to RGBA
PNG (as a source pixel format) is RGB or RGBA order. Wuffs' std/png
benchmarks, like the other image formats, decode to BGRA order. *If*
those benchmarks are altered to target RGBA instead, we get:

name                                                       old speed     new speed     delta

wuffs_png_decode_image_40k_24bpp/clang14                   279MB/s ± 0%  293MB/s ± 0%  +5.11%  (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/clang14                 289MB/s ± 0%  303MB/s ± 0%  +4.89%  (p=0.008 n=5+5)

wuffs_png_decode_image_40k_24bpp/gcc12                     311MB/s ± 0%  332MB/s ± 0%  +6.84%  (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/gcc12                   325MB/s ± 0%  339MB/s ± 0%  +4.49%  (p=0.008 n=5+5)

When starting from 3-channel RGB, ending with RGBA is now as fast as
ending with BGRA.

Updates #141
2024-03-26 10:07:58 +11:00
Nigel Tao 793ab36569 std/lzip: add new package 2024-03-01 09:52:54 +11:00
Nigel Tao e5dc87e4d3 cgen: have writeStatementIOManip use switches 2024-02-09 15:21:37 +11:00
Nigel Tao be1b1b564c cgen: reformat "uint8_t *o_etc" 2024-02-09 15:09:50 +11:00
Nigel Tao d2ecc20141 std/xz: use io_forget_history 2024-02-09 15:06:11 +11:00
Nigel Tao e8af2d0635 lang: refactor anticipating io_forget_history 2024-02-09 14:55:35 +11:00
Nigel Tao d9bb6d4b4f base: add {io_reader,io_writer}.peek_undo_byte 2024-02-05 22:58:18 +11:00
Nigel Tao 992fd9622a base: rename bitvec256.get to bitvec256.get_u64 2023-12-27 17:05:54 +11:00
Nigel Tao 79af52bb24 std/xz: add SHA-256 checksum support 2023-12-26 17:04:16 +11:00
Nigel Tao eed1af7bee base: rename history_retain_length
It was renamed to dst_history_retain_length.

It also was removed from image_decoders and token_decoders. It only
applies to io_transformers, as retaining history applies to the
destination (not source) IO buffer.

Also adjust example/bzcat and example/zcat to apply the history retain
length to the dst (not src) buffer.
2023-12-17 12:26:08 +11:00
Nigel Tao b4e09690a7 pixconv: fix -Werror=sign-conversion
Updates #138
2023-12-15 11:52:18 +11:00
Nigel Tao 0164364106 ast: add TypeExpr.IsSmallInteger method 2023-12-14 10:22:38 +11:00
Nigel Tao c4d2fa13da cgen: apply disableWconversion even more often 2023-12-14 10:20:16 +11:00
Nigel Tao 9520d6de36 cgen: apply disableWconversion more often
Fixes #138
2023-12-14 10:07:50 +11:00
Nigel Tao bf0492b59a cgen: cast to uint8_t/uint16_t more often
Updates #138
2023-12-13 14:17:58 +11:00
Nigel Tao 988af1c03c floatconv: fix -Werror=sign-conversion
Updates #138
2023-12-13 13:08:06 +11:00
Nigel Tao 8de7f559e0 base: io_writer.limited_etc_fast now needs len>=1 2023-11-25 10:50:02 +11:00
Nigel Tao 82ea1985b4 base: add optional_u63 type 2023-11-19 12:02:24 +11:00
Nigel Tao e517ca4bee base: add io_writer.limited_copy_etc_return_cusp 2023-11-19 10:32:59 +11:00
Nigel Tao 2c2bb9baa5 cgen: simplify 1-elem in-case-of-recursion arrays 2023-11-05 11:44:21 +11:00
Nigel Tao 5407f39386 base: use wuffs_base__empty_slice_u8 more often 2023-11-02 22:43:01 +11:00