Ejemplo n.º 1
0
Bool PowerControlKnob::commitSetting()
{
	try
	{
		if (m_powerControl->supportsPowerControls())
		{
			// find lowest power limit in request
			Power lowestPowerLimit = snapToCapabilitiesBounds(findLowestPowerLimitRequest());

			// set new power status
			Power currentPowerLimit = m_powerControl->getPowerLimitPL1();
			if (currentPowerLimit != lowestPowerLimit)
			{
				stringstream messageBefore;
				messageBefore << "Attempting to change power limit to " << lowestPowerLimit.toString() << ".";
				getPolicyServices().messageLogging->writeMessageDebug(
					PolicyMessage(FLF, messageBefore.str(), getParticipantIndex(), getDomainIndex()));
				m_powerControl->setPowerLimitPL1(lowestPowerLimit);

				stringstream messageAfter;
				messageAfter << "Changed power limit to " << lowestPowerLimit.toString() << ".";
				getPolicyServices().messageLogging->writeMessageDebug(
					PolicyMessage(FLF, messageAfter.str(), getParticipantIndex(), getDomainIndex()));
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	catch (std::exception& ex)
	{
		getPolicyServices().messageLogging->writeMessageDebug(
			PolicyMessage(FLF, ex.what(), getParticipantIndex(), getDomainIndex()));
		throw ex;
	}
}
Ejemplo n.º 2
0
std::shared_ptr<XmlNode> PowerControlKnob::getXml() const
{
	auto knobStatus = XmlNode::createWrapperElement("power_control_status");
	if (m_powerControl->supportsPowerControls())
	{
		auto pl1Capabilities = m_powerControl->getCapabilities().getCapability(PowerControlType::PL1);
		knobStatus->addChild(pl1Capabilities.getXml());
		Power currentPowerLimit = m_powerControl->getPowerLimitPL1();
		auto powerControl = XmlNode::createDataElement("power_limit", currentPowerLimit.toString());
		knobStatus->addChild(powerControl);
	}
	return knobStatus;
}
Ejemplo n.º 3
0
void PowerControlKnob::limit(UIntN target)
{
	if (canLimit(target))
	{
		try
		{
			getPolicyServices().messageLogging->writeMessageDebug(PolicyMessage(
				FLF, "Calculating request to limit power controls.", getParticipantIndex(), getDomainIndex()));

			const auto& pl1Capabilities = m_powerControl->getCapabilities().getCapability(PowerControlType::PL1);
			Power minimumPowerLimit = pl1Capabilities.getMinPowerLimit();
			Power stepSize = pl1Capabilities.getPowerStepSize();

			Power nextPowerLimit(pl1Capabilities.getMaxPowerLimit());
			Power targetRequest = getTargetRequest(target);
			if (targetRequest >= pl1Capabilities.getMaxPowerLimit())
			{
				// limit one step from current power
				Power currentPower = m_powerControl->getAveragePower();
				getPolicyServices().messageLogging->writeMessageDebug(PolicyMessage(
					FLF, "Current power is " + currentPower.toString() + ".", getParticipantIndex(), getDomainIndex()));
				nextPowerLimit = calculateNextLowerPowerLimit(currentPower, minimumPowerLimit, stepSize, targetRequest);
			}
			else
			{
				// limit one step size down
				nextPowerLimit = std::max((int)targetRequest - (int)stepSize, (int)minimumPowerLimit);
			}
			m_requests[target] = nextPowerLimit;

			stringstream message;
			message << "Requesting to limit power to " << nextPowerLimit.toString() << ".";
			getPolicyServices().messageLogging->writeMessageDebug(
				PolicyMessage(FLF, message.str(), getParticipantIndex(), getDomainIndex()));
		}
		catch (std::exception& ex)
		{
			getPolicyServices().messageLogging->writeMessageDebug(
				PolicyMessage(FLF, ex.what(), getParticipantIndex(), getDomainIndex()));
			throw ex;
		}
	}
}
Ejemplo n.º 4
0
std::string DomainPlatformPowerControl_001::createStatusStringForLimitValue(PlatformPowerLimitType::Type limitType)
{
    try
    {
        if (isEnabled(limitType))
        {
            Power powerLimit = getPlatformPowerLimit(getParticipantIndex(), getDomainIndex(),
                limitType);
            return powerLimit.toString();
        }
        else
        {
            return "DISABLED";
        }
    }
    catch (...)
    {
        return "ERROR";
    }
}
Ejemplo n.º 5
0
std::string DomainPowerControl_001::createStatusStringForLimitValue(PowerControlType::Type controlType)
{
    try
    {
        if (isEnabled(controlType))
        {
            Power powerLimit = getPowerLimit(getParticipantIndex(), getDomainIndex(), controlType);
            return powerLimit.toString();
        }
        else
        {
            return "DISABLED";
        }
    }
    catch (primitive_not_found_in_dsp)
    {
        return "NOT SUPPORTED";
    }
    catch (...)
    {
        return "ERROR";
    }
}