From aa4caa0f01a8c24e80d96f2b078c3a193235ea4b Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 7 Oct 2019 17:40:37 +0200 Subject: [PATCH] remove a now useless conversion script The C++ code will hint how to do the conversion. That may be time consuming for someone wanting to convert a large file manually, but I'm not sure of how long we'd need that script around. And I think that nobody has such a long XML file (but the PR authors) so that should be OK. --- MANIFEST.in | 1 - tools/CMakeLists.txt | 1 - tools/sg_xml_energy_ponecore_to_pepsilon.py | 94 --------------------- 3 files changed, 96 deletions(-) delete mode 100755 tools/sg_xml_energy_ponecore_to_pepsilon.py diff --git a/MANIFEST.in b/MANIFEST.in index a7c7aadd5d..7ff3407fc8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1686,7 +1686,6 @@ include tools/graphicator/graphicator.tesh include tools/normalize-pointers.py include tools/pkg-config/simgrid.pc.in include tools/sanitizers.supp -include tools/sg_xml_energy_ponecore_to_pepsilon.py include tools/sg_xml_unit_converter.py include tools/simgrid.supp include tools/simgrid2vite.sed diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 7ad8d054e2..821c0f2110 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,7 +2,6 @@ set(bin_files ${bin_files} ${CMAKE_CURRENT_SOURCE_DIR}/fix-paje-trace.sh ${CMAKE_CURRENT_SOURCE_DIR}/generate-dwarf-functions ${CMAKE_CURRENT_SOURCE_DIR}/normalize-pointers.py ${CMAKE_CURRENT_SOURCE_DIR}/sg_xml_unit_converter.py - ${CMAKE_CURRENT_SOURCE_DIR}/sg_xml_energy_ponecore_to_pepsilon.py ${CMAKE_CURRENT_SOURCE_DIR}/simgrid_update_xml.pl ${CMAKE_CURRENT_SOURCE_DIR}/simgrid_convert_TI_traces.py ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/fig2dev_postprocessor.pl diff --git a/tools/sg_xml_energy_ponecore_to_pepsilon.py b/tools/sg_xml_energy_ponecore_to_pepsilon.py deleted file mode 100755 index b78523ef0c..0000000000 --- a/tools/sg_xml_energy_ponecore_to_pepsilon.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright (c) 2019. The SimGrid Team. -# All rights reserved. - -# This program is free software; you can redistribute it and/or modify it -# under the terms of the license (GNU LGPL) which comes with this package. - -'''Update 3-part energy consumption syntax in SimGrid XML platform files. - -- watt_per_state: "pIdle:pOneCore:pFull" -> "pIdle:pEpsilon:pFull" - This is done by computing pEpsilon from pOneCore, pFull and #core.''' -import fnmatch -import os -import sys -import xml.etree.ElementTree as ET - -class TreeBuilderWithComments(ET.TreeBuilder): - def comment(self, data): - self.start(ET.Comment, {}) - self.data(data) - self.end(ET.Comment) - -def update_platform_file(filename): - comment_tb = TreeBuilderWithComments() - tree = ET.parse(filename, parser=ET.XMLParser(target=comment_tb)) - root = tree.getroot() - - parent_dict = {c:p for p in root.iter() for c in p} - - for prop in root.iter('prop'): - if 'id' in prop.attrib and prop.attrib['id'] == 'watt_per_state': - # Parse energy consumption and core count - values_str = "".join(prop.attrib['value'].split()) # remove whitespaces - values = values_str.split(',') - nb_core = 1 - if 'core' in parent_dict[prop].attrib: - nb_core = int(parent_dict[prop].attrib['core']) - if nb_core < 1: raise Exception(f'Invalid core count: {nb_core}') - - # If a middle value is given, pIdle:pOneCore:pFull is assumed - # and converted to pIdle:pEpsilon:pFull - consumption_per_pstate = [] - update_required = False - for value in values: - powers = value.split(':') - if len(powers) == 3: - update_required = True - (pIdle, p1, pFull) = [float(x) for x in powers] - if nb_core == 1: - if p1 != pFull: - raise Exception('Invalid energy consumption: ' + - "A 1-core host has pOneCore != pFull " + - f'({p1} != {pFull}).\n' + - 'Original watt_per_state value: "{}"'.format(prop.attrib['value'])) - pEpsilon = pFull - else: - pEpsilon = p1 - ((pFull - p1) / (nb_core - 1)) - consumption_per_pstate.append(f"{pIdle}:{pEpsilon}:{pFull}") - if pIdle > pEpsilon: - print(f"WARNING: pIdle > pEpsilon ({pIdle} > {pEpsilon})") - else: # len(powers) == 2 - if nb_core == 1: - update_required = True - (pIdle, pFull) = [float(x) for x in powers] - pEpsilon = pFull - consumption_per_pstate.append(f"{pIdle}:{pEpsilon}:{pFull}") - print(f"WARNING: putting {pFull} as pEpsilon by default for a single core") - else: - consumption_per_pstate.append(value) - - if update_required: - updated_value = ', '.join(consumption_per_pstate) - print(f'"{values_str}" -> "{updated_value}" (core={nb_core})') - prop.attrib['value'] = updated_value - - with open(filename, 'w', encoding='utf-8') as output_file: - # xml.etree.ElementTree does not handle doctypes =/ - # https://stackoverflow.com/questions/15304229/convert-python-elementtree-to-string - content = ''' - -{} -'''.format(ET.tostring(root, encoding="unicode")) - output_file.write(content) - -if __name__ == '__main__': - usage = "usage: {cmd} FILE\n\n{doc}".format(cmd=sys.argv[0], doc=__doc__) - - if len(sys.argv) != 2: - print(usage) - sys.exit(1) - - update_platform_file(sys.argv[1]) -- 2.20.1