mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	cpu: add zero_denormals method
Add a method to enable/disable the denormals flush-to-zero and denormals-as-zero CPU options. Add a config option to make it possible to disable this again. Fixes high CPU usage when dealing with denormals, which can happen in many DSP functions. Fixes #1681
This commit is contained in:
		
							parent
							
								
									036371c48f
								
							
						
					
					
						commit
						85d5c8cd6c
					
				
					 6 changed files with 70 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -123,3 +123,40 @@ arm_init(struct impl *impl)
 | 
			
		|||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static int arm_zero_denormals(void *object, bool enable)
 | 
			
		||||
{
 | 
			
		||||
#if defined(__aarch64__)
 | 
			
		||||
	uint64_t cw;
 | 
			
		||||
	if (enable)
 | 
			
		||||
		__asm__ __volatile__(
 | 
			
		||||
			"mrs	%0, fpcr		\n"
 | 
			
		||||
			"orr	%0, %0, #0x1000000	\n"
 | 
			
		||||
			"msr	fpcr, %0		\n"
 | 
			
		||||
			"isb				\n"
 | 
			
		||||
			: "=r"(cw)::"memory");
 | 
			
		||||
	else
 | 
			
		||||
		__asm__ __volatile__(
 | 
			
		||||
			"mrs	%0, fpcr		\n"
 | 
			
		||||
			"and	%0, %0, #~0x1000000	\n"
 | 
			
		||||
			"msr	fpcr, %0		\n"
 | 
			
		||||
			"isb				\n"
 | 
			
		||||
			: "=r"(cw)::"memory");
 | 
			
		||||
#else
 | 
			
		||||
	uint32_t cw;
 | 
			
		||||
	if (enable)
 | 
			
		||||
		__asm__ __volatile__(
 | 
			
		||||
			"vmrs	%0, fpscr		\n"
 | 
			
		||||
			"orr	%0, %0, #0x1000000	\n"
 | 
			
		||||
			"vmsr	fpscr, %0		\n"
 | 
			
		||||
			: "=r"(cw)::"memory");
 | 
			
		||||
	else
 | 
			
		||||
		__asm__ __volatile__(
 | 
			
		||||
			"vmrs	%0, fpscr		\n"
 | 
			
		||||
			"and	%0, %0, #~0x1000000	\n"
 | 
			
		||||
			"vmsr	fpscr, %0		\n"
 | 
			
		||||
			: "=r"(cw)::"memory");
 | 
			
		||||
#endif
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue