tags:

views:

140

answers:

1

Hi,

I'm trying to get the page faults when I run a program with two different parts.

What I do is some operations using two matrix multiplication methods and try to figure out wich one causes more page faults.

/Operations for method 1

getrusage (RUSAGE_SELF, &usage);
fault1=usage.ru_minflt;

/operations for Method 2


getrusage (RUSAGE_SELF, &usage);
fault2=usage.ru_minflt-fault1;

But seems that fault2=0, what I don't think is correct. If I use two different variables usage and usage2, seems not working neither. Is there any command to start counting the faults for each multiplication method? Am I wrong with the code?

Thanks for the answers

A: 

It's entirely possible that the number of page faults is zero. It's got more to do with the way in which you're loading data, which shared libraries you're using (and whether they're already in memory or not), copy-on-write usage and similar than it does with your algorithms.

Are you sure you're not looking for the number of processor cache misses instead? For matrix multiplication of large matrices, a naive algorithm can have much worse cache usage than an optimal one. Try using valgrind with the cachegrind tool.

caf
Thanks for the comment, how can I check the cache faults instead?
Peter
caf