f7ba02
commit 2098e8656156084104ab8d1981b53c50d22b8f62
f7ba02
Author: Masahiko, Yamada <yamada.masahiko@fujitsu.com>
f7ba02
Date:   Fri Mar 4 13:34:20 2022 +0900
f7ba02
f7ba02
    PAPI_get_hardware_info: improve PAPI_hw_info_t for ARM processors
f7ba02
    
f7ba02
    Currently, it is not possible to determine which company the ARM processor
f7ba02
    was designed by from the PAPI_hw_info_t available in PAPI_get_hardware_info().
f7ba02
    On ARM processors, the PAPI_hw_info_t obtained with PAPI_get_hardware_info()
f7ba02
    does not contain information indicating which company was designed.
f7ba02
    For ARM processors, improve the vendor and vendor_string entries
f7ba02
    in PAPI_hw_info_t, which can be retrieved with PAPI_get_hardware_info(),
f7ba02
    to include information indicating which company was designed.
f7ba02
    
f7ba02
    Signed-off-by: Masahiko, Yamada <yamada.masahiko@fujitsu.com>
f7ba02
f7ba02
diff --git a/src/components/perf_event/pe_libpfm4_events.c b/src/components/perf_event/pe_libpfm4_events.c
f7ba02
index 744851ff0..6dcb5e023 100644
f7ba02
--- a/src/components/perf_event/pe_libpfm4_events.c
f7ba02
+++ b/src/components/perf_event/pe_libpfm4_events.c
f7ba02
@@ -1248,8 +1248,10 @@ _pe_libpfm4_init(papi_vector_t *component, int cidx,
f7ba02
 						    &pinfo,sizeof(pfm_pmu_info_t));
f7ba02
                         found_default++;
f7ba02
 				}
f7ba02
+
f7ba02
+				/* For ARM processors, */
f7ba02
 				if ( (pinfo.type==PFM_PMU_TYPE_CORE) &&
f7ba02
-					( _papi_hwi_system_info.hw_info.vendor == PAPI_VENDOR_ARM)) {
f7ba02
+					( _papi_hwi_system_info.hw_info.vendor >= PAPI_VENDOR_ARM_ARM)) {
f7ba02
 					if (strlen(_papi_hwi_system_info.hw_info.model_string) == 0) {
f7ba02
 						strSize = sizeof(_papi_hwi_system_info.hw_info.model_string);
f7ba02
 						strncpy( _papi_hwi_system_info.hw_info.model_string, pinfo.desc, strSize - 1);
f7ba02
diff --git a/src/components/perf_event/perf_event.c b/src/components/perf_event/perf_event.c
f7ba02
index a50194cf6..6985fc4cb 100644
f7ba02
--- a/src/components/perf_event/perf_event.c
f7ba02
+++ b/src/components/perf_event/perf_event.c
f7ba02
@@ -137,7 +137,8 @@ pe_vendor_fixups(papi_vector_t *vector)
f7ba02
   }
f7ba02
 
f7ba02
 	/* ARM */
f7ba02
-	if ( _papi_hwi_system_info.hw_info.vendor == PAPI_VENDOR_ARM) {
f7ba02
+	/* If implementer is ARM Limited. */
f7ba02
+	if ( _papi_hwi_system_info.hw_info.vendor == PAPI_VENDOR_ARM_ARM) {
f7ba02
 
f7ba02
 		/* Some ARMv7 and earlier could not measure	*/
f7ba02
 		/* KERNEL and USER separately.			*/
f7ba02
diff --git a/src/linux-common.c b/src/linux-common.c
f7ba02
index 99601db86..2527981ad 100644
f7ba02
--- a/src/linux-common.c
f7ba02
+++ b/src/linux-common.c
f7ba02
@@ -112,8 +112,20 @@ decode_vendor_string( char *s, int *vendor )
f7ba02
 		*vendor = PAPI_VENDOR_IBM;
f7ba02
 	else if ( strcasecmp( s, "Cray" ) == 0 )
f7ba02
 		*vendor = PAPI_VENDOR_CRAY;
f7ba02
-	else if ( strcasecmp( s, "ARM" ) == 0 )
f7ba02
-		*vendor = PAPI_VENDOR_ARM;
f7ba02
+	else if ( strcasecmp( s, "ARM_ARM" ) == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_ARM;
f7ba02
+	else if ( strcasecmp( s, "ARM_BROADCOM" ) == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_BROADCOM;
f7ba02
+	else if ( strcasecmp( s, "ARM_CAVIUM" ) == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_CAVIUM;
f7ba02
+	else if ( strcasecmp( s, "ARM_FUJITSU" ) == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_FUJITSU;
f7ba02
+	else if ( strcasecmp( s, "ARM_HISILICON") == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_HISILICON;
f7ba02
+	else if ( strcasecmp( s, "ARM_APM" ) == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_APM;
f7ba02
+	else if ( strcasecmp( s, "ARM_QUALCOMM" ) == 0 )
f7ba02
+		*vendor = PAPI_VENDOR_ARM_QUALCOMM;
f7ba02
 	else if ( strcasecmp( s, "MIPS" ) == 0 )
f7ba02
 		*vendor = PAPI_VENDOR_MIPS;
f7ba02
 	else if ( strcasecmp( s, "SiCortex" ) == 0 )
f7ba02
@@ -409,9 +421,38 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
f7ba02
 				}
f7ba02
 				else {
f7ba02
 					/* "CPU implementer" indicates ARM */
f7ba02
+					/* For ARM processors, hwinfo->vendor >= PAPI_VENDOR_ARM_ARM(0x41). */
f7ba02
+					/* If implementer is ARM Limited., hwinfo->vendor == PAPI_VENDOR_ARM_ARM. */
f7ba02
+					/* If implementer is Cavium Inc., hwinfo->vendor == PAPI_VENDOR_ARM_CAVIUM(0x43). */
f7ba02
 					s = search_cpu_info( f, "CPU implementer");
f7ba02
 					if ( s ) {
f7ba02
-						strcpy( hwinfo->vendor_string, "ARM" );
f7ba02
+						int tmp;
f7ba02
+						sscanf( s, "%x", &tmp );
f7ba02
+						switch( tmp ) {
f7ba02
+						case PAPI_VENDOR_ARM_ARM:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_ARM" );
f7ba02
+							break;
f7ba02
+						case PAPI_VENDOR_ARM_BROADCOM:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_BROADCOM" );
f7ba02
+							break;
f7ba02
+						case PAPI_VENDOR_ARM_CAVIUM:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_CAVIUM" );
f7ba02
+							break;
f7ba02
+						case PAPI_VENDOR_ARM_FUJITSU:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_FUJITSU" );
f7ba02
+							break;
f7ba02
+						case PAPI_VENDOR_ARM_HISILICON:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_HISILICON" );
f7ba02
+							break;
f7ba02
+						case PAPI_VENDOR_ARM_APM:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_APM" );
f7ba02
+							break;
f7ba02
+						case PAPI_VENDOR_ARM_QUALCOMM:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_QUALCOMM" );
f7ba02
+							break;
f7ba02
+						default:
f7ba02
+							strcpy( hwinfo->vendor_string, "ARM_UNKNOWN" );
f7ba02
+						}
f7ba02
 					}
f7ba02
 				}
f7ba02
 			}
f7ba02
@@ -438,7 +479,7 @@ _linux_get_cpu_info( PAPI_hw_info_t *hwinfo, int *cpuinfo_mhz )
f7ba02
 		decode_cpuinfo_power(f,hwinfo);
f7ba02
 	}
f7ba02
 
f7ba02
-	if (hwinfo->vendor==PAPI_VENDOR_ARM) {
f7ba02
+	if (hwinfo->vendor>=PAPI_VENDOR_ARM_ARM) {
f7ba02
 
f7ba02
 		decode_cpuinfo_arm(f,hwinfo);
f7ba02
 	}
f7ba02
diff --git a/src/papi.h b/src/papi.h
f7ba02
index 14b05da1f..b05b368cb 100644
f7ba02
--- a/src/papi.h
f7ba02
+++ b/src/papi.h
f7ba02
@@ -354,6 +354,13 @@ All of the functions in the PerfAPI should use the following set of constants.
f7ba02
 #define PAPI_VENDOR_FREESCALE 6
f7ba02
 #define PAPI_VENDOR_ARM     7
f7ba02
 #define PAPI_VENDOR_MIPS    8
f7ba02
+#define PAPI_VENDOR_ARM_ARM       0x41
f7ba02
+#define PAPI_VENDOR_ARM_BROADCOM  0x42
f7ba02
+#define PAPI_VENDOR_ARM_CAVIUM    0x43
f7ba02
+#define PAPI_VENDOR_ARM_FUJITSU   0x46
f7ba02
+#define PAPI_VENDOR_ARM_HISILICON 0x48
f7ba02
+#define PAPI_VENDOR_ARM_APM       0x50
f7ba02
+#define PAPI_VENDOR_ARM_QUALCOMM  0x51
f7ba02
 /** @} */
f7ba02
 
f7ba02
 /** @internal