mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	bench: add avx resampler to benchmark
This commit is contained in:
		
							parent
							
								
									e7ef13e310
								
							
						
					
					
						commit
						fe6ebd0e8a
					
				
					 2 changed files with 19 additions and 4 deletions
				
			
		| 
						 | 
					@ -80,6 +80,8 @@ static void run_test1(const char *name, const char *impl, bool in_packed, bool o
 | 
				
			||||||
	clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
						clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
				
			||||||
	t2 = SPA_TIMESPEC_TO_NSEC(&ts);
 | 
						t2 = SPA_TIMESPEC_TO_NSEC(&ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(n_results < MAX_RESULTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	results[n_results++] = (struct stats) {
 | 
						results[n_results++] = (struct stats) {
 | 
				
			||||||
		.n_samples = n_samples,
 | 
							.n_samples = n_samples,
 | 
				
			||||||
		.n_channels = n_channels,
 | 
							.n_channels = n_channels,
 | 
				
			||||||
| 
						 | 
					@ -236,8 +238,6 @@ int main(int argc, char *argv[])
 | 
				
			||||||
	test_interleave();
 | 
						test_interleave();
 | 
				
			||||||
	test_deinterleave();
 | 
						test_deinterleave();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spa_assert(n_results <= MAX_RESULTS);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	qsort(results, n_results, sizeof(struct stats), compare_func);
 | 
						qsort(results, n_results, sizeof(struct stats), compare_func);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < n_results; i++) {
 | 
						for (i = 0; i < n_results; i++) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,12 +56,13 @@ static const int in_rates[] = { 44100, 44100, 48000, 96000, 22050, 96000 };
 | 
				
			||||||
static const int out_rates[] = { 44100, 48000, 44100, 48000, 48000, 44100 };
 | 
					static const int out_rates[] = { 44100, 48000, 44100, 48000, 48000, 44100 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MAX_RESAMPLER	4
 | 
					#define MAX_RESAMPLER	5
 | 
				
			||||||
#define MAX_SIZES	SPA_N_ELEMENTS(sample_sizes)
 | 
					#define MAX_SIZES	SPA_N_ELEMENTS(sample_sizes)
 | 
				
			||||||
#define MAX_RATES	SPA_N_ELEMENTS(in_rates)
 | 
					#define MAX_RATES	SPA_N_ELEMENTS(in_rates)
 | 
				
			||||||
 | 
					#define MAX_RESULTS	MAX_RESAMPLER * MAX_SIZES * MAX_RATES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static uint32_t n_results = 0;
 | 
					static uint32_t n_results = 0;
 | 
				
			||||||
static struct stats results[MAX_RESAMPLER * MAX_SIZES * MAX_RATES];
 | 
					static struct stats results[MAX_RESULTS];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void run_test1(const char *name, const char *impl, struct resample *r, int n_samples)
 | 
					static void run_test1(const char *name, const char *impl, struct resample *r, int n_samples)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -90,6 +91,8 @@ static void run_test1(const char *name, const char *impl, struct resample *r, in
 | 
				
			||||||
	clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
						clock_gettime(CLOCK_MONOTONIC, &ts);
 | 
				
			||||||
	t2 = SPA_TIMESPEC_TO_NSEC(&ts);
 | 
						t2 = SPA_TIMESPEC_TO_NSEC(&ts);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_assert(n_results < MAX_RESULTS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	results[n_results++] = (struct stats) {
 | 
						results[n_results++] = (struct stats) {
 | 
				
			||||||
		.in_rate = r->i_rate,
 | 
							.in_rate = r->i_rate,
 | 
				
			||||||
		.out_rate = r->o_rate,
 | 
							.out_rate = r->o_rate,
 | 
				
			||||||
| 
						 | 
					@ -160,6 +163,18 @@ int main(int argc, char *argv[])
 | 
				
			||||||
		resample_free(&r);
 | 
							resample_free(&r);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					#if defined (HAVE_AVX) && defined(HAVE_FMA)
 | 
				
			||||||
 | 
						for (i = 0; i < SPA_N_ELEMENTS(in_rates); i++) {
 | 
				
			||||||
 | 
							spa_zero(r);
 | 
				
			||||||
 | 
							r.channels = 2;
 | 
				
			||||||
 | 
							r.cpu_flags = SPA_CPU_FLAG_AVX | SPA_CPU_FLAG_FMA3;
 | 
				
			||||||
 | 
							r.i_rate = in_rates[i];
 | 
				
			||||||
 | 
							r.o_rate = out_rates[i];
 | 
				
			||||||
 | 
							impl_native_init(&r);
 | 
				
			||||||
 | 
							run_test("native", "avx", &r);
 | 
				
			||||||
 | 
							resample_free(&r);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < SPA_N_ELEMENTS(in_rates); i++) {
 | 
						for (i = 0; i < SPA_N_ELEMENTS(in_rates); i++) {
 | 
				
			||||||
		spa_zero(r);
 | 
							spa_zero(r);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue