add sim output artifact and move some of the data into publicly readable variables

This commit is contained in:
Fabian Posch 2024-01-11 17:32:09 -05:00
parent 9afc044002
commit d6ef1dbf0d
2 changed files with 132 additions and 0 deletions

View file

@ -29,6 +29,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <memory> #include <memory>
#include "db_types.hpp"
#include "util.h" #include "util.h"
namespace pl { namespace pl {
@ -74,6 +75,31 @@ class Artifact {
public: public:
/**
* @brief Construct a new blank Artifact
*
*/
Artifact();
/**
* @brief Construct a new Artifact with a database UUID attached to it.
*
* This should be used when downloading the artifact from the database.
* This ID is actually required when an update in the database is required.
*
* @param id
*/
Artifact(db::uuid_t& id);
/**
* @brief The ID of this object in the database
*
* This ID will be 0 if this artifact is not tied to anything in the
* database yet, as IDs are assigned on first upload.
*
*/
const db::uuid_t& id = id_;
/** /**
* @brief Get the type of the artifact the object is holding. * @brief Get the type of the artifact the object is holding.
* *
@ -102,6 +128,26 @@ class Artifact {
* @return long The number of elements in this artifact * @return long The number of elements in this artifact
*/ */
virtual long get_size() = 0; virtual long get_size() = 0;
/**
* @brief Inform a tool whether this artifact can be handled by multiple nodes
*
* By default, one artifact should only be handled once. However, there might be
* situations where multiple nodes can handle a single artifact. This could for example
* be a situation where a simulation for a design has a coverage model for constrained
* random testing. In this case we want to cover everything as fast as possible and
* simulation can be distributed.
*
* @return true The artifact can be handled by multiple nodes
* @return false The artifact cannot be handled by multiple nodes
*/
bool parallelizable() { return false; };
protected:
db::uuid_t id_;
}; };
@ -154,6 +200,8 @@ class ActArtifact: public Artifact {
struct testcase_t { struct testcase_t {
/** Commands to be executed for this testcase */ /** Commands to be executed for this testcase */
std::vector<std::string> commands; std::vector<std::string> commands;
/** This simulation should be run by multiple noes */
bool parallelizable;
/** Maximum pipeline load factor that should be allowed */ /** Maximum pipeline load factor that should be allowed */
float max_plf; float max_plf;
}; };
@ -164,6 +212,14 @@ struct testcase_t {
class SimConfigArtifact: public Artifact { class SimConfigArtifact: public Artifact {
public: public:
SimConfigArtifact();
SimConfigArtifact(db::uuid_t& id, db::uuid_t& design);
/**
* @brief The UUID of the design this simulation uses
*/
const db::uuid_t& design = design_;
/** /**
* @brief Get the content of the artifact * @brief Get the content of the artifact
* *
@ -195,9 +251,27 @@ class SimConfigArtifact: public Artifact {
*/ */
long get_size() { return testcases.size(); }; long get_size() { return testcases.size(); };
/**
* @brief Can this simulation be handled by multiple nodes
*
* By default, one artifact should only be handled once. However, there might be
* situations where multiple nodes can handle a single artifact. This could for example
* be a situation where a simulation for a design has a coverage model for constrained
* random testing. In this case we want to cover everything as fast as possible and
* simulation can be distributed.
*
* @return true The simulation can be handled by multiple nodes
* @return false The simulation cannot be handled by multiple nodes
*/
bool parallelizable() {
if (this->testcases.size() != 1) return false;
return this->testcases.front().parallelizable;
};
private: private:
std::vector<testcase_t> testcases; std::vector<testcase_t> testcases;
db::uuid_t design_;
}; };
/** Reference to a signal in an ACT design */ /** Reference to a signal in an ACT design */
@ -245,6 +319,48 @@ class SignalListArtifact: public Artifact {
std::vector<signal_t> signals; std::vector<signal_t> signals;
}; };
/**
* @brief Artifact containing simulator output from actsim
*/
class SimOutputArtifact: public Artifact {
public:
/**
* @brief Get the content of the artifact
*
* @return std::vector<testcase_t> Vector of all generated simulator output lines
*/
std::vector<std::string>& get_content() { return sim_log; };
/**
* @brief Add a log line to the artifact
*
* @param log_line
*/
void add_log_output(std::string log_line);
/**
* @brief Returns the type of this artifact, which is SIM_OUTPUT.
*
* @return ArtifactType Will return the SIM_OUTPUT artifact type.
*/
constexpr ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; };
/**
* @brief Get the number of log lines stored in this artifact
*
* @return long The size of the log lines vector
*/
long get_size() { return sim_log.size(); };
private:
std::vector<std::string> sim_log;
};
}; };
#endif #endif

View file

@ -26,12 +26,28 @@
namespace pl { namespace pl {
Artifact::Artifact() {}
Artifact::Artifact(db::uuid_t& id) {
this->id_ = id;
}
void SimConfigArtifact::add_testcase(testcase_t testcase) { void SimConfigArtifact::add_testcase(testcase_t testcase) {
this->testcases.emplace_back(testcase); this->testcases.emplace_back(testcase);
} }
SimConfigArtifact::SimConfigArtifact() {}
SimConfigArtifact::SimConfigArtifact(db::uuid_t& id, db::uuid_t& design) : Artifact(id) {
this->design_ = design;
}
void SignalListArtifact::add_signal(signal_t signal) { void SignalListArtifact::add_signal(signal_t signal) {
this->signals.emplace_back(signal); this->signals.emplace_back(signal);
} }
void SimOutputArtifact::add_log_output(std::string log_line) {
this->sim_log.emplace_back(log_line);
}
} }