Skip to content
Snippets Groups Projects
Commit 9e75d34a authored by Bouquillon Fabien's avatar Bouquillon Fabien
Browse files

suite clean

parent b93c2831
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 535 deletions
{ ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
application: application.o
$(CXX= -o application application.o $(LDLIBS2)
application.o: application.cpp
File deleted
#include <otawa/app/Application.h>
#include <otawa/cfg/features.h>
#include <otawa/script/Script.h>
#include <otawa/prog/WorkSpace.h>
#include <otawa/proc/DynProcessor.h>
#include <otawa/cfg/Dominance.h>
#include <otawa/proc/DynFeature.h>
//includes pour l'affichage du CFG
#include <otawa/display/CFGOutput.h>
#include <otawa/ipet/features.h>
#include <elm/io/OutFileStream.h>
#include <otawa/flowfact/features.h>
#include "../ucb_cond/include/ucb_cond.h"
#include "../classic_ecb/include/classic_ecb.h"
#include "../classic_ucb/include/classic_ucb.h"
using namespace otawa; //comme import
using namespace otawa::classic_ecb;
using namespace otawa::classic_ucb;
using namespace otawa::ucb_cond;
using namespace Mathset;
int main(int argc, char **argv) {
if (argc != 2 && argc != 3) {
fprintf(stderr, "usage: %s <binary> <flow fact file> \n", argv[0]);
exit(1);
}
WorkSpace *ws = NULL;
PropList conf;
Manager manager;
NO_SYSTEM(conf) = true;
TASK_ENTRY(conf) = "main";
VERBOSE(conf) = true;
CACHE_CONFIG_PATH(conf) = "./cache.xml";
if(argc == 3) {
FLOW_FACTS_PATH(conf) = argv[2];
}
StringBuffer buf;
buf << argv[1] << "-decomp.c";
elm::io::OutFileStream s(buf.toString());
elm::io::Output out(s);
conf.print(out);
ws = manager.load(argv[1], conf);
ws->require(DynFeature("otawa::ucb_cond::UCB_COND_FEATURE"), conf);
ws->require(DynFeature("otawa::classic_ecb::CLASSIC_ECB_PROCESSOR"), conf);
ws->require(DynFeature("otawa::classic_ucb::CLASSIC_CB_PROCESSOR"), conf);
// ws->require(otawa::ipet::ILP_SYSTEM_FEATURE, conf);
// ws->require(otawa::ipet::INTERBLOCK_SUPPORT_FEATURE, conf);
// ws->require(otawa::ipet::WCET_FEATURE, conf);
//unsigned long wcet = ipet::WCET(ENTRY_CFG(ws));
std::vector<Multiset<int>> *ucbs = UCBS(ws);
Multiset<int> *ecbs= ECBS(ws);
//std::cout << "---------WCET: " << wcet << "--------------" << std::endl;
std::cout << "---------ECBS------------" << std::endl;
ecbs->print_vector();
std::cout << "---------UCBs------------" << std::endl;
ucbs_c->print_vector();
std::cout << "---------UCBS mp ms -----" << std::endl;
for(auto iter = (*ucbs).begin(); iter != (*ucbs).end(); iter++) {
iter->print_vector();
}
}
{ ID(otawa::FLOW_FACTS_PATH) = ff.ff, ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
#ifndef __LIB_MATH_MULTISET__
#define __LIB_MATH_MULTISET__
/**
* \file multiset.hpp
* \author Fabien Bouquillon
* \brief This file contains the namespace Mathset with the class Multiset.
* It proposes some functions to compute Multiset.
* Nowadays the files is not really finished, if use in anormal way the multisets can be corrupt.
*/
#include <vector>
#include <algorithm>
/**
* \namespace Mathset
* \brief This namespace contains all the functions of this tiny library but also the class Multiset and the structure element
*/
namespace Mathset {
/**
* \struct Element
* \brief This structure represent one or more same element in a multiset.
*/
template <typename T>
struct Element {
/*! The number of this elemennt in the multiset.*/
int counter;
/*! The element, it's a template type */
T elem;
};
/**
*\class Multiset
* \brief It's the class which represent a set or a multiset.
*/
template <typename T>
class Multiset {
private:
std::vector<struct Element<T>> multiset; /*! the actual multiset, a vector of Element. */
public:
/**
* \fn Multiset()
* \prama nothing
* \return nothing
* \brief the default constructor, build a empty multiset.
*/
Multiset() {
}
/**
* \fn Multiset(std::vector<struct Element<T>> multiset)
*\param std::vector<struct Element<T>> multiset, it's a vector of Element
*\return nothing
*\brief Allow the developper to build a non-empty multiset.
*/
Multiset(std::vector<struct Element<T>> multiset) {
this->multiset = multiset;
}
/**
* \fn void add_elem(T elem)
* \param T elem; represents the new element to add
* \return nothing
* \brief jus add a new element in the multiset
*/
void add_elem(T elem) {
for(int i = 0; i < (int)multiset.size(); i++) {
if(multiset[i].elem == elem) {
multiset[i].counter++;
return;
}
}
struct Element<T> e;
e.elem = elem;
e.counter = 1;
multiset.push_back(e);
}
/**
* \fn void rm_elem(T elem)
* \param T elm, the element to remove
* \return nothing
* \brief This function remove an element T of the multiset
*/
void rm_elem(T elem) {
for(int i = 0; i < (int)multiset.size(); i++) {
if(multiset[i].elem == elem) {
multiset[i].counter--;
if(multiset[i].counter <= 0) {
multiset.erase(multiset.begin() + i);
return;
}
}
}
}
/**
* \fn void add_elem_struct(struct Element<T> e)
* \param struct Element<T> e, the element(s) to add
* \return nothing
* \brief add one ore more same element to the multiset
*/
void add_elem_struct(struct Element<T> e) {
if(e.counter <= 0) {
return;
}
for(int i = 0; i < (int)multiset.size(); i++) {
if(multiset[i].elem == e.elem) {
multiset[i].counter += e.counter;
return;
}
}
multiset.push_back(e);
}
/**
* \fn void rm_elem_from_struct(struct Element<T> e)
* \param struct Element<T> e
* \return nothing
* \brief remove one or more same element to the multiset
*/
void rm_elem_from_struct(struct Element<T> e) {
if(e.counter <=0 ) {
return;
}
for(int i = 0; i < (int)multiset.size(); i++) {
if(multiset[i].elem == e.elem) {
multiset[i].counter -= e.counter;
if(multiset[i].counter <= 0) {
multiset.erase(multiset.begin() + i);
return;
}
}
}
}
/**
* \fn void to_set()
* \param nothing
* \return nothing
* \brief Allow the developper to change the multiset into a set
*/
void to_set() {
for(int i = 0; i < (int)multiset.size(); i++) {
multiset[i].counter = 1;
}
}
/**
* \fn std::vector<struct Element<T>> get_multiset()
* \param nothing
* \return std::vector<struct Element<T>>, the multiset of the class
* \brief This function returns the vector which represents the multiset in the class.
*/
std::vector<struct Element<T>> get_multiset() const {
return multiset;
}
void multiply_counter(int n) {
for(int i = 0; i < (int)multiset.size(); i++) {
multiset[i].counter *= n;
}
}
/**
* \fn void print_vector()
* \param nothing
* \return nothing
* \brief This function just print in a human understanding way the multiset in a the std::cout ouput.
*/
void print_vector() {
int sum_t = 0;
for(int i = 0; i < (int)multiset.size(); i++) {
sum_t += multiset[i].counter;
}
std::cout << "multiset of " << sum_t << " elements:" << std::endl;
for(int i = 0; i < (int)multiset.size(); i++) {
for(int j = 0; j < multiset[i].counter; j++) {
std::cout << multiset[i].elem;
if(i != (int)multiset.size() - 1 || j != multiset[i].counter - 1) {
std::cout << ",";
} else {
std::cout << std::endl;
return;
}
}
}
}
string to_string() {
int sum_t = 0;
for(int i = 0; i < (int)multiset.size(); i++) {
sum_t += multiset[i].counter;
}
string s_tmp;
for(int i = 0; i < (int)multiset.size(); i++) {
for(int j = 0; j < multiset[i].counter; j++) {
s_tmp << multiset[i].elem;
if(i != (int)multiset.size() - 1 || j != multiset[i].counter - 1) {
s_tmp << ",";
} else {
return s_tmp;
}
}
}
return s_tmp;
}
/**
* \fn void clear()
* \param nothing
* \return nothing
* \brief remove all the elements in the Multiset
*/
void clear() {
multiset.clear();
}
int size() {
int sum = 0;
for(int i = 0; i < (int) multiset.size(); i++) {
sum += multiset[i].counter;
}
return sum;
}
T elem_max() {
T max = 0;
for(int i = 0; i < (int)multiset.size(); i++) {
if(multiset[i].counter > 0 && max < multiset[i].elem) {
max = multiset[i].elem;
}
}
return max;
}
};
/**
* /fn Multiset<T> math_set_union(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the Union set operation and return a set
*/
template <typename T>
Multiset<T> math_set_union(Multiset<T> a, Multiset<T> b) {
Multiset<T> tmp(a.get_multiset());
std::vector<struct Element<T>> b_bis = b.get_multiset();
for(int i = 0; i < (int)b_bis.size(); i++) {
tmp.add_elem_struct(b_bis[i]);
}
tmp.to_set();
return tmp;
}
/**
* /fn Multiset<T> math_set_intersection(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the Intersection set operation and return a set
*/
template <typename T>
Multiset<T> math_set_intersection(Multiset<T> a, Multiset<T> b) {
std::vector<struct Element<T>> tmp_m;
std::vector<struct Element<T>> a_bis = a.get_multiset();
std::vector<struct Element<T>> b_bis = b.get_multiset();
for(int i = 0; i < (int)a_bis.size(); i++) {
for(int j = 0; j < (int)b_bis.size(); j++) {
if(
(a_bis[i].counter > 0 && b_bis[j].counter > 0) &&
(a_bis[i].elem == b_bis[j].elem)) {
struct Element<T> e;
e.counter = 1;
e.elem = a_bis[i].elem;
tmp_m.push_back(e);
}
}
}
Multiset<T> tmp(tmp_m);
return tmp;
}
/**
* /fn Multiset<T> math_set_minus(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the minus set operation (a - b) and return a set
*/
template <typename T>
Multiset<T> math_set_minus(Multiset<T> a, Multiset<T> b) {
std::vector<struct Element<T>> a_bis = a.get_multiset();
std::vector<struct Element<T>> b_bis = b.get_multiset();
for(int i = 0; i < (int)a_bis.size(); i++) {
a_bis[i].counter = 1;
}
for(int i = 0; i < (int)b_bis.size(); i++) {
b_bis[i].counter = 1;
}
Multiset<T> tmp(a_bis);
for(int i = 0; i < (int)b_bis.size(); i++) {
tmp.rm_elem_from_struct(b_bis[i]);
}
return tmp;
}
/**
* /fn Multiset<T> math_multiset_union(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the Union multiset operation and return a multiset
*/
template <typename T>
Multiset<T> math_multiset_union(Multiset<T> a, Multiset<T> b) {
Multiset<T> tmp(a.get_multiset());
std::vector<struct Element<T>> b_bis = b.get_multiset();
for(int i = 0; i < (int)b_bis.size(); i++) {
tmp.add_elem_struct(b_bis[i]);
}
return tmp;
}
/**
* /fn Multiset<T> math_multiset_intersection(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the Intersection multiset operation and return a set
*/
template <typename T>
Multiset<T> math_multiset_intersection(Multiset<T> a, Multiset<T> b) {
std::vector<struct Element<T>> tmp_m;
std::vector<struct Element<T>> a_bis = a.get_multiset();
std::vector<struct Element<T>> b_bis = b.get_multiset();
for(int i = 0; i < (int)a_bis.size(); i++) {
for(int j = 0; j < (int)b_bis.size(); j++) {
if(
(a_bis[i].counter > 0 && b_bis[j].counter > 0) &&
(a_bis[i].elem == b_bis[j].elem)) {
struct Element<T> e;
e.counter = std::min(a_bis[i].counter, b_bis[j].counter);
e.elem = a_bis[i].elem;
tmp_m.push_back(e);
}
}
}
Multiset<T> tmp(tmp_m);
return tmp;
}
/**
* /fn Multiset<T> math_mutliset_minus(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the minus multiset (a - b) operation and return a multiset
*/
template <typename T>
Multiset<T> math_multiset_minus(Multiset<T> a, Multiset<T> b) {
std::vector<struct Element<T>> b_bis = b.get_multiset();
Multiset<T> tmp(a.get_multiset());
for(int i = 0; i < (int)b_bis.size(); i++) {
tmp.rm_elem_from_struct(b_bis[i]);
}
return tmp;
}
/**
* /fn Multiset<T> math_multiset_diff_sym(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the symetric difference multiset operation and return a multiset
*/
template <typename T>
Multiset<T> math_multiset_diff_sym(Multiset<T> a, Multiset<T> b) {
return math_multiset_union(math_multiset_minus(a,b), math_multiset_minus(b,a));
}
/**
* /fn Multiset<T> math_multiset_fusion(Multiset<T> a, Multiset<T> b)
* /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
* /return Multiset<T> it's the multiset compute
* /brief this function compute the fusion multiset operation and return a set
*/
template <typename T>
Multiset<T> math_multiset_fusion(Multiset<T> a, Multiset<T> b) {
return math_multiset_union(math_multiset_diff_sym(a,b), math_multiset_intersection(a,b));
}
template <typename T>
bool operator==(Multiset<T> const& a, Multiset<T> const& b) {
std::vector<struct Element<T>> a_v = a.get_multiset();
std::vector<struct Element<T>> b_v = b.get_multiset();
if(a_v.size() != b_v.size()) {
return false;
}
for(int i = 0; i < a_v.size(); i++) {
bool not_found = true;
for(int j = 0; j < b_v.size(); j++) {
if(b_v[j].elem == a_v[i].elem) {
not_found = false;
if(b_v[j].counter != a_v[i].counter) {
return false;
}
}
}
if(not_found) {
return false;
}
}
return true;
}
}
#endif // __LIB_MATH_MULTISET__
File deleted
File deleted
{ ID(otawa::FLOW_FACTS_PATH) = flow_fact.ff, ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
File deleted
{ ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
File deleted
{ ID(otawa::FLOW_FACTS_PATH) = flow_fact_simple_code.ff, ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
File deleted
File deleted
{ ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
{ ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
{ ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
{ ID(otawa::CACHE_CONFIG_PATH) = ./cache.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
{ ID(otawa::CACHE_CONFIG_PATH) = ./cache_simple.xml, ID(otawa::VERBOSE) = true, ID(otawa::TASK_ENTRY) = main, ID(otawa::NO_SYSTEM) = true }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment