Use papi to test the cache hit rate and TLB Loss Rate

Source: Internet
Author: User

I have two guesses, but I don't know if they are accurate. Please contact us:

1. The values element seems to have to be 64-bit. In FORTRAN, INTEGER (kind = 8) or INTEGER (8 ).

2. Only two event_codes can be added at a time.

 

 

        program papitest        implicit none#include "f90papi.h"        integer, parameter::N = 5000        integer x(N,N),y(N,N),z(N,N)        integer check,event_set,event_code        integer i, j        integer(kind=8) values(4)        do j = 1, N        do i = 1, N                x(i,j) = i + j                y(i,j) = i + 1                z(i,j) = 0        enddo        enddo        do i = 1, 4                values(i) = -1        enddo!       print *, values        ! initialize the PAPI library        check = PAPI_VER_CURRENT        call PAPIF_library_init(check)        ! create the eventset        event_set = PAPI_NULL        call PAPIF_create_eventset(event_set, check)        event_code = PAPI_L1_DCH ! Total L1 Data Cache hits        call PAPIF_add_event(event_set, event_code, check)        event_code = PAPI_L1_DCM ! Total L1 Data Cache misses        call PAPIF_add_event(event_set, event_code, check)!       event_code = PAPI_TLB_DM ! TLB misses!       call PAPIF_add_event(event_set, event_code, check)        ! start counting         call PAPIF_start(event_set, check)        do j = 1,N        do i = 1,N                z(i,j) = x(i,j)+y(i,j)        end do        end do        ! stop counting        call PAPIF_stop(event_set, values, check)        print *,'L1 cache hits:',values(1)        print *,'L1 cache misses:',values(2)        print *,'L1 cache hit rates:',     &  values(1) *100 / (values(1) + values(2))        ! reset the PAPI counters        call PAPIF_reset(event_set, check)        call PAPIF_shutdown        end

 

[root@c0106 simple]# gfortran hello.F -o hello -lpapi[root@c0106 simple]# ./hello L1 cache hits:            331640400 L1 cache misses:              4697189 L1 cache hit rates:                   98[root@c0106 simple]# 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.