I have some code written in c++ that simulates a prefetcher for a CPU. In the code I have some definitions that look like this
#define x 5
...
for(int i = 0; i < x; i++)
...
At the end of the simulation the simulator outputs the average access time which is a measure of how good the prefetcher did. The performance of the prefetcher depends on x and some other similar definitions.
I would like to have a program that changes x, recompiles the new code, runs it, looks at the value, and based on the change in simulated access time repeats the process.
Does anyone know of an easy way to do this that isn't manually changing values?
EDIT: I think I need to clarify that I do not want to have to program a learning algorithm since I have never done it and probably couldn't do it nearly as well as others.
I guess your current program looks something like this
int main() {
#define x 5
<do the simulation>
cout << "x=" << x << " time=" << aat << endl;
Instead you might create a simulate function that takes x as an explicit parameter and returns the average access time ...
double simulate( int x ) {
<do simulation>
}
And call it from main
int main() {
x= initial x value
While ( necessary ) {
Double aat = simulate(x)
Cout << "x=" << x << " time=" << aat << endl;
x = <updated x according to some strategy>
This way your machine learning to learn x happens in main.
But ... If you're writing a program to simulate CPU prefetching I can't help thinking that you know all this perfectly well already. I don't really understand why you were using the compiler to change a simulation parameter in the first place.