The Sparta Modeling Framework
Loading...
Searching...
No Matches
Preloader.cpp
1
2#include "Preloader.hpp"
4#include "cache/preload/PreloadableIF.hpp"
5
6namespace core_example
7{
9 {
10 if (filepath_ != "")
11 {
12 std::cout << "[Preloading caches]: " << filepath_ << std::endl;
13 sparta::cache::PreloaderIF::parseYaml_(filepath_);
14 }
15 }
16
17 void Preloader::preloadPacket_(const std::string& treenode,
18 sparta::cache::PreloadPkt& pkt)
19 {
20 // This is a very dump preloader and just sends the pkt directly to
21 // the Preloadable node specified in the yaml. Other preloaders
22 // may be more verbose.
24 std::vector<sparta::TreeNode*> nodes;
25 root->getSearchScope()->findChildren(treenode, nodes);
26 bool preloaded_atleast_one = false;
27 for (auto& node : nodes)
28 {
29 sparta::cache::PreloadableIF* cache = dynamic_cast<sparta::cache::PreloadableIF*>(node);
30 if (cache)
31 {
32 bool success = cache->preloadPkt(pkt);
33 preloaded_atleast_one |= success;
34 }
35 }
36 sparta_assert(preloaded_atleast_one, "Failed to preload the packet to any cache");
37 }
38} // namespace core_example
Simulation setup base class.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
TreeNode * getContainer()
Gets the TreeNode (container) for this resource (if any)
TreeNode which represents the root ("top") of a device tree.
GlobalTreeNode * getSearchScope()
Gets the search node "parent" of this root node which is suitable for performing searches that includ...
app::Simulation * getSimulation() const
Gets the simulation (if any) associated with this tree.
uint32_t findChildren(const std::string &pattern, std::vector< TreeNode * > &results, std::vector< std::vector< std::string > > &replacements)
Finds all children starting at this node with a given pattern relative to this node by matching names...
sparta::RootTreeNode * getRoot() noexcept
Returns the tree root.