Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Memory Bandwidth Monitoring

Kundan__Shivam
Beginner
746 Views

Hello,

I am trying to record the number of number of memory accesses for each core on an Intel(R) Xeon(R) Gold 6130 CPU @ 2.10GHz using its MBM capability. The function I am using is listed below. I followed the steps in Intel's software developer manual vol 3 section 17.18 but I do not get any output. I tried all three events (0x01, 0x02, and 0x03) listed in table 17-18 but none worked. Does anyone know what I am doing wrong here?

void InitRMID (aff_counters_t *cntrs)
{
    int i, cpus_nr;
    __u64 pqr_assoc_msr, qm_evtsel;
    __u64 rmid, maxrmid;
    __u64 event;
    prfcnt_t *handle;

    L3CMTGetCapabilities(&cntrs->L3Cap);

    printf("MaxRMID: %d and UpscalingFactor: %d\n", cntrs->L3Cap.MaxRMID, cntrs->L3Cap.UpscalingFactor);

    maxrmid = cntrs->L3Cap.MaxRMID;
    cpus_nr = cntrs->cpus_nr;
    

\\ cpus, given from command line, should correspond to those of socket 0.
\\ RMID are associated to cpus like following: [MaxRMID-cpu0], [(MaxRMID-1)-cpu1] 
    rmid = maxrmid;

    for(i = 0; i < cpus_nr; i++)
    {
        handle = &cntrs->prfcnt;

        // Association between core and RMID (Filling IA32_PQR_ASSOC register)

        prfcnt_rdmsr(handle->msr_fd, IA32_PQR_ASSOC, &pqr_assoc_msr);

        printf("pqr_assoc_msr before: %d\n",pqr_assoc_msr );

        pqr_assoc_msr &= 0xfffffffffffffc00;

        if ((rmid > 0x4ff) || (rmid > maxrmid))
        {
            printf("rmid value exceeds the limits\n");
            exit(-1);
        }

        rmid &= 0x00000000000004ff;
        pqr_assoc_msr |= rmid;
        printf("pqr_assoc_msr after: %d\n",pqr_assoc_msr );
        printf("Associating CPU: %d with RMID: %lld and pqr_assoc_msr: %#18llx\n", handle->cpu, rmid, pqr_assoc_msr);

        prfcnt_wrmsr(handle->msr_fd, IA32_PQR_ASSOC, pqr_assoc_msr);

        // Select event in IA32_QM_EVTSEL (Filling RMID and EvtID)

        event = (rmid<<32);
        qm_evtsel = event | 0x0000000000000002;    \\Selecting the event 0x02

        printf("qm_evtsel value: %#18llx\n", qm_evtsel);

        prfcnt_wrmsr(handle->msr_fd, IA32_QM_EVTSEL, qm_evtsel);
        --rmid;
    }
}

 

0 Kudos
0 Replies
Reply