sys-sage
|
This function starts with the root component and exports the entire topology to an XML file, including the Datapaths, which are appended at the end of the file.
For attribute parsing, the function uses default parsing mechanisms if no custom functions are provided. The default parsing includes the following simple attributes:
Key | Value-Type |
---|---|
CATcos | uint64_t |
CATL3mask | uint64_t |
mig_size | long long |
Number_of_streaming_multiprocessors | int |
Number_of_cores_in_GPU | int |
Number_of_cores_per_SM | int |
Bus_Width_bit | int |
Clock_Frequency | double |
latency | float |
latency_min | float |
latency_max | float |
For complex attributes the default function can parse the freq_history and GPU_Clock_Rate.
The freq_history might look like this in the resulting xml-file:
And for the GPU_Clock_Rate the xml-node will look like this
The Attribute-Nodes are all inserted as child-nodes under the corresponding Component-Node in the xml-file.
The XML Export function supports two optional custom functions, allowing users to customize the export process for both simple attributes and complex attributes.
Custom Function for Simple Attributes:\ If a custom function for simple attributes is provided, the export function forwards the key-value pair from the attrib
map of the respective component to the custom function. The custom function is expected to return the processed value as a string, which will be written into the export as the provided ret_value_string (the last parameter of the custom function).
Such a function might look like this:
Custom Function for Complex Attributes:\ Similarly, for complex attributes, the export function forwards the key-value pair from the attrib
map to the custom function. In addition, the current XML node is passed as a third parameter. Unlike the simple attributes, the custom function is responsible for directly writing the corresponding XML node(s) to the provided node.
One example of this kind of custom funcion is shown below:
The export tries to parse the attributes in this order:
It will try each function in this order untill one function returns 1.
The Import of xml-files works similiar to the export but in the opposite direction. It reads the xml-file with the same structure as the xml-export-files and returns the topology node. All the Datapaths and attributes are also stored after import.
The Attributes are stored in the attrib map of the components. Per default all the attribute types that can be parsed in the export can also be parsed in import.
Simple Attributes:\ For simple attributes, the corresponding attribute node from the XML file is forwarded to the custom function. The custom function is expected to produce a void*
that can then be stored in the attrib
map of the component.
Here is an example of how to define such a function:
Complex Attributes:\ For complex attributes, the attribute node is forwarded alongside the current component. This allows the custom function to access the component’s attrib
map and store the parsed attributes directly.
Defining a custom parsing function might look like this
While traversing XML nodes, it may be necessary to skip text nodes to avoid processing unintended data. For example:
The custom function for complex attributes should return 1 on success and 0 on failure.