From patchwork Wed Oct 11 11:53:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 824367 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463926-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PI/OJK6z"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yBsnz4kPdz9sNc for ; Wed, 11 Oct 2017 22:53:58 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=UZu1LgAM3nfc Hulrb1nw5HqGQbHv1qpXijKKta22+6iRrVSJJWp0rRPpy8XWWx+4twijIY4/5eW/ phIh9p+Jy/FCAMZJYZBCAI3p2hpHB3sIyfQo/L6mAzLlcjxOSgbZukk6RjAKSZe2 ZoQKlr/+qut+lpmXzXZO4EQUo5lg558= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=D2FeTQGed8krwrw1e0 5vyNh0AnU=; b=PI/OJK6zZzmQzSDKOdHW+D/3ahInxdPzSYoY78y0SQOvs5B83f pxFVttuw/uMgpavPfSwcz8qJ22lqLcfD5n8T2Hj7ZmWd/3nagpgDwdbEVEoTas8b 1LY5SDGKgPGjonpKrra4mosDyAqwXOEpVJAcM7zE/IAeO10c3aOsqhA88= Received: (qmail 55710 invoked by alias); 11 Oct 2017 11:53:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 55692 invoked by uid 89); 11 Oct 2017 11:53:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=measurements, Hx-languages-length:4045, balancing, robin X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 11:53:48 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9BBrapT057613 for ; Wed, 11 Oct 2017 07:53:42 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dhh9wej4s-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 11 Oct 2017 07:53:42 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 11 Oct 2017 12:53:40 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 11 Oct 2017 12:53:38 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9BBrcno23330850; Wed, 11 Oct 2017 11:53:38 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D019442045; Wed, 11 Oct 2017 12:49:20 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0D1942041; Wed, 11 Oct 2017 12:49:20 +0100 (BST) Received: from oc6142347168.ibm.com (unknown [9.152.212.41]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 11 Oct 2017 12:49:20 +0100 (BST) From: Robin Dapp To: gcc-patches@gcc.gnu.org Cc: krebbel@linux.vnet.ibm.com Subject: [PATCH 1/2] S/390: Handle long-running instructions Date: Wed, 11 Oct 2017 13:53:37 +0200 X-TM-AS-GCONF: 00 x-cbid: 17101111-0020-0000-0000-000003BFBBA7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101111-0021-0000-0000-00004252F514 Message-Id: <20171011115338.4072-1-rdapp@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-11_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710110165 This patch introduces balancing of long-running instructions that may clog the pipeline. gcc/ChangeLog: 2017-10-11 Robin Dapp * config/s390/s390.c (NUM_SIDES): New constant. (LONGRUNNING_THRESHOLD): New constant. (LATENCY_FACTOR): New constant. (s390_sched_score): Lower score for long-running instructions on same side. (s390_sched_variable_issue): Bookkeeping for long-running instructions. --- gcc/config/s390/s390.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 36bc67d..2430933 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -355,6 +355,18 @@ static rtx_insn *last_scheduled_insn; #define MAX_SCHED_UNITS 3 static int last_scheduled_unit_distance[MAX_SCHED_UNITS]; +#define NUM_SIDES 2 +static int current_side = 1; +#define LONGRUNNING_THRESHOLD 5 + +/* Estimate of number of cycles a long-running insn occupies an + execution unit. */ +static unsigned fxu_longrunning[NUM_SIDES]; +static unsigned vfu_longrunning[NUM_SIDES]; + +/* Factor to scale latencies by, determined by measurements. */ +#define LATENCY_FACTOR 4 + /* The maximum score added for an instruction whose unit hasn't been in use for MAX_SCHED_MIX_DISTANCE steps. Increase this value to give instruction mix scheduling more priority over instruction @@ -14483,7 +14495,24 @@ s390_sched_score (rtx_insn *insn) if (m & unit_mask) score += (last_scheduled_unit_distance[i] * MAX_SCHED_MIX_SCORE / MAX_SCHED_MIX_DISTANCE); + + unsigned latency = insn_default_latency (insn); + + int other_side = 1 - current_side; + + /* Try to delay long-running insns when side is busy. */ + if (latency > LONGRUNNING_THRESHOLD) + { + if (get_attr_z13_unit_fxu (insn) && fxu_longrunning[current_side] + && fxu_longrunning[other_side] <= fxu_longrunning[current_side]) + score = MAX (0, score - 10); + + if (get_attr_z13_unit_vfu (insn) && vfu_longrunning[current_side] + && vfu_longrunning[other_side] <= vfu_longrunning[current_side]) + score = MAX (0, score - 10); + } } + return score; } @@ -14602,6 +14631,8 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more) { last_scheduled_insn = insn; + bool starts_group = false; + if (s390_tune >= PROCESSOR_2827_ZEC12 && reload_completed && recog_memoized (insn) >= 0) @@ -14609,6 +14640,11 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more) unsigned int mask = s390_get_sched_attrmask (insn); if ((mask & S390_SCHED_ATTR_MASK_CRACKED) != 0 + || (mask & S390_SCHED_ATTR_MASK_EXPANDED) != 0 + || (mask & S390_SCHED_ATTR_MASK_GROUPALONE) != 0) + starts_group = true; + + if ((mask & S390_SCHED_ATTR_MASK_CRACKED) != 0 || (mask & S390_SCHED_ATTR_MASK_EXPANDED) != 0) s390_sched_state = S390_SCHED_STATE_CRACKED; else if ((mask & S390_SCHED_ATTR_MASK_ENDGROUP) != 0 @@ -14623,8 +14659,13 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more) case 1: case 2: case S390_SCHED_STATE_NORMAL: + if (s390_sched_state == 0) + starts_group = true; if (s390_sched_state == S390_SCHED_STATE_NORMAL) - s390_sched_state = 1; + { + starts_group = true; + s390_sched_state = 1; + } else s390_sched_state++; @@ -14650,6 +14691,27 @@ s390_sched_variable_issue (FILE *file, int verbose, rtx_insn *insn, int more) last_scheduled_unit_distance[i]++; } + /* If this insn started a new group, the side flipped. */ + if (starts_group) + current_side = current_side ? 0 : 1; + + for (int i = 0; i < 2; i++) + { + if (fxu_longrunning[i] >= 1) + fxu_longrunning[i] -= 1; + if (vfu_longrunning[i] >= 1) + vfu_longrunning[i] -= 1; + } + + unsigned latency = insn_default_latency (insn); + if (latency > LONGRUNNING_THRESHOLD) + { + if (get_attr_z13_unit_fxu (insn)) + fxu_longrunning[current_side] = latency * LATENCY_FACTOR; + else + vfu_longrunning[current_side] = latency * LATENCY_FACTOR; + } + if (verbose > 5) { unsigned int sched_mask;