From patchwork Tue Oct 10 04:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhang X-Patchwork-Id: 150480 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2281541vqo; Mon, 9 Oct 2023 22:02:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIBMa4fTg2i/S3+u1TYX9gicqB5dOD1RIMg9e37pgwE/Wj6qOLPq4i0mwqQ2Ge/OdXwqji X-Received: by 2002:aa7:d599:0:b0:52f:3051:f7dd with SMTP id r25-20020aa7d599000000b0052f3051f7ddmr14787104edq.35.1696914149906; Mon, 09 Oct 2023 22:02:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696914149; cv=none; d=google.com; s=arc-20160816; b=e7t5bMXjvrlMXwVliKPfvF1WMizxnz2sVVzKo9D+gdlHPGfkrmTmfk4ofui7bWDJex kX7XNfNG32Au8VmSbvS0myS7ixh5+gNWVjcT2H8eTJyLHgWbFdGgqoUIjQleDK5sL8j/ +3dW+L3vDOp7E0NAMxMXcGEsuiGBcpU8X6LaiRqK5PO7h6Gv6PZAPR4Ofu27FSmCXO7T ndmSrHVcb2diLYQGNYG35DlnGKs0nE4bR+3tyVmUHVG8dWNdKpE7CsFyd6Fv86651CKB t5Q6MZR7+zPQS8SquZrOatPeG1DlE6fWqvVXOeDR8qKi4jKlk6vGua78n9jojlfyyxBY UWdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=c0Iwp/SDreobl4du17GkuvNDynlBe+9K3eLKLHMHOLQ=; fh=tRraQiMPPSfUMuclBPtL0PLljw3MIu49oXKhKrffu4o=; b=NSJSx7UpAdhiVJN/7YPeFiegU/UW1167LjGhNmIP+SIbJOVraFkYrzZGpglp3+Ex8c jGp/mCOYQHyk1ZhmkwfFSV6Y3YAGNTensoLsoehQkmFnG5GPgsm9Ejg/Gyo5p7HxSuac HFNNyTmVbFIdV2Xd4gH/CTosamz8FnHPwX6/dTMVNdWrmmNIP08/nXszMSWEJrzlWlPt AAie6Y4rMW+cMj8AHSBu5CEWnKh5GL6Ki6JYJlBSUwzFnjDH1xw94r/evbr5Goy3Bjrg k5V6p/eBufuLRhc+5H7EaYkrq98C0FSJ/Km0Dupnju6tYO/TbnlfqC8f9aOqfUgx7E66 WuYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="nu/pOQDa"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q20-20020aa7da94000000b0053849d19e78si5291622eds.636.2023.10.09.22.02.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 22:02:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="nu/pOQDa"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A857385841E for ; Tue, 10 Oct 2023 05:02:25 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by sourceware.org (Postfix) with ESMTPS id 4FE3E3858D28 for ; Tue, 10 Oct 2023 05:01:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4FE3E3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696914118; x=1728450118; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5J6EavZFVTUAbo2zsKCbRKw38EohhGYSUsH6l4Xrmt8=; b=nu/pOQDaLOJR5GRDX0N1vpr2XE3pYMuV0OLfPg7RG3M+MYHD1EYoBGXr NctFdEO8ooHhpyRFwra19uyWTAHFS11t3aAy8jbql4X/L5rCLNIyHHn6L M1jS/k92XK2kFeJJ9LRJWMZH6cyOdkeCk+KPMbplVVQEPQuRyQFj/LyCN u2+7zF7+8EjMGKgB/sfHSesn4TAuTwwmdC3HnkXCB4uOBJczF/lYdQhMq OMSBLV/L6wa9eogyJlv4FmkER7xxBS5ZMZxT0W8SGWfZbEQeEcK9Gfmlt eG6V44addJD5nNlD07Sk4A9QzzzqUdsEIZN2is4BLeWrdAnNheHcMW9lF A==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="387147861" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="387147861" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 22:01:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="729944374" X-IronPort-AV: E=Sophos;i="6.03,211,1694761200"; d="scan'208";a="729944374" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga006.jf.intel.com with ESMTP; 09 Oct 2023 22:01:54 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id 0A97C100570F; Tue, 10 Oct 2023 13:01:53 +0800 (CST) From: Jun Zhang To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com, jakub@redhat.com, hongtao.liu@intel.com, jun.zhang@intel.com Subject: [PATCH] x86: set spincount 1 for x86 hybrid platform [PR109812] Date: Tue, 10 Oct 2023 12:59:52 +0800 Message-Id: <20231010045952.572596-1-jun.zhang@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779343451796255108 X-GMAIL-MSGID: 1779343451796255108 From: "Zhang, Jun" By test, we find in hybrid platform spincount 1 is better. Use '-march=native -Ofast -funroll-loops -flto', results as follows: spec2017 speed RPL ADL 657.xz_s 0.00% 0.50% 603.bwaves_s 10.90% 26.20% 607.cactuBSSN_s 5.50% 72.50% 619.lbm_s 2.40% 2.50% 621.wrf_s -7.70% 2.40% 627.cam4_s 0.50% 0.70% 628.pop2_s 48.20% 153.00% 638.imagick_s -0.10% 0.20% 644.nab_s 2.30% 1.40% 649.fotonik3d_s 8.00% 13.80% 654.roms_s 1.20% 1.10% Geomean-int 0.00% 0.50% Geomean-fp 6.30% 21.10% Geomean-all 5.70% 19.10% omp2012 RPL ADL 350.md -1.81% -1.75% 351.bwaves 7.72% 12.50% 352.nab 14.63% 19.71% 357.bt331 -0.20% 1.77% 358.botsalgn 0.00% 0.00% 359.botsspar 0.00% 0.65% 360.ilbdc 0.00% 0.25% 362.fma3d 2.66% -0.51% 363.swim 10.44% 0.00% 367.imagick 0.00% 0.12% 370.mgrid331 2.49% 25.56% 371.applu331 1.06% 4.22% 372.smithwa 0.74% 3.34% 376.kdtree 10.67% 16.03% GEOMEAN 3.34% 5.53% include/ChangeLog: * omphook.h: define RUNOMPHOOK macro. libgomp/ChangeLog: * env.c (initialize_env): add RUNOMPHOOK macro. * config/linux/x86/omphook.h: define RUNOMPHOOK macro. --- include/omphook.h | 1 + libgomp/config/linux/x86/omphook.h | 19 +++++++++++++++++++ libgomp/env.c | 3 +++ 3 files changed, 23 insertions(+) create mode 100644 include/omphook.h create mode 100644 libgomp/config/linux/x86/omphook.h diff --git a/include/omphook.h b/include/omphook.h new file mode 100644 index 00000000000..2ebe3ad57e6 --- /dev/null +++ b/include/omphook.h @@ -0,0 +1 @@ +#define RUNOMPHOOK() diff --git a/libgomp/config/linux/x86/omphook.h b/libgomp/config/linux/x86/omphook.h new file mode 100644 index 00000000000..aefb311cc07 --- /dev/null +++ b/libgomp/config/linux/x86/omphook.h @@ -0,0 +1,19 @@ +#ifdef __x86_64__ +#include "cpuid.h" + +/* only for x86 hybrid platform */ +#define RUNOMPHOOK() \ + do \ + { \ + unsigned int eax, ebx, ecx, edx; \ + if ((getenv ("GOMP_SPINCOUNT") == NULL) && (wait_policy < 0) \ + && __get_cpuid_count (7, 0, &eax, &ebx, &ecx, &edx) \ + && ((edx >> 15) & 1)) \ + gomp_spin_count_var = 1LL; \ + if (gomp_throttled_spin_count_var > gomp_spin_count_var) \ + gomp_throttled_spin_count_var = gomp_spin_count_var; \ + } \ + while (0) +#else +# include "../../../../include/omphook.h" +#endif diff --git a/libgomp/env.c b/libgomp/env.c index a21adb3fd4b..1f13a148694 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -61,6 +61,7 @@ #include "secure_getenv.h" #include "environ.h" +#include "omphook.h" /* Default values of ICVs according to the OpenMP standard, except for default-device-var. */ @@ -2496,5 +2497,7 @@ initialize_env (void) goacc_runtime_initialize (); goacc_profiling_initialize (); + + RUNOMPHOOK (); } #endif /* LIBGOMP_OFFLOADED_ONLY */