From fdc1ac731d7b4d5d49e20fb52183eeb65c8af17e Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Tue, 2 Feb 2021 11:34:37 +0800 Subject: [PATCH] Update starch to upstream commit 521d7632a1076733030017a571facd1cd304e669 --- dsp/generated/benchmark.c | 14 ++------------ starch/example/generated/benchmark.c | 25 +++++++++++++++++++++---- starch/templates/benchmark.c.template | 4 ++-- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/dsp/generated/benchmark.c b/dsp/generated/benchmark.c index 56a590c..1fd014a 100644 --- a/dsp/generated/benchmark.c +++ b/dsp/generated/benchmark.c @@ -154,7 +154,6 @@ static void starch_benchmark_one_magnitude_uc8( starch_magnitude_uc8_regentry * starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -267,7 +266,6 @@ static void starch_benchmark_one_magnitude_uc8_aligned( starch_magnitude_uc8_ali starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -380,7 +378,6 @@ static void starch_benchmark_one_magnitude_power_uc8( starch_magnitude_power_uc8 starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -493,7 +490,6 @@ static void starch_benchmark_one_magnitude_power_uc8_aligned( starch_magnitude_p starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -606,7 +602,6 @@ static void starch_benchmark_one_magnitude_sc16( starch_magnitude_sc16_regentry starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -719,7 +714,6 @@ static void starch_benchmark_one_magnitude_sc16_aligned( starch_magnitude_sc16_a starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -832,7 +826,6 @@ static void starch_benchmark_one_magnitude_sc16q11( starch_magnitude_sc16q11_reg starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -945,7 +938,6 @@ static void starch_benchmark_one_magnitude_sc16q11_aligned( starch_magnitude_sc1 starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -1058,7 +1050,6 @@ static void starch_benchmark_one_mean_power_u16( starch_mean_power_u16_regentry starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -1171,7 +1162,6 @@ static void starch_benchmark_one_mean_power_u16_aligned( starch_mean_power_u16_a starch_benchmark_validation_failed = true; return; } - if (starch_benchmark_validate_only) { fprintf(stderr, "validation ok\n"); return; @@ -1253,7 +1243,7 @@ static void starch_benchmark_run_mean_power_u16_aligned( const uint16_t * arg0, #define STARCH_BENCHMARK(_function) starch_ ## _function ## _benchmark #define STARCH_BENCHMARK_VERIFY(_function) starch_ ## _function ## _benchmark_verify #define STARCH_BENCHMARK_RUN(_function, ...) starch_benchmark_run_ ## _function ( __VA_ARGS__ ) -#define STARCH_BENCHMARK_ALLOC(_count, _type) starch_benchmark_aligned_alloc(1, alignof(_type), (_count) * sizeof(_type)) +#define STARCH_BENCHMARK_ALLOC(_count, _type) ((_type *) starch_benchmark_aligned_alloc(1, alignof(_type), (_count) * sizeof(_type))) #define STARCH_BENCHMARK_FREE(_ptr) starch_benchmark_aligned_free(_ptr) #include "../benchmark/magnitude_sc16_benchmark.c" @@ -1281,7 +1271,7 @@ static void starch_benchmark_run_mean_power_u16_aligned( const uint16_t * arg0, #define STARCH_BENCHMARK(_function) starch_ ## _function ## _aligned_benchmark #define STARCH_BENCHMARK_VERIFY(_function) starch_ ## _function ## _aligned_benchmark_verify #define STARCH_BENCHMARK_RUN(_function, ...) starch_benchmark_run_ ## _function ## _aligned ( __VA_ARGS__ ) -#define STARCH_BENCHMARK_ALLOC(_count, _type) starch_benchmark_aligned_alloc(STARCH_MIX_ALIGNMENT, alignof(_type), (_count) * sizeof(_type)) +#define STARCH_BENCHMARK_ALLOC(_count, _type) ((_type *) starch_benchmark_aligned_alloc(STARCH_MIX_ALIGNMENT, alignof(_type), (_count) * sizeof(_type))) #define STARCH_BENCHMARK_FREE(_ptr) starch_benchmark_aligned_free(_ptr) #include "../benchmark/magnitude_sc16_benchmark.c" diff --git a/starch/example/generated/benchmark.c b/starch/example/generated/benchmark.c index 8e1908e..5baf491 100644 --- a/starch/example/generated/benchmark.c +++ b/starch/example/generated/benchmark.c @@ -42,6 +42,8 @@ static starch_benchmark_flavor_list *starch_benchmark_flavor_whitelist = NULL; static starch_benchmark_flavor_list *starch_benchmark_flavor_blacklist = NULL; static bool starch_benchmark_list_only = false; +static bool starch_benchmark_validate_only = false; +static bool starch_benchmark_validation_failed = false; static bool starch_benchmark_top_only = false; static unsigned starch_benchmark_iterations = 1; @@ -149,6 +151,11 @@ static void starch_benchmark_one_subtract_n( starch_subtract_n_regentry * _entry /* verify correctness of the output */ if (! starch_subtract_n_benchmark_verify ( arg0, arg1, arg2, arg3 )) { fprintf(stderr, "skipped (verification failed)\n"); + starch_benchmark_validation_failed = true; + return; + } + if (starch_benchmark_validate_only) { + fprintf(stderr, "validation ok\n"); return; } @@ -256,6 +263,11 @@ static void starch_benchmark_one_subtract_n_aligned( starch_subtract_n_aligned_r /* verify correctness of the output */ if (! starch_subtract_n_aligned_benchmark_verify ( arg0, arg1, arg2, arg3 )) { fprintf(stderr, "skipped (verification failed)\n"); + starch_benchmark_validation_failed = true; + return; + } + if (starch_benchmark_validate_only) { + fprintf(stderr, "validation ok\n"); return; } @@ -335,7 +347,7 @@ static void starch_benchmark_run_subtract_n_aligned( const uint16_t * arg0, unsi #define STARCH_BENCHMARK(_function) starch_ ## _function ## _benchmark #define STARCH_BENCHMARK_VERIFY(_function) starch_ ## _function ## _benchmark_verify #define STARCH_BENCHMARK_RUN(_function, ...) starch_benchmark_run_ ## _function ( __VA_ARGS__ ) -#define STARCH_BENCHMARK_ALLOC(_count, _type) starch_benchmark_aligned_alloc(1, alignof(_type), (_count) * sizeof(_type)) +#define STARCH_BENCHMARK_ALLOC(_count, _type) ((_type *) starch_benchmark_aligned_alloc(1, alignof(_type), (_count) * sizeof(_type))) #define STARCH_BENCHMARK_FREE(_ptr) starch_benchmark_aligned_free(_ptr) #include "../benchmark/subtract_n_benchmark.c" @@ -359,7 +371,7 @@ static void starch_benchmark_run_subtract_n_aligned( const uint16_t * arg0, unsi #define STARCH_BENCHMARK(_function) starch_ ## _function ## _aligned_benchmark #define STARCH_BENCHMARK_VERIFY(_function) starch_ ## _function ## _aligned_benchmark_verify #define STARCH_BENCHMARK_RUN(_function, ...) starch_benchmark_run_ ## _function ## _aligned ( __VA_ARGS__ ) -#define STARCH_BENCHMARK_ALLOC(_count, _type) starch_benchmark_aligned_alloc(STARCH_MIX_ALIGNMENT, alignof(_type), (_count) * sizeof(_type)) +#define STARCH_BENCHMARK_ALLOC(_count, _type) ((_type *) starch_benchmark_aligned_alloc(STARCH_MIX_ALIGNMENT, alignof(_type), (_count) * sizeof(_type))) #define STARCH_BENCHMARK_FREE(_ptr) starch_benchmark_aligned_free(_ptr) #include "../benchmark/subtract_n_benchmark.c" @@ -404,6 +416,7 @@ static void starch_benchmark_usage(const char *argv0) " -N FLAVOR Add FLAVOR to blacklist\n" " (default: no blacklist, run all runtime-supported flavors)\n" " -l List compiled-in implementations but don't benchmark them\n" + " -V Run validation tests, but don't run benchmarks\n" " -t Include only the top candidate per function in wisdom output\n" " -i ITERS Run benchmark ITERS times and use the mean. If ITERS > 2, ignore\n" " the smallest and largest runs when calculating the mean.\n" @@ -453,7 +466,7 @@ int main(int argc, char **argv) const char *output_path = NULL; int opt; - while ((opt = getopt(argc, argv, "r:o:F:N:i:lht")) != -1) { + while ((opt = getopt(argc, argv, "r:o:F:N:i:lhtV")) != -1) { switch (opt) { case 'r': if (starch_read_wisdom(optarg) < 0) { @@ -495,6 +508,10 @@ int main(int argc, char **argv) starch_benchmark_iterations = atoi(optarg); break; + case 'V': + starch_benchmark_validate_only = true; + break; + case 'h': starch_benchmark_usage(argv[0]); return 0; @@ -565,5 +582,5 @@ int main(int argc, char **argv) fprintf(stderr, "%s: wrote sorted wisdom to %s\n", argv[0], output_path); } - return 0; + return starch_benchmark_validation_failed ? 1 : 0; } diff --git a/starch/templates/benchmark.c.template b/starch/templates/benchmark.c.template index c77bd59..766ec84 100644 --- a/starch/templates/benchmark.c.template +++ b/starch/templates/benchmark.c.template @@ -249,7 +249,7 @@ static void starch_benchmark_run_${function.name}( ${function.declaration_arglis #define STARCH_BENCHMARK(_function) ${gen.symbol_prefix} ## _function ## _benchmark #define STARCH_BENCHMARK_VERIFY(_function) ${gen.symbol_prefix} ## _function ## _benchmark_verify #define STARCH_BENCHMARK_RUN(_function, ...) starch_benchmark_run_ ## _function ( __VA_ARGS__ ) -#define STARCH_BENCHMARK_ALLOC(_count, _type) starch_benchmark_aligned_alloc(1, alignof(_type), (_count) * sizeof(_type)) +#define STARCH_BENCHMARK_ALLOC(_count, _type) ((_type *) starch_benchmark_aligned_alloc(1, alignof(_type), (_count) * sizeof(_type))) #define STARCH_BENCHMARK_FREE(_ptr) starch_benchmark_aligned_free(_ptr) % for source in gen.benchmark_files: @@ -275,7 +275,7 @@ static void starch_benchmark_run_${function.name}( ${function.declaration_arglis #define STARCH_BENCHMARK(_function) ${gen.symbol_prefix} ## _function ## _aligned_benchmark #define STARCH_BENCHMARK_VERIFY(_function) ${gen.symbol_prefix} ## _function ## _aligned_benchmark_verify #define STARCH_BENCHMARK_RUN(_function, ...) starch_benchmark_run_ ## _function ## _aligned ( __VA_ARGS__ ) -#define STARCH_BENCHMARK_ALLOC(_count, _type) starch_benchmark_aligned_alloc(STARCH_MIX_ALIGNMENT, alignof(_type), (_count) * sizeof(_type)) +#define STARCH_BENCHMARK_ALLOC(_count, _type) ((_type *) starch_benchmark_aligned_alloc(STARCH_MIX_ALIGNMENT, alignof(_type), (_count) * sizeof(_type))) #define STARCH_BENCHMARK_FREE(_ptr) starch_benchmark_aligned_free(_ptr) % for source in gen.benchmark_files: