Last change
on this file since 859 was
536,
checked in by meunier, 11 years ago
|
Added a tool which generates tests for the LL/SC table, in the soft/ directory.
|
File size:
1.5 KB
|
Line | |
---|
1 | |
---|
2 | #ifndef _testthread_hpp_ |
---|
3 | #define _testthread_hpp_ |
---|
4 | |
---|
5 | #include <iostream> |
---|
6 | #include <sstream> |
---|
7 | #include <list> |
---|
8 | |
---|
9 | #include "Increment.hpp" |
---|
10 | |
---|
11 | using namespace std; |
---|
12 | |
---|
13 | class TestThread { |
---|
14 | |
---|
15 | int proc_id; |
---|
16 | std::list<Increment *> requests; |
---|
17 | |
---|
18 | public: |
---|
19 | |
---|
20 | TestThread(int nb_locks, int nb_max_accesses, int line_size, bool lock_in_line, bool vars_in_line, int proc_id) { |
---|
21 | this->proc_id = proc_id; |
---|
22 | const int nb_accesses = randint(1, nb_max_accesses); |
---|
23 | for (int i = 0; i < nb_accesses; i++) { |
---|
24 | Increment * t; |
---|
25 | t = new Increment(nb_locks, line_size, lock_in_line, vars_in_line); |
---|
26 | requests.push_back(t); |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | ~TestThread() { |
---|
31 | std::list<Increment *>::iterator it; |
---|
32 | for (it = requests.begin(); it != requests.end(); it++) { |
---|
33 | delete (*it); |
---|
34 | } |
---|
35 | requests.clear(); |
---|
36 | } |
---|
37 | |
---|
38 | string write_output() { |
---|
39 | stringstream res; |
---|
40 | res << "void run" << proc_id << "() {" << endl; |
---|
41 | |
---|
42 | std::list<Increment *>::iterator it; |
---|
43 | for (it = requests.begin(); it != requests.end(); it++) { |
---|
44 | res << (*it)->write_output(); |
---|
45 | } |
---|
46 | |
---|
47 | res << "}" << endl; |
---|
48 | res << endl; |
---|
49 | |
---|
50 | return res.str(); |
---|
51 | } |
---|
52 | |
---|
53 | |
---|
54 | string write_task() { |
---|
55 | stringstream res; |
---|
56 | res << "__attribute__((constructor)) void run" << proc_id << "() {" << endl; |
---|
57 | |
---|
58 | std::list<Increment *>::iterator it; |
---|
59 | for (it = requests.begin(); it != requests.end(); it++) { |
---|
60 | res << (*it)->write_task(); |
---|
61 | } |
---|
62 | |
---|
63 | res << "}" << endl; |
---|
64 | res << endl; |
---|
65 | |
---|
66 | return res.str(); |
---|
67 | } |
---|
68 | }; |
---|
69 | |
---|
70 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.