!330 [sync] PR-327: [Sync] Sync patch from openeuler/gcc

From: @openeuler-sync-bot 
Reviewed-by: @huang-xiaoquan 
Signed-off-by: @huang-xiaoquan
This commit is contained in:
openeuler-ci-bot 2023-09-05 06:21:23 +00:00 committed by Gitee
commit 47180897e5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 160 additions and 1 deletions

View File

@ -0,0 +1,114 @@
From 2f0d0b1298fb9c3266bb102796b027a5570ad833 Mon Sep 17 00:00:00 2001
From: dingguangya <dingguangya1@huawei.com>
Date: Mon, 4 Sep 2023 16:27:38 +0800
Subject: [PATCH 1/2] [AArch64] Rewrite the tsv110 option
Reset the more appropriate options for tsv110.
---
gcc/common/config/aarch64/aarch64-common.cc | 76 +++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index dfda5b837..85ce8133b 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -44,6 +44,8 @@
#undef TARGET_OPTION_INIT_STRUCT
#define TARGET_OPTION_INIT_STRUCT aarch64_option_init_struct
+#define INVALID_IMP ((unsigned) -1)
+
/* Set default optimization options. */
static const struct default_options aarch_option_optimization_table[] =
{
@@ -65,6 +67,77 @@ static const struct default_options aarch_option_optimization_table[] =
{ OPT_LEVELS_NONE, 0, NULL, 0 }
};
+/* CPU vendor id. */
+static unsigned vendor_id = INVALID_IMP;
+
+/* The part number of the CPU. */
+static unsigned part_id = INVALID_IMP;
+
+/* Return the hex integer that is after ':' for the FIELD.
+ Return -1 if there was problem parsing the integer. */
+static unsigned
+parse_cpuinfo (char *field)
+{
+ if (field == NULL)
+ return INVALID_IMP;
+ const char *rest = strchr (field, ':');
+
+ if (rest == NULL)
+ return INVALID_IMP;
+
+ char *after;
+ unsigned fint = strtol (rest + 1, &after, 16);
+ if (after == rest + 1)
+ return INVALID_IMP;
+ return fint;
+}
+
+/* Read CPU vendor_id and part_id. */
+
+static void
+read_cpuinfo ()
+{
+ FILE *fp = fopen ("/proc/cpuinfo", "r");
+ if (fp == NULL)
+ return;
+
+ /* Read 1024-byte data from /proc/cpuinfo. */
+ char cpuinfo[1024];
+ fread(cpuinfo, sizeof(char), sizeof(cpuinfo) - 1, fp);
+
+ char *vendor = strstr(cpuinfo, "CPU implementer");
+ vendor_id = parse_cpuinfo(vendor);
+
+ char *part = strstr(cpuinfo, "CPU part");
+ part_id = parse_cpuinfo(part);
+
+ fclose(fp);
+}
+
+/* Reset the tsv110 option. After checking the platform information,
+ this function can reset the more appropriate options.
+ TODO: Currently, this function is not applicable to the cross
+ compilation scenario. */
+
+static void
+reset_tsv110_option ()
+{
+ /* Read CPU Information. */
+ if (vendor_id == INVALID_IMP)
+ read_cpuinfo ();
+
+ if (vendor_id == 0x48 && part_id == 0xd01)
+ {
+ /* Outline-atomics is enabled by default and
+ aarch64_flag_outline_atomics defaults to 2. Therefore, the current
+ modification affects only the default scenario. When the option
+ moutline-atomics is added, the value of aarch64_flag_outline_atomics is 1,
+ that is, aarch64_flag_outline_atomics is not reset to 0. */
+ if (aarch64_flag_outline_atomics == 2)
+ aarch64_flag_outline_atomics = 0;
+ }
+}
+
/* Implement TARGET_HANDLE_OPTION.
This function handles the target specific options for CPU/target selection.
@@ -83,6 +156,9 @@ aarch64_handle_option (struct gcc_options *opts,
const char *arg = decoded->arg;
int val = decoded->value;
+ /* Reset the tsv110 options. */
+ reset_tsv110_option ();
+
switch (code)
{
case OPT_march_:
--
2.33.0

View File

@ -0,0 +1,37 @@
From 7efae59159577657f22511aa3b2cebe85ca60d9d Mon Sep 17 00:00:00 2001
From: dingguangya <dingguangya1@huawei.com>
Date: Mon, 4 Sep 2023 16:30:58 +0800
Subject: [PATCH 2/2] [GOMP] Enabling moutline-atomics improves libgomp
performance in multi-thread scenarios
Libgomp is used in multi-thread scenarios,
Enabling moutline-atomics improves performance.
---
libgomp/configure.tgt | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
index 2cd7272fc..f924e9f98 100644
--- a/libgomp/configure.tgt
+++ b/libgomp/configure.tgt
@@ -32,6 +32,17 @@ if test $gcc_cv_have_tls = yes ; then
esac
fi
+# Enabling moutline-atomics improves libgomp performance in multi-thread scenarios.
+case "${target_cpu}" in
+ aarch64*)
+ case "${target}" in
+ aarch64*-*-linux*)
+ XCFLAGS="${XCFLAGS} -moutline-atomics"
+ ;;
+ esac
+ ;;
+esac
+
tmake_file=
# Since we require POSIX threads, assume a POSIX system by default.
config_path="posix"
--
2.33.0

View File

@ -2,7 +2,7 @@
%global gcc_major 12
# Note, gcc_release must be integer, if you want to add suffixes to
# %%{release}, append them after %%{gcc_release} on Release: line.
%global gcc_release 9
%global gcc_release 10
%global _unpackaged_files_terminate_build 0
%global _performance_build 1
@ -159,6 +159,8 @@ Patch21: 0021-StructReorderFields-Structure-reorder-fields.patch
Patch22: 0022-DFE-Add-Dead-Field-Elimination-in-Struct-Reorg.patch
Patch23: 0023-PGO-kernel-Add-fkernel-pgo-option-to-support-PGO-ker.patch
Patch24: 0024-Struct-Reorg-Refactoring-and-merge-reorder-fields-in.patch
Patch25: 0025-AArch64-Rewrite-the-tsv110-option.patch
Patch26: 0026-GOMP-Enabling-moutline-atomics-improves-libgomp-perf.patch
# On ARM EABI systems, we do want -gnueabi to be part of the
# target triple.
@ -649,6 +651,8 @@ not stable, so plugins must be rebuilt any time GCC is updated.
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
echo '%{_vendor} %{version}-%{release}' > gcc/DEV-PHASE
@ -2752,6 +2756,10 @@ end
%doc rpm.doc/changelogs/libcc1/ChangeLog*
%changelog
* Mon Sep 04 2023 dingguangya <dingguangya1@huawei.com> 12.3.1-10
- Type: Sync
- DESC: Sync patch from openeuler/gcc
* Tue Aug 29 2023 huangxiaoquan <huangxiaoquan1@huawei.com> 12.3.1-9
- Type: Sync
- DESC: Sync patch from openeuler/gcc part 2