aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2016-06-23 14:33:53 +0000
committerAndi Kleen <ak@gcc.gnu.org>2016-06-23 14:33:53 +0000
commit7b72d14a9fc6f99caf54ed7b2a5b567d97bd3bb3 (patch)
tree216126c09cb0d4e822fbfb1aac9111a1067ecc67 /gcc
parent60fa7862a0a1ad80f587cb29bcc8613a78303f90 (diff)
downloadgcc-7b72d14a9fc6f99caf54ed7b2a5b567d97bd3bb3.zip
gcc-7b72d14a9fc6f99caf54ed7b2a5b567d97bd3bb3.tar.gz
gcc-7b72d14a9fc6f99caf54ed7b2a5b567d97bd3bb3.tar.bz2
Add gcc-auto-profile script
Using autofdo is currently something difficult. It requires using the model specific branches taken event, which differs on different CPUs. The example shown in the manual requires a special patched version of perf that is non standard, and also will likely not work everywhere. This patch adds a new gcc-auto-profile script that figures out the correct event and runs perf. This is needed to actually make use of autofdo in a generic way in the build system and in the test suite. Since maintaining the script would be somewhat tedious (needs changes every time a new CPU comes out) I auto generated it from the online Intel event database. The script to do that is in contrib and can be rerun. Right now there is no test if perf works in configure. This would vary depending on the build and target system, and since it currently doesn't work in virtualization and needs uptodate kernel it may often fail in common distribution build setups. So far the script is not installed. gcc/: 2016-06-23 Andi Kleen <ak@linux.intel.com> * config/i386/gcc-auto-profile: New file. contrib/: 2016-06-23 Andi Kleen <ak@linux.intel.com> * gen_autofdo_event.py: New file to regenerate gcc-auto-profile. From-SVN: r237731
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rwxr-xr-xgcc/config/i386/gcc-auto-profile70
2 files changed, 74 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 850a3ca..84df8a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2016-06-23 Andi Kleen <ak@linux.intel.com>
+
+ * config/i386/gcc-auto-profile: New file.
+
2016-06-23 Martin Liska <mliska@suse.cz>
PR middle-end/71619
diff --git a/gcc/config/i386/gcc-auto-profile b/gcc/config/i386/gcc-auto-profile
new file mode 100755
index 0000000..5da5c63
--- /dev/null
+++ b/gcc/config/i386/gcc-auto-profile
@@ -0,0 +1,70 @@
+#!/bin/sh
+# profile workload for gcc profile feedback (autofdo) using Linux perf
+# auto generated. to regenerate for new CPUs run
+# contrib/gen_autofdo_event.py --shell --all in gcc source
+
+# usages:
+# gcc-auto-profile program (profile program and children)
+# gcc-auto-profile -a sleep X (profile all for X secs, may need root)
+# gcc-auto-profile -p PID sleep X (profile PID)
+# gcc-auto-profile --kernel -a sleep X (profile kernel)
+# gcc-auto-profile --all -a sleep X (profile kernel and user space)
+
+# identify branches taken event for CPU
+#
+
+FLAGS=u
+
+if [ "$1" = "--kernel" ] ; then
+ FLAGS=k
+ shift
+fi
+if [ "$1" = "--all" ] ; then
+ FLAGS=uk
+ shift
+fi
+
+if ! grep -q Intel /proc/cpuinfo ; then
+ echo >&2 "Only Intel CPUs supported"
+ exit 1
+fi
+
+if grep -q hypervisor /proc/cpuinfo ; then
+ echo >&2 "Warning: branch profiling may not be functional in VMs"
+fi
+
+case `egrep -q "^cpu family\s*: 6" /proc/cpuinfo &&
+ egrep "^model\s*:" /proc/cpuinfo | head -n1` in
+model*:\ 55|\
+model*:\ 77|\
+model*:\ 76) E="cpu/event=0xC4,umask=0xFE/p$FLAGS" ;;
+model*:\ 42|\
+model*:\ 45|\
+model*:\ 58|\
+model*:\ 62|\
+model*:\ 60|\
+model*:\ 69|\
+model*:\ 70|\
+model*:\ 63|\
+model*:\ 61|\
+model*:\ 71|\
+model*:\ 86|\
+model*:\ 78|\
+model*:\ 94) E="cpu/event=0xC4,umask=0x20/p$FLAGS" ;;
+model*:\ 46|\
+model*:\ 30|\
+model*:\ 31|\
+model*:\ 26|\
+model*:\ 47|\
+model*:\ 37|\
+model*:\ 44) E="cpu/event=0x88,umask=0x40/p$FLAGS" ;;
+model*:\ 28|\
+model*:\ 38|\
+model*:\ 39|\
+model*:\ 54|\
+model*:\ 53) E="cpu/event=0x88,umask=0x41/p$FLAGS" ;;
+*)
+echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to update script."
+ exit 1 ;;
+esac
+exec perf record -e $E -b "$@"