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

ECB LRU TESTED

parent 1cb065c4
Branches
No related tags found
No related merge requests found
Showing
with 18069 additions and 19 deletions
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
CXXFLAGS=`otawa-config otawa/display --cflags` CXXFLAGS=`otawa-config otawa/display --cflags`
#ldlibs pour compiler le plugin #ldlibs pour compiler le plugin
LDLIBS=`otawa-config otawa/display --libs` LDLIBS=`otawa-config otawa/display otawa/loop_bound --libs`
#ldlibs pour compiler la application #ldlibs pour compiler la application
LDLIBS2=`otawa-config otawa/display otawa/classic_ecb --libs` LDLIBS2=`otawa-config otawa/display otawa/classic_ecb --libs`
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
#include <otawa/flowfact/features.h> #include <otawa/flowfact/features.h>
#include "../loop_bound/include/loop_bound.h"
using namespace Mathset; using namespace Mathset;
namespace otawa { namespace otawa {
namespace classic_ecb { namespace classic_ecb {
...@@ -38,6 +40,7 @@ namespace otawa { ...@@ -38,6 +40,7 @@ namespace otawa {
.require(MKFF_PRESERVATION_FEATURE) .require(MKFF_PRESERVATION_FEATURE)
.require(cache::COLLECTED_LBLOCKS_FEATURE) .require(cache::COLLECTED_LBLOCKS_FEATURE)
.require(hard::CACHE_CONFIGURATION_FEATURE) .require(hard::CACHE_CONFIGURATION_FEATURE)
.require(loop_bound::LOOP_BOUND_FEATURE)
.provide(CLASSIC_ECB_PROCESSOR); .provide(CLASSIC_ECB_PROCESSOR);
// definition feature // definition feature
...@@ -50,17 +53,21 @@ namespace otawa { ...@@ -50,17 +53,21 @@ namespace otawa {
} }
int nb_iteration(BasicBlock *bb) { // int nb_iteration(BasicBlock *bb) {
Loop* current_loop = Loop::of(bb); // Loop* current_loop = Loop::of(bb);
Block* loop_header = current_loop->header(); // Block* loop_header = current_loop->header();
if(loop_header->isBasic()) { // if(loop_header->isBasic()) {
BasicBlock *header_basic = loop_header->toBasic(); // BasicBlock *header_basic = loop_header->toBasic();
return MAX_ITERATION(header_basic->first()); // return MAX_ITERATION(header_basic);
} // } else {
// if(loop_header->isVirtual()) {
return 1; // }
} // }
// return 1;
// }
void Classic_EcbProcessor::processWorkSpace(WorkSpace *ws) { void Classic_EcbProcessor::processWorkSpace(WorkSpace *ws) {
const otawa::hard::CacheConfiguration *cf = otawa::hard::CACHE_CONFIGURATION_FEATURE.get(ws); const otawa::hard::CacheConfiguration *cf = otawa::hard::CACHE_CONFIGURATION_FEATURE.get(ws);
...@@ -72,7 +79,7 @@ namespace otawa { ...@@ -72,7 +79,7 @@ namespace otawa {
if(block_iter->isBasic()) { if(block_iter->isBasic()) {
BasicBlock *bb = block_iter->toBasic(); BasicBlock *bb = block_iter->toBasic();
int nb_iter = nb_iteration(bb); int nb_iter = loop_bound::TOTAL_BOUND(bb);
AllocArray<LBlock*> *lblock_array = BB_LBLOCKS(bb); AllocArray<LBlock*> *lblock_array = BB_LBLOCKS(bb);
for(int i = 0; i < lblock_array->count(); i++) { for(int i = 0; i < lblock_array->count(); i++) {
...@@ -89,6 +96,7 @@ namespace otawa { ...@@ -89,6 +96,7 @@ namespace otawa {
case FIRST_MISS: case FIRST_MISS:
tmp_e.counter = 1; tmp_e.counter = 1;
ecb_set->add_elem_struct(tmp_e); ecb_set->add_elem_struct(tmp_e);
break;
case FIRST_HIT: case FIRST_HIT:
tmp_e.counter = nb_iter - 1; tmp_e.counter = nb_iter - 1;
......
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
name = classic_ecb name = classic_ecb
author = Fabien Bouquillon <fabien.bouquillon@univ-lille.fr> author = Fabien Bouquillon <fabien.bouquillon@univ-lille.fr>
description = list ECBs, simple set used in most popular approach. description = list ECBs, simple set used in most popular approach.
deps = loop_bound
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <otawa/proc/DynProcessor.h> #include <otawa/proc/DynProcessor.h>
#include <otawa/cfg/Dominance.h> #include <otawa/cfg/Dominance.h>
#include <otawa/proc/DynFeature.h> #include <otawa/proc/DynFeature.h>
#include <otawa/flowfact/features.h>
//includes pour l'affichage du CFG //includes pour l'affichage du CFG
#include <otawa/display/CFGOutput.h> #include <otawa/display/CFGOutput.h>
#include <elm/io/OutFileStream.h> #include <elm/io/OutFileStream.h>
...@@ -16,8 +16,8 @@ using namespace otawa; //comme import ...@@ -16,8 +16,8 @@ using namespace otawa; //comme import
using namespace otawa::explo; using namespace otawa::explo;
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc != 3) { if (argc != 4) {
fprintf(stderr, "usage: %s <binary> <cache> ", argv[0]); fprintf(stderr, "usage: %s <binary> <cache> <flowfact>", argv[0]);
exit(1); exit(1);
} }
WorkSpace *ws = NULL; WorkSpace *ws = NULL;
...@@ -26,14 +26,13 @@ int main(int argc, char **argv) { ...@@ -26,14 +26,13 @@ int main(int argc, char **argv) {
NO_SYSTEM(conf) = true; NO_SYSTEM(conf) = true;
TASK_ENTRY(conf) = "main"; TASK_ENTRY(conf) = "main";
VERBOSE(conf) = true; VERBOSE(conf) = true;
CACHE_CONFIG_PATH(conf) = argv[2]; CACHE_CONFIG_PATH(conf) = argv[2];
FLOW_FACTS_PATH(conf) = argv[3];
StringBuffer buf; StringBuffer buf;
buf << argv[1] << "-decomp.c"; buf << argv[1] << "-decomp.c";
elm::io::OutFileStream s(buf.toString()); elm::io::OutFileStream s(buf.toString());
elm::io::Output out(s); elm::io::Output out(s);
conf.print(out); conf.print(out);
ws = manager.load(argv[1], conf); ws = manager.load(argv[1], conf);
ws->require(DynFeature("otawa::explo::EXPLO_FEATURE"), conf); ws->require(DynFeature("otawa::explo::EXPLO_FEATURE"), conf);
} }
...@@ -32,8 +32,8 @@ namespace otawa { ...@@ -32,8 +32,8 @@ namespace otawa {
.require(COLLECTED_CFG_FEATURE) .require(COLLECTED_CFG_FEATURE)
.require(LOOP_INFO_FEATURE) .require(LOOP_INFO_FEATURE)
.require(ICACHE_CATEGORY2_FEATURE) .require(ICACHE_CATEGORY2_FEATURE)
.require(ipet::FLOW_FACTS_FEATURE)
.require(MKFF_PRESERVATION_FEATURE) .require(MKFF_PRESERVATION_FEATURE)
.require(ipet::FLOW_FACTS_FEATURE)
.require(cache::COLLECTED_LBLOCKS_FEATURE) .require(cache::COLLECTED_LBLOCKS_FEATURE)
.require(hard::CACHE_CONFIGURATION_FEATURE) .require(hard::CACHE_CONFIGURATION_FEATURE)
.provide(EXPLO_FEATURE); .provide(EXPLO_FEATURE);
...@@ -98,6 +98,7 @@ namespace otawa { ...@@ -98,6 +98,7 @@ namespace otawa {
std::cout << "Block: " << b->id() << " "; std::cout << "Block: " << b->id() << " ";
if(b->isBasic()) { if(b->isBasic()) {
std::cout << "Basic " << std::endl; std::cout << "Basic " << std::endl;
std::cout << "total iteration: " << TOTAL_ITERATION(b->toBasic()->first()) << std::endl;
AllocArray<LBlock *> *lblock_array = BB_LBLOCKS(b->toBasic()); AllocArray<LBlock *> *lblock_array = BB_LBLOCKS(b->toBasic());
if (lblock_array != NULL) if (lblock_array != NULL)
...@@ -107,6 +108,7 @@ namespace otawa { ...@@ -107,6 +108,7 @@ namespace otawa {
{ {
LBlock *lb = (*lblock_array)[i]; LBlock *lb = (*lblock_array)[i];
category_t status = cache::CATEGORY(lb); category_t status = cache::CATEGORY(lb);
const hard::Cache *cache = lb->lblockset()->cache(); const hard::Cache *cache = lb->lblockset()->cache();
otawa::Address lb_id = cache->round(lb->address()); otawa::Address lb_id = cache->round(lb->address());
......
...@@ -31,6 +31,10 @@ namespace Mathset { ...@@ -31,6 +31,10 @@ namespace Mathset {
T elem; T elem;
}; };
////////////////////////////////////////////////////////////////////////////////////////
// Class Multiset //
////////////////////////////////////////////////////////////////////////////////////////
/** /**
*\class Multiset *\class Multiset
* \brief It's the class which represent a set or a multiset. * \brief It's the class which represent a set or a multiset.
...@@ -273,8 +277,24 @@ namespace Mathset { ...@@ -273,8 +277,24 @@ namespace Mathset {
} }
return true; return true;
} }
T& operator[](int index) {
int sum = 0;
for(int i = 0; i < this->multiset.size(); i++) {
sum += this->multiset[i].counter;
if(index < sum) {
return this->multiset[i].elem;
}
}
return this->multiset[index].elem; // will cause a segmented fault, the correct behavior in this case
}
}; };
////////////////////////////////////////////////////////////////////////////////////////
// Functions sur La classe //
////////////////////////////////////////////////////////////////////////////////////////
/** /**
* /fn Multiset<T> math_set_union(Multiset<T> a, Multiset<T> b) * /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 * /param Multiset<T> a, the first multiset in the computation, Multiset<T> b, the second multiset in the computation
......
#cflags pour tout compiler
CXXFLAGS=`otawa-config otawa/display --cflags`
#ldlibs pour compiler le plugin
LDLIBS=`otawa-config otawa/display --libs`
#ldlibs pour compiler la application
LDLIBS2=`otawa-config otawa/display otawa/loop_bound --libs`
ARMCC=arm-none-eabi-gcc
CXXFLAGS += -std=c++11 -O0 -g -I ../otawa-core2-build/otawa/include/ -I ../otawa-core2-build/elm/include/
all: clean loop_bound.so install application binaire
binaire: binaire.c
$(ARMCC) -nostdlib -nostdinc -static -o binaire binaire.c
##debut
application: application.o
$(CXX) -o application application.o $(LDLIBS2)
application.o: application.cpp
loop_bound.so: loop_bound.cpp include/loop_bound.h
$(CXX) -fPIC -shared $(CXXFLAGS) -o loop_bound.so loop_bound.cpp $(LDLIBS)
##fin
clean:
rm -f *.o application binaire *~ *.dot *.ps *.so
install: loop_bound.so
mkdir -p $(HOME)/.otawa/proc/otawa
cp loop_bound.eld $(HOME)/.otawa/proc/otawa/
cp loop_bound.so $(HOME)/.otawa/proc/otawa/
.PHONY: all test clean graph
#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 <elm/io/OutFileStream.h>
#include <otawa/flowfact/features.h>
#include "include/loop_bound.h"
using namespace otawa; //comme import
using namespace otawa::loop_bound;
int main(int argc, char **argv) {
if (argc != 3) {
fprintf(stderr, "usage: %s <binary> <flow fact> ", 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";
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::loop_bound::LOOP_BOUND_FEATURE"), conf);
}
<?xml version="1.0" encoding="UTF-8"?>
<cache-config>
<icache>
<block_bits>8</block_bits>
<way_bits>4</way_bits>
<row_bits>6</row_bits>
<miss_penalty>70</miss_penalty>
</icache>
</cache-config>
\ No newline at end of file
#ifndef LOOP_BOUND_H
#define LOOP_BOUND_H
#include <typeinfo>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <functional>
#include <otawa/cfg.h>
#include <otawa/cfg/features.h>
#include <otawa/proc/ProcessorPlugin.h>
#include <otawa/cfg/Dominance.h>
#include <otawa/otawa.h>
namespace otawa { namespace loop_bound {
class Loop_boundProcessor : public Processor {
public:
static p::declare reg;
explicit Loop_boundProcessor(p::declare &r = reg);
protected:
void processWorkSpace(WorkSpace * /*ws*/) override;
void configure(const PropList &props) override;
};
// declaration feature
extern p::feature LOOP_BOUND_FEATURE;
//declaration propriete
extern Identifier<int> TOTAL_BOUND;
} }
#endif
#ifndef LOOP_BOUND_H
#define LOOP_BOUND_H
#include <typeinfo>
#include <vector>
#include <algorithm>
#include <assert.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <functional>
#include <otawa/cfg.h>
#include <otawa/cfg/features.h>
#include <otawa/proc/ProcessorPlugin.h>
#include <otawa/cfg/Dominance.h>
#include <otawa/otawa.h>
namespace otawa { namespace loop_bound {
class Loop_boundProcessor : public Processor {
public:
static p::declare reg;
explicit Loop_boundProcessor(p::declare &r = reg);
protected:
void processWorkSpace(WorkSpace * /*ws*/) override;
void configure(const PropList &props) override;
};
// declaration feature
extern p::feature LOOP_BOUND_FEATURE;
//declaration propriete
/*
extern Identifier<DAGHNode*> DAG_HNODE;
*/
} }
#endif
\ No newline at end of file
#include "include/loop_bound.h"
#include <otawa/cfg/Loop.h>
#include <otawa/ipet/FlowFactLoader.h>
#include <otawa/flowfact/features.h>
namespace otawa {
namespace loop_bound {
// Declaration du plugin
class Plugin : public ProcessorPlugin {
public:
Plugin() : ProcessorPlugin("otawa::loop_bound", Version(1, 0, 0), OTAWA_PROC_VERSION) {}
};
otawa::loop_bound::Plugin loop_bound_plugin;
ELM_PLUGIN(loop_bound_plugin, OTAWA_PROC_HOOK);
p::declare Loop_boundProcessor::reg = p::init("otawa::loop_bound::Loop_boundProcessor", Version(1, 0, 0))
.require(COLLECTED_CFG_FEATURE)
.require(LOOP_INFO_FEATURE)
.require(MKFF_PRESERVATION_FEATURE)
.require(FLOW_FACTS_FEATURE)
.provide(LOOP_BOUND_FEATURE);
// definition feature
p::feature LOOP_BOUND_FEATURE("otawa::loop_bound::LOOP_BOUND_FEATURE", new Maker<Loop_boundProcessor>());
Loop_boundProcessor::Loop_boundProcessor(p::declare &r) : Processor(r) {}
void Loop_boundProcessor::configure(const PropList &props) {
Processor::configure(props);
}
int sum_iteration_caller(CFG* cfg) {
int iteration = 0;
elm::List<otawa::SynthBlock*> list = cfg->callers();
for(int i = 0; i < list.count(); i++) {
SynthBlock * sb = list[i];
Loop* l = Loop::of(sb);
Block* header = l->header();
if(header->isBasic()) {
iteration += TOTAL_ITERATION(header->toBasic()->first());
} else {
iteration += sum_iteration_caller(header->cfg());
}
}
if(iteration == 0) {
return 1;
}
return iteration;
}
void explo_collection(WorkSpace *ws) {
const CFGCollection *coll = INVOLVED_CFGS(ws);
for (CFGCollection::Iter cfg_iter(*coll); cfg_iter(); cfg_iter++) {
for (CFG::BlockIter block_iter = cfg_iter->blocks(); block_iter(); block_iter++) {
Block* b = *block_iter;
Loop* l = Loop::of(b);
int iteration = 0;
if(l != NULL) {
Block* header = l->header();
if(header->isBasic()) {
iteration = TOTAL_ITERATION(header->toBasic()->first());
} else {
iteration = sum_iteration_caller(header->cfg());
}
} else {
iteration = 1;
}
TOTAL_BOUND(b) = iteration;
}
}
}
void Loop_boundProcessor::processWorkSpace(WorkSpace *ws) {
explo_collection(ws);
}
// definition propriete
Identifier<int> TOTAL_BOUND("otawa::loop_bound::TOTAL_BOUND");
}
}
[elm-plugin]
name = loop_bound
author = Fabien Bouquillon <fabien.bouquillon@univ-lille.fr>
description = plugin vide
\ No newline at end of file
#cflags pour tout compiler
CXXFLAGS=`otawa-config otawa/display --cflags`
#ldlibs pour compiler le plugin
LDLIBS=`otawa-config otawa/display --libs`
#ldlibs pour compiler la application
LDLIBS2=`otawa-config otawa/display otawa/classic_ecb --libs`
ARMCC=arm-none-eabi-gcc
CXXFLAGS += -std=c++11 -O0 -g -I /home/fabien/cristal/otawa/include/ -I ../otawa-core2-build/otawa/include/elm/ -I ../include -I ../classic_ecb/include/
all: test_1 test_ecb
test_1: test_1.c
$(ARMCC) -nostdlib -nostdinc -static -o test_1 test_1.c
test_main.o: test_main.cpp
$(CXX) $(CXXFLAGS) -c test_main.cpp
test_ecb.o: test_ecb.cpp
$(CXX) $(CXXFLAGS) -c test_ecb.cpp
test_ecb: test_main.o test_ecb.o
$(CXX) $(CXXFLAGS) -o test_ecb test_main.o test_ecb.o $(LDLIBS2)
clean:
rm *.o
rm test_1
rm test_ecb
all: test_1 test_ecb
test_1: test_1.c
$(ARMCC) -nostdlib -nostdinc -static -o test_1 test_1.C
test_main.o: test_main.c
$(CXX) -c test_main.o test_main.c $(LDLIBS2)
test_ecb: test_1.o test_main.o
<?xml version="1.0" encoding="UTF-8"?>
<cache-config>
<icache>
<block_bits>5</block_bits>
<way_bits>2</way_bits>
<row_bits>5</row_bits>
<miss_penalty>70</miss_penalty>
</icache>
</cache-config>
<?xml version="1.0" encoding="UTF-8"?>
<cache-config>
<icache>
<block_bits>3</block_bits>
<way_bits>1</way_bits>
<row_bits>2</row_bits>
<miss_penalty>70</miss_penalty>
</icache>
</cache-config>
This diff is collapsed.
int function_1() {
int i = 0;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
}
int main() {
for(int i = 0; i < 100; i++) {
if(i == 5) {
function_1();
} else {
int j = 0;
j++;
j++;
j++;
j++;
j++;
j++;
j++;
}
int k = 0;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
}
int function_1() {
i = 0;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
i++;
}
int main() {
for(int i = 0; i < 100; i++) {
if(i == 5) {
function_1();
} else {
int j = 0;
j++;
j++;
j++;
j++;
j++;
j++;
j++;
}
int k = 0;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
k++;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment