<commit_before>/*
 * Copyright (c) 2015 - 2022, Intel Corporation
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "config.h"

#include "PlatformIOImp.hpp"

#include <string.h>
#include <sys/types.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <memory>

#include "geopm/Agg.hpp"
#include "geopm/Exception.hpp"
#include "geopm/Helper.hpp"
#include "geopm/IOGroup.hpp"
#include "geopm/PlatformTopo.hpp"

#include "geopm_pio.h"
#include "BatchServer.hpp"
#include "CombinedSignal.hpp"
#include "ServiceIOGroup.hpp"

namespace geopm
{

    static PlatformIO &platform_io_helper(bool do_reset)
    {
        static std::unique_ptr<PlatformIOImp> instance = geopm::make_unique<PlatformIOImp>();
        if (do_reset) {
            instance = geopm::make_unique<PlatformIOImp>();
        }
        return *instance;
    }

    PlatformIO &platform_io(void)
    {
        return platform_io_helper(false);
    }

    static void platform_io_reset(void)
    {
        platform_io_helper(true);
    }

    PlatformIOImp::PlatformIOImp()
        : PlatformIOImp({}, platform_topo())
    {

    }


    const std::map<const std::string, const std::string>
    PlatformIOImp::m_signal_descriptions = {
        {"BOARD_ENERGY",
         "    description: Total energy measured on the server's board.\n"
         "    iogroup: CNL\n"
         "    alias_for: CNL::BOARD_ENERGY"},
        {"BOARD_POWER",
         "    description: Power measured on the server's board.\n"
         "    iogroup: CNL\n"
         "    alias_for: CNL::BOARD_POWER"},
        {"CPU_CYCLES_REFERENCE",
         "    description: The count of the number of cycles while the logical processor is not in a "
         "halt state and not in a stop-clock state. The count rate is fixed at the "
         "TIMESTAMP_COUNT rate.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::FIXED_CTR2:CPU_CLK_UNHALTED_REF_TSC"},
        {"CPU_CYCLES_THREAD",
         "    description: The count of the number of cycles while the logical processor is not in a "
         "halt state.  The count rate may change based on core frequency.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::FIXED_CTR1:CPU_CLK_UNHALTED_THREAD"},
        {"CPU_ENERGY",
         "    description: An increasing meter of energy consumed by the package over time. It will "
         "reset periodically due to roll-over.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PKG_ENERGY_STATUS:ENERGY"},
        {"CPU_FREQUENCY_MAX_AVAIL",
         "    description: Maximum processor frequency.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::TURBO_RATIO_LIMIT:MAX_RATIO_LIMIT_0 or if HWP is enabled MSR::HWP_CAPABILITIES:HIGHEST_PERFORMANCE"},
        {"CPU_FREQUENCY_STATUS",
         "    description: The current operating frequency of the CPU.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PERF_STATUS:FREQ"},
        {"CPU_INSTRUCTIONS_RETIRED",
         "    description: The count of the number of instructions executed.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::FIXED_CTR0:INST_RETIRED_ANY"},
        {"CPU_POWER_LIMIT_CONTROL",
         "    description: The average power usage limit over the time window specified in "
         "PL1_TIME_WINDOW.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PKG_POWER_LIMIT:PL1_POWER_LIMIT"},
        {"CPU_POWER_TIME_WINDOW",
         "    description: The time window associated with power limit 1.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PKG_POWER_LIMIT:PL1_TIME_WINDOW"},<commit_msg>Add missing aliases to the PIO description map<commit_after>/*
 * Copyright (c) 2015 - 2022, Intel Corporation
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include "config.h"

#include "PlatformIOImp.hpp"

#include <string.h>
#include <sys/types.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <memory>

#include "geopm/Agg.hpp"
#include "geopm/Exception.hpp"
#include "geopm/Helper.hpp"
#include "geopm/IOGroup.hpp"
#include "geopm/PlatformTopo.hpp"

#include "geopm_pio.h"
#include "BatchServer.hpp"
#include "CombinedSignal.hpp"
#include "ServiceIOGroup.hpp"

namespace geopm
{

    static PlatformIO &platform_io_helper(bool do_reset)
    {
        static std::unique_ptr<PlatformIOImp> instance = geopm::make_unique<PlatformIOImp>();
        if (do_reset) {
            instance = geopm::make_unique<PlatformIOImp>();
        }
        return *instance;
    }

    PlatformIO &platform_io(void)
    {
        return platform_io_helper(false);
    }

    static void platform_io_reset(void)
    {
        platform_io_helper(true);
    }

    PlatformIOImp::PlatformIOImp()
        : PlatformIOImp({}, platform_topo())
    {

    }


    const std::map<const std::string, const std::string>
    PlatformIOImp::m_signal_descriptions = {
        {"BOARD_ENERGY",
         "    description: Total energy measured on the server's board.\n"
         "    iogroup: CNL\n"
         "    alias_for: CNL::BOARD_ENERGY"},
        {"BOARD_POWER",
         "    description: Power measured on the server's board.\n"
         "    iogroup: CNL\n"
         "    alias_for: CNL::BOARD_POWER"},
        {"CPU_CYCLES_REFERENCE",
         "    description: The count of the number of cycles while the logical processor is not in a "
         "halt state and not in a stop-clock state. The count rate is fixed at the "
         "TIMESTAMP_COUNT rate.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::FIXED_CTR2:CPU_CLK_UNHALTED_REF_TSC"},
        {"CPU_CYCLES_THREAD",
         "    description: The count of the number of cycles while the logical processor is not in a "
         "halt state.  The count rate may change based on core frequency.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::FIXED_CTR1:CPU_CLK_UNHALTED_THREAD"},
        {"CPU_ENERGY",
         "    description: An increasing meter of energy consumed by the package over time. It will "
         "reset periodically due to roll-over.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PKG_ENERGY_STATUS:ENERGY"},
        {"CPU_FREQUENCY_MIN_AVAIL",
         "    description: Minimum processor frequency.\n"
         "    iogroup: Cpuinfo\n"
         "    alias_for: CPUINFO::FREQ_MIN"},
        {"CPU_FREQUENCY_MAX_AVAIL",
         "    description: Maximum processor frequency.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::TURBO_RATIO_LIMIT:MAX_RATIO_LIMIT_0 or if HWP is enabled MSR::HWP_CAPABILITIES:HIGHEST_PERFORMANCE"},
        {"CPU_FREQUENCY_STICKER",
         "    description: Processor base frequency.\n"
         "    iogroup: Cpuinfo\n"
         "    alias_for: CPUINFO::FREQ_STICKER"},
        {"CPU_FREQUENCY_STEP",
         "    description: Step size between process frequency settings.\n"
         "    iogroup: Cpuinfo\n"
         "    alias_for: CPUINFO::FREQ_STEP"},
        {"CPU_FREQUENCY_STATUS",
         "    description: The current operating frequency of the CPU.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PERF_STATUS:FREQ"},
        {"CPU_INSTRUCTIONS_RETIRED",
         "    description: The count of the number of instructions executed.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::FIXED_CTR0:INST_RETIRED_ANY"},
        {"CPU_POWER_LIMIT_CONTROL",
         "    description: The average power usage limit over the time window specified in "
         "PL1_TIME_WINDOW.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PKG_POWER_LIMIT:PL1_POWER_LIMIT"},
        {"CPU_POWER_TIME_WINDOW",
         "    description: The time window associated with power limit 1.\n"
         "    iogroup: MSR\n"
         "    alias_for: MSR::PKG_POWER_LIMIT:PL1_TIME_WINDOW"},
{'fraction_non_alphanumeric': 0.10812883435582822, 'fraction_numerical': 0.0043456032719836404, 'mean_word_length': 2.5375226039783003, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3681553', 'n_tokens_mistral': 2637, 'n_tokens_neox': 2601, 'n_words': 578}