Commit Graph

31 Commits

Author SHA1 Message Date
Peter Harris 1108685c3c Fix arm64 invariance in NONE builds 2021-07-14 22:27:09 +01:00
pete 8b98d65c44 Add missing refactor of vfloat2 test file 2021-05-07 17:16:24 +01:00
pete f90be8e3eb Add VLA for compute_value_of_texel_int 2021-05-03 21:20:39 +01:00
pete f668a6e99b Add scalar vmask8 constructor 2021-04-16 22:11:46 +01:00
pete e5d6288f3e Add scalar vmask4 constructor 2021-04-13 23:35:07 +01:00
pete 207536a7bb Comment typo fixes 2021-03-30 22:13:59 +01:00
pete 1bfbf348ca Add float2 operator+= 2021-03-30 21:08:08 +01:00
Pete Harris f85e4ce126 Fix vint4.two_to_the_n tests 2021-03-11 11:22:18 +00:00
Peter Harris 422ddfebb7 Fix two_to_the_n test on NEON 2021-03-10 13:05:58 +00:00
pete 3b72af06ca Add bankers rounding unit test 2021-03-02 22:20:55 +00:00
pete 6ceaae8410 Use round(x) not floor(x + 0.5f) for invariance 2021-03-02 21:51:54 +00:00
Pete Harris 23af1ae5e3 Use vector versions of working pixel conversions (#230)
Replace conversions between storage types (unorm16, LNS16),
decode types(float16), and codec types (float), with vectorized
versions of the same algorithms.
2021-03-02 16:59:55 +00:00
Pete Harris fe730105a4 Make code OS/architecture invariant
This change makes the output of the codec invariant across operating systems (removed std::math dependency), and across CPU architectures (NEON vector code now matches the halving reduction patterns used by x86-64).
2021-03-01 13:20:05 +00:00
Pete Harris b11d6e4819 Make codec invariant across None/SSE/AVX2 builds (#224)
This patch makes the none (no SIMD), SSE, and AVX2 builds invariant with respect to each other. Prior to this only the SSE2 and 4.1 builds were invariant. This is a  fix for #223.

Four classes of change were needed to avoid reassociation rounding differences:

* Horizontal sums in a vector must match the odd-even reduce used by the SIMD cases, even for non-SIMD code, to ensure consistent reduction sums.
* All vector body accumulators that use lane-wise accumulation must use the same accumulator width, irrespective of instruction set, to ensure consistent lane-wise partial sums. For this reason the 1-wide VLA fallback has been removed, as we decided to use 4-wide accumulators. 
* AVX2 vector body accumulators must split into two 4-wide operations, and sequentially adding these into the running sum, to ensure consistent accumulator partial sums.  
* Vector loop bodies that use a loop tail for accumulation must execute the same number of times, irrespective of instruction set, to ensure that the loop tail runs the same number of times. This is because a the vector body will do odd+even partial sums (reduction across the vector), whereas the loop tail will do linear partial sums (iterating though the remaining tail). 

For this patch I've implemented the last bullet simply by rounding down all vector bodies that use accumulators and loop tails to a multiple of 8. This will reduce the number of vectorized loop iterations for 4-wide hardware in some cases, e.g. for an iteration count of 13, the left over is 5, which would have run one more vectorized path. Measured impact is small and only hits some block sizes, although 6x6 is impacted by ~2% on -thorough. This will be optimized in a follow-on patch.
2021-02-25 09:34:45 +00:00
Pete Harris 8ece971630 Vectorize decimation search (#221)
This implementation provides an AVX2 accelerated path for decimation table searches. It primarily helps larger block sizes, as use of weight grid decimation is more likely, and there are more texels to pack out vector operations.
2021-02-24 16:29:20 +00:00
pete 9ba78960dc Make vec4 normalize ISA agnostic, add _safe ver 2021-02-20 16:17:22 +00:00
Pete Harris 6fc0531e78 Implement vec4 support for float16 conversions (#214)
This PR implements the ability to convert floats stored in vfloat4 vectors to fp16 bit patterns stored in vint4 vectors. Scalar versions are also provided as overloaded functions of the same name, for sake of convenience.

The code has been refactored to take advantage of the vectorization opportunities this gives, in particular using NEON (Arm) and F16C (x86-64) ISA support for float<>fp16 conversion. The F16C support is tied to the AVX2 enable config option, it is not a separate enable. In cases where the soft-float code is not needed, code size reduces by ~5KB.
2021-02-16 23:29:56 +00:00
pete 7c3a36dbd0 Add vint4 unaligned store 2021-02-15 21:50:07 +00:00
pete 0840e3a55e Make all builds ISA invariant, and remove option 2021-02-15 08:44:58 +00:00
pete 1639c88f49 Use vfloat4 to back float3 types, allowing SIMD 2021-02-14 00:48:08 +00:00
pete 8a12563e18 Fix vint4.set_lane on SSE2 2021-02-13 19:31:07 +00:00
pete 01d4caaf08 Replace int4/uint4 with vint4 and remove vtype4 2021-02-13 17:03:29 +00:00
pete 0b9c1b23c7 Add more vint4 functions to SIMD library 2021-02-13 16:17:16 +00:00
Pete Harris affbeea396 Migrate to vfloat4 everywhere (#212)
Prior to this PR we had two vec4 implementations for floats, the legacy "float4" and the newer "vfloat4". The newer vfloat4 is a superset of the capabilities of the float4, and using it everywhere would give other opportunities to optimize by e.g. using the conditional select functionality rather than scalarizing chunks of vector code.

This patch is just the basic migration - where possible I've translated the original code without additional refactoring. Further optimizations to make better use of the vfloat4 functionality will come later. Overall this patch has no impact on IQ or performance, but does give a slight reduction in code size.
2021-02-11 09:15:26 +00:00
pete e824c20106 Remove data table for angular steppings an stepsizes
This replaces the angular_steppings table with a computationally
generated one, where the steppings are evenly spaced 1-40.
This isn't quite as effective, reducing quality by up to 0.05dB,
but improves performance by 3-6%.
2021-01-20 20:52:25 +00:00
pete 2618393f53 Add more functions to vector library 2021-01-13 00:45:18 +00:00
pete 524c27e257 Make scalar and vector horizontal vector ops 2021-01-13 00:17:41 +00:00
Pete Harris 39f0260928 Implement optimizations for compute_error_squared_rgb/a() (#198)
This implementation alters the algorithm and vectorizes these two functions.

The algorithm change will have a minor image quality impact; it now uses a faster approximation for selecting which component to assign to a second plane when choosing a partition. There is an insignificant IQ hit on -medium (under < 0.01dB), as we rarely use two planes anyway, and a slightly larger one on -thorough (under < -0.05dB). The significant (>10%) performance gain on -thorough is worth the quality loss (i.e. users are more likely to use -thorough if it's faster, and the overall IQ gain vs medium is still net positive).
2021-01-11 22:10:03 +00:00
Pete Harris 1b90f69a61 Implement SIMD optimized compute_error_for_weight_set (#197)
This PR vectorizes the implementation of the compute_error_for_weight_set() function using the vector-length agnostic SIMD support. It is bit-exact with the original implementation, so no image diffs are expected.

To make this vectorizable it needs to switch some structures from AOS to SOA, but we can't use these everywhere, so we duplicate some data tables in the decimation table and store both array orderings.

5-7% faster for -thorough
2-4% faster for -medium
1-2% faster for -fast
Neutral for -fastest
2021-01-11 22:05:05 +00:00
pete abba3c6c77 Enable full None SIMD vfloat4 and enable in unit tests 2021-01-01 23:44:22 +00:00
Pete Harris fb388737fb Add Arm aarch64 builds and NEON acceleration (#191)
This PR adds support for Arm aarch64 builds, including the corresponding NEON accelerated vector library.

As part of this work I also improved testing:

- Native C++ unit tests support using `googletest` integrated into CMake/CTest. 
- First unit test suite added, for 4-wide SIMD implementations.
- Command line functional tests can target any build, not just AVX2.
2021-01-01 23:27:18 +00:00