PerformanceControlSet DomainPerformanceControl_002::createCombinedPerformanceControlSet(UIntN domainIndex) { PerformanceControlSet performanceStateSet = getPerformanceStateSet(domainIndex); PerformanceControlSet throttlingStateSet; // Get T-States if (performanceStateSet.getCount() > 0) { throttlingStateSet = getThrottlingStateSet(domainIndex); } // Create all encompassing set (P and T states) // P-States PerformanceControlSet combinedStateSet(performanceStateSet); // T-States auto tStateStartIndex = isFirstTstateDeleted(domainIndex) ? 1 : 0; combinedStateSet.append(throttlingStateSet, tStateStartIndex); ParticipantMessage message = ParticipantMessage(FLF, "Performance controls created."); message.addMessage("Total Entries", combinedStateSet.getCount()); message.addMessage("P-State Count", performanceStateSet.getCount()); message.addMessage("T-State Count", throttlingStateSet.getCount()); getParticipantServices()->writeMessageDebug(message); return PerformanceControlSet(combinedStateSet); }
Bool DomainPerformanceControl_002::isFirstTstateDeleted(UIntN domainIndex) { if (m_isFirstTstateDeleted.isInvalid()) { m_isFirstTstateDeleted.set(false); PerformanceControlSet performanceStateSet = getPerformanceStateSet(domainIndex); PerformanceControlSet throttlingStateSet; // Get T-States if (performanceStateSet.getCount() > 0) { throttlingStateSet = getThrottlingStateSet(domainIndex); } // Removing the first Tstate if the last Pstate and first Tstate are same. if (performanceStateSet.getCount() > 0 && throttlingStateSet.getCount() > 0) { auto lastPstateIndex = performanceStateSet.getCount() - 1; if (performanceStateSet[lastPstateIndex].getControlAbsoluteValue() == throttlingStateSet[0].getControlAbsoluteValue()) { m_isFirstTstateDeleted.set(true); } } } return m_isFirstTstateDeleted.get(); }
UIntN PassiveDomainControlStatus::indexOfFirstControlWithType( const PerformanceControlSet& controlSet, PerformanceControlType::Type type) const { for (UIntN controlIndex = 0; controlIndex < controlSet.getCount(); controlIndex++) { if (controlSet[controlIndex].getPerformanceControlType() == type) { return controlIndex; } } throw dptf_exception("Performance control set does not contain the specified type."); }
UIntN PassiveDomainControlStatus::getNumberOfElementsOfControlType( const PerformanceControlSet& controlSet, PerformanceControlType::Type type) const { UIntN count(0); for (UIntN controlIndex = 0; controlIndex < controlSet.getCount(); controlIndex++) { if (controlSet[controlIndex].getPerformanceControlType() == type) { count++; } } return count; }
void PassiveDomainControlStatus::addTstateStatus(DomainProxy& domain) { PerformanceControlFacade& perfControl = domain.getPerformanceControl(); if (perfControl.supportsPerformanceControls()) { try { PerformanceControlSet tstateControls = filterControlSet( perfControl.getControls(), perfControl.getDynamicCapabilities(), PerformanceControlType::ThrottleState); UIntN maxUnlimitedIndex = 0; UIntN maxLimitedIndex = tstateControls.getCount() == 0 ? 0 : tstateControls.getCount() - 1; IntN tstateIndexStart = indexOfFirstControlWithType(perfControl.getControls(), PerformanceControlType::ThrottleState); IntN currentIndex = perfControl.getStatus().getCurrentControlSetIndex() - tstateIndexStart; currentIndex = std::max(0, currentIndex); m_controlStatus.push_back( ControlStatus( "T-States", maxUnlimitedIndex, maxLimitedIndex, currentIndex)); } catch (...) { m_controlStatus.push_back( ControlStatus("T-States", Constants::Invalid, Constants::Invalid, Constants::Invalid)); } } else { m_controlStatus.push_back( ControlStatus("T-States", Constants::Invalid, Constants::Invalid, Constants::Invalid)); } }
void PassiveDomainControlStatus::addTstateStatus(std::shared_ptr<DomainProxyInterface> domain) { auto perfControl = domain->getPerformanceControl(); if (perfControl->supportsPerformanceControls()) { try { PerformanceControlSet tstateControls = filterControlSet( perfControl->getControls(), perfControl->getDynamicCapabilities(), PerformanceControlType::ThrottleState); UIntN maxUnlimitedIndex = 0; UIntN maxLimitedIndex = tstateControls.getCount() == 0 ? 0 : tstateControls.getCount() - 1; IntN tstateIndexStart = indexOfFirstControlWithType(perfControl->getControls(), PerformanceControlType::ThrottleState); IntN currentIndex = perfControl->getStatus().getCurrentControlSetIndex() - tstateIndexStart; currentIndex = std::max(0, currentIndex); if (maxUnlimitedIndex == maxLimitedIndex) { throw dptf_exception("No T-state controls are available."); } m_controlStatus.push_back(ControlStatus("T-States", maxLimitedIndex, maxUnlimitedIndex, currentIndex)); } catch (...) { m_controlStatus.push_back( ControlStatus("T-States", Constants::Invalid, Constants::Invalid, Constants::Invalid)); } } else { m_controlStatus.push_back( ControlStatus("T-States", Constants::Invalid, Constants::Invalid, Constants::Invalid)); } }
void DomainPerformanceControl_002::updateBasedOnConfigTdpInformation(UIntN participantIndex, UIntN domainIndex, ConfigTdpControlSet configTdpControlSet, ConfigTdpControlStatus configTdpControlStatus) { UInt64 tdpFrequencyLimit = configTdpControlSet[configTdpControlStatus.getCurrentControlIndex()].getTdpFrequency(); PerformanceControlSet controlSet = getPerformanceControlSet(participantIndex, domainIndex); for (UIntN controlIndex = 0; controlIndex < controlSet.getCount(); controlIndex++) { if (tdpFrequencyLimit >= controlSet[controlIndex].getControlAbsoluteValue()) { m_tdpFrequencyLimitControlIndex = controlIndex; break; } } m_performanceControlDynamicCaps.invalidate(); }
PerformanceControlSet PassiveDomainControlStatus::filterControlSet( const PerformanceControlSet& controlSet, PerformanceControlDynamicCaps dynamicCapabilities, PerformanceControlType::Type type) const { std::vector<PerformanceControl> filteredControls; UIntN startIndex = dynamicCapabilities.getCurrentUpperLimitIndex(); UIntN endIndex = dynamicCapabilities.getCurrentLowerLimitIndex(); for (UIntN controlIndex = startIndex; controlIndex < std::min(endIndex + 1, controlSet.getCount()); controlIndex++) { if (controlSet[controlIndex].getPerformanceControlType() == type) { filteredControls.push_back(controlSet[controlIndex]); } } return PerformanceControlSet(filteredControls); }
PerformanceControlSet DomainPerformanceControl_002::createThrottlingStateSet(UIntN domainIndex) { PerformanceControlSet performanceStateSet = getPerformanceStateSet(domainIndex); PerformanceControlSet throttlingStateSet; try { DptfBuffer tstateBuffer = getParticipantServices()->primitiveExecuteGet( esif_primitive_type::GET_TSTATES, ESIF_DATA_BINARY, domainIndex); throttlingStateSet = PerformanceControlSet::createFromProcessorTss( performanceStateSet[performanceStateSet.getCount() - 1], tstateBuffer); } catch (...) { // T-States aren't supported. throttlingStateSet = PerformanceControlSet(); } return throttlingStateSet; }