Home | History | Annotate | Line # | Download | only in i386
gcc-auto-profile revision 1.1.1.1.4.2
      1  1.1.1.1.4.2  martin #!/bin/sh
      2  1.1.1.1.4.2  martin # profile workload for gcc profile feedback (autofdo) using Linux perf
      3  1.1.1.1.4.2  martin # auto generated. to regenerate for new CPUs run
      4  1.1.1.1.4.2  martin # contrib/gen_autofdo_event.py --shell --all in gcc source
      5  1.1.1.1.4.2  martin 
      6  1.1.1.1.4.2  martin # usages:
      7  1.1.1.1.4.2  martin # gcc-auto-profile program             (profile program and children)
      8  1.1.1.1.4.2  martin # gcc-auto-profile -a sleep X          (profile all for X secs, may need root)
      9  1.1.1.1.4.2  martin # gcc-auto-profile -p PID sleep X      (profile PID)
     10  1.1.1.1.4.2  martin # gcc-auto-profile --kernel -a sleep X (profile kernel)
     11  1.1.1.1.4.2  martin # gcc-auto-profile --all -a sleep X    (profile kernel and user space)
     12  1.1.1.1.4.2  martin 
     13  1.1.1.1.4.2  martin # identify branches taken event for CPU
     14  1.1.1.1.4.2  martin #
     15  1.1.1.1.4.2  martin 
     16  1.1.1.1.4.2  martin FLAGS=u
     17  1.1.1.1.4.2  martin 
     18  1.1.1.1.4.2  martin if [ "$1" = "--kernel" ] ; then
     19  1.1.1.1.4.2  martin   FLAGS=k
     20  1.1.1.1.4.2  martin   shift
     21  1.1.1.1.4.2  martin fi
     22  1.1.1.1.4.2  martin if [ "$1" = "--all" ] ; then
     23  1.1.1.1.4.2  martin   FLAGS=uk
     24  1.1.1.1.4.2  martin   shift
     25  1.1.1.1.4.2  martin fi
     26  1.1.1.1.4.2  martin 
     27  1.1.1.1.4.2  martin if ! grep -q Intel /proc/cpuinfo ; then
     28  1.1.1.1.4.2  martin   echo >&2 "Only Intel CPUs supported"
     29  1.1.1.1.4.2  martin   exit 1
     30  1.1.1.1.4.2  martin fi
     31  1.1.1.1.4.2  martin 
     32  1.1.1.1.4.2  martin if grep -q hypervisor /proc/cpuinfo ; then
     33  1.1.1.1.4.2  martin   echo >&2 "Warning: branch profiling may not be functional in VMs"
     34  1.1.1.1.4.2  martin fi
     35  1.1.1.1.4.2  martin 
     36  1.1.1.1.4.2  martin case `egrep -q "^cpu family\s*: 6" /proc/cpuinfo &&
     37  1.1.1.1.4.2  martin   egrep "^model\s*:" /proc/cpuinfo | head -n1` in
     38  1.1.1.1.4.2  martin model*:\ 55|\
     39  1.1.1.1.4.2  martin model*:\ 77|\
     40  1.1.1.1.4.2  martin model*:\ 76) E="cpu/event=0xC4,umask=0xFE/p$FLAGS" ;;
     41  1.1.1.1.4.2  martin model*:\ 42|\
     42  1.1.1.1.4.2  martin model*:\ 45|\
     43  1.1.1.1.4.2  martin model*:\ 58|\
     44  1.1.1.1.4.2  martin model*:\ 62|\
     45  1.1.1.1.4.2  martin model*:\ 60|\
     46  1.1.1.1.4.2  martin model*:\ 69|\
     47  1.1.1.1.4.2  martin model*:\ 70|\
     48  1.1.1.1.4.2  martin model*:\ 63|\
     49  1.1.1.1.4.2  martin model*:\ 61|\
     50  1.1.1.1.4.2  martin model*:\ 71|\
     51  1.1.1.1.4.2  martin model*:\ 86|\
     52  1.1.1.1.4.2  martin model*:\ 78|\
     53  1.1.1.1.4.2  martin model*:\ 94) E="cpu/event=0xC4,umask=0x20/p$FLAGS" ;;
     54  1.1.1.1.4.2  martin model*:\ 46|\
     55  1.1.1.1.4.2  martin model*:\ 30|\
     56  1.1.1.1.4.2  martin model*:\ 31|\
     57  1.1.1.1.4.2  martin model*:\ 26|\
     58  1.1.1.1.4.2  martin model*:\ 47|\
     59  1.1.1.1.4.2  martin model*:\ 37|\
     60  1.1.1.1.4.2  martin model*:\ 44) E="cpu/event=0x88,umask=0x40/p$FLAGS" ;;
     61  1.1.1.1.4.2  martin model*:\ 28|\
     62  1.1.1.1.4.2  martin model*:\ 38|\
     63  1.1.1.1.4.2  martin model*:\ 39|\
     64  1.1.1.1.4.2  martin model*:\ 54|\
     65  1.1.1.1.4.2  martin model*:\ 53) E="cpu/event=0x88,umask=0x41/p$FLAGS" ;;
     66  1.1.1.1.4.2  martin *)
     67  1.1.1.1.4.2  martin echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to update script."
     68  1.1.1.1.4.2  martin 	exit 1 ;;
     69  1.1.1.1.4.2  martin esac
     70  1.1.1.1.4.2  martin exec perf record -e $E -b "$@"
     71