Re: [PATCH] contrib/gen_autofdo_event.py: Allow for it to work if there are more than 3 hyphens in Family-model

2020-05-24 Thread Andi Kleen via Gcc-patches
Javad Karabi via Gcc-patches  writes:
>
> diff --git a/contrib/gen_autofdo_event.py b/contrib/gen_autofdo_event.py
> index c97460c61c6..cd77a8686d9 100755
> --- a/contrib/gen_autofdo_event.py
> +++ b/contrib/gen_autofdo_event.py
> @@ -94,7 +94,7 @@ for j in u:
>  n = j.rstrip().split(',')
>  if len(n) >= 4 and (args.all or n[0] == cpu) and n[3] == "core":
>  if args.all:
> -vendor, fam, model = n[0].split("-")
> +vendor, fam, model = n[0].split("-")[:3]

That doesn't fix the problem, we really need to match
the stepping too. You turned a visible failure into a silent one.

-Andi


Re: [PATCH] gcov: Use system IO buffering

2021-04-22 Thread Andi Kleen via Gcc-patches
Martin Liška  writes:

> Hey.
>
> I/O buffering in gcov seems duplicite to what modern C library can provide.
> The patch is a simplification and can provide easier interface for system
> that don't have a filesystem and would like using GCOV.
>
> I'm going to install the patch after 11.1 if there are no objections.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

What happens if someone compiles the C library with gcov?

Being as self contained as possible (only system calls) would seem
safer.

-Andi


[PATCH] Update perf auto profile script

2023-05-30 Thread Andi Kleen via Gcc-patches
- Fix gen_autofdo_event: The download URL for the Intel Perfmon Event
  list has changed, as well as the JSON format.
  Also it now uses pattern matching to match CPUs. Update the script to support 
all of this.
- Regenerate gcc-auto-profile with the latest published Intel model
  numbers, so it works with recent systems.
- So far it's still broken on hybrid systems
---
 contrib/gen_autofdo_event.py | 7 ---
 gcc/config/i386/gcc-auto-profile | 9 -
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/contrib/gen_autofdo_event.py b/contrib/gen_autofdo_event.py
index ac23b83888db..533c706c090b 100755
--- a/contrib/gen_autofdo_event.py
+++ b/contrib/gen_autofdo_event.py
@@ -32,8 +32,9 @@ import json
 import argparse
 import collections
 import os
+import fnmatch
 
-baseurl = "https://download.01.org/perfmon";
+baseurl = "https://raw.githubusercontent.com/intel/perfmon/main";
 
 target_events = ('BR_INST_RETIRED.NEAR_TAKEN',
  'BR_INST_EXEC.TAKEN',
@@ -74,7 +75,7 @@ def get_cpustr():
 def find_event(eventurl, model):
 print("Downloading", eventurl, file = sys.stderr)
 u = urllib.request.urlopen(eventurl)
-events = json.loads(u.read())
+events = json.loads(u.read())["Events"]
 u.close()
 
 found = 0
@@ -102,7 +103,7 @@ found = 0
 cpufound = 0
 for j in u:
 n = j.rstrip().decode().split(',')
-if len(n) >= 4 and (args.all or n[0] == cpu) and n[3] == "core":
+if len(n) >= 4 and (args.all or fnmatch.fnmatch(cpu, n[0])) and n[3] == 
"core":
 components = n[0].split("-")
 model = components[2]
 model = int(model, 16)
diff --git a/gcc/config/i386/gcc-auto-profile b/gcc/config/i386/gcc-auto-profile
index 5ab224b041b9..04f7d35dcc51 100755
--- a/gcc/config/i386/gcc-auto-profile
+++ b/gcc/config/i386/gcc-auto-profile
@@ -43,8 +43,10 @@ model*:\ 47|\
 model*:\ 37|\
 model*:\ 44) E="cpu/event=0x88,umask=0x40/$FLAGS" ;;
 model*:\ 55|\
+model*:\ 74|\
 model*:\ 77|\
 model*:\ 76|\
+model*:\ 90|\
 model*:\ 92|\
 model*:\ 95|\
 model*:\ 87|\
@@ -75,14 +77,19 @@ model*:\ 165|\
 model*:\ 166|\
 model*:\ 85|\
 model*:\ 85) E="cpu/event=0xC4,umask=0x20/p$FLAGS" ;;
+model*:\ 125|\
 model*:\ 126|\
+model*:\ 167|\
 model*:\ 140|\
 model*:\ 141|\
 model*:\ 143|\
+model*:\ 207|\
 model*:\ 106|\
 model*:\ 108) E="cpu/event=0xc4,umask=0x20/p$FLAGS" ;;
 model*:\ 134|\
-model*:\ 150) E="cpu/event=0xc4,umask=0xfe/p$FLAGS" ;;
+model*:\ 150|\
+model*:\ 156|\
+model*:\ 190) E="cpu/event=0xc4,umask=0xfe/p$FLAGS" ;;
 *)
 echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to 
update script."
exit 1 ;;
-- 
2.40.1



Re: [EXTERNAL] [PATCH] contrib: modernize gen_autofdo_event.py

2022-08-05 Thread Andi Kleen via Gcc-patches



On 8/6/2022 1:07 AM, Eugene Rozenfeld wrote:

The changes look good to me. Also adding Andi, the author of the script.



Looks all good to me too.


-Andi




Re: [PATCH] Add divide by zero side effect.

2022-05-27 Thread Andi Kleen via Gcc-patches
Andrew MacLeod via Gcc-patches  writes:
>
> diff --git a/gcc/gimple-range-side-effect.cc b/gcc/gimple-range-side-effect.cc
> index 2c8c77dc569..548e4bea313 100644
> --- a/gcc/gimple-range-side-effect.cc
> +++ b/gcc/gimple-range-side-effect.cc
> @@ -116,6 +116,23 @@ stmt_side_effects::stmt_side_effects (gimple *s)
>  walk_stmt_load_store_ops (s, (void *)this, non_null_loadstore,
> non_null_loadstore);
>  
> +  if (is_a (s))
> +{
> +  switch (gimple_assign_rhs_code (s))
> + {
> + case TRUNC_DIV_EXPR:
> + case CEIL_DIV_EXPR:
> + case FLOOR_DIV_EXPR:
> + case ROUND_DIV_EXPR:
> + case EXACT_DIV_EXPR:
> +   // Divide means operand 2 is not zero after this stmt.
> +   if (gimple_range_ssa_p (gimple_assign_rhs2 (s)))
> + add_nonzero (gimple_assign_rhs2 (s));

Sorry I'm late, but how does this ensure the value is a integer?
I believe for floating point the assumption is not correct because
division by zero doesn't necessarily fault.

-Andi


Re: [PATCH] Add instruction level discriminator support.

2022-06-12 Thread Andi Kleen via Gcc-patches
Eugene Rozenfeld via Gcc-patches  writes:
>  {
> diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
> index d1dc73724d1..5ed6b7b0f94 100644
> --- a/gcc/cp/module.cc
> +++ b/gcc/cp/module.cc
> @@ -15587,6 +15587,8 @@ module_state::write_location (bytes_out &sec, 
> location_t loc)
>   range.m_start = UNKNOWN_LOCATION;
>write_location (sec, range.m_start);
>write_location (sec, range.m_finish);
> +  unsigned discriminator = get_discriminator_from_adhoc_loc (line_table, 
> loc);
> +  sec.u (discriminator);

I hope this has a corresponding reader change, wasn't fully
clear. Should it use some common function?

The patch looks good to me, but I cannot approve.

-Andi


Re: [PATCH] gcov-profile/71672 Fix indirect call inlining with AutoFDO

2021-07-30 Thread Andi Kleen via Gcc-patches



On 7/30/2021 12:08 AM, Eugene Rozenfeld wrote:

This patch has the following changes:



Great thanks. Thanks for working on this. Looks all good to me (except I 
guess the patches could be split up for commit)



-Andi



Re: [PATCH] Update gen_autofdo_event.py and gcc-auto-profile

2021-07-01 Thread Andi Kleen via Gcc-patches



On 7/1/2021 4:40 PM, Eugene Rozenfeld wrote:

gen_autofdo_event.py was stumbling on models with stepping so
I updated the script to handle this case similar to the code in
https://github.com/andikleen/pmu-tools/blob/c6a5f63aede19def8886d6a8b74d7a55c38ca947/event_download.py

The second change was to tolerate cases when the CPU supports PEBS but the
perf command with /p fails. This can happen in, e.g., a virtual machine.
In newer perf :P would work too, but that's not available in older perf, 
so I guess that's ok.


I regenerated gcc-auto-profile using the updated script.



Thanks. Looks good to me.


-Andi