optimize artifact library and add fields for reduced reference data

This commit is contained in:
Fabian Posch 2025-01-08 16:59:15 +01:00
parent 87aabba22b
commit 217f59ec36
2 changed files with 32 additions and 65 deletions

View file

@ -25,6 +25,7 @@
#define __PIPELINE_ARTIFACT_H__
#include <act/act.h>
#include <cstdint>
#include <vector>
#include <unordered_map>
#include <string>
@ -77,7 +78,7 @@ class Artifact {
* @brief Construct a new blank Artifact
*
*/
Artifact();
Artifact() = default;
/**
* @brief Get the type of the artifact the object is holding.
@ -186,7 +187,7 @@ struct testcase_t {
class SimConfigArtifact: public Artifact {
public:
SimConfigArtifact();
SimConfigArtifact() = default;
SimConfigArtifact(bool has_reference) { this->has_reference_ = has_reference; };
/**
@ -202,7 +203,7 @@ class SimConfigArtifact: public Artifact {
*
* @param testcase
*/
void add_testcase(testcase_t testcase);
inline void add_testcase(testcase_t testcase) { this->testcases.emplace_back(testcase); };
/**
@ -267,7 +268,7 @@ class SignalListArtifact: public Artifact {
*
* @param testcase
*/
void add_signal(signal_t signal);
inline void add_signal(signal_t signal) { this->signals.emplace_back(signal); };
/**
@ -297,22 +298,27 @@ class SimOutputArtifact: public Artifact {
public:
SimOutputArtifact() {};
SimOutputArtifact(const std::vector<std::string>& sim_log, const std::vector<std::string>& error_log);
SimOutputArtifact(const std::vector<std::string>& sim_log, const std::vector<std::string>& error_log) {
this->sim_log = sim_log;
this->sim_err_log = error_log;
has_content_ = true;
};
/**
* @brief Get the content of the artifact
*
* @return std::vector<testcase_t> Vector of all generated simulator output lines
*/
std::pair<std::vector<std::string>&, std::vector<std::string>&> get_content() { return {sim_log, sim_err_log}; };
inline std::pair<std::vector<std::string>&, std::vector<std::string>&> get_content() { return {sim_log, sim_err_log}; };
inline std::vector<uint32_t>& get_output_token_timings() { return output_token_timings; };
inline void set_output_token_timings(std::vector<uint32_t> timings) { this->output_token_timings = timings; };
/**
* @brief Add a log line to the artifact
*
* @param log_line
*/
void add_log_output(std::string log_line);
inline void add_log_output(std::string log_line) { this->sim_log.emplace_back(log_line); has_content_ = true; };
/**
@ -320,7 +326,18 @@ class SimOutputArtifact: public Artifact {
*
* @param log_line
*/
void add_err_output(std::string log_line);
inline void add_err_output(std::string log_line) { this->sim_err_log.emplace_back(log_line); has_content_ = true; };
inline void clear_logs() {
// save the size
size_ = this->sim_err_log.size() + this->sim_log.size();
this->sim_err_log.clear();
this->sim_log.clear();
has_content_ = false;
};
inline void add_output_token_timing(uint32_t timing) { this->output_token_timings.emplace_back(timing); };
/**
@ -328,7 +345,7 @@ class SimOutputArtifact: public Artifact {
*
* @return ArtifactType Will return the SIM_OUTPUT artifact type.
*/
ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; };
inline ArtifactType get_type() override { return ArtifactType::SIM_OUTPUT; };
/**
@ -336,7 +353,8 @@ class SimOutputArtifact: public Artifact {
*
* @return long The size of the log lines vector
*/
long get_size() override { return sim_log.size(); };
inline long get_size() override { if (has_content_) {return sim_log.size();} else {return size_;} };
inline void set_size(long size) { if (!has_content_) this->size_ = size; };
const bool& fault_timing_deviation = fault_timing_deviation_;
const bool& fault_value = fault_value_;
@ -360,6 +378,7 @@ class SimOutputArtifact: public Artifact {
std::vector<std::string> sim_log;
std::vector<std::string> sim_err_log;
std::vector<uint32_t> output_token_timings;
bool fault_timing_deviation_ = false;
bool fault_value_ = false;
bool fault_coding_ = false;
@ -368,6 +387,8 @@ class SimOutputArtifact: public Artifact {
bool fault_token_count_ = false;
int output_tokens_;
long size_ = 0;
bool has_content_ = false;
};
};

View file

@ -1,54 +0,0 @@
/*************************************************************************
*
* Copyright (c) 2023 Fabian Posch
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
**************************************************************************
*/
#include "artifact.hpp"
#include "yaml.h"
namespace pl {
Artifact::Artifact() {}
void SimConfigArtifact::add_testcase(testcase_t testcase) {
this->testcases.emplace_back(testcase);
}
SimConfigArtifact::SimConfigArtifact() {}
void SignalListArtifact::add_signal(signal_t signal) {
this->signals.emplace_back(signal);
}
void SimOutputArtifact::add_log_output(std::string log_line) {
this->sim_log.emplace_back(log_line);
}
void SimOutputArtifact::add_err_output(std::string log_line) {
this->sim_err_log.emplace_back(log_line);
}
SimOutputArtifact::SimOutputArtifact(const std::vector<std::string>& sim_log, const std::vector<std::string>& error_log) {
this->sim_log = sim_log;
this->sim_err_log = error_log;
}
}