Blame SOURCES/papi-rhbz2037427.patch

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