Skip to content

Commit

Permalink
gprofng: add hardware counters for AMD Zen4
Browse files Browse the repository at this point in the history
ChangeLog
2024-06-01  Vladimir Mezentsev  <[email protected]>

	* common/hwctable.c: Add the hwc table for AMD Zen4.
	* src/hwc_amd_zen4.h: New file.
	* src/hwc_amd_zen3.h: Define _HWC_AMD_ZEN3_H.
  • Loading branch information
Vladimir Mezentsev committed Jun 3, 2024
1 parent 7c493aa commit 9af067b
Show file tree
Hide file tree
Showing 3 changed files with 889 additions and 1 deletion.
22 changes: 22 additions & 0 deletions gprofng/common/hwctable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,7 @@ static Hwcentry generic_list[] = {
};

#include "hwc_amd_zen3.h"
#include "hwc_amd_zen4.h"

/* structure defining the counters for a CPU type */
typedef struct
Expand Down Expand Up @@ -1353,6 +1354,7 @@ static cpu_list_t cputabs[] = {
{ARM_CPU_IMP_APM, generic_list, {"insts,,cycles", 0}},
{CPC_AMD_Authentic, generic_list, {"insts,,cycles", 0}},
{CPC_AMD_FAM_19H_ZEN3, amd_zen3_list, {"insts,,cycles", 0}},
{CPC_AMD_FAM_19H_ZEN4, amd_zen4_list, {"insts,,cycles", 0}},
{0, generic_list, {"insts,,cycles", 0}},
};

Expand Down Expand Up @@ -1825,6 +1827,26 @@ setup_cpc_general (int skip_hwc_test)
hwcdrv->hwcdrv_get_info (&cpcx_cpuver, &cpcx_cciname, &cpcx_npics,
&cpcx_docref, &cpcx_support_bitmask);

/* Fix cpcx_cpuver for new Zen machines */
cpu_info_t *cpu_p = read_cpuinfo ();
if (strcmp (cpu_p->cpu_vendorstr, "AuthenticAMD") == 0)
{
if (cpu_p->cpu_family == AMD_ZEN3_FAMILY)
switch (cpu_p->cpu_model)
{
case AMD_ZEN3_RYZEN:
case AMD_ZEN3_RYZEN2:
case AMD_ZEN3_RYZEN3:
case AMD_ZEN3_EPYC_TRENTO:
cpcx_cpuver = CPC_AMD_FAM_19H_ZEN3;
break;
case AMD_ZEN4_RYZEN:
case AMD_ZEN4_EPYC:
cpcx_cpuver = CPC_AMD_FAM_19H_ZEN4;
break;
}
}

#ifdef DISALLOW_PENTIUM_PRO_MMX_7007575
if (cpcx_cpuver == CPC_PENTIUM_PRO_MMX)
{
Expand Down
5 changes: 4 additions & 1 deletion gprofng/src/hwc_amd_zen3.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
Foundation, 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */

#ifndef _HWC_AMD_ZEN3_H
#define _HWC_AMD_ZEN3_H

#define I(nm, event, umask, mtr) INIT_HWC(nm, mtr, (event) | ((umask) << 8), PERF_TYPE_RAW)

static Hwcentry amd_zen3_list[] = {
Expand Down Expand Up @@ -629,4 +632,4 @@ static Hwcentry amd_zen3_list[] = {
};

#undef I

#endif
Loading

0 comments on commit 9af067b

Please sign in to comment.