Last active
March 16, 2023 10:43
-
-
Save V0XNIHILI/2b6fa61edd4c06d9ffce5551065124c1 to your computer and use it in GitHub Desktop.
Functions to compute energy per operation on a chip
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
"""Data taken from paper: Computing's Energy Problem (and what we can do about it) - Mark Horowitz | |
All output energies are in pJ (pico Joule) | |
""" | |
import math | |
E_INT_ADD_PER_BIT = (0.03 / 8 + 0.1 / 32) / 2 | |
def int_add(n_bits: int): | |
if n_bits == 8: | |
return 0.03 | |
if n_bits == 32: | |
return 0.1 | |
return E_INT_ADD_PER_BIT * n_bits | |
E_INT_MUL_PER_BIT = (0.2 / 8**2 + 3.1 / 32**2) / 2 | |
def int_mul(n_bits: int): | |
if n_bits == 8: | |
return 0.2 | |
if n_bits == 32: | |
return 3.1 | |
return E_INT_MUL_PER_BIT * n_bits**2 | |
E_FP_ADD_PER_BIT = (0.4 / 16 + 0.9 / 32) / 2 | |
def fp_add(n_bits: int): | |
if n_bits == 16: | |
return 0.4 | |
if n_bits == 32: | |
return 0.9 | |
return E_FP_ADD_PER_BIT * n_bits | |
E_FP_MUL_PER_BIT = (1.1 / 16**2 + 3.7 / 32**2) / 2 | |
def fp_mul(n_bits: int): | |
if n_bits == 16: | |
return 1.1 | |
if n_bits == 32: | |
return 3.7 | |
return E_FP_MUL_PER_BIT * n_bits**2 | |
E_DRAM = (1.3 + 2.6) / 2 * 1000 | |
E_CACHE = (10 / math.sqrt(8) + 20 / math.sqrt(32) + 100 / math.sqrt(1000)) / 3 | |
def memory_access(n_bytes: int, location: str): | |
"""Assuming 64-bit word size""" | |
if location == "cache": | |
return E_CACHE * math.sqrt(n_bytes / 1000) | |
if location == "DRAM": | |
return | |
else: | |
raise ValueError(f"Unknown location {location}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment