-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sdram_per_timestep' into extractorJ
- Loading branch information
Showing
44 changed files
with
702 additions
and
240 deletions.
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
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,63 @@ | ||
from six import add_metaclass | ||
|
||
from spinn_utilities.abstract_base import ( | ||
AbstractBase, abstractmethod, abstractproperty) | ||
|
||
|
||
@add_metaclass(AbstractBase) | ||
class AbstractSDRAM(object): | ||
""" Represents an amount of SDRAM used on a chip in the\ | ||
machine. | ||
""" | ||
|
||
@abstractmethod | ||
def get_total_sdram(self, n_timesteps): | ||
""" | ||
The total sdram. | ||
:param n_timesteps: number of timesteps to cost for | ||
:type n_timesteps: int | ||
:return: | ||
""" | ||
|
||
@abstractmethod | ||
def __add__(self, other): | ||
""" Combines this SDRAM resource with the other one and creates a new one | ||
:param other: another SDRAM resource | ||
:type other: AbstractSDRAM | ||
:return: a New AbstractSDRAM | ||
:rtype AbstractSDRAM | ||
""" | ||
|
||
@abstractmethod | ||
def __sub__(self, other): | ||
""" Creates a new SDRAM which is this one less the other | ||
:param other: another SDRAM resource | ||
:type other: AbstractSDRAM | ||
:return: a New AbstractSDRAM | ||
:rtype AbstractSDRAM | ||
""" | ||
|
||
@abstractmethod | ||
def sub_from(self, other): | ||
""" Creates a new SDRAM which is the other less this one | ||
:param other: another SDRAM resource | ||
:type other: AbstractSDRAM | ||
:return: a New AbstractSDRAM | ||
:rtype AbstractSDRAM | ||
""" | ||
|
||
@abstractproperty | ||
def fixed(self): | ||
""" Returns the fixed sdram cost | ||
""" | ||
|
||
@abstractproperty | ||
def per_timestep(self): | ||
""" Returns extra sdram cost for each additional timestep | ||
Warning may well be zero | ||
""" |
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,56 @@ | ||
from .abstract_sdram import AbstractSDRAM | ||
|
||
|
||
class ConstantSDRAM(AbstractSDRAM): | ||
""" Represents an amount of SDRAM used on a chip in the machine. | ||
This is used when the amount of SDRAM needed is not effected by runtime | ||
""" | ||
|
||
__slots__ = [ | ||
# The amount of SDRAM in bytes | ||
"_sdram" | ||
] | ||
|
||
def __init__(self, sdram): | ||
""" | ||
:param sdram: The amount of SDRAM in bytes | ||
:type sdram: int | ||
:raise None: No known exceptions are raised | ||
""" | ||
self._sdram = sdram | ||
|
||
def get_total_sdram(self, n_timesteps): | ||
return self._sdram | ||
|
||
@property | ||
def fixed(self): | ||
return self._sdram | ||
|
||
@property | ||
def per_timestep(self): | ||
return 0 | ||
|
||
def __add__(self, other): | ||
if isinstance(other, ConstantSDRAM): | ||
return ConstantSDRAM( | ||
self._sdram + other._sdram) | ||
else: | ||
# The other is more complex so delegate to it | ||
return other.__add__(self) | ||
|
||
def __sub__(self, other): | ||
if isinstance(other, ConstantSDRAM): | ||
return ConstantSDRAM( | ||
self._sdram - other._sdram) | ||
else: | ||
# The other is more complex so delegate to it | ||
return other.sub_from(self) | ||
|
||
def sub_from(self, other): | ||
if isinstance(other, ConstantSDRAM): | ||
return ConstantSDRAM( | ||
other._sdram - self._sdram) | ||
else: | ||
# The other is more complex so delegate to it | ||
return other - self |
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 was deleted.
Oops, something went wrong.
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,76 @@ | ||
from .abstract_sdram import AbstractSDRAM | ||
from .constant_sdram import ConstantSDRAM | ||
from pacman.exceptions import PacmanConfigurationException | ||
|
||
|
||
class VariableSDRAM(AbstractSDRAM): | ||
""" Represents an amount of SDRAM used on a chip in the machine. | ||
This is where the usage increase as the run time increases | ||
""" | ||
|
||
__slots__ = [ | ||
# The amount of SDRAM in bytes used no matter what | ||
"_fixed_sdram" | ||
# The amount of extra SDRAm used for each timestep | ||
"_per_timestep_sdram" | ||
] | ||
|
||
def __init__( | ||
self, fixed_sdram, per_timestep_sdram): | ||
""" | ||
:param sdram: The amount of SDRAM in bytes | ||
:type sdram: int | ||
:raise None: No known exceptions are raised | ||
""" | ||
self._fixed_sdram = fixed_sdram | ||
self._per_timestep_sdram = per_timestep_sdram | ||
|
||
def get_total_sdram(self, n_timesteps): | ||
if n_timesteps: | ||
return self._fixed_sdram + \ | ||
(self._per_timestep_sdram * n_timesteps) | ||
else: | ||
if self._per_timestep_sdram == 0: | ||
return self._fixed_sdram | ||
else: | ||
raise PacmanConfigurationException( | ||
"Unable to run forever with a variable SDRAM cost") | ||
|
||
@property | ||
def fixed(self): | ||
return self._fixed_sdram | ||
|
||
@property | ||
def per_timestep(self): | ||
return self._per_timestep_sdram | ||
|
||
def __add__(self, other): | ||
if isinstance(other, ConstantSDRAM): | ||
return VariableSDRAM( | ||
self._fixed_sdram + other.fixed, | ||
self._per_timestep_sdram) | ||
else: | ||
return VariableSDRAM( | ||
self._fixed_sdram + other._fixed_sdram, | ||
self._per_timestep_sdram + other._per_timestep_sdram) | ||
|
||
def __sub__(self, other): | ||
if isinstance(other, ConstantSDRAM): | ||
return VariableSDRAM( | ||
self._fixed_sdram - other.fixed, | ||
self._per_timestep_sdram) | ||
else: | ||
return VariableSDRAM( | ||
self._fixed_sdram - other._fixed_sdram, | ||
self._per_timestep_sdram - other._per_timestep_sdram) | ||
|
||
def sub_from(self, other): | ||
if isinstance(other, ConstantSDRAM): | ||
return VariableSDRAM( | ||
other.fixed - self._fixed_sdram, | ||
0 - self._per_timestep_sdram) | ||
else: | ||
return VariableSDRAM( | ||
other._fixed_sdram - self._fixed_sdram, | ||
other._per_timestep_sdram - self._per_timestep_sdram) |
Oops, something went wrong.