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