From patchwork Tue May 30 11:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 70310 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BE4B63858C31 for ; Tue, 30 May 2023 11:09:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE4B63858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685444943; bh=BgjtsdlRVP0LVrLujB1lhINzX+I5JJ19M34EFFtFPeQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=oS/k+OLAcwtzrtjOYRvoPy1Qkf8hgc2RcFXGU/HJLZl9zywxHRZNsh6xXW4MhUYhv OaGbzrS2ZZd5WzqMGCPdUrCOTm6lGx7zf8ZUlEGDxHaNCVN4DXFulhR+AI93WGDeJb hjughXpGcrVJggPXUdZlriQ8s95U2Bf4d01Rb9Rw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by sourceware.org (Postfix) with ESMTPS id 671C03858D28 for ; Tue, 30 May 2023 11:08:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 671C03858D28 X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="334505307" X-IronPort-AV: E=Sophos;i="6.00,204,1681196400"; d="scan'208";a="334505307" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 04:08:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="796243614" X-IronPort-AV: E=Sophos;i="6.00,204,1681196400"; d="scan'208";a="796243614" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 04:08:31 -0700 To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH] Update perf auto profile script Date: Tue, 30 May 2023 04:08:18 -0700 Message-Id: <20230530110818.142552-1-ak@linux.intel.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andi Kleen via Gcc-patches From: Andi Kleen Reply-To: Andi Kleen Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "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 ;;