hwcomponents 0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: hwcomponents
3
+ Version: 0.5
4
+ Summary: Hardware Component Energy+Area Models
5
+ Author-email: Tanner Andrulis <andrulis@mit.edu>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+
10
+ # HWComponents
11
+ The HWComponents (Hardware Components) package, part of the
12
+ [CiMLoop](https://github.com/mit-emze/cimloop) project, provides an interface for the
13
+ estimation of energy, area, and leakage power of hardware components in hardware
14
+ architectures. Key features in HWComponents include:
15
+
16
+ [Information about the package is available on the hwcomponents website](https://accelergy-project.github.io/hwcomponents/).
17
+
18
+ ## Citing HWComponents
19
+
20
+ If you use this package in your work, please cite the CiMLoop project:
21
+
22
+ ```bibtex
23
+ @INPROCEEDINGS{10590023,
24
+ author={Andrulis, Tanner and Emer, Joel S. and Sze, Vivienne},
25
+ booktitle={2024 IEEE International Symposium on Performance Analysis of Systems and Software (ISPASS)},
26
+ title={CiMLoop: A Flexible, Accurate, and Fast Compute-In-Memory Modeling Tool},
27
+ year={2024},
28
+ volume={},
29
+ number={},
30
+ pages={10-23},
31
+ keywords={Performance evaluation;Accuracy;Computational modeling;Computer architecture;Artificial neural networks;In-memory computing;Data models;Compute-In-Memory;Processing-In-Memory;Analog;Deep Neural Networks;Systems;Hardware;Modeling;Open-Source},
32
+ doi={10.1109/ISPASS61541.2024.00012}
33
+ }
34
+ @INPROCEEDINGS{8942149,
35
+ author={Wu, Yannan Nellie and Emer, Joel S. and Sze, Vivienne},
36
+ booktitle={2019 IEEE/ACM International Conference on Computer-Aided Design (ICCAD)},
37
+ title={Accelergy: An Architecture-Level Energy Estimation Methodology for Accelerator Designs},
38
+ year={2019},
39
+ volume={},
40
+ number={},
41
+ pages={1-8},
42
+ keywords={Program processors;Electric breakdown;Neural networks;Estimation;Hardware;Energy efficiency;Compounds},
43
+ doi={10.1109/ICCAD45719.2019.8942149}
44
+ }
45
+ ```
@@ -0,0 +1,36 @@
1
+ # HWComponents
2
+ The HWComponents (Hardware Components) package, part of the
3
+ [CiMLoop](https://github.com/mit-emze/cimloop) project, provides an interface for the
4
+ estimation of energy, area, and leakage power of hardware components in hardware
5
+ architectures. Key features in HWComponents include:
6
+
7
+ [Information about the package is available on the hwcomponents website](https://accelergy-project.github.io/hwcomponents/).
8
+
9
+ ## Citing HWComponents
10
+
11
+ If you use this package in your work, please cite the CiMLoop project:
12
+
13
+ ```bibtex
14
+ @INPROCEEDINGS{10590023,
15
+ author={Andrulis, Tanner and Emer, Joel S. and Sze, Vivienne},
16
+ booktitle={2024 IEEE International Symposium on Performance Analysis of Systems and Software (ISPASS)},
17
+ title={CiMLoop: A Flexible, Accurate, and Fast Compute-In-Memory Modeling Tool},
18
+ year={2024},
19
+ volume={},
20
+ number={},
21
+ pages={10-23},
22
+ keywords={Performance evaluation;Accuracy;Computational modeling;Computer architecture;Artificial neural networks;In-memory computing;Data models;Compute-In-Memory;Processing-In-Memory;Analog;Deep Neural Networks;Systems;Hardware;Modeling;Open-Source},
23
+ doi={10.1109/ISPASS61541.2024.00012}
24
+ }
25
+ @INPROCEEDINGS{8942149,
26
+ author={Wu, Yannan Nellie and Emer, Joel S. and Sze, Vivienne},
27
+ booktitle={2019 IEEE/ACM International Conference on Computer-Aided Design (ICCAD)},
28
+ title={Accelergy: An Architecture-Level Energy Estimation Methodology for Accelerator Designs},
29
+ year={2019},
30
+ volume={},
31
+ number={},
32
+ pages={1-8},
33
+ keywords={Program processors;Electric breakdown;Neural networks;Estimation;Hardware;Energy efficiency;Compounds},
34
+ doi={10.1109/ICCAD45719.2019.8942149}
35
+ }
36
+ ```
@@ -0,0 +1,10 @@
1
+ from hwcomponents.model import EnergyAreaModel, actionDynamicEnergy
2
+ from hwcomponents.find_models import get_models
3
+ from hwcomponents.select_models import get_energy, get_area
4
+ import hwcomponents.scaling as scaling
5
+ from hwcomponents.select_models import (
6
+ get_area,
7
+ get_energy,
8
+ get_model,
9
+ get_leak_power,
10
+ )
@@ -0,0 +1,99 @@
1
+ import logging
2
+ import queue
3
+ from typing import List, Union
4
+ from logging.handlers import QueueHandler
5
+
6
+ logging.basicConfig(
7
+ format="%(levelname)-8s%(message)s",
8
+ )
9
+ if logging.getLogger().level == logging.NOTSET:
10
+ logging.getLogger().setLevel(logging.INFO)
11
+
12
+ LOG_QUEUES = {}
13
+ NAME2LOGGER = {}
14
+
15
+
16
+ def queue_from_logger(logger: Union[logging.Logger, str]) -> List[str]:
17
+ if isinstance(logger, str) and logger in LOG_QUEUES:
18
+ return LOG_QUEUES[logger]
19
+ for name, other_logger in NAME2LOGGER.items():
20
+ if other_logger is logger and name in LOG_QUEUES:
21
+ return LOG_QUEUES[name]
22
+ raise ValueError(f"Logger {logger} not found")
23
+
24
+
25
+ def messages_from_logger(logger: Union[logging.Logger, str]) -> List[str]:
26
+ return [m.getMessage() for m in queue_from_logger(logger).queue]
27
+
28
+
29
+ def get_logger(name: str) -> logging.Logger:
30
+ logger = logging.getLogger(name)
31
+ logger.propagate = False
32
+ NAME2LOGGER[name] = logger
33
+ if name not in LOG_QUEUES:
34
+ LOG_QUEUES[name] = queue.Queue()
35
+ logger.addHandler(QueueHandler(LOG_QUEUES[name]))
36
+ return logger
37
+
38
+
39
+ def move_queue_from_one_logger_to_another(
40
+ src: Union[logging.Logger, str], dest: Union[logging.Logger, str]
41
+ ):
42
+ src_queue = queue_from_logger(src)
43
+ dest_queue = queue_from_logger(dest)
44
+ if src_queue is dest_queue:
45
+ return
46
+ while not src_queue.empty():
47
+ dest_queue.put(src_queue.get())
48
+
49
+
50
+ def pop_all_messages(logger: Union[logging.Logger, str]) -> List[str]:
51
+ messages = messages_from_logger(logger)
52
+ queue_from_logger(logger).queue.clear()
53
+ return messages
54
+
55
+
56
+ def print_messages(logger: Union[logging.Logger, str]):
57
+ for message in messages_from_logger(logger):
58
+ print(message)
59
+
60
+
61
+ class ListLoggable:
62
+ def __init__(self, name: str = None):
63
+ self._init_logger(name)
64
+
65
+ def _init_logger(self, name: str = None):
66
+ if self.logger is not None:
67
+ return
68
+ if name is None:
69
+ if hasattr(self, "__name__"):
70
+ name = self.__name__
71
+ else:
72
+ name = self.__class__.__name__
73
+ self.logger = get_logger(name)
74
+
75
+ @property
76
+ def logger(self) -> logging.Logger:
77
+ if getattr(self, "_logger", None) is None:
78
+ if hasattr(self, "__name__"):
79
+ self._logger = get_logger(self.__name__)
80
+ else:
81
+ self._logger = get_logger(self.__class__.__name__)
82
+ self._logger.setLevel(logging.INFO)
83
+ return self._logger
84
+
85
+
86
+ def log_all_lines(logger_name, level, to_split):
87
+ logger = logging.getLogger(logger_name)
88
+ if isinstance(level, str):
89
+ logfunc = getattr(logger, level)
90
+ for s in to_split.splitlines():
91
+ logfunc(s)
92
+ else:
93
+ for s in to_split.splitlines():
94
+ logging.getLogger(logger_name).log(level, s)
95
+
96
+
97
+ def clear_logs():
98
+ for name, queue in LOG_QUEUES.items():
99
+ queue.queue.clear()