Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
plugin_cache_blocks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OTAWA-plugins
plugin_cache_blocks
Commits
59a7b217
Commit
59a7b217
authored
4 years ago
by
Bouquillon Fabien
Browse files
Options
Downloads
Patches
Plain Diff
first change
parent
a6b56c9f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
vulnerability/include/vulnerability.h
+11
-0
11 additions, 0 deletions
vulnerability/include/vulnerability.h
vulnerability/vulnerability.cpp
+120
-104
120 additions, 104 deletions
vulnerability/vulnerability.cpp
with
131 additions
and
104 deletions
vulnerability/include/vulnerability.h
+
11
−
0
View file @
59a7b217
...
@@ -31,6 +31,17 @@ protected:
...
@@ -31,6 +31,17 @@ protected:
// declaration feature
// declaration feature
extern
p
::
feature
VULNERABILITY_FEATURE
;
extern
p
::
feature
VULNERABILITY_FEATURE
;
// Declaration structures
typedef
struct
{
otawa
::
Address
addr
;
long
reload_time
;
}
LBlock_vulnerable
;
typedef
struct
{
std
::
vector
<
LBlock_vulnerable
>
lblocks
;
long
vulnerability
;
}
Struct_path
;
//declaration propriete
//declaration propriete
/*
/*
extern Identifier<DAGHNode*> DAG_HNODE;
extern Identifier<DAGHNode*> DAG_HNODE;
...
...
This diff is collapsed.
Click to expand it.
vulnerability/vulnerability.cpp
+
120
−
104
View file @
59a7b217
...
@@ -142,118 +142,118 @@ namespace otawa {
...
@@ -142,118 +142,118 @@ namespace otawa {
}
}
unsigned
long
compute_vul_block_out
(
BasicBlock
*
bb
,
std
::
vector
<
Address
>
ucb_out
,
const
otawa
::
hard
::
Cache
*
cache
,
std
::
vector
<
unsigned
long
>
lblock_time_array
)
{
//
unsigned long compute_vul_block_out(BasicBlock *bb, std::vector<Address> ucb_out, const otawa::hard::Cache* cache, std::vector<unsigned long> lblock_time_array) {
AllocArray
<
LBlock
*>
*
lblock_array
=
BB_LBLOCKS
(
bb
);
//
AllocArray<LBlock *> *lblock_array = BB_LBLOCKS(bb);
double
vul
=
0
;
//
double vul = 0;
for
(
int
i
=
0
;
i
<
ucb_out
.
size
();
i
++
)
{
//
for(int i = 0; i < ucb_out.size(); i++) {
bool
found
=
false
;
//
bool found = false;
for
(
int
j
=
0
;
j
<
lblock_array
->
count
();
j
++
)
{
//
for (int j = 0; j < lblock_array->count(); j++) {
LBlock
*
lb
=
(
*
lblock_array
)[
j
];
//
LBlock *lb = (*lblock_array)[j];
if
(
found
)
{
//
if(found) {
vul
+=
lblock_time_array
[
j
];
//
vul += lblock_time_array[j];
}
//
}
if
(
cache
->
round
(
lb
->
address
())
==
ucb_out
[
i
])
{
//
if(cache->round(lb->address()) == ucb_out[i]) {
found
=
true
;
//
found = true;
}
//
}
}
//
}
}
//
}
return
vul
*
cache
->
blockSize
();
//
return vul * cache->blockSize();
}
//
}
unsigned
long
compute_vul_block_in
(
BasicBlock
*
bb
,
std
::
vector
<
Address
>
ucb_in
,
const
otawa
::
hard
::
Cache
*
cache
,
std
::
vector
<
unsigned
long
>
lblock_time_array
)
{
//
unsigned long compute_vul_block_in(BasicBlock *bb, std::vector<Address> ucb_in, const otawa::hard::Cache* cache, std::vector<unsigned long> lblock_time_array) {
AllocArray
<
LBlock
*>
*
lblock_array
=
BB_LBLOCKS
(
bb
);
//
AllocArray<LBlock *> *lblock_array = BB_LBLOCKS(bb);
double
vul
=
0
;
//
double vul = 0;
for
(
int
i
=
0
;
i
<
ucb_in
.
size
();
i
++
)
{
//
for(int i = 0; i < ucb_in.size(); i++) {
for
(
int
j
=
0
;
j
<
lblock_array
->
count
();
j
++
)
{
//
for (int j = 0; j < lblock_array->count(); j++) {
LBlock
*
lb
=
(
*
lblock_array
)[
j
];
//
LBlock *lb = (*lblock_array)[j];
if
(
cache
->
round
(
lb
->
address
())
==
ucb_in
[
i
])
{
//
if(cache->round(lb->address()) == ucb_in[i]) {
break
;
//
break;
}
//
}
vul
+=
lblock_time_array
[
j
];
//
vul += lblock_time_array[j];
}
//
}
}
//
}
return
vul
*
cache
->
blockSize
();
//
return vul * cache->blockSize();
}
//
}
unsigned
long
compute_vul_block
(
BasicBlock
*
bb
,
std
::
vector
<
Address
>
ucb_in
,
std
::
vector
<
Address
>
ucb_out
,
const
otawa
::
hard
::
Cache
*
cache
,
ilp
::
System
*
sys
)
{
//
unsigned long compute_vul_block(BasicBlock *bb, std::vector<Address> ucb_in, std::vector<Address> ucb_out, const otawa::hard::Cache* cache, ilp::System* sys) {
// Compute average instruction time
//
// Compute average instruction time
unsigned
long
bb_time
=
ipet
::
TIME
(
bb
);
//
unsigned long bb_time = ipet::TIME(bb);
unsigned
long
instr_time
=
ceil
(
bb_time
/
bb
->
count
());
//
unsigned long instr_time = ceil(bb_time / bb->count());
// --- compute vulnerability during execution ---
//
// --- compute vulnerability during execution ---
unsigned
long
vul
=
0
;
//
unsigned long vul = 0;
auto
iter
=
bb
->
begin
();
//
auto iter = bb->begin();
AllocArray
<
LBlock
*>
*
lblock_array
=
BB_LBLOCKS
(
bb
);
//
AllocArray<LBlock *> *lblock_array = BB_LBLOCKS(bb);
std
::
vector
<
unsigned
long
>
lblock_time_array
;
//
std::vector<unsigned long> lblock_time_array;
for
(
int
i
=
0
;
i
<
lblock_array
->
count
();
i
++
)
{
//
for (int i = 0; i < lblock_array->count(); i++) {
LBlock
*
lb
=
(
*
lblock_array
)[
i
];
//
LBlock *lb = (*lblock_array)[i];
unsigned
long
time_lblock
=
0
;
//
unsigned long time_lblock = 0;
for
(
int
j
=
0
;
j
<
lb
->
countInsts
();
j
++
)
{
//
for(int j = 0; j < lb->countInsts(); j++) {
time_lblock
+=
instr_time
;
//
time_lblock += instr_time;
iter
++
;
//
iter++;
}
//
}
lblock_time_array
.
push_back
(
time_lblock
);
//
lblock_time_array.push_back(time_lblock);
vul
+=
time_lblock
*
lb
->
size
();
//
vul += time_lblock * lb->size();
}
//
}
// compute vulnerability ucb_in bb
//
// compute vulnerability ucb_in bb
vul
+=
compute_vul_block_in
(
bb
,
ucb_in
,
cache
,
lblock_time_array
);
//
vul += compute_vul_block_in(bb, ucb_in, cache, lblock_time_array);
//compute vulnerability ucb_out bb
//
//compute vulnerability ucb_out bb
vul
+=
compute_vul_block_out
(
bb
,
ucb_out
,
cache
,
lblock_time_array
);
//
vul += compute_vul_block_out(bb, ucb_out, cache, lblock_time_array);
unsigned
long
head_iteration
=
0
;
//
unsigned long head_iteration = 0;
if
(
Loop
::
isHeader
(
bb
))
{
//
if(Loop::isHeader(bb)) {
head_iteration
=
1
;
//
head_iteration = 1;
}
//
}
vul
*=
WEIGHT
(
bb
)
+
head_iteration
;
//
vul *= WEIGHT(bb) + head_iteration;
// --- compute vulnerability during miss ---
//
// --- compute vulnerability during miss ---
std
::
vector
<
unsigned
long
>
lblock_miss_time_array
;
//
std::vector<unsigned long> lblock_miss_time_array;
double
miss_cost
=
0
;
//
double miss_cost = 0;
for
(
int
i
=
0
;
i
<
lblock_array
->
count
();
i
++
)
{
//
for (int i = 0; i < lblock_array->count(); i++) {
LBlock
*
lb
=
(
*
lblock_array
)[
i
];
//
LBlock *lb = (*lblock_array)[i];
lblock_miss_time_array
.
push_back
(
sys
->
valueOf
(
MISS_VAR
(
lb
))
*
cache
->
missPenalty
());
//
lblock_miss_time_array.push_back(sys->valueOf(MISS_VAR(lb)) * cache->missPenalty());
}
//
}
// compute vulnerability ucb_in bb
//
// compute vulnerability ucb_in bb
vul
+=
compute_vul_block_in
(
bb
,
ucb_in
,
cache
,
lblock_miss_time_array
);
//
vul += compute_vul_block_in(bb, ucb_in, cache, lblock_miss_time_array);
//compute vulnerability ucb_out bb
//
//compute vulnerability ucb_out bb
vul
+=
compute_vul_block_out
(
bb
,
ucb_out
,
cache
,
lblock_miss_time_array
);
//
vul += compute_vul_block_out(bb, ucb_out, cache, lblock_miss_time_array);
return
vul
;
// return vul;
}
// }
// // unsigned long compute_edge_time(Edge *edge, ilp::System* sys) {
// // unsigned long time_edge = etime::LTS_TIME(edge);
// unsigned long compute_edge_time(Edge *edge, ilp::System* sys) {
// // elm::Pair<long int, otawa::ilp::Var*> p_s = etime::HTS_CONFIG(edge);
// unsigned long time_edge = etime::LTS_TIME(edge);
// // if(p_s.snd != NULL) {
// // time_edge += p_s.fst * sys->valueOf(p_s.snd);
// // }
// // return time_edge;
// // }
// std::pair<unsigned long, unsigned long> compute_edge_time(Edge *edge, ilp::System* sys)
// {
// std::pair<unsigned long, unsigned long> time_edge;
// time_edge.first = etime::LTS_TIME(edge);
// time_edge.second = 0;
// elm::Pair<long int, otawa::ilp::Var*> p_s = etime::HTS_CONFIG(edge);
// elm::Pair<long int, otawa::ilp::Var*> p_s = etime::HTS_CONFIG(edge);
// if(p_s.snd != NULL) {
// if(p_s.snd != NULL) {
// time_edge += p_s.fst * sys->valueOf(p_s.snd);
//
time_edge
.second
+= p_s.fst * sys->valueOf(p_s.snd);
// }
// }
// return time_edge;
// return time_edge;
// }
// }
std
::
pair
<
unsigned
long
,
unsigned
long
>
compute_edge_time
(
Edge
*
edge
,
ilp
::
System
*
sys
)
{
std
::
pair
<
unsigned
long
,
unsigned
long
>
time_edge
;
time_edge
.
first
=
etime
::
LTS_TIME
(
edge
);
time_edge
.
second
=
0
;
elm
::
Pair
<
long
int
,
otawa
::
ilp
::
Var
*>
p_s
=
etime
::
HTS_CONFIG
(
edge
);
if
(
p_s
.
snd
!=
NULL
)
{
time_edge
.
second
+=
p_s
.
fst
*
sys
->
valueOf
(
p_s
.
snd
);
}
return
time_edge
;
}
// //------------------------------------
// //------------------------------------
// // Function compute_edge_between
// // Function compute_edge_between
// // compute the value of a set of edge between two basic block separates by synth blocks.
// // compute the value of a set of edge between two basic block separates by synth blocks.
...
@@ -1008,7 +1008,7 @@ namespace otawa {
...
@@ -1008,7 +1008,7 @@ namespace otawa {
}
}
long
data_vulnerability_on_path_ex
(
otawa
::
Address
cb
,
Block
*
b
,
const
otawa
::
hard
::
Cache
*
cache
,
std
::
vector
<
Block
*>
current_path
,
ilp
::
System
*
sys
)
{
void
data_vulnerability_on_path_ex
(
otawa
::
Address
cb
,
Block
*
b
,
const
otawa
::
hard
::
Cache
*
cache
,
std
::
vector
<
Block
*>
current_path
,
ilp
::
System
*
sys
,
std
::
vector
<
Struct_path
>
&
paths
,
long
vul
)
{
struct
Memory_block
*
mb
=
MB_STRUCT
(
b
);
struct
Memory_block
*
mb
=
MB_STRUCT
(
b
);
std
::
vector
<
Address
>
ucb_out
=
compute_ucb
(
*
(
mb
->
rmb_out
),
*
(
mb
->
lmb_out
),
cache
->
wayCount
());
std
::
vector
<
Address
>
ucb_out
=
compute_ucb
(
*
(
mb
->
rmb_out
),
*
(
mb
->
lmb_out
),
cache
->
wayCount
());
std
::
vector
<
Address
>
ucb_in
=
compute_ucb
(
*
(
mb
->
rmb_in
),
*
(
mb
->
lmb_in
),
cache
->
wayCount
());
std
::
vector
<
Address
>
ucb_in
=
compute_ucb
(
*
(
mb
->
rmb_in
),
*
(
mb
->
lmb_in
),
cache
->
wayCount
());
...
@@ -1020,7 +1020,8 @@ namespace otawa {
...
@@ -1020,7 +1020,8 @@ namespace otawa {
}
}
}
}
if
(
!
is_present
)
{
if
(
!
is_present
)
{
return
-
1
;
// not a path
return
;
}
}
// If no present in the entry ucb of the block (call during the block)
// If no present in the entry ucb of the block (call during the block)
...
@@ -1032,7 +1033,10 @@ namespace otawa {
...
@@ -1032,7 +1033,10 @@ namespace otawa {
}
}
}
}
if
(
!
is_present
)
{
if
(
!
is_present
)
{
return
0
;
Struct_path
path_tmp
;
path_tmp
.
vulnerability
=
vul
;
//TODO add reload time
return
;
}
}
// Explore different paths
// Explore different paths
...
@@ -1058,7 +1062,7 @@ namespace otawa {
...
@@ -1058,7 +1062,7 @@ namespace otawa {
return
longuest_path
;
return
longuest_path
;
}
}
long
data_vulnerability_on_path
(
LBlock
*
lb
,
const
otawa
::
hard
::
Cache
*
cache
,
ilp
::
System
*
sys
)
{
void
data_vulnerability_on_path
(
LBlock
*
lb
,
const
otawa
::
hard
::
Cache
*
cache
,
ilp
::
System
*
sys
,
std
::
vector
<
Struct_path
>
&
paths
)
{
// Look if the cache block of the lblock is present in the Useful Cache Block at the entry of the Basic Block
// Look if the cache block of the lblock is present in the Useful Cache Block at the entry of the Basic Block
BasicBlock
*
bb
=
lb
->
bb
();
BasicBlock
*
bb
=
lb
->
bb
();
struct
Memory_block
*
mb
=
MB_STRUCT
(
bb
);
struct
Memory_block
*
mb
=
MB_STRUCT
(
bb
);
...
@@ -1072,19 +1076,29 @@ namespace otawa {
...
@@ -1072,19 +1076,29 @@ namespace otawa {
}
}
// If it is not the case then it means that the lblock is not vulnerable on a path.
// If it is not the case then it means that the lblock is not vulnerable on a path.
if
(
!
is_present
)
{
if
(
!
is_present
)
{
return
0
;
paths
.
clear
();
return
;
}
}
// If it is the case we have to list all the path and take the longest.
// If it is the case we have to list all the path and take the longest.
// TODO !!!
std
::
vector
<
Block
*>
current_path
;
std
::
vector
<
Block
*>
current_path
;
long
max_value
=
0
;
for
(
Block
::
EdgeIter
iter_pred
(
bb
->
ins
());
iter_pred
();
iter_pred
++
)
{
for
(
Block
::
EdgeIter
iter_pred
(
bb
->
ins
());
iter_pred
();
iter_pred
++
)
{
Edge
*
edge
=
*
iter_pred
;
Edge
*
edge
=
*
iter_pred
;
Block
*
source
=
edge
->
source
();
Block
*
source
=
edge
->
source
();
max_value
=
max
(
max_value
,
data_vulnerability_on_path_ex
(
cache
->
round
(
lb
->
address
()),
source
,
cache
,
current_path
,
sys
));
data_vulnerability_on_path_ex
(
cache
->
round
(
lb
->
address
()),
source
,
cache
,
current_path
,
sys
,
paths
);
}
}
return
max_value
;
// long max_value = 0;
// for (Block::EdgeIter iter_pred(bb->ins()); iter_pred(); iter_pred++) {
// Edge *edge = *iter_pred;
// Block *source = edge->source();
// max_value = max(max_value, data_vulnerability_on_path_ex(cache->round(lb->address()), source, cache, current_path, sys));
// }
// return max_value;
}
}
long
maximum_execution_time_bb
(
BasicBlock
*
bb
,
ilp
::
System
*
sys
)
{
long
maximum_execution_time_bb
(
BasicBlock
*
bb
,
ilp
::
System
*
sys
)
{
...
@@ -1126,8 +1140,10 @@ namespace otawa {
...
@@ -1126,8 +1140,10 @@ namespace otawa {
long
data_vulnerability
(
LBlock
*
lb
,
const
otawa
::
hard
::
Cache
*
cache
,
ilp
::
System
*
sys
)
{
long
data_vulnerability
(
LBlock
*
lb
,
const
otawa
::
hard
::
Cache
*
cache
,
ilp
::
System
*
sys
)
{
long
data_size
=
data_vulnerable
(
lb
,
cache
);
long
data_size
=
data_vulnerable
(
lb
,
cache
);
long
v
=
maximum_execution_time_bb
(
lb
->
bb
(),
sys
);
long
v
=
maximum_execution_time_bb
(
lb
->
bb
(),
sys
);
v
+=
data_vulnerability_on_path
(
lb
,
cache
,
sys
);
v
*=
data_size
;
return
data_size
*
v
;
data_vulnerability_on_path
(
lb
,
cache
,
sys
);
// return only vulnerability during Lblock execution
return
v
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment