CPU#
- class impacthpc.src.CPU(embodied_impacts: Impacts | None = None, electric_power: ReplicableValue | str | None = None, peak_power: ReplicableValue | str | None = None, idle_power: ReplicableValue | str | None = None, name: Name | None = None, tdp: float | None = None, model_range: str | None = None, power_measures: List[PowerMeasure] = [], die_size: ReplicableValue | str | None = None, cpu_family: str | None = None, cores: int | None = None, release_date_range: DateRange | None = None)#
Bases:
HasConsumptionAndEmbodiedImpacts
Subclass of
Component
representing a CPU.This class uses the same estimation as BoavitzAPI, described in
Thibault Simon, David Ekchajzer, Adrien Berthelot, Eric Fourboul, Samuel Rince, et al.. BoaviztAPI: a bottom-up model to assess the environmental impacts of cloud services. HotCarbon’24 - 3rd Workshop on Sustainable Computer Systems, Jul 2024, Santa Cruz, United States. hal-04621947v3"
See the documentation of BoavitzAPI : https://doc.api.boavizta.org/Explanations/components/cpu/
Examples
from impacthpc import CPU, ExactName impacts = CPU(name=ExactName("Intel Xeon Gold 6248")).estimate_embodied_impacts() impacts_climate_change = impacts["gwp"] print(impacts_climate_change.explain())
If you don’t know the exact name of you CPU, use
find_close_cpu_model_name()
from impacthpc import CPU, ExactName, find_close_cpu_model_name impacts = CPU(name=find_close_cpu_model_name("Intel 6248")).estimate_embodied_impacts() impacts_climate_change = impacts["gwp"] print(impacts_climate_change.explain())
Electric power of this cpu :
from impacthpc import CPU, ExactName power = CPU(name=ExactName("Intel Xeon Gold 6248")).estimate_electric_power() print(power.explain())
- name#
The name of a CPU model present in the database. Can be an instance of
ExactName
or the return value offind_close_cpu_model_name()
for fuzzy matching name. Defaults to None.- Type:
Name, optional
- tdp#
The Thermal Design Power of the CPU, used to determine the CPU’s instantaneous power consumption. Defaults to None.
- Type:
float | None, optional
- model_range#
The model range of the CPU, for example
EPYC
,Athlon X4
,Core i5
,Xeon Gold
… The supported model ranges are listed in the CSV file at the path defined in the config file under csv > cpu_profile.csv. Iftdp
orpower_measures
are provided, model_range will be ignored. Defaults to None.- Type:
str | None, optional
- power_measures#
Measurements of the CPU’s power consumption depending on the workload. Defaults to [].
- Type:
List[PowerMeasure], optional
- die_size#
The surface area of the CPU die. Used to determine the embodied impacts of the CPU. Defaults to None.
- Type:
ReplicableValue | None, optional
- cpu_family#
The family of the CPU. Ignored if the name is provided and the die size is in the database for the CPU name. Defaults to None.
- Type:
str | None, optional
- release_date_range#
The date range in which the CPU was released. Used in computations when the exact name of the CPU isn’t known and estimations are done with average values. Defaults to the ten last years.
- Type:
DateRange | None, optional
Methods Summary
Methods Documentation
- _cpu_profile() tuple[ReplicableValue, ReplicableValue, ReplicableValue, ReplicableValue] #
Estimate the profile of the CPU.
CPU energy consumption is estimated using the formula
a * ln(b * (workload + c)) + d
, where: - workload is a percentage indicating how much the CPU is being used. - a, b, c, and d are parameters estimated using power measurements and TDP.The CPU profile is the set of these four parameters: a, b, c, and d. This method is used to estimate them.
If the TDP and/or power measures are known, we use scipy.optimize to find a, b, c, and d values that fit best. Otherwise, we use default values for the
model_range
.- Returns:
The CPU profile consisting of the four parameters a, b, c, and d.
- Return type:
tuple[ReplicableValue, ReplicableValue, ReplicableValue, ReplicableValue]
- _estimate_die_size() ReplicableValue #
Estimate the Die size of a CPU.
- Alt:
Schema that explains the logic used in this method
- Returns:
The estimated Die size.
- Return type:
- _get_cpus_matching_by_name() DataFrame #
Return a sub-dataframe of
CPUs_specs
containing only the row matchingname
.Return an empty dataframe with the same columns as
CPUs_specs
ifname
is None.- Raises:
ValueError –
name
should be an instance of the abstract className
or None. Therefore, it can be anExactName
, aFuzzymatchSingleResult
, aFuzzymatchMultipleResult
, or None.- Returns:
A sub-dataframe of
CPUs_specs
containing only the row matchingname
.- Return type:
pandas.DataFrame
- _linear_regression_core_to_die_size(cpus: DataFrame) SourcedValue #
Perform a linear regression on the die sizes and numbers of cores of different CPUs to estimate the die size of the current CPU.
- Parameters:
cpus (pandas.DataFrame) – A dataframe with at least two columns, “cores” and “total_die_size”, which describes CPUs and is used to perform the linear regression.
- Raises:
ValueError – all pairs of cores and total_die_size in
cpus
are (nan, nan).- Returns:
The estimated die size of the CPU.
- Return type:
- estimate_electric_power(workload: ReplicableValue | None = None) ReplicableValue #
Estimate the electric power of the CPU.
CPU electric power is estimated using the formula
a * ln(b * (workload + c)) + d
, where:workload is a percentage indicating how much the CPU is being used.
a, b, c, and d are parameters estimated using power measurements and TDP.
These four parameters a, b, c, and d are called the CPU profile and are estimated by the method
_cpu_profile()
.- Parameters:
workload (ReplicableValue, optional) – The :arg:`workload` of the CPU, between 0 and 100, as a ReplicableValue. The unit should be dimensionless. Defaults to the value defined in the config file under default_values_cpu > workload.
- Returns:
The estimated instant consumption of the CPU.
- Return type:
- estimate_embodied_impacts() Impacts #
Estimate the embodied impacts of the CPU.
CPU embodied impacts are estimated using:
self._die_size_factor * self.die_size + self._base_impact
, where:_die_size_factor
is the impact of 1 mm² of die. It is defined in the config file under default_values_cpu > die_size_factor.die_size
is the surface of the die in mm², either provided by the user or estimated in_estimate_die_size()
.base_impact
is the impact of everything that isn’t the die in a CPU, and is defined in the config file under default_values_cpu > base_impact.
- Returns:
The embodied impacts of the CPU.
- Return type:
Impact
- estimate_idle_power()#
Estimate the static electric power of the CPU when the workload is 0%.
The CPU’s static instant consumption is estimated using the
estimate_electric_power()
method with a workload of 0%.- Returns:
The electric power of the CPU.
- Return type:
Impact
- estimate_peak_power()#
Estimate the peak (maximum) electric power of the CPU when the workload is 100%.
The CPU’s peak instant consumption is estimated using the
estimate_electric_power()
method with a workload of 100%.- Returns:
The electric power of the CPU.
- Return type:
Impact