Skip to main content

set_cpu_ceiling

Function set_cpu_ceiling 

Source
pub fn set_cpu_ceiling(level: CpuLevel) -> Result<(), CpuCeilingError>
Expand description

The ceiling on the instruction sets the kernels may use: see set_cpu_ceiling. The ceiling on the instruction sets the kernels may use: see set_cpu_ceiling. The ceiling on the instruction sets the kernels may use: see set_cpu_ceiling. Limit every kernel the codec picks at run time to level and below, for the rest of the process. A kernel is still used only where the CPU supports it: the ceiling never raises a choice.

Only the run-time choices are limited. A build compiled for a wider baseline (-C target-cpu=...) uses those instructions throughout, below any ceiling.

§Errors

CpuCeilingError::AlreadyResolved once any kernel has been chosen or a ceiling set. Building a codec context can already choose kernels (a decoder does, at construction), and so does querying one (active_cpu_kernel_name, cpu_ceiling): set the ceiling before creating any context, not merely before the first compression or decompression. CpuCeilingError::OtherArchitecture for a level of another architecture.

§Examples

use structured_zstd::{CpuLevel, set_cpu_ceiling};

// Before any compression or decompression in the process.
set_cpu_ceiling(CpuLevel::Scalar).unwrap();
assert_eq!(structured_zstd::cpu_ceiling(), Some(CpuLevel::Scalar));