Last change
on this file since 1003 was
843,
checked in by devigne, 10 years ago
|
RWT Commit : Add soft directory.
Soft directory contains scripts used to validate the RWT protocol
|
File size:
1.3 KB
|
Rev | Line | |
---|
[843] | 1 | |
---|
| 2 | #ifndef _transaction_hpp_ |
---|
| 3 | #define _transaction_hpp_ |
---|
| 4 | |
---|
| 5 | #include "Increment.hpp" |
---|
| 6 | #include "EnsembleVariables.hpp" |
---|
| 7 | |
---|
| 8 | #include <iostream> |
---|
| 9 | #include <list> |
---|
| 10 | #include <set> |
---|
| 11 | |
---|
| 12 | using namespace std; |
---|
| 13 | |
---|
| 14 | class Transaction { |
---|
| 15 | |
---|
| 16 | EnsembleVariables * E; |
---|
| 17 | int proc_id; |
---|
| 18 | std::list<Increment*> requests; |
---|
| 19 | |
---|
| 20 | public: |
---|
| 21 | |
---|
| 22 | Transaction(int nb_diff_ML, int nb_diff_CL, int nb_max_insts, int line_size, int cache_lines, EnsembleVariables * E, int proc_id){ |
---|
| 23 | this->proc_id = proc_id; |
---|
| 24 | this->E = E; |
---|
| 25 | const int nb_insts = randint(1, nb_max_insts); |
---|
| 26 | for (int i = 0; i < nb_insts; i++) { |
---|
| 27 | Increment *incr; |
---|
| 28 | incr = new Increment(nb_diff_ML, nb_diff_CL, line_size, cache_lines, E, proc_id); |
---|
| 29 | requests.push_back(incr); |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | ~Transaction() { |
---|
| 34 | std::list<Increment*>::iterator it; |
---|
| 35 | for (it = requests.begin(); it != requests.end(); it++){ |
---|
| 36 | delete (*it); |
---|
| 37 | } |
---|
| 38 | requests.clear(); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | string writeOutput() { |
---|
| 42 | stringstream res; |
---|
| 43 | res << E->writePrivateAccesses(proc_id); |
---|
| 44 | res << " // Debut Transaction" << endl; |
---|
| 45 | |
---|
| 46 | std::list<Increment*>::iterator it; |
---|
| 47 | for (it = requests.begin(); it != requests.end(); it++) { |
---|
| 48 | res << (*it)->writeOutput(); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | res << " // Fin Transaction" << endl; |
---|
| 52 | res << endl; |
---|
| 53 | |
---|
| 54 | return res.str(); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | }; |
---|
| 58 | |
---|
| 59 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.