The Sparta Modeling Framework
|
Contains a set of contiguous line of architectural data which can be referred to by any architected object model. When layout() is called, reserves space for each element in a registered set of ArchDataSegment instances at offsets within Lines within the ArchData. More...
#include <ArchData.hpp>
Classes | |
class | Line |
Line object which composes part of an entire ArchData. More... | |
Public Types | |
Access Types | |
typedef ArchDataSegment::offset_type | offset_type |
typedef offset_type | line_idx_type |
Represents offsets into this ArchData. | |
typedef std::vector< ArchDataSegment * > | SegmentList |
ArchData line index. | |
typedef std::list< Line * > | LineList |
List of ArchDataSegment. | |
typedef TieredMap< line_idx_type, Line * > | LineMap |
List of Line pointers. | |
typedef std::unordered_map< ArchDataSegment::ident_type, ArchDataSegment * > | LayoutHelperMap |
Helper map for quick lookup from ArchDataSegment::ident_type to an ArchDataSegment*. | |
typedef std::vector< ArchDataSegment * > | LayoutHelperVector |
Vector of ArchDataSegment pointers. | |
Public Member Functions | |
Constuction | |
ArchData (TreeNode *owner_node=nullptr, offset_type line_size=DEFAULT_LINE_SIZE, uint64_t initial=DEFAULT_INITIAL_FILL, uint16_t initial_val_size=DEFAULT_INITIAL_FILL_SIZE, bool can_free_lines=true) | |
Constructor. | |
Segments | |
void | registerSegment (ArchDataSegment *seg) |
All constructed segments must register themselves through this method to be laid out within the ArchData object. | |
const SegmentList | getSegments () const |
Gets the list of segments within this ArchData. | |
uint32_t | getNumSegments () const |
Gets number of segments in this ArchData. | |
Layout and ArchData Lines | |
void | layout () |
Organizes the Segments into overlapping regions as needed, eventually calling ArchDataSegment::place on each segment with its location inside this ArchData. | |
void | layoutRange (offset_type size) |
Lays out the archdata to contain a range of addresses without specifying any segments. | |
Line & | getLine (offset_type offset) |
Gets the line associated with this offset, allocating a new line if necessary. | |
const Line * | tryGetLine (offset_type offset) const |
Gets the line associated with this offset only if it already exists. | |
Line Queries | |
const LineMap & | getLineMap () const |
Only const access is allowed to internal map. | |
void | clean () |
Deletes (if possible) data held within the ArchData, restoring it to a 'clean-state'. This is not a 're-initialize' state, but rather all data is cleared to the fill-value specified at ArchData construction. Depending in whether canFreeLines returns true, Lines may actually be deleted and reclaimed. | |
void | reset () |
Cleans the ArchData (see clean) then applies all initial values through ArchDataSegment::writeInitial(). | |
offset_type | getLineSize () const |
Gets the size of a line within this ArchData instance. | |
line_idx_type | getNumAllocatedLines () const |
Gets the number of lines with allocated data;. | |
line_idx_type | getLineIndex (offset_type offset) const |
Gets Index of a line containing the specified offset. | |
offset_type | getLineOffset (line_idx_type idx) const |
Gets offset associated with a particular line that exists in this ArchData. | |
bool | canFreeLines () const |
Indicates whether this ArchData can free its lines after allocating them. Otherwise, any allocated line must exist for the lifetime of this ArchData. | |
Access and layout validation | |
void | checkCanAccess (offset_type offset, offset_type bytes) const |
Determines if an access of size 'bytes' can be performed at the given offset based only on the size of the ArchData and Line span. Validity checking matches that of ArchData::Line::read. | |
bool | containsAddress (offset_type offset) const noexcept |
Determines if this ArchData contains a byte for the specified address. | |
void | checkDataSize (offset_type size) const |
Checks to see that the size of the data is a valid access size. | |
void | checkSegment (offset_type offset, offset_type size) const |
Checks that a segment is valid within this archdata by its given offset and size. | |
void | checkInSingleLine (offset_type offset, offset_type size) const |
Determines whether the access defined by offset and size spans multiple ArchData Lines. | |
Selective Copy | |
virtual void | updateFrom (const ArchData &other) |
Checkpointing | |
template<typename StorageT > | |
void | save (StorageT &out) |
Writes checkpointing data from this ArchData to a stream. | |
template<typename StorageT > | |
void | saveAll (StorageT &out) |
Writes snapshot checkpointing data (all lines) from this ArchData to a stream regardless of dirtiness. | |
template<typename StorageT > | |
void | restore (StorageT &in) |
Restores a delta checkpoint (not a full snapshot). This contains only additive changes. | |
template<typename StorageT > | |
void | restoreAll (StorageT &in) |
Restores a full checkpoint snapshot (not a delta). This removes all lines NOT found in the snapshot data. | |
Static Public Member Functions | |
static void | fillValue (uint8_t *buf, uint32_t size, uint64_t fill, uint16_t fill_val_size, uint16_t fill_pattern_offset=0) |
Fill a buffer with a fill pattern. | |
Diagnostics | |
static const std::vector< const ArchData * > | getAllArchDatas () |
Static method to return a const vector of all ArchVectors that currently exist. | |
Static Public Attributes | |
Constants | |
static const offset_type | DEFAULT_LINE_SIZE = 512 |
static const offset_type | MAX_LINE_SIZE = 0x80000000 |
ArchData construction line size maximum in bytes. | |
static const uint64_t | DEFAULT_INITIAL_FILL = 0xcc |
Default initial fill value for an ArchData when allocated. | |
static const uint16_t | DEFAULT_INITIAL_FILL_SIZE = 1 |
Number of of bytes from DEFAULT_INITIAL_FILL to use as a default. | |
static const line_idx_type | INVALID_LINE_IDX = std::numeric_limits<line_idx_type>::max() |
Invalid line index. | |
Friends | |
class | SpartaStaticInitializer |
Allow initialization of statics through this helper. | |
Layout Status and instrumentation | |
Also includes layout and content-dump helper functions | |
static bool | compareSegmentOffsets (const ArchDataSegment *s1, const ArchDataSegment *s2) |
Comparison functions for sorting by segment. | |
const TreeNode * | getOwnerNode () const |
Returns the owner TreeNode. | |
void | setOwnerNode (TreeNode *node) |
Set the owner tree node. | |
bool | isLaidOut () const |
Has this ArchData been laid out yet. | |
offset_type | getSize () const |
Gets the current size of the layout for this ArchData. | |
uint64_t | getInitial () const |
Gets the value used to initialize unwritten memory. | |
uint32_t | getInitialValSize () const |
Gets the size of the initial value. | |
uint32_t | getTotalWaste () const |
Number of bytes wasted total during layout for any reason. | |
uint32_t | getPaddingWaste () const |
Number of bytes wasted during layout because of optimal word-alignment. | |
uint32_t | getLineWaste () const |
Number of bytes wasted during layout because of line-ending alignment. | |
void | dumpLayout (std::ostream &o) const |
Prints content of each ArchData Line in order. | |
std::vector< std::string > | getLineStates () const |
Gets state information for each line in this ArchData. | |
uint64_t | getNumTiers () const |
Contains a set of contiguous line of architectural data which can be referred to by any architected object model. When layout() is called, reserves space for each element in a registered set of ArchDataSegment instances at offsets within Lines within the ArchData.
Definition at line 38 of file ArchData.hpp.
typedef std::unordered_map<ArchDataSegment::ident_type, ArchDataSegment*> sparta::ArchData::LayoutHelperMap |
Helper map for quick lookup from ArchDataSegment::ident_type to an ArchDataSegment*.
Definition at line 69 of file ArchData.hpp.
typedef std::vector<ArchDataSegment*> sparta::ArchData::LayoutHelperVector |
Vector of ArchDataSegment pointers.
Used to ensure consistent ordering of segments during layout on different hosts. LayoutHelperMap losts ordering information and is not reliably consistent for different versions of boost or compilers.
Definition at line 79 of file ArchData.hpp.
typedef offset_type sparta::ArchData::line_idx_type |
Represents offsets into this ArchData.
Definition at line 59 of file ArchData.hpp.
typedef std::list<Line*> sparta::ArchData::LineList |
List of ArchDataSegment.
Definition at line 62 of file ArchData.hpp.
typedef TieredMap<line_idx_type, Line*> sparta::ArchData::LineMap |
List of Line pointers.
Definition at line 63 of file ArchData.hpp.
typedef ArchDataSegment::offset_type sparta::ArchData::offset_type |
Definition at line 58 of file ArchData.hpp.
typedef std::vector<ArchDataSegment*> sparta::ArchData::SegmentList |
ArchData line index.
Definition at line 60 of file ArchData.hpp.
|
inline |
Constructor.
owner_node | TreeNode which owns this ArchData. Is allowed to be nullptr. This owner must exist through the lifetime of this ArchData. This owner is part of a diagnostic utility to determine whether all relevant ArchDatas can be located by checkpointing mechanisms. See sparta::RootTreeNode::checkArchDataAssociations. |
line_size | Line size in bytes. All segments referring to this ArchData must be aligned to one line. segments referring to ranges spanning lines will be allowed to construct. Must be a power of 2. A line size of 0 indicates that everything is to be laid out on one line |
initial | Initial value of each byte allocated by the ArchData. Bytes beyond initial_val_size must be 0 |
initial_val_size | Number of bytes from Value to use repeating fill. This must be a power of 2 between 1 and 8 inclusive. |
can_free_lines | Can this ArchData free its lines when reset. This allows Memory objects to reclaim memory when reset but may be undesired when representing a set of registers or counters where Register or Counter classes have cached pointers into the lines. Any ArchData which will allow objects to cache pointers to its lines or lines' memory must set this to false unless it plans to update those cached pointers each time it is reset. |
Definition at line 448 of file ArchData.hpp.
|
inlinevirtual |
Definition at line 497 of file ArchData.hpp.
|
inline |
Indicates whether this ArchData can free its lines after allocating them. Otherwise, any allocated line must exist for the lifetime of this ArchData.
Generally, Registers and Counters will not allow freeing lines since they cache pointers to lines. Memory objects (without simple DMA support) will allow this.
Definition at line 822 of file ArchData.hpp.
|
inline |
Determines if an access of size 'bytes' can be performed at the given offset based only on the size of the ArchData and Line span. Validity checking matches that of ArchData::Line::read.
offset | Offset of access to check within this archdata (not within a line) |
bytes | Number of bytes in access. |
SpartaException | if access spans a line, is outside of the ArchData, or is an illegal size. This works regardless of isLaidOut |
This test exists for sparse usage where a 'fake' read might be performed and arguments must be validated without an ArchData::Line instance
Definition at line 846 of file ArchData.hpp.
|
inline |
Checks to see that the size of the data is a valid access size.
size | Size of access to check |
SpartaException | if size is invalid (i.e. exceeds some ceiling, is zero, or is not a power of 2) |
Definition at line 874 of file ArchData.hpp.
|
inline |
Determines whether the access defined by offset and size spans multiple ArchData Lines.
offset | Offset of access into this ArchData |
size | Size of access in bytes |
SpartaException | if access endpoints are in differnet Lines |
Definition at line 916 of file ArchData.hpp.
|
inline |
Checks that a segment is valid within this archdata by its given offset and size.
offset | Offset of start of segment within this ArchData (not a line) |
size | Size of segment to check |
SpartaException | if the access is invalid (i.e. size is invalid according to checkDataSize or endpoints of the segment spans a line). |
Definition at line 896 of file ArchData.hpp.
|
inline |
Deletes (if possible) data held within the ArchData, restoring it to a 'clean-state'. This is not a 're-initialize' state, but rather all data is cleared to the fill-value specified at ArchData construction. Depending in whether canFreeLines returns true, Lines may actually be deleted and reclaimed.
This method exists mainly for checkpointer usage and is faster than reset. To reinitialize contained data to layout-time values, use reset() instead.
Definition at line 739 of file ArchData.hpp.
|
inlinestatic |
Comparison functions for sorting by segment.
Definition at line 1114 of file ArchData.hpp.
|
inlinenoexcept |
Determines if this ArchData contains a byte for the specified address.
offset | Offset into this ArchData |
This is a trivial bounds check to see if offset < getSize(). This method can be called at any time but is only meaningful once ArchData is laid out (see isLaidOut)
Definition at line 863 of file ArchData.hpp.
|
inline |
Prints content of each ArchData Line in order.
o | ostream to which layout will be written. |
Definition at line 1131 of file ArchData.hpp.
|
inlinestatic |
Fill a buffer with a fill pattern.
buf | Buffer to fil |
size | Bytes to write in the buffer |
fill | Fill pattern |
fill_val_size | Number of bytes in the fill pattern to write to buf before repeating |
fill_pattern_offset | See fillWith_ |
Definition at line 127 of file ArchData.hpp.
|
inlinestatic |
Static method to return a const vector of all ArchVectors that currently exist.
Definition at line 1200 of file ArchData.hpp.
|
inline |
Gets the value used to initialize unwritten memory.
Definition at line 1087 of file ArchData.hpp.
|
inline |
Gets the size of the initial value.
Definition at line 1094 of file ArchData.hpp.
|
inline |
Gets the line associated with this offset, allocating a new line if necessary.
offset | Offset within the line requested (lookup done by getLineIndex) |
May | assert if offset does not fall within this ArchData. |
If this line is not yet allocated, it will be allocated. Checks whether the offset is valid (within ArchData) using containsAddress.
If this ArchData is used as a sparse memory representation, then tryGetLine should be used to detect unrealized lines.
Definition at line 663 of file ArchData.hpp.
|
inline |
Gets Index of a line containing the specified offset.
Does not require that offset be part of an actual line. This is just a numeric computation.
Definition at line 796 of file ArchData.hpp.
|
inline |
Only const access is allowed to internal map.
Definition at line 718 of file ArchData.hpp.
|
inline |
Gets offset associated with a particular line that exists in this ArchData.
idx | Index of line whose offset should be returned |
This method can safely be called before layout is complete. Does not require that idx be associated with an actual line. This is just a numeric computation.
Definition at line 809 of file ArchData.hpp.
|
inline |
Gets the size of a line within this ArchData instance.
Definition at line 778 of file ArchData.hpp.
|
inline |
Gets state information for each line in this ArchData.
This value is not mean to be parsed and is subject to change.
For a 5 lines (getNumAllocatedLines) with various states:
* {" 0:d", " 1:c", " 2:!", " 3:!", " 4:c"} *
Definition at line 1161 of file ArchData.hpp.
|
inline |
Number of bytes wasted during layout because of line-ending alignment.
Definition at line 1109 of file ArchData.hpp.
|
inline |
Gets the number of lines with allocated data;.
Definition at line 786 of file ArchData.hpp.
|
inline |
Gets number of segments in this ArchData.
Definition at line 565 of file ArchData.hpp.
|
inline |
Definition at line 1182 of file ArchData.hpp.
|
inline |
Returns the owner TreeNode.
Definition at line 1050 of file ArchData.hpp.
|
inline |
Number of bytes wasted during layout because of optimal word-alignment.
Definition at line 1104 of file ArchData.hpp.
|
inline |
Gets the list of segments within this ArchData.
Definition at line 562 of file ArchData.hpp.
|
inline |
Gets the current size of the layout for this ArchData.
SpartaException | if not yet laid out. |
Definition at line 1077 of file ArchData.hpp.
|
inline |
Number of bytes wasted total during layout for any reason.
Definition at line 1099 of file ArchData.hpp.
|
inline |
Has this ArchData been laid out yet.
Definition at line 1069 of file ArchData.hpp.
|
inline |
Organizes the Segments into overlapping regions as needed, eventually calling ArchDataSegment::place on each segment with its location inside this ArchData.
Layout can also be performed through layoutRange(...)
Definition at line 586 of file ArchData.hpp.
|
inline |
Lays out the archdata to contain a range of addresses without specifying any segments.
Layout can also be performed through layout()
Definition at line 634 of file ArchData.hpp.
|
inline |
All constructed segments must register themselves through this method to be laid out within the ArchData object.
seg | Segment to add. Must outlive this ArchData. |
Segment-subset relationships are not checked here - only in layout.
Definition at line 534 of file ArchData.hpp.
|
inline |
Cleans the ArchData (see clean) then applies all initial values through ArchDataSegment::writeInitial().
Definition at line 768 of file ArchData.hpp.
|
inline |
Restores a delta checkpoint (not a full snapshot). This contains only additive changes.
To restore full snapshots, use restoreAll
Definition at line 1006 of file ArchData.hpp.
|
inline |
Restores a full checkpoint snapshot (not a delta). This removes all lines NOT found in the snapshot data.
To restore deltas, use restore instead
Definition at line 1029 of file ArchData.hpp.
|
inline |
Writes checkpointing data from this ArchData to a stream.
Definition at line 963 of file ArchData.hpp.
|
inline |
Writes snapshot checkpointing data (all lines) from this ArchData to a stream regardless of dirtiness.
Definition at line 984 of file ArchData.hpp.
|
inline |
Set the owner tree node.
Definition at line 1055 of file ArchData.hpp.
|
inline |
Gets the line associated with this offset only if it already exists.
offset | Offset within the line requested (lookup done by getLineIndex) |
May | assert if offset does not fall within this ArchData. |
Checks whether the offset is valid (within ArchData) using containsAddress.
Definition at line 697 of file ArchData.hpp.
|
inlinevirtual |
Definition at line 930 of file ArchData.hpp.
|
friend |
Allow initialization of statics through this helper.
Definition at line 50 of file ArchData.hpp.
|
static |
Default initial fill value for an ArchData when allocated.
Definition at line 102 of file ArchData.hpp.
|
static |
Number of of bytes from DEFAULT_INITIAL_FILL to use as a default.
Definition at line 107 of file ArchData.hpp.
|
static |
Definition at line 88 of file ArchData.hpp.
|
static |
Invalid line index.
Definition at line 112 of file ArchData.hpp.
|
static |
ArchData construction line size maximum in bytes.
Must be less than or equal to this value. An ArchData line size of 0 implies infinite line size, which is not constrained to this limit.
Definition at line 97 of file ArchData.hpp.