21.04.2011 4:16, Julian Seward пишет:
>> 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.
Thanks, this could help, and I need to change my program only a little, 
that's convenient :)
> 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.
>
Of course I agree with you, it depends on other accesses, but it is 
interesting for my research to get caches misses for particular arrays 
as well as for the whole program.
And in simple programs like this influence of different arrays on each 
other can be approximately estimated.
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to