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:
Wim Taymans 2021-10-11 14:54:48 +02:00
parent 036371c48f
commit 85d5c8cd6c
6 changed files with 70 additions and 3 deletions

View file

@ -15,6 +15,7 @@ context.properties = {
#mem.mlock-all = false
#clock.power-of-two-quantum = true
#log.level = 2
#cpu.zero.denormals = true
core.daemon = true # listening for socket connections
core.name = pipewire-0 # core name and socket name

View file

@ -395,9 +395,14 @@ struct pw_context *pw_context_new(struct pw_loop *main_loop,
pw_properties_update_string(properties, str, strlen(str));
pw_properties_set(properties, "vm.overrides", NULL);
}
if (pw_properties_get(properties, PW_KEY_CPU_MAX_ALIGN) == NULL && cpu != NULL)
pw_properties_setf(properties, PW_KEY_CPU_MAX_ALIGN,
if (cpu != NULL) {
if (pw_properties_get(properties, PW_KEY_CPU_MAX_ALIGN) == NULL)
pw_properties_setf(properties, PW_KEY_CPU_MAX_ALIGN,
"%u", spa_cpu_get_max_align(cpu));
if ((str = pw_properties_get(properties, SPA_KEY_CPU_ZERO_DENORMALS)) == NULL)
str = "true";
spa_cpu_zero_denormals(cpu, spa_atob(str));
}
if (getenv("PIPEWIRE_DEBUG") == NULL &&
(str = pw_properties_get(properties, "log.level")) != NULL)