The Sparta Modeling Framework
Loading...
Searching...
No Matches
Skeleton Pipeline Using Sparta

The Sparta Skeleton Pipeline is located in sparta/example/SkeletonPipeline.


Skeleton Pipeline Layout

The Skeleton Pipeline is an example Sparta simulator that uses the Sparta framework to mimic a simple producer/consumer event-triggered communication paradigm. It illustrates the use of the following Sparta classes:

Visually, this is the flow of the pipeline:

dot_inline_dotgraph_4.png

The files involved are Consumer.hpp / Consumer.cpp, Producer.hpp / Producer.cpp, and SkeletonSimulator.hpp / SkeletonSimulator.cpp

The pipeline is pretty simple. The Producer, using a sparta::SignalInPort, waits for the Consumer to send "go" via a sparta::SignalOutPort.

When the Producer receives that signal, the Producer will send data (in this case, a uint32_t) on a sparta::DataOutPort to the consumer.

The simulator can allow the user to set up more than one producer, with the -p top.consumer.params.num_producers <count> command line option (See sparta::Parameter). Only one Consumer will be created in simulation to consume from all of the Producer objects created.

When the data arrives on the Consumer's sparta::DataInPort, the Consumer defers consumption of that data using a sparta::UniqueEvent (registered callback is Consumer::dataArrived_).

While the purpose of the simulator is simple, there's a lot that can be done with it. Try the following command lines.

Getting Help and Simulation Layout

# Get help
% ./sparta_skeleton --help
# Get help on a particular topic
% ./sparta_skeleton --help-topic logging
Logging Options:
-l [ --log ] PATTERN CATEGORY DEST ...
# Dump the simulation tree
% ./sparta_skeleton --show-tree --no-run
# Dump the counters/states
% ./sparta_skeleton --show-counters --no-run
# Dump the parameters
% ./sparta_skeleton --show-parameters --no-run
# Set a parameter (max_ints_to_send to 10,000), show it, but don't run
% ./sparta_skeleton -p top.producer0.params.max_ints_to_send 10K --show-parameters --no-run

Running the simulator

# Run the simulation with default number of producers: 1
% ./sparta_skeleton
# Run the simulation with more verbose reporting
% ./sparta_skeleton --auto-summary verbose
# Run the simulation with 10 producers
% ./sparta_skeleton -p top.consumer.params.num_producers 10

Running the simulator and generating reports

# Run the simulation with default number of producers: 1
% ./sparta_skeleton --report-all output.html html # HTML format
% ./sparta_skeleton --report-all output.html text # Plain text
% ./sparta_skeleton --report-all output.html json # JSON format

Running the simulator and generating logs

# Run the simulation with default number of producers: 1
% ./sparta_skeleton -l top info all.msgs
% ./sparta_skeleton -l top info all.msgs -l top.consumer info consumer_only.msgs
% ./sparta_skeleton -l top info all.msgs -l top.producer* info producer_only.msgs
% ./sparta_skeleton -l top.producer* info producer_consumer.msgs -l top.consumer info producer_consumer.msgs

Running the simulator and configuring it

# Run the simulation with default parameter and generate a configuration file
% ./sparta_skeleton --write-final-config skeleton_default_config.yaml --no-run
# Edit the file
% sed -i"" -e 's/num_producers: 1/num_producers: 100/' skeleton_default_config.yaml
# Run with the new config
% ./sparta_skeleton -c skeleton_default_config.yaml

Looking at the Code

The Skeleton Pipeline has three parts: Consumer, Producer, and SkeletonSimulator, with each class deriving from a Sparta component:

Class Sparta Class Derived
Consumer sparta::Unit
Producer sparta::Unit
SkeletonSimulator sparta::app::Simulation

SkeletonSimulator is where the tree is build. It's divided into three phases that Sparta will call: