-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Accelergy-Project/allow_custom_art_ert
Add the option to provide ART and ERT keywords
- Loading branch information
Showing
11 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ART: | ||
version: 0.4 | ||
tables: | ||
- name: ComponentA | ||
area: 1.0 | ||
- name: ComponentB | ||
area: 2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ERT: | ||
version: '0.4' | ||
tables: | ||
- name: ComponentA | ||
actions: | ||
- name: ActionA1 | ||
arguments: | ||
global_cycle_seconds: 1e-09 | ||
action_latency_cycles: 1 | ||
energy: 1.0 | ||
- name: ActionA2 | ||
arguments: | ||
global_cycle_seconds: 1e-09 | ||
action_latency_cycles: 1 | ||
energy: 2.0 | ||
- name: ComponentB | ||
actions: | ||
- name: ActionB1 | ||
arguments: | ||
global_cycle_seconds: 1e-09 | ||
action_latency_cycles: 1 | ||
energy: 3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pathlib import Path | ||
import unittest | ||
|
||
from timeloopfe.v4.specification import Specification | ||
|
||
|
||
class TestArt(unittest.TestCase): | ||
TEST_DIR = Path(__file__).parent | ||
ARCH_NEST_PATH = str(TEST_DIR / 'arch_nest.yaml') | ||
ART_PATH = str(TEST_DIR / 'art.yaml') | ||
|
||
def test_art(self): | ||
spec = Specification.from_yaml_files( | ||
TestArt.ARCH_NEST_PATH, TestArt.ART_PATH | ||
) | ||
self.assertEqual(spec.ART.tables[0].name, "ComponentA") | ||
self.assertEqual(spec.ART.tables[0].area, 1.0) | ||
self.assertEqual(spec.ART.tables[1].name, "ComponentB") | ||
self.assertEqual(spec.ART.tables[1].area, 2.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
import unittest | ||
|
||
from timeloopfe.v4.specification import Specification | ||
|
||
|
||
class TestErt(unittest.TestCase): | ||
TEST_DIR = Path(__file__).parent | ||
ARCH_NEST_PATH = str(TEST_DIR / 'arch_nest.yaml') | ||
ERT_PATH = str(TEST_DIR / 'ert.yaml') | ||
|
||
def test_ert(self): | ||
spec = Specification.from_yaml_files( | ||
TestErt.ARCH_NEST_PATH, TestErt.ERT_PATH | ||
) | ||
|
||
ert = spec.ERT.tables | ||
|
||
self.assertEqual(ert[0].name, 'ComponentA') | ||
self.assertEqual(ert[0].actions[0].name, 'ActionA1') | ||
self.assertEqual(ert[0].actions[0].energy, 1.0) | ||
self.assertEqual(ert[0].actions[1].name, 'ActionA2') | ||
self.assertEqual(ert[0].actions[1].energy, 2.0) | ||
|
||
self.assertEqual(ert[1].name, 'ComponentB') | ||
self.assertEqual(ert[1].actions[0].name, 'ActionB1') | ||
self.assertEqual(ert[1].actions[0].energy, 3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from ..common.nodes import DictNode, ListNode | ||
|
||
|
||
class Art(DictNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
super().add_attr("version", default="0.4") | ||
super().add_attr("tables", Tables) | ||
|
||
def isempty(self) -> bool: | ||
return self.tables.isempty() | ||
|
||
|
||
class Tables(ListNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
super().add_attr("", Table) | ||
|
||
|
||
class Table(DictNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
super().add_attr("name", str) | ||
super().add_attr("area", float) | ||
|
||
|
||
Art.declare_attrs() | ||
Tables.declare_attrs() | ||
Table.declare_attrs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from ..common.nodes import DictNode, ListNode | ||
|
||
|
||
class Ert(DictNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
|
||
super().add_attr("version", default="0.4") | ||
super().add_attr("tables", Tables) | ||
|
||
def isempty(self) -> bool: | ||
return self.tables.isempty() | ||
|
||
|
||
class Tables(ListNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
|
||
super().add_attr("", Table) | ||
|
||
|
||
class Table(DictNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
|
||
super().add_attr("name", str) | ||
super().add_attr("actions", Actions) | ||
|
||
|
||
class Actions(ListNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
|
||
super().add_attr("", Action) | ||
|
||
|
||
class Action(DictNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
|
||
super().add_attr("name", str) | ||
super().add_attr("arguments", ActionArguments) | ||
super().add_attr("energy", float) | ||
|
||
|
||
class ActionArguments(DictNode): | ||
@classmethod | ||
def declare_attrs(cls, *args, **kwargs): | ||
super().declare_attrs(*args, **kwargs) | ||
|
||
|
||
for cls in [Ert, Tables, Table, Actions, Action, ActionArguments]: | ||
cls.declare_attrs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters