Otawa  0.10
PERSProblem.h
Go to the documentation of this file.
1 /*
2  * dcache::PERSProblem class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2007-13, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  */
22 
23 #ifndef OTAWA_DCACHE_PERSPROBLEM_H_
24 #define OTAWA_DCACHE_PERSPROBLEM_H_
25 
26 #include <elm/io.h>
27 #include <elm/assert.h>
28 #include <otawa/prog/WorkSpace.h>
29 #include <otawa/dcache/features.h>
30 #include <otawa/hard/Cache.h>
31 #include <otawa/cfg/BasicBlock.h>
32 #include <otawa/util/HalfAbsInt.h>
33 
34 
35 namespace otawa { namespace dcache {
36 
37 class PERSProblem {
38 public:
39 
40  class Item: public ACS {
41  public:
42  inline Item(const int _size, const int _A): ACS(_size, _A, -1) { }
43  inline Item(const Item &source): ACS(source) { }
44  inline Item(const ACS &source): ACS(source) { }
45  inline Item& operator=(const Item &src) { ACS::operator=(src); return *this; }
46  inline Item& operator=(const ACS &src) { ACS::operator=(src); return *this; }
47  inline void refresh(int id, int newage)
48  { ASSERT((id >= 0) && (id < size)); if ((newage != -1) && ((age[id] > newage) || (age[id] == -1))) age[id] = newage; }
49  void lub(const Item &dom);
50  bool equals(const Item &dom) const;
51  void inject(MUSTProblem::Domain *must, const int id);
52  inline bool isWiped(const int id) { return(age[id] == A); }
53  inline bool isPersistent(const int id) { return(contains(id) && !isWiped(id)); }
54  void addDamage(const int id, int damage);
55  void ageAll(void);
56  };
57 
58  class Domain {
59  public:
60  inline Domain(const int _size, const int _A): whole(_size, _A), isBottom(true) { }
61  inline Domain(const Domain &source): whole(source.whole), isBottom(source.isBottom)
62  { for (int i = 0; i < source.data.length(); i++) data.add(new Item(*source.data[i])); }
63  inline ~Domain(void) { for (int i = 0; i < data.length(); i++) delete data[i]; }
64 
65  Domain& operator=(const Domain &src);
66  void lub(const Domain &dom);
67  void lub(const Item &item);
68  bool equals(const Domain &dom) const;
69  void empty(void);
70  void setToBottom(void);
71  inline Item &getWhole(void) { return whole; }
72  inline bool contains(const int id, const int index) { ASSERT(!isBottom); return(data[index]->contains(id)); }
73  void inject(MUSTProblem::Domain *must, const int id);
74  inline bool isWiped(const int id, const int index) { ASSERT(!isBottom); return(data[index]->isWiped(id)); }
75  inline int getAge(const int id, const int index) const { ASSERT(!isBottom); return(data[index]->getAge(id)); }
76  inline bool isPersistent(const int id, const int index) { ASSERT(!isBottom); return(data[index]->isPersistent(id)); }
77  inline void addDamage(const int id, const int index, int damage) { ASSERT(!isBottom); data[index]->addDamage(id, damage); }
78  void addDamage(const int id, int damage);
79  inline void refresh(const int id, const int index, int newage) { ASSERT(!isBottom); data[index]->refresh(id, newage); }
80  void refresh(const int id, int newage);
81  void print(elm::io::Output &output) const;
82  void enterContext(void);
83  void leaveContext(void);
84  inline int length(void) const { ASSERT(!isBottom); return data.length(); }
85  inline Item& getItem(const int idx) const { ASSERT(!isBottom); return(*data.get(idx)); }
86  void ageAll(void);
87  inline void setNotBottom(void) { isBottom = false; }
88  inline void set(const ACS& w, const genstruct::Table<ACS *>& d) {
89  isBottom = false;
90  whole = w;
91  int m = min(data.count(), d.count());
92  for(int i = m; i < data.count(); i++)
93  delete data[i];
94  data.setLength(d.count());
95  for(int i = 0; i < m; i++)
96  *data[i] = *d[i];
97  for(int i = m; i < d.count(); i++)
98  data[i] = new Item(*d[i]);
99  }
100 
101  private:
104  bool isBottom;
105  };
106 
107 
109 
110 public:
111  PERSProblem(const int _size, const BlockCollection *_lbset, WorkSpace *_fw, const hard::Cache *_cache, const int _A);
112  ~PERSProblem(void);
113  const Domain& bottom(void) const;
114  const Domain& entry(void) const;
115 
116  inline void lub(Domain &a, const Domain &b) const { a.lub(b); }
117  inline void assign(Domain &a, const Domain &b) const { a = b; }
118  inline bool equals(const Domain &a, const Domain &b) const { return (a.equals(b)); }
119  void update(Domain& out, const Domain& in, BasicBlock* bb);
120  void update(Domain& s, const BlockAccess& access);
121  void purge(Item& item, const BlockAccess& acc);
122  void purge(Domain& domain, const BlockAccess& acc);
123 
124  inline void enterContext(Domain& dom, BasicBlock *header, util::hai_context_t ctx) {
125 #ifndef PERFTEST
126  if (ctx == util::CTX_LOOP)
127  dom.enterContext();
128 #endif
129  }
130 
131  inline void leaveContext(Domain& dom, BasicBlock *header, util::hai_context_t ctx) {
132 #ifndef PERFTEST
133  if (ctx == util::CTX_LOOP)
134  dom.leaveContext();
135 #endif
136  }
137 
138 private:
145  const int line;
146 };
147 
149 
150 } } // otawa::dcache
151 
152 #endif /* OTAWA_DCACHE_PERSPROBLEM_H_*/
ACS for the multi-level data cache persistence analysis.
Definition: PERSProblem.h:40
CFG * cfg
Definition: PERSProblem.h:140
int A
Definition: features.h:82
void update(Domain &out, const Domain &in, BasicBlock *bb)
Definition: dcache_ACSBuilder.cpp:579
Item(const ACS &source)
Definition: PERSProblem.h:44
dtd::RefAttr< BasicBlock * > source("source", dtd::STRICT|dtd::REQUIRED)
~PERSProblem(void)
Definition: dcache_ACSBuilder.cpp:568
void assign(Domain &a, const Domain &b) const
Definition: PERSProblem.h:117
A block access represents a data memory access of an instruction.
Definition: features.h:125
void addDamage(const int id, const int index, int damage)
Definition: PERSProblem.h:77
const Domain & bottom(void) const
Definition: dcache_ACSBuilder.cpp:571
void leaveContext(Domain &dom, BasicBlock *header, util::hai_context_t ctx)
Definition: PERSProblem.h:131
void refresh(const int id, const int index, int newage)
Definition: PERSProblem.h:79
void inject(MUSTProblem::Domain *must, const int id)
Consider that an access to the designed block is performed.
Definition: dcache_ACSBuilder.cpp:803
void addDamage(const int id, int damage)
Change the age of the designed block considering the given damage to the ACS.
Definition: dcache_ACSBuilder.cpp:823
void print(elm::io::Output &output) const
Display the ACS.
Definition: dcache_ACSBuilder.cpp:988
intn_t min(intn_t a, intn_t b)
Return the min with a signed comparison.
Definition: clp_analysis.cpp:171
elm::io::Output & operator<<(elm::io::Output &output, const MUSTProblem::Domain &dom)
Definition: dcache_ACSBuilder.cpp:155
void refresh(int id, int newage)
Definition: PERSProblem.h:47
Definition: ACSBuilder.h:37
Item & getItem(const int idx) const
Definition: PERSProblem.h:85
bool contains(const int id) const
Test if a block is in the ACS , that is, its each age is in the interval [0, A[ where A is the associ...
Definition: features.h:68
void lub(Domain &a, const Domain &b) const
Definition: PERSProblem.h:116
Item(const int _size, const int _A)
Definition: PERSProblem.h:42
void enterContext(void)
Called when a loop context is entered to add a level.
Definition: dcache_ACSBuilder.cpp:1010
Domain ent
Definition: PERSProblem.h:144
sys::SystemInStream & in
const Domain & entry(void) const
Definition: dcache_ACSBuilder.cpp:575
void lub(const Domain &dom)
Compute the join of the current value with the given one and the result is left in the current ACS...
Definition: dcache_ACSBuilder.cpp:867
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
Control Flow Graph representation.
Definition: CFG.h:42
~Domain(void)
Definition: PERSProblem.h:63
uint32 size
void purge(Item &item, const BlockAccess &acc)
Apply the given purge action to the given item.
Definition: dcache_ACSBuilder.cpp:590
void lub(const Item &dom)
Perform join on persistent ACS.
Definition: dcache_ACSBuilder.cpp:776
PERSProblem(const int _size, const BlockCollection *_lbset, WorkSpace *_fw, const hard::Cache *_cache, const int _A)
Definition: dcache_ACSBuilder.cpp:549
Domain callstate
Definition: PERSProblem.h:108
void enterContext(Domain &dom, BasicBlock *header, util::hai_context_t ctx)
Definition: PERSProblem.h:124
void ageAll(void)
Consider that an unknown access is performed and, therefore, all blocks must be aged.
Definition: dcache_ACSBuilder.cpp:635
Domain bot
Definition: PERSProblem.h:143
bool equals(const Domain &a, const Domain &b) const
Definition: PERSProblem.h:118
Domain(const int _size, const int _A)
Definition: PERSProblem.h:60
int length(void) const
Definition: PERSProblem.h:84
Item whole
Definition: PERSProblem.h:102
bool isPersistent(const int id)
Definition: PERSProblem.h:53
Item & operator=(const Item &src)
Definition: PERSProblem.h:45
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
This class contains the configuration of a level of cache of processor.
Definition: Cache.h:34
int getAge(const int id, const int index) const
Definition: PERSProblem.h:75
bool isWiped(const int id)
Definition: PERSProblem.h:52
void inject(MUSTProblem::Domain *must, const int id)
Consider that the designed block is accessed.
Definition: dcache_ACSBuilder.cpp:950
bool isBottom
Definition: PERSProblem.h:104
genstruct::Vector< Item * > data
Definition: PERSProblem.h:103
const hard::Cache * cache
Definition: PERSProblem.h:142
void setNotBottom(void)
Definition: PERSProblem.h:87
sys::SystemOutStream & out
Definition: PERSProblem.h:58
const int line
Definition: PERSProblem.h:145
Domain & operator=(const Domain &src)
Assignement of persistence analysis ACS.
Definition: dcache_ACSBuilder.cpp:838
hai_context_t
Definition: HalfAbsInt.h:50
ACS & operator=(const ACS &src)
Definition: features.h:59
Problem for computing the PERS ACS of L-blocks.
Definition: PERSProblem.h:37
void empty(void)
Empty the domain.
Definition: dcache_ACSBuilder.cpp:924
Definition: HalfAbsInt.h:51
bool contains(const int id, const int index)
Definition: PERSProblem.h:72
bool isPersistent(const int id, const int index)
Definition: PERSProblem.h:76
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
int * age
Definition: features.h:83
WorkSpace * fw
Definition: PERSProblem.h:141
bool isWiped(const int id, const int index)
Definition: PERSProblem.h:74
void ageAll(void)
Consider that an unknown access is performed and, therefore, all blocks must be aged.
Definition: dcache_ACSBuilder.cpp:646
Item & operator=(const ACS &src)
Definition: PERSProblem.h:46
bool equals(const Domain &dom) const
Test if two ACS are equals.
Definition: dcache_ACSBuilder.cpp:912
Domain(const Domain &source)
Definition: PERSProblem.h:61
void set(const ACS &w, const genstruct::Table< ACS * > &d)
Definition: PERSProblem.h:88
void leaveContext(void)
Called when a loop context is left to remove the top-level.
Definition: dcache_ACSBuilder.cpp:1022
bool equals(const Item &dom) const
Test if two ACS are equals.
Definition: dcache_ACSBuilder.cpp:789
Item(const Item &source)
Definition: PERSProblem.h:43
void setToBottom(void)
Set the bottom value in the ACS.
Definition: dcache_ACSBuilder.cpp:936
Representation of an Abstract Cache State where each data cache block is represented by its age...
Definition: features.h:47
const BlockCollection * lbset
Definition: PERSProblem.h:139
A block collections stores the list of data blocks used in a task for a specific line.
Definition: features.h:108
Item & getWhole(void)
Definition: PERSProblem.h:71