337 Commits

Author SHA1 Message Date
Martin Storsjö e1bd6f76c2 checkasm: Readd a dependency on threads
3a2a874994, which switched to using
the checkasm core from the separate checkasm project, removed the
thread dependency from the checkasm executable, as the checkasm
library itself has a thread dependency.

However, checkasm doesn't always include that thread dependency,
it only does that when pthread_setaffinity_np is detected.

The dav1d object files themselves use pthreads as well, causing
undefined symbols if checkasm doesn't link in pthreads.

This should fix linking on OpenBSD after
3a2a874994, fixing issue #467.
2026-05-03 12:42:39 +03:00
Martin Storsjö 04b69f93e5 checkasm: Reinstate check for TRIM_DSP_FUNCTIONS
This was lost in 3a2a874994.

Without this, checkasm ends up printing a quite confusing output
consisting only of the functions that have two or more assembly
implementations, if trim_dsp happens to be enabled.
2026-01-14 22:29:38 +02:00
Martin Storsjö 574e7f4727 checkasm: Pass HAVE_C11_GENERIC to checkasm as -DCHECKASM_HAVE_GENERIC=1/0
For this to have an effect, it requires using a newer version of
the wrapped checkasm subproject; including checkasm commit
be05a7972e47c658a7c5c186294d27caa5735db2 or newer.
2026-01-07 16:22:18 +02:00
Martin Storsjö b2f9c10670 checkasm: Fix building with MSVC
The glue code in our headers, for integrating with the external
checkasm, was incompatible with MSVC.

MSVC has a nonstandard handling of __VA_ARGS__ with macros; when
one macro invokes another macro, __VA_ARGS__ gets treated as one
single parameter and can't map to more than one parameter in the
invoked macro. (In other words, when calling another macro,
__VA_ARGS__ must map in its entirety to a ... parameter of the
other macro.)

Modern versions of MSVC do implement the correct mode as well,
but defaults to the old one for backwards compatibility. To
choose the new mode, we'd have to build our code with
-Zc:preprocessor. That's certainly doable, but it's fairly easy to
avoid the issue as well.

To avoid this issue, change the variadic PIXEL_RECT(...) to explicitly
names its arguments. There's actually no variability in the arguments
involved here. (Alternatively, we could force the preprocessor to expand
the arguments one extra time, avoiding the issue, with e.g.
"#define EXPAND(x) x" and wrapping PIXEL_RECT with it, e.g.
"#define PIXEL_RECT(...) EXPAND(BUF_RECT(pixel, __VA_ARGS__))".)

See [1], [2] and [3] for more discussion on the matter.

[1] https://stackoverflow.com/a/5134656/3115956
[2] https://stackoverflow.com/a/7459803/3115956
[2] https://learn.microsoft.com/en-us/cpp/preprocessor/preprocessor-experimental-overview?view=msvc-160
2026-01-07 11:57:09 +02:00
Niklas Haas 3a2a874994 tests/checkasm: switch to external checkasm
There are a number of benefits tied to the upstream / third-party checkasm
version, including:

- Improved long-term maintainability, code reuse with other projects, etc.

- Vastly improved overall performance / runtime for benchmarking, due
  primarily to the ability to scale the runtime of each test to that test's
  complexity.

- Much more robust statistical analysis of benchmarking results; including
  robust outlier rejection, an estimation of the histogram, and the ability
  to report the variance / stddev in addition to the (trimmed) mean.

- Interactive HTML and JSON output formats in addition to CSV/TSV.

- More readable and user-friendly output across the board, especially for
  failures and data dumps (e.g. also showing errors inside padding bytes).

- Better cross-platform support, including dynamic fallback of timer
  implementations on ARM platforms, a better RISC-V harness, and more.

There are multiple approaches to how we can solve the problem of integrating
this third party checkasm into dav1d, but I think the hybrid approach of
loading it as an external dependency, falling back to a meson wrap file,
provides the best overall compromise. This avoids the messiness of git e.g.
git submodules, while still allowing us to pin individual tags.
2026-01-01 17:33:55 +01:00
Niklas Haas 3374404179 tests/checkasm/loopfilter: avoid printf format warning
Upstream checkasm adds a printf format attribute to report(), so we should
avoid directly passing the name string to silence a warning.
2026-01-01 12:29:02 +01:00
Henrik Gramner 43f3b8d33b checkasm: Group itx functions by their largest dimension
This reduces the number of itx reports per instruction set from
19 to 5, which avoids excessively flooding the console output.
2025-12-09 22:02:52 +01:00
Henrik Gramner 165e9e251b checkasm: Only run DC-only itx tests for dct_dct 2025-12-09 21:01:10 +01:00
Cameron Cawley 28b165940d Use CLOCK_REALTIME for providing the initial seed value
CLOCK_MONOTONIC is specified as returning time "since an unspecified point in the past". On RISC OS with UnixLib this returns the time since the last hard reset, but with SharedCLibrary this returns the time since the program started - combined with the coarse resolution used internally, this almost always results in a seed of 0.

CLOCK_REALTIME meanwhile is specified as returning time since the epoch, so it should behave consistently across all platforms.
2025-11-22 23:30:02 +00:00
Martin Storsjö 2eac05d648 checkasm: arm: Use X() instead of inline ifdefs
This works fine when the referenced symbol has the same prefix
as PRIVATE_PREFIX in the same file; otherwise we could also
create a macro like X() that only prepends the extern symbol
prefix but no symbol namespace prefix.
2025-11-12 15:54:40 +02:00
Henrik Gramner 29efbb9496 refmvs: Shrink mfmv_ref arrays
Includes updates to load_tmvs() asm implementations.
2025-05-28 19:01:45 +02:00
Brad Smith cd5bfa124a riscv: Fix building on non-Linux OS's
CLOCK_MONOTONIC_RAW is not POSIX/portable.
2024-12-29 18:32:23 +00:00
Martin Storsjö f8d2620d82 checkasm: looprestoration: Do strict bounds checking of the output
This would allow to immediately detect unintended writes out of
bounds like the ones fixed in
72b5380757 and
1c7433a5eb.

Extend the PIXEL_RECT macro to provide a variable containing the
full, padded height of the buffer, for uses that operate on the
full buffer.

Allow overwriting past the right edge of the target output rectangle,
up to an alignment of 64 pixels, but allow no overwrite past the
bottom.
2024-11-21 09:05:33 +00:00
Marvin Scholz c8fdaa8611 checkasm: add loongarch GAS file to checkasm_asm_sources
This is not an object so putting it in the objects variable seems wrong
and would also break using gaspp for that file.
2024-11-16 14:51:35 +01:00
Martin Storsjö 55fb9433b7 checkasm: Remove leftover comment
This comment no longer is relevant after
9278a14cf4.
2024-10-18 14:37:28 +00:00
Nathan E. Egge 7f2bb2fbc9 riscv: Move get_vlenb() from checkasm_ to dav1d_ 2024-10-09 16:18:42 +02:00
Luca Barbato 21d9f29d38 tests: Add a fail fast option 2024-10-02 13:00:26 +02:00
guxiwei e3101ddc8b LoongArch64: Implement checked_call()
Now checkasm calls the test function 'func_new' through
the wrapper 'checked_call' instead of calling it directly.
The purpose of the wrapper is to check if 'func_new' correctly
saves and restores static registers. The wrapper writes dirty
values to the static registers, and after calling 'func_new',
it checks if the dirty values in the static registers remain consistent.

Change-Id: Ia9290b55ab0f2dd87801f6fd175813d3f717d851
2024-09-30 06:37:00 +00:00
guxiwei 02309b9f60 msac: Add msac_decode_bool_equia_lsx and msac_decode_hi_tok_lsx
The performance data is as follows:
msac_decode_bool_equi_c:             0.4 ( 1.00x)
msac_decode_bool_equi_lsx:           0.3 ( 1.07x)
msac_decode_hi_tok_c:                1.8 ( 1.00x)
msac_decode_hi_tok_lsx:              1.4 ( 1.27x)

Change-Id: Ic2f2678cf699bb22c579424af71ae2603e228482
2024-09-30 06:37:00 +00:00
Cameron Cawley a7a40a3fde Define __ARM_ARCH with older compilers
This is needed for GCC 4.7 and earlier, as well as Visual Studio 2022 version 17.9 and earlier.
2024-09-18 18:29:36 +00:00
Cameron Cawley 8e993f4d0b Support older ARM versions with checkasm 2024-09-18 18:29:36 +00:00
Michael Bradshaw dd32cd5027 Use #if HAVE_* instead of #ifdef HAVE_* 2024-09-12 20:40:08 +00:00
Martin Storsjö 166e1df543 tests: Add an option to dav1d_argon.bash for using a wrapper tool
This allows executing all the tools within e.g. valgrind.

This matches the "meson test --wrap <tool>" feature.
2024-09-06 20:32:45 +00:00
Cameron Cawley 7490d98654 Only include unistd.h and pthread.h when necessary 2024-08-29 21:15:22 +00:00
Ronald S. Bultje ca83ee6d9d itx: restrict number of columns iterated over based on EOB 2024-06-17 12:44:34 -04:00
Henrik Gramner bb948769e3 tests: Verify dav1d command line in dav1d_argon.bash
Error out early instead of producing bogus mismatch errors in case
of an incorrect cpu mask for example.
2024-05-20 14:29:13 +02:00
Kyle Siefring 7f68f23c27 ARM64: Various optimizations for symbol decode
Changes stem from redesigning the reduction stage of the multisymbol
decode function.
* No longer use adapt4 for 5 possible symbol values
* Specialize reduction for 4/8/16 decode functions
* Modify control flow

+------------------------+--------------+--------------+---------------+
|                        |  Neoverse V1 |  Neoverse N1 |   Cortex A72  |
|                        | (Graviton 3) | (Graviton 2) |  (Graviton 1) |
+------------------------+-------+------+-------+------+-------+-------+
|                        |  Old  |  New |  Old  |  New |  Old  |  New  |
+------------------------+-------+------+-------+------+-------+-------+
| decode_bool_neon       |  13.0 | 12.9 |  14.9 | 14.0 |  39.3 |  29.0 |
+------------------------+-------+------+-------+------+-------+-------+
| decode_bool_adapt_neon |  15.4 | 15.6 |  17.5 | 16.8 |  41.6 |  33.5 |
+------------------------+-------+------+-------+------+-------+-------+
| decode_bool_equi_neon  |  11.3 | 12.0 |  14.0 | 12.2 |  35.0 |  26.3 |
+------------------------+-------+------+-------+------+-------+-------+
| decode_hi_tok_c        |  73.7 | 57.8 |  73.4 | 60.5 | 130.1 | 103.9 |
+------------------------+-------+------+-------+------+-------+-------+
| decode_hi_tok_neon     |  63.3 | 48.2 |  65.2 | 51.2 | 119.0 | 105.3 |
+------------------------+-------+------+-------+------+-------+-------+
| decode_symbol_\        |  28.6 | 22.5 |  28.4 | 23.5 |  67.8 |  55.1 |
| adapt4_neon            |       |      |       |      |       |       |
+------------------------+-------+------+-------+------+-------+-------+
| decode_symbol_\        |  29.5 | 26.6 |  29.0 | 28.8 |  76.6 |  74.0 |
| adapt8_neon            |       |      |       |      |       |       |
+------------------------+-------+------+-------+------+-------+-------+
| decode_symbol_\        |  31.6 | 31.2 |  33.3 | 33.0 |  77.5 |  68.1 |
| adapt16_neon           |       |      |       |      |       |       |
+------------------------+-------+------+-------+------+-------+-------+
2024-05-14 16:20:38 +00:00
Henrik Gramner cc1137c85b checkasm: Eliminate unreachable code in the Windows exception handler 2024-05-13 14:01:17 +02:00
Henrik Gramner 471549f268 checkasm: Avoid UB in setjmp() invocations
Both POSIX and the C standard places several environmental limits on
setjmp() invocations, with essentially anything beyond comparing the
return value with a constant as a simple branch condition being UB.

We were previously performing a function call using the setjmp()
return value as an argument, which is technically not allowed
even though it happened to work correctly in practice.

Some systems may loosen those restrictions and allow for more
flexible usage, but we shouldn't be relying on that.
2024-05-13 13:57:35 +02:00
Luca Barbato 700c36a687 ppc: Add pwr9 flag
Will be used to gate code using vec_absd and other useful instructions.
2024-05-10 18:58:47 +00:00
Kyle Siefring 37d52435d1 ARM64: Port msac improvements to more functions
Port improvements from the hi token functions to the rest of the symbol
adaption functions. These weren't originally ported since they didn't
work with arbitrary padding. In practice, zero padding is already used
and only the tests need to be updated.

Results - Neoverse N1

Old:
msac_decode_symbol_adapt4_c:         41.4 ( 1.00x)
msac_decode_symbol_adapt4_neon:      31.0 ( 1.34x)
msac_decode_symbol_adapt8_c:         54.5 ( 1.00x)
msac_decode_symbol_adapt8_neon:      32.2 ( 1.69x)
msac_decode_symbol_adapt16_c:        85.6 ( 1.00x)
msac_decode_symbol_adapt16_neon:     37.5 ( 2.28x)

New:
msac_decode_symbol_adapt4_c:         41.5 ( 1.00x)
msac_decode_symbol_adapt4_neon:      27.7 ( 1.50x)
msac_decode_symbol_adapt8_c:         55.7 ( 1.00x)
msac_decode_symbol_adapt8_neon:      30.1 ( 1.85x)
msac_decode_symbol_adapt16_c:        82.4 ( 1.00x)
msac_decode_symbol_adapt16_neon:     35.2 ( 2.34x)
2024-04-15 12:38:20 +00:00
Henrik Gramner dc9490134f meson: Enable parallel execution of checkasm in 'meson test'
It was originally disabled due to older meson versions mixing the output
of 'meson test -v' from different tests, which made the log difficult to
read. Newer versions however caches the output from each test as it runs
and prints it in one contiguous block, so that's no longer an issue.
2024-04-08 22:51:15 +02:00
Martin Storsjö 5e31720b89 checkasm: Add support for the private macOS kperf API for benchmarking
On AArch64, the performance counter registers usually are
restricted and not accessible from user space.

On macOS, we currently use mach_absolute_time() as timer on
aarch64. This measures wallclock time but with a very coarse
resolution.

There is a private API, kperf, that one can use for getting
high precision timers though. Unfortunately, it requires running
the checkasm binary as root (e.g. with sudo).

Also, as it is a private, undocumented API, it can potentially
change at any time.

This is handled by adding a new meson build option, for switching
to this timer. If the timer source in checkasm could be changed
at runtime with an option, this wouldn't need to be a build time
option.

This allows getting benchmarks like this:

mc_8tap_regular_w16_hv_8bpc_c:              1522.1 ( 1.00x)
mc_8tap_regular_w16_hv_8bpc_neon:            331.8 ( 4.59x)

Instead of this:

mc_8tap_regular_w16_hv_8bpc_c:                 9.0 ( 1.00x)
mc_8tap_regular_w16_hv_8bpc_neon:              1.9 ( 4.76x)

Co-authored-by: J. Dekker <jdek@itanimul.li>
2024-04-02 10:35:29 +00:00
Martin Storsjö fd60097eb2 checkasm: aarch64: Print the SVE vector length, if available 2024-03-04 23:04:51 +02:00
Henrik Gramner 85a10359cd checkasm: Add --list-cpuflags option
Prints a list of cpuflags available for the current architecture.

Flags which are supported on the current system will be printed in
green, and flags which are unsupported in red with a ~ prefix.
2024-02-29 00:13:23 +00:00
Arpad Panyik acc1121d2f Extend Arm and AArch64 run-time CPU feature detection
Add run-time CPU feature detection for DotProd, i8mm, SVE and SVE2.
SVE and SVE2 are AArch64-only features.
2024-02-28 16:32:28 +00:00
Nathan E. Egge 52948bbfcc riscv/checkasm: Print the RVV vector length, if available 2024-02-26 18:07:11 -05:00
Arpad Panyik f1d42ae8f1 AArch64: Enable benchmarks for 8-tap sharp filters
The 6-tap sub-pel filter specialisation uses different code paths for
sharp (8-tap) and regular/smooth (6-tap) filtering kernels.

This patch enables benchmarking for the different code paths.
2024-02-22 08:58:17 +01:00
Henrik Gramner 83ae3e9a47 checkasm: Improve msac tests
* Process the entire buffer to get better coverage of eob handling.

* Use a more reasonable buffer size.

* Ignore trailing dif bits to allow for more implementation flexibility.
2024-02-21 11:17:41 +00:00
Henrik Gramner bb26bdca06 tests: Automatically determine job count in dav1d_argon.bash
Default to using the number of logical cores divided by thread count.
2024-02-18 15:37:04 +01:00
Nathan E. Egge a6878be7e0 Alphabetize architecture defines and usage 2024-01-31 06:04:21 -05:00
Nathan E. Egge e67f630613 checkasm: riscv64: Print modified register names 2024-01-31 06:04:21 -05:00
Nathan E. Egge e7660b8b24 checkasm: riscv64: Add stack canary test 2024-01-31 06:04:21 -05:00
Nathan E. Egge 8ee8b9eba1 checkasm: Implement riscv64 checked_call() 2024-01-31 06:04:21 -05:00
Nathan E. Egge 43ee02a99c riscv64/itx: Add 4-point 8bpc RVV idtx transform
inv_txfm_add_4x4_identity_identity_0_8bpc_c:      534.6 ( 1.00x)
inv_txfm_add_4x4_identity_identity_0_8bpc_rvv:     72.2 ( 7.40x)
inv_txfm_add_4x4_identity_identity_1_8bpc_c:      534.7 ( 1.00x)
inv_txfm_add_4x4_identity_identity_1_8bpc_rvv:     72.3 ( 7.40x)
2024-01-31 06:04:19 -05:00
Nathan E. Egge 7362fcf653 riscv: Add support for checkasm --bench 2024-01-30 12:16:54 -05:00
Henrik Gramner 227c37f74a Use a constant length for progress reporting in dav1d_argon.bash 2024-01-24 00:29:54 +00:00
Henrik Gramner cdb2a1a27b Avoid printing full path names in dav1d_argon.bash
Only print the paths relative to the argon directory. This avoids
excessive terminal line wrapping due to long path names which
otherwise interferes with the '\r' usage for progress reporting.
2024-01-24 00:29:54 +00:00
Matthias Dressel 2c9bbb4908 meson: Add 'enable_seek_stress' option
Allows to explicitly enable/disable seek-stress tests.
2024-01-23 17:47:46 +00:00
jinbo 38bc00849a loongarch: Improve the performance of msac series functions
Relative speedup over C code:

msac_decode_bool_c:                            0.5 ( 1.00x)
msac_decode_bool_lsx:                          0.5 ( 1.09x)
msac_decode_bool_adapt_c:                      0.7 ( 1.00x)
msac_decode_bool_adapt_lsx:                    0.6 ( 1.20x)
msac_decode_symbol_adapt4_c:                   1.3 ( 1.00x)
msac_decode_symbol_adapt4_lsx:                 1.0 ( 1.30x)
msac_decode_symbol_adapt8_c:                   2.1 ( 1.00x)
msac_decode_symbol_adapt8_lsx:                 1.0 ( 2.05x)
msac_decode_symbol_adapt16_c:                  3.7 ( 1.00x)
msac_decode_symbol_adapt16_lsx:                0.8 ( 4.77x)
2024-01-21 15:31:46 +08:00