From patchwork Fri Jul 10 22:58:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Sawdey X-Patchwork-Id: 1327153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ZDuA28bV; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B3T4l3nFwz9sRR for ; Sat, 11 Jul 2020 08:59:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 517FD385701B; Fri, 10 Jul 2020 22:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 517FD385701B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594421955; bh=UbKyTTkPVORNPTmmLMvPB3ie1B8v0H8CYyRUSBywfMg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZDuA28bVYAv43avVjjJGKkO2U8P0jA1A/6Z/1i7+kt0bse3zT3NILuAIlPk1kF+DM e8WmM8Zbv3s0DNr4OIMLfLkzn/v4nqmaHwolnoDmmY4Rn6nQBa7EeZSMpZYyyrafAI swnKYY2EJVJwAzp0oBsVcfMB7kczeXvKYgpayO8c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id BB8C63857011 for ; Fri, 10 Jul 2020 22:59:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BB8C63857011 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06AMUpW5121131; Fri, 10 Jul 2020 18:59:11 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0b-001b2d01.pphosted.com with ESMTP id 326bp12jvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Jul 2020 18:59:11 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 06AMsnI3030717; Fri, 10 Jul 2020 22:59:10 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma05wdc.us.ibm.com with ESMTP id 326bcayyg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Jul 2020 22:59:10 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 06AMx6D530278074 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 10 Jul 2020 22:59:06 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 564EB78060; Fri, 10 Jul 2020 22:59:09 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 302B37805E; Fri, 10 Jul 2020 22:59:09 +0000 (GMT) Received: from marlin.aus.stglabs.ibm.com (unknown [9.40.194.84]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS; Fri, 10 Jul 2020 22:59:09 +0000 (GMT) Received: from marlin.aus.stglabs.ibm.com (localhost [127.0.0.1]) by marlin.aus.stglabs.ibm.com (8.15.2/8.15.2/Debian-10) with ESMTP id 06AMx3JJ149665; Fri, 10 Jul 2020 17:59:03 -0500 Received: (from sawdey@localhost) by marlin.aus.stglabs.ibm.com (8.15.2/8.15.2/Submit) id 06AMx0Fb145327; Fri, 10 Jul 2020 17:59:00 -0500 To: gcc-patches@gcc.gnu.org Subject: [PATCH] rs6000: add effective-target test ppc_mma_hw Date: Fri, 10 Jul 2020 17:58:59 -0500 Message-Id: <20200710225859.141589-1-acsawdey@linux.ibm.com> X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-07-10_14:2020-07-10, 2020-07-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 suspectscore=1 spamscore=0 clxscore=1015 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007100148 X-Spam-Status: No, score=-20.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, SUBJ_OBFU_PUNCT_FEW, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Aaron Sawdey via Gcc-patches From: Aaron Sawdey Reply-To: Aaron Sawdey Cc: wschmidt@linux.ibm.com, segher@kernel.crashing.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Add a test for dejagnu to determine if execution of MMA instructions is supported in the test environment. Add an execution test to make sure that __builtin_cpu_supports("mma") is true if we can execute MMA instructions. OK for trunk and backport to 10? Thanks! Aaron gcc/testsuite/ * lib/target-supports.exp (check_ppc_mma_hw_available): New function. (is-effective-target): Add ppc_mma_hw. (is-effective-target-keyword): Add ppc_mma_hw. * gcc.target/powerpc/mma-supported.c: New file. * gcc.target/powerpc/mma-single-test.c: Require ppc_mma_hw. * gcc.target/powerpc/mma-double-test.c: Require ppc_mma_hw. --- .../gcc.target/powerpc/mma-double-test.c | 1 + .../gcc.target/powerpc/mma-single-test.c | 1 + .../gcc.target/powerpc/mma-supported.c | 24 +++++++++++++++++ gcc/testsuite/lib/target-supports.exp | 27 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/mma-supported.c diff --git a/gcc/testsuite/gcc.target/powerpc/mma-double-test.c b/gcc/testsuite/gcc.target/powerpc/mma-double-test.c index 9ba0010978f..ac84ae30004 100755 --- a/gcc/testsuite/gcc.target/powerpc/mma-double-test.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-double-test.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target power10_hw } */ +/* { dg-require-effective-target ppc_mma_hw } */ /* { dg-options "-mdejagnu-cpu=power10 -O2" } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/mma-single-test.c b/gcc/testsuite/gcc.target/powerpc/mma-single-test.c index aa71fa7f0af..15369a64025 100755 --- a/gcc/testsuite/gcc.target/powerpc/mma-single-test.c +++ b/gcc/testsuite/gcc.target/powerpc/mma-single-test.c @@ -1,5 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target power10_hw } */ +/* { dg-require-effective-target ppc_mma_hw } */ /* { dg-options "-mdejagnu-cpu=power10 -O2" } */ #include diff --git a/gcc/testsuite/gcc.target/powerpc/mma-supported.c b/gcc/testsuite/gcc.target/powerpc/mma-supported.c new file mode 100644 index 00000000000..64943e362a8 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/mma-supported.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-require-effective-target ppc_mma_hw } */ +/* { dg-options "-mdejagnu-cpu=power10 -O2" } */ + +/* This test will only run when the ppc_mma_hw test passes. If that + test passes, then we expect to see that mma feature is supported. + If this is not the case, then the test environment has problems. */ + +#include +#include + +int +main (int argc, char *argv[]) +{ + int ret = 0; +#ifdef __BUILTIN_CPU_SUPPORTS__ + if ( !__builtin_cpu_supports ("mma")) + { + printf ("Error: __builtin_cpu_supports says mma not supported, but ppc_mma_hw test passed.\n"); + ret++; + } +#endif + return ret; +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index aeb0351073d..04f6db53eca 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2234,6 +2234,31 @@ proc check_power10_hw_available { } { }] } +# Return 1 if the target supports executing MMA instructions, 0 otherwise. +# Cache the result. It is assumed that if a simulator does not support the +# MMA instructions, that it will generate an error and this test will fail. + +proc check_ppc_mma_hw_available { } { + return [check_cached_effective_target ppc_mma_hw_available { + check_runtime_nocache ppc_mma_hw_available { + #include + typedef double v4sf_t __attribute__ ((vector_size (16))); + + int main() + { + __vector_quad acc0; + v4sf_t result[4]; + result[0][0] = 1.0; + __builtin_mma_xxsetaccz (&acc0); + __builtin_mma_disassemble_acc (result, &acc0); + if ( result[0][0] != 0.0 ) + return 1; + return 0; + } + } "-mcpu=power10" + }] +} + # Return 1 if the target supports executing __float128 on PowerPC via software # emulation, 0 otherwise. Cache the result. @@ -7836,6 +7861,7 @@ proc is-effective-target { arg } { "gc_sections" { set selected [check_gc_sections_available] } "cxa_atexit" { set selected [check_cxa_atexit_available] } "power10_hw" { set selected [check_power10_hw_available] } + "ppc_mma_hw" { set selected [check_ppc_mma_hw_available] } default { error "unknown effective target keyword `$arg'" } } } @@ -7865,6 +7891,7 @@ proc is-effective-target-keyword { arg } { "named_sections" { return 1 } "gc_sections" { return 1 } "cxa_atexit" { return 1 } + "ppc_mma_hw" { return 1 } default { return 0 } } }