LCOV - code coverage report
Current view: top level - plugins/perfmon/intel/bundle - backend_bound_mem.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 1 33 3.0 %
Date: 2023-07-05 22:20:52 Functions: 1 2 50.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2021 Intel and/or its affiliates.
       3             :  * Licensed under the Apache License, Version 2.0 (the "License");
       4             :  * you may not use this file except in compliance with the License.
       5             :  * You may obtain a copy of the License at:
       6             :  *
       7             :  *     http://www.apache.org/licenses/LICENSE-2.0
       8             :  *
       9             :  * Unless required by applicable law or agreed to in writing, software
      10             :  * distributed under the License is distributed on an "AS IS" BASIS,
      11             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             :  * See the License for the specific language governing permissions and
      13             :  * limitations under the License.
      14             :  */
      15             : 
      16             : #include <perfmon/perfmon.h>
      17             : #include <perfmon/intel/core.h>
      18             : 
      19             : enum
      20             : {
      21             :   STALLS_L1D_MISS = 0,
      22             :   STALLS_L2_MISS = 1,
      23             :   STALLS_L3_MISS = 2,
      24             :   STALLS_MEM_ANY = 3,
      25             :   STALLS_TOTAL = 4,
      26             :   BOUND_ON_STORES = 5,
      27             :   FB_FULL = 6,
      28             :   THREAD = 7,
      29             : };
      30             : 
      31             : static u8 *
      32           0 : format_intel_backend_bound_mem (u8 *s, va_list *args)
      33             : {
      34           0 :   perfmon_node_stats_t *ss = va_arg (*args, perfmon_node_stats_t *);
      35           0 :   int row = va_arg (*args, int);
      36           0 :   f64 sv = 0;
      37             : 
      38           0 :   if (!ss->n_packets)
      39           0 :     return s;
      40             : 
      41           0 :   if (0 == row)
      42             :     {
      43           0 :       sv = ss->value[THREAD] / ss->n_packets;
      44             : 
      45           0 :       s = format (s, "%.0f", sv);
      46           0 :       return s;
      47             :     }
      48             : 
      49           0 :   switch (row)
      50             :     {
      51           0 :     case 1:
      52           0 :       sv = ss->value[BOUND_ON_STORES];
      53           0 :       break;
      54           0 :     case 2:
      55           0 :       sv = ss->value[STALLS_MEM_ANY] - ss->value[STALLS_L1D_MISS];
      56           0 :       break;
      57           0 :     case 3:
      58           0 :       sv = ss->value[FB_FULL];
      59           0 :       break;
      60           0 :     case 4:
      61           0 :       sv = ss->value[STALLS_L1D_MISS] - ss->value[STALLS_L2_MISS];
      62           0 :       break;
      63           0 :     case 5:
      64           0 :       sv = ss->value[STALLS_L2_MISS] - ss->value[STALLS_L3_MISS];
      65           0 :       break;
      66           0 :     case 6:
      67           0 :       sv = ss->value[STALLS_L3_MISS];
      68           0 :       break;
      69             :     }
      70             : 
      71           0 :   sv = clib_max ((sv / ss->value[THREAD]) * 100, 0);
      72             : 
      73           0 :   s = format (s, "%04.1f", sv);
      74             : 
      75           0 :   return s;
      76             : }
      77             : 
      78             : static perfmon_cpu_supports_t backend_bound_mem_cpu_supports[] = {
      79             :   { clib_cpu_supports_avx512_bitalg, PERFMON_BUNDLE_TYPE_NODE },
      80             : };
      81             : 
      82         559 : PERFMON_REGISTER_BUNDLE (intel_core_backend_bound_mem) = {
      83             :   .name = "td-backend-mem",
      84             :   .description = "Topdown BackEnd-bound Memory - % cycles not retiring "
      85             :                  "instructions due to memory stalls",
      86             :   .source = "intel-core",
      87             :   .events[0] = INTEL_CORE_E_CYCLE_ACTIVITY_STALLS_L1D_MISS, /* 0x0F */
      88             :   .events[1] = INTEL_CORE_E_CYCLE_ACTIVITY_STALLS_L2_MISS,  /* 0x0F */
      89             :   .events[2] = INTEL_CORE_E_CYCLE_ACTIVITY_STALLS_L3_MISS,  /* 0x0F */
      90             :   .events[3] = INTEL_CORE_E_CYCLE_ACTIVITY_STALLS_MEM_ANY,  /* 0xFF */
      91             :   .events[4] = INTEL_CORE_E_CYCLE_ACTIVITY_STALLS_TOTAL,    /* 0xFF */
      92             :   .events[5] = INTEL_CORE_E_EXE_ACTIVITY_BOUND_ON_STORES,   /* 0xFF */
      93             :   .events[6] = INTEL_CORE_E_L1D_PEND_MISS_FB_FULL,          /* 0x0F */
      94             :   .events[7] = INTEL_CORE_E_CPU_CLK_UNHALTED_THREAD_P,      /* 0xFF */
      95             :   .n_events = 8,
      96             :   .format_fn = format_intel_backend_bound_mem,
      97             :   .cpu_supports = backend_bound_mem_cpu_supports,
      98             :   .n_cpu_supports = ARRAY_LEN (backend_bound_mem_cpu_supports),
      99             :   .column_headers = PERFMON_STRINGS ("Clocks/Packet", "%Store Bound",
     100             :                                      "%L1 Bound", "%FB Full", "%L2 Bound",
     101             :                                      "%L3 Bound", "%DRAM Bound"),
     102             : };

Generated by: LCOV version 1.14