Skip to content

Commit

Permalink
Adding power metrics (EDAAC#3)
Browse files Browse the repository at this point in the history
* initializing project report

* update vs code settings

* first attempt to implement flow models

* bump version

* improved module import

* fix bug in negative bounds

* bump up version

* adding innovus power reports
  • Loading branch information
abdelrahmanhosny authored Apr 14, 2020
1 parent eaec283 commit 06025b1
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ test:
check:
twine check dist/*

publish:
publish: clean build
twine upload dist/*
3 changes: 2 additions & 1 deletion edaac/metrics/parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@

from .innovus_drc_report import *
from .innovus_conn_report import *
from .innovus_timing_report import *
from .innovus_timing_report import *
from .innovus_power_report import *
75 changes: 75 additions & 0 deletions edaac/metrics/parsers/innovus_power_report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'''
EDA Analytics Central (EDAAC)
Copyright (c) 2019, Abdelrahman Hosny
All rights reserved.
BSD 3-Clause License
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''

from edaac.log import get_logger
import re


def parse_innovus_power_report(report_file_path):
logger = get_logger()
# this could be substituted by a default dictionary
# but keeping it this way to see what metrics this function reports
metrics = {
'power_internal_total': None,
'power_switching_total': None,
'power_leakage_total': None,
'power_internal_percentage': None,
'power_switching_percentage': None,
'power_leakage_percentage': None,
'power_total': None,
}

try:
with open(report_file_path, 'r') as f:
report = ''.join(f.readlines())
except Exception as e:
logger.error('Can\'t read report file: %s. Skipping ..',
report_file_path)
return

# Internal power
regex = 'Total Internal Power:[ \t]+(?P<total>[0-9\.]*)[ \t]+(?P<percentage>[%0-9\.]*)%'
m = re.search(regex, report)
if m:
metrics['power_internal_total'] = float(m.group('total'))
metrics['power_internal_percentage'] = float(m.group('percentage'))

# Switching power
regex = 'Total Switching Power:[ \t]+(?P<total>[0-9\.]*)[ \t]+(?P<percentage>[%0-9\.]*)%'
m = re.search(regex, report)
if m:
metrics['power_switching_total'] = float(m.group('total'))
metrics['power_switching_percentage'] = float(m.group('percentage'))

# Leakage power
regex = 'Total Leakage Power:[ \t]+(?P<total>[0-9\.]*)[ \t]+(?P<percentage>[%0-9\.]*)%'
m = re.search(regex, report)
if m:
metrics['power_leakage_total'] = float(m.group('total'))
metrics['power_leakage_percentage'] = float(m.group('percentage'))

# Total power
regex = 'Total Power:[ \t]+(?P<total>[0-9\.]*)'
m = re.search(regex, report)
if m:
metrics['power_total'] = float(m.group('total'))

logger.info('Successfully extracted metrics from %s', report_file_path)

return metrics
2 changes: 1 addition & 1 deletion edaac/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
'''

__version__ = '0.0.10'
__version__ = '0.0.11'

def version():
print("EDA Analytics Central (EDAAC) v" + __version__)
1 change: 1 addition & 0 deletions test/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .test_innovus_drc import *
from .test_innovus_conn import *
from .test_innovus_timing import *
from .test_innovus_power import *
from .test_initialize_project import *
from .test_add_flow import *
2 changes: 1 addition & 1 deletion test/test_innovus_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def test(self):
result = parse_innovus_conn_report(report_file)
self.assertDictEqual(metrics, result)
else:
logger.warning('Skipping private DRC report file %s' % report_file)
logger.warning('Skipping private Connectivity report file %s' % report_file)
26 changes: 26 additions & 0 deletions test/test_innovus_power.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import unittest
import os
import pathlib

from edaac.metrics.parsers import parse_innovus_power_report


class TestInnovusPower(unittest.TestCase):
def test(self):
report_file = os.path.join(
pathlib.Path(__file__).parent.absolute(), 'data', 'pwr1.rpt')
metrics = {
'power_internal_total': 26.31116662,
'power_switching_total': 21.61735782,
'power_leakage_total': 13.58182182,
'power_total': 61.51034631,
'power_internal_percentage': 42.7752,
'power_switching_percentage': 35.1443,
'power_leakage_percentage': 22.0805
}

if os.path.exists(report_file):
result = parse_innovus_power_report(report_file)
self.assertDictEqual(metrics, result)
else:
logger.warning('Skipping private Power report file %s' % report_file)
2 changes: 1 addition & 1 deletion test/test_innovus_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def test(self):
result = parse_innovus_timing_report(report_file)
self.assertDictEqual(metrics, result)
else:
logger.warning('Skipping private DRC report file %s' % report_file)
logger.warning('Skipping private Timing report file %s' % report_file)

0 comments on commit 06025b1

Please sign in to comment.