{"action":"created","comment":{"url":"https://api.github.com/repos/ARM-software/lisa/pulls/comments/91513340","pull_request_review_id":12021660,"id":91513340,"diff_hunk":"@@ -0,0 +1,106 @@\n+# SPDX-License-Identifier: Apache-2.0\n+#\n+# Copyright (C) 2016, ARM Limited and contributors.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+# not use this file except in compliance with the License.\n+# You may obtain a copy of the License at\n+#\n+# http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing, software\n+# distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+# See the License for the specific language governing permissions and\n+# limitations under the License.\n+#\n+\n+import logging\n+from collections import namedtuple, OrderedDict\n+\n+import pandas as pd\n+import numpy as np\n+\n+from devlib.utils.misc import memoized\n+\n+ActiveState = namedtuple(\"ActiveState\", [\"capacity\", \"power\"])\n+ActiveState.__new__.__defaults__ = (None, None)\n+\n+class EnergyModelNode(namedtuple(\"EnergyModelNode\",\n+                                 [\"cpus\", \"active_states\", \"idle_states\",\n+                                  \"power_domain\", \"freq_domain\"])):\n+    @property\n+    def max_capacity(self):\n+        return max(s.capacity for s in self.active_states.values())\n+\n+    def idle_state_idx(self, state):\n+        return self.idle_states.keys().index(state)\n+\n+EnergyModelNode.__new__.__defaults__ = (None, None, None, None, None)\n+\n+class PowerDomain(object):\n+    def __init__(self, idle_states, parent, cpus):\n+        self.cpus = set()\n+        self.idle_states = idle_states\n+\n+        self.parent = parent\n+        self.add_cpus(set(cpus))\n+\n+    def add_cpus(self, cpus):\n+        self.cpus = self.cpus.union(cpus)\n+        if self.parent:\n+            self.parent.add_cpus(self.cpus)\n+\n+    def __repr__(self):\n+        return \"PowerDomain(cpus={})\".format(list(self.cpus))\n+\n+class EnergyModel(object):\n+    \"\"\"\n+    Represents hierarchical CPU topology with power and capacity data\n+\n+    Describes a CPU topology similarly to trappy's Topology class, additionally\n+    describing relative CPU compute capacity, frequency domains and energy costs\n+    in various configurations.\n+\n+    The topology is stored in \"levels\", currently hard-coded to be \"cpu\" and\n+    \"cluster\". Each level is a list of EnergyModelNode objects. An EnergyModel","path":"libs/utils/energy_model.py","position":66,"original_position":66,"commit_id":"a833aa16021c29c3700f4294be14e5c7be297c73","original_commit_id":"4a5d6f93691219ef029f67a60a0fab70da43248b","user":{"login":"bjackman","id":2939691,"avatar_url":"https://avatars.githubusercontent.com/u/2939691?v=3","gravatar_id":"","url":"https://api.github.com/users/bjackman","html_url":"https://github.com/bjackman","followers_url":"https://api.github.com/users/bjackman/followers","following_url":"https://api.github.com/users/bjackman/following{/other_user}","gists_url":"https://api.github.com/users/bjackman/gists{/gist_id}","starred_url":"https://api.github.com/users/bjackman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjackman/subscriptions","organizations_url":"https://api.github.com/users/bjackman/orgs","repos_url":"https://api.github.com/users/bjackman/repos","events_url":"https://api.github.com/users/bjackman/events{/privacy}","received_events_url":"https://api.github.com/users/bjackman/received_events","type":"User","site_admin":false},"body":"Yeah, that's a good point. I think probably they should have no name at all and just be numerically indexed. We can assume that level 0 is the logical CPU. I'll play around with that and see if it works.","created_at":"2016-12-08T13:32:44Z","updated_at":"2016-12-08T13:32:44Z","html_url":"https://github.com/ARM-software/lisa/pull/246#discussion_r91513340","pull_request_url":"https://api.github.com/repos/ARM-software/lisa/pulls/246","_links":{"self":{"href":"https://api.github.com/repos/ARM-software/lisa/pulls/comments/91513340"},"html":{"href":"https://github.com/ARM-software/lisa/pull/246#discussion_r91513340"},"pull_request":{"href":"https://api.github.com/repos/ARM-software/lisa/pulls/246"}}},"pull_request":{"url":"https://api.github.com/repos/ARM-software/lisa/pulls/246","id":95949761,"html_url":"https://github.com/ARM-software/lisa/pull/246","diff_url":"https://github.com/ARM-software/lisa/pull/246.diff","patch_url":"https://github.com/ARM-software/lisa/pull/246.patch","issue_url":"https://api.github.com/repos/ARM-software/lisa/issues/246","number":246,"state":"open","locked":false,"title":"Initial energy model RFC","user":{"login":"bjackman","id":2939691,"avatar_url":"https://avatars.githubusercontent.com/u/2939691?v=3","gravatar_id":"","url":"https://api.github.com/users/bjackman","html_url":"https://github.com/bjackman","followers_url":"https://api.github.com/users/bjackman/followers","following_url":"https://api.github.com/users/bjackman/following{/other_user}","gists_url":"https://api.github.com/users/bjackman/gists{/gist_id}","starred_url":"https://api.github.com/users/bjackman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjackman/subscriptions","organizations_url":"https://api.github.com/users/bjackman/orgs","repos_url":"https://api.github.com/users/bjackman/repos","events_url":"https://api.github.com/users/bjackman/events{/privacy}","received_events_url":"https://api.github.com/users/bjackman/received_events","type":"User","site_admin":false},"body":"This class provides a model of systems with:\r\n\r\n- CPU capacity at different frequencies.\r\n- Power usage at different frequency.\r\n- Power usage in different idle states.\r\n\r\nThe model is aware of topologically shared resources (clusters),\r\ntopological dependencies for idle states (power domains) and frequency\r\ndomains.\r\n\r\nThe intended use case for this model is for testing energy-aware\r\nscheduling in a platform-agnostic way.\r\n\r\n----\r\n\r\nThis is an RFC of the EnergyModel class. This doesn't include the complex stuff, just the expression of the data. A later version will introduce code to estimate energy usage for a workload both by imagining ideal kernel behaviour and examining Trappy traces. This will be used to compare traces against \"ideal\" behaviour for automated tests of Energy Aware Scheduling. \r\n\r\nThe first commit (energy_model: Add EnergyModel class) contains the interesting bit, the rest of the commits demonstrate some intended uses.\r\n\r\nThis leaves lots of room for refactoring around LISA, for example the TestEnv::platform attribute becomes redundant. However I'm leaving that until the design is finalised here as the way that refactoring is done will probably need quite a lot of discussion.","created_at":"2016-11-30T18:45:20Z","updated_at":"2016-12-08T13:32:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3353e6af88c851477a27c44eb5f65230922727f7","assignee":{"login":"derkling","id":63746,"avatar_url":"https://avatars.githubusercontent.com/u/63746?v=3","gravatar_id":"","url":"https://api.github.com/users/derkling","html_url":"https://github.com/derkling","followers_url":"https://api.github.com/users/derkling/followers","following_url":"https://api.github.com/users/derkling/following{/other_user}","gists_url":"https://api.github.com/users/derkling/gists{/gist_id}","starred_url":"https://api.github.com/users/derkling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derkling/subscriptions","organizations_url":"https://api.github.com/users/derkling/orgs","repos_url":"https://api.github.com/users/derkling/repos","events_url":"https://api.github.com/users/derkling/events{/privacy}","received_events_url":"https://api.github.com/users/derkling/received_events","type":"User","site_admin":false},"assignees":[{"login":"derkling","id":63746,"avatar_url":"https://avatars.githubusercontent.com/u/63746?v=3","gravatar_id":"","url":"https://api.github.com/users/derkling","html_url":"https://github.com/derkling","followers_url":"https://api.github.com/users/derkling/followers","following_url":"https://api.github.com/users/derkling/following{/other_user}","gists_url":"https://api.github.com/users/derkling/gists{/gist_id}","starred_url":"https://api.github.com/users/derkling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derkling/subscriptions","organizations_url":"https://api.github.com/users/derkling/orgs","repos_url":"https://api.github.com/users/derkling/repos","events_url":"https://api.github.com/users/derkling/events{/privacy}","received_events_url":"https://api.github.com/users/derkling/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ARM-software/lisa/pulls/246/commits","review_comments_url":"https://api.github.com/repos/ARM-software/lisa/pulls/246/comments","review_comment_url":"https://api.github.com/repos/ARM-software/lisa/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ARM-software/lisa/issues/246/comments","statuses_url":"https://api.github.com/repos/ARM-software/lisa/statuses/a833aa16021c29c3700f4294be14e5c7be297c73","head":{"label":"bjackman:initial-energy-model-rfc","ref":"initial-energy-model-rfc","sha":"a833aa16021c29c3700f4294be14e5c7be297c73","user":{"login":"bjackman","id":2939691,"avatar_url":"https://avatars.githubusercontent.com/u/2939691?v=3","gravatar_id":"","url":"https://api.github.com/users/bjackman","html_url":"https://github.com/bjackman","followers_url":"https://api.github.com/users/bjackman/followers","following_url":"https://api.github.com/users/bjackman/following{/other_user}","gists_url":"https://api.github.com/users/bjackman/gists{/gist_id}","starred_url":"https://api.github.com/users/bjackman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjackman/subscriptions","organizations_url":"https://api.github.com/users/bjackman/orgs","repos_url":"https://api.github.com/users/bjackman/repos","events_url":"https://api.github.com/users/bjackman/events{/privacy}","received_events_url":"https://api.github.com/users/bjackman/received_events","type":"User","site_admin":false},"repo":{"id":61138100,"name":"lisa","full_name":"bjackman/lisa","owner":{"login":"bjackman","id":2939691,"avatar_url":"https://avatars.githubusercontent.com/u/2939691?v=3","gravatar_id":"","url":"https://api.github.com/users/bjackman","html_url":"https://github.com/bjackman","followers_url":"https://api.github.com/users/bjackman/followers","following_url":"https://api.github.com/users/bjackman/following{/other_user}","gists_url":"https://api.github.com/users/bjackman/gists{/gist_id}","starred_url":"https://api.github.com/users/bjackman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjackman/subscriptions","organizations_url":"https://api.github.com/users/bjackman/orgs","repos_url":"https://api.github.com/users/bjackman/repos","events_url":"https://api.github.com/users/bjackman/events{/privacy}","received_events_url":"https://api.github.com/users/bjackman/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bjackman/lisa","description":"Linux Integrated System Analysis","fork":true,"url":"https://api.github.com/repos/bjackman/lisa","forks_url":"https://api.github.com/repos/bjackman/lisa/forks","keys_url":"https://api.github.com/repos/bjackman/lisa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bjackman/lisa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bjackman/lisa/teams","hooks_url":"https://api.github.com/repos/bjackman/lisa/hooks","issue_events_url":"https://api.github.com/repos/bjackman/lisa/issues/events{/number}","events_url":"https://api.github.com/repos/bjackman/lisa/events","assignees_url":"https://api.github.com/repos/bjackman/lisa/assignees{/user}","branches_url":"https://api.github.com/repos/bjackman/lisa/branches{/branch}","tags_url":"https://api.github.com/repos/bjackman/lisa/tags","blobs_url":"https://api.github.com/repos/bjackman/lisa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bjackman/lisa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bjackman/lisa/git/refs{/sha}","trees_url":"https://api.github.com/repos/bjackman/lisa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bjackman/lisa/statuses/{sha}","languages_url":"https://api.github.com/repos/bjackman/lisa/languages","stargazers_url":"https://api.github.com/repos/bjackman/lisa/stargazers","contributors_url":"https://api.github.com/repos/bjackman/lisa/contributors","subscribers_url":"https://api.github.com/repos/bjackman/lisa/subscribers","subscription_url":"https://api.github.com/repos/bjackman/lisa/subscription","commits_url":"https://api.github.com/repos/bjackman/lisa/commits{/sha}","git_commits_url":"https://api.github.com/repos/bjackman/lisa/git/commits{/sha}","comments_url":"https://api.github.com/repos/bjackman/lisa/comments{/number}","issue_comment_url":"https://api.github.com/repos/bjackman/lisa/issues/comments{/number}","contents_url":"https://api.github.com/repos/bjackman/lisa/contents/{+path}","compare_url":"https://api.github.com/repos/bjackman/lisa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bjackman/lisa/merges","archive_url":"https://api.github.com/repos/bjackman/lisa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bjackman/lisa/downloads","issues_url":"https://api.github.com/repos/bjackman/lisa/issues{/number}","pulls_url":"https://api.github.com/repos/bjackman/lisa/pulls{/number}","milestones_url":"https://api.github.com/repos/bjackman/lisa/milestones{/number}","notifications_url":"https://api.github.com/repos/bjackman/lisa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bjackman/lisa/labels{/name}","releases_url":"https://api.github.com/repos/bjackman/lisa/releases{/id}","deployments_url":"https://api.github.com/repos/bjackman/lisa/deployments","created_at":"2016-06-14T16:22:30Z","updated_at":"2016-06-14T16:22:33Z","pushed_at":"2016-12-08T12:39:45Z","git_url":"git://github.com/bjackman/lisa.git","ssh_url":"git@github.com:bjackman/lisa.git","clone_url":"https://github.com/bjackman/lisa.git","svn_url":"https://github.com/bjackman/lisa","homepage":"","size":39673,"stargazers_count":0,"watchers_count":0,"language":"Jupyter Notebook","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ARM-software:master","ref":"master","sha":"09a30120a001fb1cd5132eb31bf12f36f8427e91","user":{"login":"ARM-software","id":5690313,"avatar_url":"https://avatars.githubusercontent.com/u/5690313?v=3","gravatar_id":"","url":"https://api.github.com/users/ARM-software","html_url":"https://github.com/ARM-software","followers_url":"https://api.github.com/users/ARM-software/followers","following_url":"https://api.github.com/users/ARM-software/following{/other_user}","gists_url":"https://api.github.com/users/ARM-software/gists{/gist_id}","starred_url":"https://api.github.com/users/ARM-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARM-software/subscriptions","organizations_url":"https://api.github.com/users/ARM-software/orgs","repos_url":"https://api.github.com/users/ARM-software/repos","events_url":"https://api.github.com/users/ARM-software/events{/privacy}","received_events_url":"https://api.github.com/users/ARM-software/received_events","type":"Organization","site_admin":false},"repo":{"id":47548304,"name":"lisa","full_name":"ARM-software/lisa","owner":{"login":"ARM-software","id":5690313,"avatar_url":"https://avatars.githubusercontent.com/u/5690313?v=3","gravatar_id":"","url":"https://api.github.com/users/ARM-software","html_url":"https://github.com/ARM-software","followers_url":"https://api.github.com/users/ARM-software/followers","following_url":"https://api.github.com/users/ARM-software/following{/other_user}","gists_url":"https://api.github.com/users/ARM-software/gists{/gist_id}","starred_url":"https://api.github.com/users/ARM-software/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARM-software/subscriptions","organizations_url":"https://api.github.com/users/ARM-software/orgs","repos_url":"https://api.github.com/users/ARM-software/repos","events_url":"https://api.github.com/users/ARM-software/events{/privacy}","received_events_url":"https://api.github.com/users/ARM-software/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARM-software/lisa","description":"Linux Integrated System Analysis","fork":false,"url":"https://api.github.com/repos/ARM-software/lisa","forks_url":"https://api.github.com/repos/ARM-software/lisa/forks","keys_url":"https://api.github.com/repos/ARM-software/lisa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARM-software/lisa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARM-software/lisa/teams","hooks_url":"https://api.github.com/repos/ARM-software/lisa/hooks","issue_events_url":"https://api.github.com/repos/ARM-software/lisa/issues/events{/number}","events_url":"https://api.github.com/repos/ARM-software/lisa/events","assignees_url":"https://api.github.com/repos/ARM-software/lisa/assignees{/user}","branches_url":"https://api.github.com/repos/ARM-software/lisa/branches{/branch}","tags_url":"https://api.github.com/repos/ARM-software/lisa/tags","blobs_url":"https://api.github.com/repos/ARM-software/lisa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARM-software/lisa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARM-software/lisa/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARM-software/lisa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARM-software/lisa/statuses/{sha}","languages_url":"https://api.github.com/repos/ARM-software/lisa/languages","stargazers_url":"https://api.github.com/repos/ARM-software/lisa/stargazers","contributors_url":"https://api.github.com/repos/ARM-software/lisa/contributors","subscribers_url":"https://api.github.com/repos/ARM-software/lisa/subscribers","subscription_url":"https://api.github.com/repos/ARM-software/lisa/subscription","commits_url":"https://api.github.com/repos/ARM-software/lisa/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARM-software/lisa/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARM-software/lisa/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARM-software/lisa/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARM-software/lisa/contents/{+path}","compare_url":"https://api.github.com/repos/ARM-software/lisa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARM-software/lisa/merges","archive_url":"https://api.github.com/repos/ARM-software/lisa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARM-software/lisa/downloads","issues_url":"https://api.github.com/repos/ARM-software/lisa/issues{/number}","pulls_url":"https://api.github.com/repos/ARM-software/lisa/pulls{/number}","milestones_url":"https://api.github.com/repos/ARM-software/lisa/milestones{/number}","notifications_url":"https://api.github.com/repos/ARM-software/lisa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARM-software/lisa/labels{/name}","releases_url":"https://api.github.com/repos/ARM-software/lisa/releases{/id}","deployments_url":"https://api.github.com/repos/ARM-software/lisa/deployments","created_at":"2015-12-07T11:32:56Z","updated_at":"2016-12-02T01:14:32Z","pushed_at":"2016-12-08T12:52:10Z","git_url":"git://github.com/ARM-software/lisa.git","ssh_url":"git@github.com:ARM-software/lisa.git","clone_url":"https://github.com/ARM-software/lisa.git","svn_url":"https://github.com/ARM-software/lisa","homepage":"","size":54731,"stargazers_count":13,"watchers_count":13,"language":"Jupyter Notebook","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":47,"forks":21,"open_issues":47,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ARM-software/lisa/pulls/246"},"html":{"href":"https://github.com/ARM-software/lisa/pull/246"},"issue":{"href":"https://api.github.com/repos/ARM-software/lisa/issues/246"},"comments":{"href":"https://api.github.com/repos/ARM-software/lisa/issues/246/comments"},"review_comments":{"href":"https://api.github.com/repos/ARM-software/lisa/pulls/246/comments"},"review_comment":{"href":"https://api.github.com/repos/ARM-software/lisa/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ARM-software/lisa/pulls/246/commits"},"statuses":{"href":"https://api.github.com/repos/ARM-software/lisa/statuses/a833aa16021c29c3700f4294be14e5c7be297c73"}}}}
{"actor":{"display_login":"bjackman"}}