TimeSpan ThermalRelationshipTable::getSampleTimeForRelationship(UIntN target, UIntN source) const
{
	for (auto entry = m_entries.begin(); entry != m_entries.end(); ++entry)
	{
		if (((*entry)->getTargetDeviceIndex() == target) && ((*entry)->getSourceDeviceIndex() == source))
		{
			auto trtEntry = std::dynamic_pointer_cast<ThermalRelationshipTableEntry>(*entry);
			if (trtEntry)
			{
				return trtEntry->thermalSamplingPeriod();
			}
		}
	}
	throw dptf_exception("No match found for target and source in TRT.");
}
Beispiel #2
0
TimeSpan ThermalRelationshipTable::getShortestSamplePeriodForTarget(UIntN target)
{
    auto shortestSamplePeriod = TimeSpan::createInvalid();
    for (auto entry = m_entries.begin(); entry != m_entries.end(); ++entry)
    {
        if ((*entry)->getTargetDeviceIndex() == target)
        {
            auto trtEntry = std::dynamic_pointer_cast<ThermalRelationshipTableEntry>(*entry);
            if (trtEntry)
            {
                auto samplingPeriod = trtEntry->thermalSamplingPeriod();
                if (shortestSamplePeriod.isInvalid() || samplingPeriod < shortestSamplePeriod)
                {
                    shortestSamplePeriod = samplingPeriod;
                }
            }
        }
    }

    return shortestSamplePeriod;
}
Beispiel #3
0
TimeSpan ThermalRelationshipTable::getMinimumActiveSamplePeriodForSource(
    UIntN sourceIndex, std::set<UIntN> activeTargets)
{
    auto minimumSamplePeriod = TimeSpan::createInvalid();
    for (auto entry = m_entries.begin(); entry != m_entries.end(); ++entry)
    {
        if (((*entry)->getSourceDeviceIndex() == sourceIndex) &&
            (activeTargets.find((*entry)->getTargetDeviceIndex()) != activeTargets.end()))
        {
            auto trtEntry = std::dynamic_pointer_cast<ThermalRelationshipTableEntry>(*entry);
            if (trtEntry)
            {
                auto samplingPeriod = trtEntry->thermalSamplingPeriod();
                if (minimumSamplePeriod.isInvalid() || samplingPeriod < minimumSamplePeriod)
                {
                    minimumSamplePeriod = samplingPeriod;
                }
            }
        }
    }
    return minimumSamplePeriod;
}
Beispiel #4
0
DptfBuffer ThermalRelationshipTable::toTrtBinary() const
{
    DptfBuffer packages;
    UInt32 offset = 0;
    for (auto entry = m_entries.begin(); entry != m_entries.end(); entry++)
    {
        auto trtEntry = std::dynamic_pointer_cast<ThermalRelationshipTableEntry>(*entry);
        if (trtEntry)
        {
            UInt32 sourceScopeLength = (UInt32)(*entry)->getSourceDeviceScope().size();
            UInt32 targetScopeLength = (UInt32)(*entry)->getTargetDeviceScope().size();

            DptfBuffer packageBuffer;
            packageBuffer.allocate(sizeof(EsifDataBinaryTrtPackage) + sourceScopeLength + targetScopeLength);

            EsifDataBinaryTrtPackage entryPackage;
            UInt32 dataAddress = 0;

            // Source Scope
            entryPackage.sourceDevice.string.length = sourceScopeLength;
            entryPackage.sourceDevice.type = esif_data_type::ESIF_DATA_STRING;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.sourceDevice)), sizeof(entryPackage.sourceDevice));
            dataAddress += sizeof(entryPackage.sourceDevice);
            packageBuffer.put(dataAddress, (UInt8*)((*entry)->getSourceDeviceScope().c_str()), sourceScopeLength);
            dataAddress += sourceScopeLength;

            // Target Scope
            entryPackage.targetDevice.string.length = targetScopeLength;
            entryPackage.targetDevice.type = esif_data_type::ESIF_DATA_STRING;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.targetDevice)), sizeof(entryPackage.targetDevice));
            dataAddress += sizeof(entryPackage.targetDevice);
            packageBuffer.put(dataAddress, (UInt8*)((*entry)->getTargetDeviceScope().c_str()), targetScopeLength);
            dataAddress += targetScopeLength;

            // Thermal Influence
            entryPackage.thermalInfluence.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.thermalInfluence.integer.value = trtEntry->thermalInfluence();
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.thermalInfluence)),
                sizeof(entryPackage.thermalInfluence));
            dataAddress += sizeof(entryPackage.thermalInfluence);

            // Sampling Period
            entryPackage.thermalSamplingPeriod.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.thermalSamplingPeriod.integer.value = trtEntry->thermalSamplingPeriod().asTenthSecondsInt();
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.thermalSamplingPeriod)),
                sizeof(entryPackage.thermalSamplingPeriod));
            dataAddress += sizeof(entryPackage.thermalSamplingPeriod);

            // Reserved1
            entryPackage.reserved1.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved1.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved1)), sizeof(entryPackage.reserved1));
            dataAddress += sizeof(entryPackage.reserved1);

            // Reserved2
            entryPackage.reserved2.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved2.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved2)), sizeof(entryPackage.reserved2));
            dataAddress += sizeof(entryPackage.reserved2);

            // Reserved3
            entryPackage.reserved3.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved3.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved3)), sizeof(entryPackage.reserved3));
            dataAddress += sizeof(entryPackage.reserved3);

            // Reserved4
            entryPackage.reserved4.integer.type = esif_data_type::ESIF_DATA_UINT64;
            entryPackage.reserved4.integer.value = 0;
            packageBuffer.put(dataAddress, (UInt8*)(&(entryPackage.reserved4)), sizeof(entryPackage.reserved4));
            dataAddress += sizeof(entryPackage.reserved4);

            packages.put(offset, packageBuffer.get(), packageBuffer.size());
            offset += packageBuffer.size();
        }
    }

    DptfBuffer buffer(packages.size());
    buffer.put(0, packages.get(), packages.size());
    return buffer;
}