MFMv2.0.10
Movable Feast Machine Simulator 2.0.10
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends
MFM::Tile< CC > Class Template Reference

#include <Tile.h>

Public Member Functions

void ReportTileStatus (Logger::Level level)
 
const char * GetLabel ()
 
OString16GetLabelPrinter ()
 
 Tile ()
 
void SetIgnoreThreadingProblems (bool value)
 
void Reinit ()
 
void ClearAtoms ()
 
void CheckCacheFromDir (Dir direction, const Tile &otherTile)
 
void SetGeneration (u8 generation)
 
u8 GetGeneration () const
 
void Connect (Tile< CC > &other, Dir toCache)
 
ConnectionGetConnection (Dir cache)
 
u32 GetSites () const
 
u32 GetTileWidth ()
 
RandomGetRandom ()
 
ElementTable< CC > & GetElementTable ()
 
const ElementTable< CC > & GetElementTable () const
 
const Element< CC > * GetElement (const u32 elementType) const
 
bool IsConnected (Dir dir) const
 
bool HasAnyConnections (Dir regionDir) const
 
bool IsLiveSite (const SPoint &location) const
 
u64 GetEventsExecuted () const
 
Dir RegionAt (const SPoint &pt, u32 reach) const
 
Dir CacheAt (const SPoint &pt) const
 
Dir SharedAt (const SPoint &pt) const
 
Dir VisibleAt (const SPoint &pt) const
 
const T * GetAtom (const SPoint &pt) const
 
T * GetWritableAtom (const SPoint &pt)
 
const T * GetAtom (s32 x, s32 y) const
 
T * GetWritableAtom (s32 x, s32 y)
 
const T * GetUncachedAtom (const SPoint &pt) const
 
const T * GetUncachedAtom (s32 x, s32 y) const
 
u64 GetUncachedSiteEvents (const SPoint site) const
 
u32 GetUncachedWriteAge (const SPoint site) const
 
void SendAcknowledgmentPacket (Packet< T > &packet)
 
void ReceivePacket (Packet< T > &packet)
 
void FillLastExecutedAtom (SPoint &out)
 
void PlaceAtom (const T &atom, const SPoint &pt)
 
void PlaceInternalAtom (const T &atom, const SPoint &pt)
 
bool FlushAndWaitOnAllBuffers (u32 dirWaitWord)
 
void ReportIfBuffersAreNonEmpty ()
 
void SetExecuteOwnEvents (bool value)
 
bool GetExecutingOwnEvents () const
 
void Execute ()
 
u32 GetAtomCount (ElementType atomType) const
 
void InternalPutAtom (const T &atom, s32 x, s32 y)
 
void SetAtomCount (ElementType atomType, s32 count)
 
void Start ()
 
void Pause ()
 
bool IsRunReady ()
 
void Run ()
 
bool IsPauseReady ()
 
void RequestPause ()
 
void IncrAtomCount (ElementType atomType, s32 delta)
 
void AssertValidAtomCounts () const
 
void RecountAtomsIfNeeded ()
 
void RecountAtoms ()
 
u64 WriteEPSRasterLine (ByteSink &outstrm, u32 lineIdx)
 
void RegisterElement (const Element< CC > &anElement)
 
void SetBackgroundRadiation (bool value)
 
void SingleXRay ()
 
void SingleXRay (u32 x, u32 y)
 
void XRay (u32 siteOdds, u32 bitOdds)
 

Static Public Member Functions

static bool IsInCache (const SPoint &pt)
 
static bool IsOwnedSite (const SPoint &location)
 
static bool IsInTile (const SPoint &pt)
 
static bool IsInUncachedTile (const SPoint &pt)
 
static void * ExecuteThreadHelper (void *tilePtr)
 

Static Public Attributes

static const u32 EVENT_WINDOW_RADIUS = R
 
static const u32 TILE_WIDTH = W
 
static const u32 TILE_SIZE = TILE_WIDTH * TILE_WIDTH
 
static const u32 ELEMENT_TABLE_BITS = B
 
static const u32 ELEMENT_TABLE_SIZE = 1u<<ELEMENT_TABLE_BITS
 
static const u32 OWNED_SIDE = TILE_WIDTH-2*R
 

Friends

class EventWindow< CC >
 

Detailed Description

template<class CC>
class MFM::Tile< CC >

The representation of a single indefinitely scalable hardware tile (whether real or simulated).

Constructor & Destructor Documentation

template<class CC >
MFM::Tile< CC >::Tile ( )

Constructs a new Tile.

Member Function Documentation

template<class CC >
void MFM::Tile< CC >::AssertValidAtomCounts ( ) const

Do a full count of atom types and FAIL unless the atom histogram in m_atomCount is consistent with the content of m_atoms.

template<class CC >
Dir MFM::Tile< CC >::CacheAt ( const SPoint pt) const

Finds the cache in this Tile which contains a specified SPoint.

Parameters
ptThe Point which should specify the location of a cache.
Returns
The direction of the cache specified by pt, or (Dir)-1 if there is no such cache.
template<class CC >
void MFM::Tile< CC >::CheckCacheFromDir ( Dir  direction,
const Tile< CC > &  otherTile 
)

Checks part of this Tile's cache assuming the given otherTile lies in the given direction from this tile, and the two tiles are connected. Logs debug messages if cache mismatches are found.

Remarks
This method relies on grid connectivity knowledge that actual distributed Tiles cannot be expected to receive.
template<class CC >
void MFM::Tile< CC >::ClearAtoms ( )

Resets all Atoms and their counts to the Empty atom.

template<class CC >
void MFM::Tile< CC >::Connect ( Tile< CC > &  other,
Dir  toCache 
)

Connects another Tile to one of this Tile's caches.

Parameters
otherThe other Tile to connect to this one.
toCacheThe cache to share with other.
template<class CC >
void MFM::Tile< CC >::Execute ( )

Executes a single new EventWindow at a randomly chosen location.

template<class CC >
void * MFM::Tile< CC >::ExecuteThreadHelper ( void *  tilePtr)
static

Used during thread execution to call the execution loop.

Parameters
tilePtrA pointer to the tile wished to put into an execution loop.
template<class CC >
void MFM::Tile< CC >::FillLastExecutedAtom ( SPoint out)

Fills a specified Point with the coordinates of the last EventWindow center.

Parameters
outThe Point to fill with the coordinates of the last EventWindow center. All previous data held within this Point will be erased.
template<class CC >
bool MFM::Tile< CC >::FlushAndWaitOnAllBuffers ( u32  dirWaitWord)

Process all incoming and outgoing Packets which are pending on this Tile .

Parameters
dirWaitWordA word describing which buffers need to be waited on for Packet communication.
Returns
true if any connection locks are currently held (by either end), else false
template<class CC>
const T* MFM::Tile< CC >::GetAtom ( const SPoint pt) const
inline

Gets an Atom from a specified point in this Tile.

Parameters
ptThe location of the Atom to retrieve.
Returns
A pointer to the Atom at location pt.
template<class CC>
const T* MFM::Tile< CC >::GetAtom ( s32  x,
s32  y 
) const
inline

Gets an Atom from a specified point in this Tile.

Parameters
xThe x coordinate of the location of the Atom to retrieve.
yThe y coordinate of the location of the Atom to retrieve.
Returns
A pointer to the Atom at the specified location.
template<class CC >
u32 MFM::Tile< CC >::GetAtomCount ( ElementType  atomType) const

Gets the number of Atoms in this Tile's main memory of a specified type.

Parameters
atomTypeThe ElementType of the Atoms to retreive this Tile's count of.
Returns
The number of Atoms in this Tile's main memory of type atomType.
template<class CC >
Connection * MFM::Tile< CC >::GetConnection ( Dir  cache)

Finds the Connection which corresponds to one of this tile's caches.

Parameters
cacheThe direction of the held Connection to find.
Returns
a pointer to the held connection, or NULL if there is none.
template<class CC>
const Element<CC>* MFM::Tile< CC >::GetElement ( const u32  elementType) const
inline

Looks up an element type in this Tile's ElementTable.

Returns
a pointer to the Element associated with elementType, or NULL if there is no such Element.
template<class CC>
ElementTable<CC>& MFM::Tile< CC >::GetElementTable ( )
inline

Gets a reference to this Tile's ElementTable.

Returns
a reference to this Tile's ElementTable.
template<class CC>
const ElementTable<CC>& MFM::Tile< CC >::GetElementTable ( ) const
inline

Gets a const reference to this Tile's ElementTable.

Returns
a reference to this Tile's ElementTable.
template<class CC>
u64 MFM::Tile< CC >::GetEventsExecuted ( ) const
inline

Gets the number of events executed within this Tile since initialization.

Returns
The number of events executed within this Tile since initialization.
template<class CC>
bool MFM::Tile< CC >::GetExecutingOwnEvents ( ) const
inline

Checks to see whether or not this Tile is executing its own events or if it is simply processing other incoming Packets.

Returns
true if this Tile is executing its own events, else false .
template<class CC>
u8 MFM::Tile< CC >::GetGeneration ( ) const
inline

Gets the tile generation

template<class CC>
const char* MFM::Tile< CC >::GetLabel ( )
inline

Returns this Tile's label, if any. May return an empty string, never returns null.

template<class CC>
OString16& MFM::Tile< CC >::GetLabelPrinter ( )
inline

Get access to reset or set the Tile's label.

template<class CC >
Random & MFM::Tile< CC >::GetRandom ( )

Gets a reference to this Tile's PRNG. a reference to this Tile's PRNG.

template<class CC>
u32 MFM::Tile< CC >::GetSites ( ) const
inline

Gets the number of sites in this Tile in sites, excluding caches.

template<class CC>
u32 MFM::Tile< CC >::GetTileWidth ( )
inline

Gets the width of this Tile in sites, including caches.

template<class CC>
const T* MFM::Tile< CC >::GetUncachedAtom ( const SPoint pt) const
inline

Gets an Atom from a specified point in this Tile. Indexing ignores the cache boundary, so possible range is (0,0) to (OWNED_SIDE-1,OWNED_SIDE-1).

Parameters
ptThe location of the Atom to retrieve.
Returns
A pointer to the Atom at location pt.
template<class CC>
const T* MFM::Tile< CC >::GetUncachedAtom ( s32  x,
s32  y 
) const
inline

Gets an Atom from a specified point in this Tile. Indexing ignores the cache boundary, so possible range is (0,0) to (OWNED_SIDE-1,OWNED_SIDE-1).

Parameters
xThe x coordinate of the location of the Atom to retrieve.
yThe y coordinate of the location of the Atom to retrieve.
Returns
A pointer to the Atom at the specified location.
template<class CC >
u64 MFM::Tile< CC >::GetUncachedSiteEvents ( const SPoint  site) const

Gets the site event count for a specified point in this Tile. Indexing ignores the cache boundary, so possible range is (0,0) to (OWNED_SIDE-1,OWNED_SIDE-1).

Parameters
siteThe coordinates of the location of the site whose event count should be retrieved.
yThe y coordinate of the location of the site whose event count should be retrieved.
Returns
The total events that have occured at that site
template<class CC >
u32 MFM::Tile< CC >::GetUncachedWriteAge ( const SPoint  site) const

Gets the 'write age' of a specified point in this Tile. Indexing ignores the cache boundary, so possible range is (0,0) to (OWNED_SIDE-1,OWNED_SIDE-1). The write age is the number of events on this tilesince the contents of the specified point changed. To obtain AEPS, divide this value by Tile::GetSites().

Parameters
siteThe coordinates of the location of the site whose write age should be retrieved.
yThe y coordinate of the location of the site whose write age should be retrieved.
Returns
The events since that site's content changed
template<class CC>
T* MFM::Tile< CC >::GetWritableAtom ( const SPoint pt)
inline

Gets an Atom from a specified point in this Tile.

Parameters
ptThe location of the Atom to retrieve.
Returns
A pointer to the Atom at location pt.
Remarks
Because we need to be able to load an Atom's body through a configuration file, and this is the only place where Atoms are unique, we need to be able to access them in a writable way. Therefore, we have this non-const accessor. Use GetAtom if not writing to this Atom.
template<class CC>
T* MFM::Tile< CC >::GetWritableAtom ( s32  x,
s32  y 
)
inline

Gets an Atom from a specified point in this Tile.

Parameters
xThe x coordinate of the location of the Atom to retrieve.
yThe y coordinate of the location of the Atom to retrieve.
Returns
A pointer to the Atom at the specified location.
Remarks
Because we need to be able to load an Atom's body through a configuration file, and this is the only place where Atoms are unique, we need to be able to access them in a writable way. Therefore, we have this non-const accessor. Use GetAtom if not writing to this Atom.
template<class CC >
void MFM::Tile< CC >::IncrAtomCount ( ElementType  atomType,
s32  delta 
)

Adds an offset to the count of a particular type of Atom.

Parameters
atomTypeThe ElementType of the Atoms of which the count will change.
deltaThe offset to add to the count of all Atoms of type atomType.
template<class CC >
void MFM::Tile< CC >::InternalPutAtom ( const T &  atom,
s32  x,
s32  y 
)

Stores an Atom after ensuring valid indices but performing no other actions (e.g., no counts are adjusted).

Parameters
atomAn atom to store
sxx coordinate in Tile (including caches)
syy coordinate in Tile (including caches)
template<class CC >
bool MFM::Tile< CC >::IsConnected ( Dir  dir) const
inline

Checks to see if this Tile has another tile in a specified direction.

Parameters
dirThe direction from this Tile in which to check for a neighboring Tile.
Returns
true if this Tile has a neighbor in direction dir, else false.
template<class CC >
bool MFM::Tile< CC >::IsInCache ( const SPoint pt)
inlinestatic

Checks to see if a specified local point is contained within a Tile's caches.

Parameters
ptThe local location which is in question of being inside of a cache.
Returns
true if pt is in a cache, else false.
template<class CC >
bool MFM::Tile< CC >::IsInTile ( const SPoint pt)
inlinestatic

Checks to see if a specified local point is contained within a Tile's sites, including caches. If this method returns true, then the GetAtom methods, applied to this location, will not FAIL.

Parameters
ptThe local location which is in question of being inside the bounds of this Tile
Returns
true if pt is a legal location in a Tile, else false.
See Also
GetAtom(const SPoint& pt)
template<class CC >
bool MFM::Tile< CC >::IsInUncachedTile ( const SPoint pt)
inlinestatic

Checks to see if a specified coordinate is contained within a Tile's sites excluding the caches. Indexing ignores the cache boundary, so possible range is (0,0) to (OWNED_SIDE-1,OWNED_SIDE-1). If this method returns true, then the 'Uncached' methods, applied to this location, will not FAIL.

Parameters
ptThe coordinate which is in question of being a legal uncached site index in this Tile
Returns
true if pt is a legal uncached location in a Tile, else false.
See Also
GetUncachedAtom(const SPoint& pt)
GetUncachedAtom(s32 x, s32 y)
GetUncachedSiteEvents(const SPoint site)
template<class CC >
bool MFM::Tile< CC >::IsLiveSite ( const SPoint location) const

Checks to see if a specified local point is a site that currently might receive events in this particular Tile. Note this method is not static, because liveness depends on the connectivity of this Tile. Therefore, even given the same location as argument, the return value from this method could change over time, if the connectivity of this Tile changes.

Parameters
ptThe local location which is in question of being a live site that receives events in this Tile
Returns
true if pt is a live site in this Tile, else false.
template<class CC >
bool MFM::Tile< CC >::IsOwnedSite ( const SPoint location)
inlinestatic

Checks to see if a specified local point is contained within a Tile's owned sites.

Parameters
ptThe local location which is in question of being inside of the Tile's own sites.
Returns
true if pt is an owned site of this Tile, else false.
template<class CC >
bool MFM::Tile< CC >::IsPauseReady ( )

Sees if this Tile is ready to be paused. There is some processing to be done between PauseRequested() and Pause() , so this method tells whether or not it is time to pause each Tile .

Returns
true if this Tile is ready to be paused, else false .
template<class CC>
bool MFM::Tile< CC >::IsRunReady ( )
inline

Sees if this Tile is ready to be run. We let all tiles respond to a RunRequest before moving on to actually running, so this method tells whether this Tile has seen the run request .

Returns
true if this Tile is ready to be run, else false .
template<class CC >
void MFM::Tile< CC >::Pause ( )

Pauses event execution on this Tile. Events will begin again once Start is called.

See Also
Start
template<class CC >
void MFM::Tile< CC >::PlaceAtom ( const T &  atom,
const SPoint pt 
)

Store an atom anywhere in the Tile, using the 'raw' coordinate system in which (0,0) is in the Tile cache.

Parameters
atomThe Atom to place within this Tile.
ptThe local location in which to store atom.
See Also
PlaceInternalAtom
template<class CC>
void MFM::Tile< CC >::PlaceInternalAtom ( const T &  atom,
const SPoint pt 
)
inline

Store an atom in the 'locally-owned' portion of a Tile, using the 'natural' coordinate system in which (0,0) is the upper left of the sites that this Tile owns.

Parameters
atomThe Atom to place within this Tile.
ptThe local location in which to store atom, beginning in this Tile's main memory.
See Also
PlaceAtom
template<class CC >
void MFM::Tile< CC >::ReceivePacket ( Packet< T > &  packet)

Processes a Packet, performing all necessary operations defined by Packet semantics.

Parameters
packetThe Packet which this Tile will process.
template<class CC >
void MFM::Tile< CC >::RecountAtoms ( )

Resets all atom counts and refreshes the atoms counts inside this tile.

template<class CC >
void MFM::Tile< CC >::RecountAtomsIfNeeded ( )

Calls RecountAtoms if anybody has signaled a need to do so. this tile.

template<class CC >
Dir MFM::Tile< CC >::RegionAt ( const SPoint pt,
u32  reach 
) const

Checks to see if a specified SPoint is in a given region of this Tile (i.e. cache, shared, visible, or hidden).

Parameters
ptThe SPoint to check region membership for.
reachThe size, in sites from the edge of the tile, of this region. For example, a reach of R would specify searching for Atoms in this Tile's cache. 2*R includes the shared region, and 3*R includes the visible region.
Returns
The direction of the cache pointed at by pt, or (Dir)-1 if pt is not pointing at a cache.
template<class CC>
void MFM::Tile< CC >::RegisterElement ( const Element< CC > &  anElement)
inline

Registers an Element into this Tile's ElementTable.

Parameters
theElement to register into this Tile's ElementTable.
template<class CC >
void MFM::Tile< CC >::Reinit ( )

Reinitializes a Tile to a like-new (actually, like-OnceOnlyInit()ed) state.

template<class CC >
void MFM::Tile< CC >::ReportIfBuffersAreNonEmpty ( )

Log warnings if connection buffers are not empty.

template<class CC>
void MFM::Tile< CC >::Run ( )
inline

Advances this Tile from THREADSTATE_RUN_READY to THREADSTATE_RUNNING.

template<class CC >
void MFM::Tile< CC >::SendAcknowledgmentPacket ( Packet< T > &  packet)

Given a Packet , sends a complementary acknowledgement Packet describing that this Packet has received and processed all relevant Packets.

Parameters
packetThe Packet of which a complementary Packet will be constructed and sent.
template<class CC >
void MFM::Tile< CC >::SetAtomCount ( ElementType  atomType,
s32  count 
)

Sets the internal count of Atoms of a specified ElementType.

Parameters
atomTypeThe ElementType of the Atoms of which the count will change.
countThe new count of all Atoms of type atomType.
template<class CC>
void MFM::Tile< CC >::SetBackgroundRadiation ( bool  value)
inline

Sets whether or not background radiation will begin mutating the Atoms of this Tile upon writing.

template<class CC>
void MFM::Tile< CC >::SetExecuteOwnEvents ( bool  value)
inline

Used to tell this Tile whether or not to actually execute any events, or to just wait on any packet communication from other Tiles instead.

Parameters
valueIf value is true, this tells the Tile to begin executing its own events. Else, this Tile will only process Packets from other Tiles.
template<class CC>
void MFM::Tile< CC >::SetGeneration ( u8  generation)
inline

Sets the tile generation to generation

template<class CC >
void MFM::Tile< CC >::SetIgnoreThreadingProblems ( bool  value)

Sets a value in this Tile corresponding to its tolerance of threading problems.

Parameters
valueIf true , allows this Tile to ignore threading problems encountered during Tile execution. This is not normally recommended because since it will cause cache inconsistencies, but it will most likely keep your instance of the MFM from crashing if this is set. If false , will crash upon detecting a threading problem.
template<class CC >
Dir MFM::Tile< CC >::SharedAt ( const SPoint pt) const

Finds the region of shared memory in this Tile which contains a specified SPoint.

Parameters
ptThe SPoint which should specify a location within shared memory.
Returns
The direction of the shared memory specified by pt, or (Dir)-1 if pt is not in shared memory.
template<class CC >
void MFM::Tile< CC >::SingleXRay ( )
inline

XRays a single randomly chosen Atom in this Tile, with the odds of flipping a bit being BACKGROUND_RADIATION_BIT_ODDS .

template<class CC >
void MFM::Tile< CC >::SingleXRay ( u32  x,
u32  y 
)
inline

XRays a single Atom in this Tile, with the odds of flipping a bit being BACKGROUND_RADIATION_BIT_ODDS .

Parameters
xThe x location of the Atom to XRay
yThe y location of the Atom to XRay
template<class CC >
void MFM::Tile< CC >::Start ( )

Begins event execution on this Tile on its own thread. Events will continue to happen until paused.

See Also
Pause
template<class CC >
Dir MFM::Tile< CC >::VisibleAt ( const SPoint pt) const

Finds the region of visible memory in this Tile which contains a specified SPoint.

Parameters
ptThe SPoint which should specify a location within visible memory.
Returns
The direction of the visible memory specified by pt, or (Dir)-1 if pt is not in visible memory.
template<class CC>
u64 MFM::Tile< CC >::WriteEPSRasterLine ( ByteSink outstrm,
u32  lineIdx 
)

Writes a single x-axis raster line of this Tile to a specified ByteSink.

Parameters
outstrmThe ByteSink to write raster data to.
template<class CC >
void MFM::Tile< CC >::XRay ( u32  siteOdds,
u32  bitOdds 
)

Iterates through each Atom in this Tile, XRaying each atom based on a provided rate and flipping a bit in each selected atom at a provided rate.

Parameters
siteOddsThe odds of an Atom to be selected for XRay.
bitOddsThe odds that a particular bit in a selected Atom will be selected for XRay.

Field Documentation

template<class CC>
const u32 MFM::Tile< CC >::EVENT_WINDOW_RADIUS = R
static

The radius of all events taking place in this Tile.

template<class CC>
const u32 MFM::Tile< CC >::OWNED_SIDE = TILE_WIDTH-2*R
static

The edge length of the portion of a Tile that is 'owned' by the Tile itself – i.e., excluding the cache boundary.

template<class CC>
const u32 MFM::Tile< CC >::TILE_SIZE = TILE_WIDTH * TILE_WIDTH
static

The area of this Tile in sites.

template<class CC>
const u32 MFM::Tile< CC >::TILE_WIDTH = W
static

The full length, in sites, of a Tile, including neighbor caches.


The documentation for this class was generated from the following files: