CoreControlLpoPreference DomainCoreControl_001::createCoreControlLpoPreference(UIntN domainIndex) { Bool useDefault = false; DptfBuffer buffer; try { buffer = getParticipantServices()->primitiveExecuteGet( esif_primitive_type::GET_PROC_CURRENT_LOGICAL_PROCESSOR_OFFLINING, ESIF_DATA_BINARY, domainIndex); } catch (...) { getParticipantServices()->writeMessageWarning(ParticipantMessage(FLF, "CLPO not found. Using defaults.")); useDefault = true; } if (useDefault == false) { try { return CoreControlLpoPreference::createFromClpo(buffer); } catch (...) { getParticipantServices()->writeMessageWarning( ParticipantMessage(FLF, "Could not parse CLPO data. Using defaults.")); useDefault = true; } } return CoreControlLpoPreference( true, 0, Percentage(.50), CoreControlOffliningMode::Smt, CoreControlOffliningMode::Core); }
EsifDataPercentage::operator Percentage(void) const { // In this case we will have 93% stored as 9300. We convert it to // .9300 which is used internally in our Percentage class. double doubleValue = static_cast<double>(m_esifDataValue) / m_conversionValue; return Percentage(doubleValue); }
PowerControlDynamicCapsSet PowerControlCapabilitiesArbitrator::getArbitratedPowerControlCapabilities() const { std::vector<PowerControlDynamicCaps> allCaps; auto controlTypes = getControlTypes(); for (auto controlType = controlTypes.begin(); controlType != controlTypes.end(); controlType++) { Power maxPowerLimit = getLowestMaxPowerLimit(*controlType); Power minPowerLimit = getHighestMinPowerLimit(*controlType); Power stepSize = getHighestPowerLimitStep(*controlType); TimeSpan maxTimeWindow = getLowestMaxTimeWindow(*controlType); TimeSpan minTimeWindow = getHighestMinTimeWindow(*controlType); PowerControlDynamicCaps caps(*controlType, minPowerLimit, maxPowerLimit, stepSize, minTimeWindow, maxTimeWindow, Percentage(0.0), Percentage(0.0)); allCaps.push_back(caps); } return PowerControlDynamicCapsSet(allCaps); }
UtilizationStatus DomainUtilization_001::getUtilizationStatus(UIntN participantIndex, UIntN domainIndex) { try { Percentage utilization = m_participantServicesInterface->primitiveExecuteGetAsPercentage( esif_primitive_type::GET_PARTICIPANT_UTILIZATION, domainIndex); return UtilizationStatus(utilization); } catch (...) { return UtilizationStatus(Percentage(1.0)); } }
void DomainCoreControl_001::createCoreControlLpoPreferenceIfNeeded(UIntN domainIndex) { if (m_coreControlLpoPreference == nullptr) { Bool useDefault = false; UInt32 dataLength = 0; DptfMemory binaryData(Constants::DefaultBufferSize); try { m_participantServicesInterface->primitiveExecuteGet( esif_primitive_type::GET_PROC_CURRENT_LOGICAL_PROCESSOR_OFFLINING, ESIF_DATA_BINARY, binaryData, binaryData.getSize(), &dataLength, domainIndex); } catch (...) { m_participantServicesInterface->writeMessageWarning( ParticipantMessage(FLF, "CLPO not found. Using defaults.")); useDefault = true; } if (useDefault == false) { try { m_coreControlLpoPreference = BinaryParse::processorClpoObject(dataLength, binaryData); } catch (...) { m_participantServicesInterface->writeMessageWarning( ParticipantMessage(FLF, "Could not parse CLPO data. Using defaults.")); DELETE_MEMORY_TC(m_coreControlLpoPreference); useDefault = true; } } if (useDefault == true) { m_coreControlLpoPreference = new CoreControlLpoPreference(true, 0, Percentage(.50), CoreControlOffliningMode::Smt, CoreControlOffliningMode::Core); } binaryData.deallocate(); } }
void TorrentListGenerator::get(HttpClientHandler* hdlr, const QHttpRequestHeader& hdr) { Q_UNUSED(hdr); HttpResponseHeader rhdr(200); server->setDefaultResponseHeaders(rhdr,"text/xml",true); QByteArray output_data; QXmlStreamWriter out(&output_data); out.setAutoFormatting(true); out.writeStartDocument(); out.writeStartElement("torrents"); kt::QueueManager* qman = core->getQueueManager(); kt::QueueManager::iterator i = qman->begin(); while (i != qman->end()) { bt::TorrentInterface* ti = *i; const bt::TorrentStats & s = ti->getStats(); out.writeStartElement("torrent"); writeElement(out,"name",ti->getDisplayName()); writeElement(out,"info_hash",ti->getInfoHash().toString()); writeElement(out,"status",s.statusToString()); writeElement(out,"bytes_downloaded",BytesToString(s.bytes_downloaded)); writeElement(out,"bytes_uploaded",BytesToString(s.bytes_uploaded)); writeElement(out,"total_bytes",BytesToString(s.total_bytes)); writeElement(out,"total_bytes_to_download",BytesToString(s.total_bytes_to_download)); writeElement(out,"download_rate",BytesPerSecToString(s.download_rate)); writeElement(out,"upload_rate",BytesPerSecToString(s.upload_rate)); writeElement(out,"num_peers",QString::number(s.num_peers)); writeElement(out,"seeders",QString::number(s.seeders_connected_to)); writeElement(out,"seeders_total",QString::number(s.seeders_total)); writeElement(out,"leechers",QString::number(s.leechers_connected_to)); writeElement(out,"leechers_total",QString::number(s.leechers_total)); writeElement(out,"running",s.running ? "1" : "0"); writeElement(out,"percentage",QString::number(Percentage(s),'f',2)); writeElement(out,"num_files",QString::number(ti->getNumFiles())); out.writeEndElement(); i++; } out.writeEndElement(); out.writeEndDocument(); hdlr->send(rhdr,output_data); }
std::vector<PerformanceControl> BinaryParse::genericPpssObject(UInt32 dataLength, void* esifData) { std::vector<PerformanceControl> controls; UInt8* data = reinterpret_cast<UInt8*>(esifData); struct EsifDataBinaryPpssPackage* currentRow = reinterpret_cast<struct EsifDataBinaryPpssPackage*>(data); validateData(dataLength); UIntN rows = countPpssRows(dataLength, data); // Reset currentRow to point to the beginning of the data block data = reinterpret_cast<UInt8*>(esifData); currentRow = reinterpret_cast<struct EsifDataBinaryPpssPackage*>(data); for (UIntN i = 0; i < rows; i++) { PerformanceControl temp( static_cast<UInt32>(currentRow->control.integer.value), PerformanceControlType::PerformanceState, static_cast<UInt32>(currentRow->power.integer.value), Percentage(static_cast<UInt32>(currentRow->performancePercentage.integer.value) / 100.0), static_cast<UInt32>(currentRow->latency.integer.value), static_cast<UInt32>(currentRow->rawPerformance.integer.value), std::string( reinterpret_cast<const char*>(&(currentRow->rawUnits)) + sizeof(union esif_data_variant), currentRow->rawUnits.string.length )); controls.push_back(temp); data += sizeof(struct EsifDataBinaryPpssPackage) + currentRow->rawUnits.string.length; currentRow = reinterpret_cast<struct EsifDataBinaryPpssPackage*>(data); } return controls; }
bool Percentage::operator==(const float& value) const { return m_value == Percentage(value).m_value ; }
bool Percentage::operator!=(const int& value) const { return m_value != Percentage(value).m_value ; }
std::vector<PowerControlStatus> PowerControlArbitrator::createInitialArbitratedPowerControlStatusVector() { // create a vector to temporarily store the arbitrated data. initialize to invalid. std::vector<PowerControlStatus> arbitratedPowerControlStatusVector; for (UIntN i = 0; i < PowerControlType::max; i++) { PowerControlStatus pcs = PowerControlStatus((PowerControlType::Type)i, Power(), Constants::Invalid, Percentage()); arbitratedPowerControlStatusVector.push_back(pcs); } return arbitratedPowerControlStatusVector; }