move artifact to cluster lib
This commit is contained in:
parent
cb34adc3e9
commit
5b06d041b2
3 changed files with 289 additions and 0 deletions
250
include/artifact.hpp
Normal file
250
include/artifact.hpp
Normal file
|
|
@ -0,0 +1,250 @@
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
**************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __PIPELINE_ARTIFACT_H__
|
||||||
|
#define __PIPELINE_ARTIFACT_H__
|
||||||
|
|
||||||
|
#include <act/act.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
namespace pl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Representation of different artifact types
|
||||||
|
*/
|
||||||
|
enum class ArtifactType {UNKNOWN, ACT, SIM_CONFIG, SIGLIST, SIM_OUTPUT};
|
||||||
|
static std::unordered_map<std::string, ArtifactType> art_type_str = {
|
||||||
|
{"unknown", ArtifactType::UNKNOWN},
|
||||||
|
{"act", ArtifactType::ACT},
|
||||||
|
{"testcases", ArtifactType::SIM_CONFIG},
|
||||||
|
{"sig_list", ArtifactType::SIGLIST},
|
||||||
|
{"sim_output", ArtifactType::SIM_OUTPUT}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::string to_string(ArtifactType const &value) {
|
||||||
|
std::string str = "unknown";
|
||||||
|
|
||||||
|
for (auto& it : art_type_str) {
|
||||||
|
if (it.second == value) {
|
||||||
|
str = it.first;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return str;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::ostream& operator<<(std::ostream& os, ArtifactType const &rhs) {
|
||||||
|
os << to_string(rhs);
|
||||||
|
return os;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** List of artifact names as well as types */
|
||||||
|
typedef std::vector<std::pair<std::string, ArtifactType>> artifact_list;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief An artifact is a data point which can be consumed or produced by a pipeline module
|
||||||
|
*/
|
||||||
|
class Artifact {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the type of the artifact the object is holding.
|
||||||
|
*
|
||||||
|
* Substitute for getting the object type
|
||||||
|
*
|
||||||
|
* @return ArtifactType
|
||||||
|
*/
|
||||||
|
virtual ArtifactType get_type() { return ArtifactType::UNKNOWN; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the content of the artifact
|
||||||
|
*
|
||||||
|
* @tparam T Content type the artifact is holding
|
||||||
|
* @return T Content of the artifact
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
T get_content();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of elements in this artifact
|
||||||
|
*
|
||||||
|
* This is mostly relevant when uploading an artifact to the database cluster.
|
||||||
|
*
|
||||||
|
* @return long The number of elements in this artifact
|
||||||
|
*/
|
||||||
|
virtual long get_size() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ACT design artifact
|
||||||
|
*/
|
||||||
|
class ActArtifact: public Artifact {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new ACT design artifact
|
||||||
|
*
|
||||||
|
* @param design The design object the artifact should point to
|
||||||
|
*/
|
||||||
|
ActArtifact(std::shared_ptr<Act> design) { this->design = design; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the content of the artifact
|
||||||
|
*
|
||||||
|
* @return std::shared_ptr<Act> Pointer to the artifact's design file.
|
||||||
|
*/
|
||||||
|
std::shared_ptr<Act> get_content() { return design; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the type of this artifact, which is ACT.
|
||||||
|
*
|
||||||
|
* @return ArtifactType Will return the ACT artifact type.
|
||||||
|
*/
|
||||||
|
constexpr ArtifactType get_type() override { return ArtifactType::ACT; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of elements in this artifact, which is 1 per definition
|
||||||
|
*
|
||||||
|
* @return long
|
||||||
|
*/
|
||||||
|
long get_size() { return 1; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::shared_ptr<Act> design;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Struct to capture one testcase.
|
||||||
|
*/
|
||||||
|
struct testcase_t {
|
||||||
|
/** Commands to be executed for this testcase */
|
||||||
|
std::vector<std::string> commands;
|
||||||
|
/** Maximum pipeline load factor that should be allowed */
|
||||||
|
float max_plf;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Artifact containing one or more configurations for actsim
|
||||||
|
*/
|
||||||
|
class SimConfigArtifact: public Artifact {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the content of the artifact
|
||||||
|
*
|
||||||
|
* @return std::vector<testcase_t> Vector of all generated testcase structures
|
||||||
|
*/
|
||||||
|
std::vector<testcase_t> get_content() { return testcases; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add a testcase to the artifact
|
||||||
|
*
|
||||||
|
* @param testcase
|
||||||
|
*/
|
||||||
|
void add_testcase(testcase_t testcase);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the type of this artifact, which is SIM_CONFIG.
|
||||||
|
*
|
||||||
|
* @return ArtifactType Will return the SIM_CONFIG artifact type.
|
||||||
|
*/
|
||||||
|
constexpr ArtifactType get_type() override { return ArtifactType::SIM_CONFIG; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of testcases stored in this artifact
|
||||||
|
*
|
||||||
|
* @return long The size of the testcase vector
|
||||||
|
*/
|
||||||
|
long get_size() { return testcases.size(); };
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<testcase_t> testcases;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Reference to a signal in an ACT design */
|
||||||
|
typedef std::string signal_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Artifact containing a list of signals
|
||||||
|
*/
|
||||||
|
class SignalListArtifact: public Artifact {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the content of the artifact
|
||||||
|
*
|
||||||
|
* @return std::vector<signal_t> Vector of all captured signals structures
|
||||||
|
*/
|
||||||
|
std::vector<signal_t> get_content() { return signals; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add a signal to the artifact
|
||||||
|
*
|
||||||
|
* @param testcase
|
||||||
|
*/
|
||||||
|
void add_signal(signal_t signal);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the type of this artifact, which is SIGLIST.
|
||||||
|
*
|
||||||
|
* @return ArtifactType Will return the SIGLIST artifact type.
|
||||||
|
*/
|
||||||
|
constexpr ArtifactType get_type() override { return ArtifactType::SIGLIST; };
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the number of signals stored in this artifact
|
||||||
|
*
|
||||||
|
* @return long The size of the signals vector
|
||||||
|
*/
|
||||||
|
long get_size() { return signals.size(); };
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector<signal_t> signals;
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
|
|
||||||
|
include_directories($ENV{ACT_HOME}/include)
|
||||||
include_directories(../include)
|
include_directories(../include)
|
||||||
|
include_directories(.)
|
||||||
|
|
||||||
file(
|
file(
|
||||||
GLOB act_cluster_lib_SRC
|
GLOB act_cluster_lib_SRC
|
||||||
|
|
|
||||||
37
src/artifact.cpp
Normal file
37
src/artifact.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* 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 {
|
||||||
|
|
||||||
|
void SimConfigArtifact::add_testcase(testcase_t testcase) {
|
||||||
|
this->testcases.emplace_back(testcase);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SignalListArtifact::add_signal(signal_t signal) {
|
||||||
|
this->signals.emplace_back(signal);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue