> Can anyone tell me, is it possible to collect number of fetches and > cache misses for a particular array using Callgrind/Cachegrind? > For example, I have such fragment: > > for (j = 0; j < length; j++) { > for (i = ip[j]; i <= ip[j+1]-1; i++) { > b[ia[i]] = b[ia[i]] + a[i]*x[j]; > } > } > > And I want to collect information only about array /b/. How can this be > done?
Short answer is, like this for (j = 0; j < length; j++) { for (i = ip[j]; i <= ip[j+1]-1; i++) { long ia_i = ia[i]; double tmp = a[i] * x[j]; // or whatever type it is b[ia_i] += tmp; } } Now the stats for the line b[ia_i] += tmp should show you info only for the /b/ access. Long answer is, the question is kind-of meaningless. Cache misses are a function of the overall memory behaviour of your program. So the misses on b[] also depend on how the program accesses a[], x[], ip[], etc, and you can't really measure each in isolation. J ------------------------------------------------------------------------------ Benefiting from Server Virtualization: Beyond Initial Workload Consolidation -- Increasing the use of server virtualization is a top priority.Virtualization can reduce costs, simplify management, and improve application availability and disaster protection. Learn more about boosting the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users