tags:

views:

76

answers:

4

How can the program be made intensively load-store so that there is maximum memory references and negligible computation(not even looping overheads!)

A: 

Use a lot of volatile variables, which are stored in-memory but I'm not sure if that answers your question.

sybreon
A: 

Use huge arrays with a lot of scattered reads/writes to maximize cache misses. If your goal is to write a program that just exercises memory - write random values into an array at indices chosen randomly.

sharptooth
hey thnks a ton...is there any way to flush cache?
Haven't heard of, and if there is one, it is platform-dependent. However you don't really need it - scattered memory access does good job on its own.
sharptooth
+2  A: 

With gcc use -funroll-loops on this code:

int main (int argc, char** argv) {
    int a = 5;
    int b = 10;
    int c;
    int i;

    while (1) {
        for (i = 0; i <= 2147483647; i++) {
            c = b;
            b = a;
            a = c;
        }
    }

    return 0;
}
Chas. Owens
Thanks sharptooth, I always write retrun instead of return.
Chas. Owens
A: 

Make a map between possible inputs to your program and possible outputs.

Calculations on the inputs to make the outputs need to be done by another program or by hand, though.

strager