From patchwork Thu Aug 6 08:41:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 504608 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 7A4061402B3 for ; Thu, 6 Aug 2015 18:41:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=aDf7wWPi; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=BbpFccDt0XhvkmW669VXfqKm6DOYkRJNsVZmoFPcLbsT08VpFF cn/4KfS9yCowF/id0jjkA9j+FaKgLiDu3+MOCumFLJ4iA4YHgvEZu5H2QjyInGv/ O3zxdRP44SjNLMXUFgSdN0acSvKOcdr1GYI0c0YFak6aEKWlGrbaLMp00= 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:to:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=3xR0FnG80avgJktTSjvUspQiJjw=; b=aDf7wWPi0oMbCIvB0Wig ejHVW0yO50nNlqaYgkfjTUPizjuYXp2y4pisoOXbn/0mjh64W4Bo5TDSASlNhv+Z VrXrpBkllL7CVkq3/1tHsQkHbF50Ux/wxY6YvEGCQ7V+TCC0h/hDQWvaBoLhy57t h5pytj0VWE8g2Hps7oohWTA= Received: (qmail 86159 invoked by alias); 6 Aug 2015 08:41:22 -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 86146 invoked by uid 89); 6 Aug 2015 08:41:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=BAYES_50, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wi0-f180.google.com Received: from mail-wi0-f180.google.com (HELO mail-wi0-f180.google.com) (209.85.212.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 06 Aug 2015 08:41:21 +0000 Received: by wijp15 with SMTP id p15so13184682wij.0 for ; Thu, 06 Aug 2015 01:41:18 -0700 (PDT) X-Received: by 10.195.11.74 with SMTP id eg10mr1029108wjd.33.1438850478028; Thu, 06 Aug 2015 01:41:18 -0700 (PDT) Received: from [192.168.10.82] (11.52.broadband16.iol.cz. [90.183.52.11]) by smtp.googlemail.com with ESMTPSA id fz16sm2087190wic.3.2015.08.06.01.41.16 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Aug 2015 01:41:17 -0700 (PDT) To: GCC Patches Cc: Cesar Philippidis From: Nathan Sidwell Subject: [gomp4] fix spinlock Message-ID: <55C31DAB.9040307@acm.org> Date: Thu, 6 Aug 2015 10:41:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 I've committed this to fix the spinlock problem Cesar fell over. While there I added more checking on the worker dimension. nathan 2015-08-06 Nathan Sidwell * config/nvptx/nvptx.c (nvptx_expand_lock_unlock): Create label. (nvptx_validate_dims): Check worker dimension is not too big. * config/nvptx/nvptx.mc (nvptx_spinlock): Take label. Index: gcc/config/nvptx/nvptx.c =================================================================== --- gcc/config/nvptx/nvptx.c (revision 226605) +++ gcc/config/nvptx/nvptx.c (working copy) @@ -3318,8 +3318,14 @@ nvptx_expand_lock_unlock (tree exp, bool if (!lock) emit_insn (barrier); if (lock) - pat = gen_nvptx_spinlock (mem, space, - gen_reg_rtx (SImode), gen_reg_rtx (BImode)); + { + rtx_code_label *label = gen_label_rtx (); + + LABEL_NUSES (label)++; + pat = gen_nvptx_spinlock (mem, space, + gen_reg_rtx (SImode), gen_reg_rtx (BImode), + label); + } else pat = gen_nvptx_spinunlock (mem, space); emit_insn (pat); @@ -3531,7 +3537,6 @@ nvptx_validate_dims (tree decl, tree dim { tree adims[GOMP_DIM_MAX]; unsigned ix; - bool changed = false; tree pos = dims; for (ix = 0; ix != GOMP_DIM_MAX; ix++) @@ -3541,6 +3546,7 @@ nvptx_validate_dims (tree decl, tree dim } /* Define vector size for known hardware. */ #define PTX_VECTOR_LENGTH 32 +#define PTX_WORKER_LENGTH 32 /* If the worker size is not 1, the vector size must be 32. If the vector size is not 1, it must be 32. */ if ((adims[GOMP_DIM_WORKER] @@ -3562,6 +3568,17 @@ nvptx_validate_dims (tree decl, tree dim } } + /* Check the num workers is not too large. */ + if (adims[GOMP_DIM_WORKER] + && TREE_INT_CST_LOW (adims[GOMP_DIM_WORKER]) > PTX_WORKER_LENGTH) + { + tree use = build_int_cst (integer_type_node, PTX_WORKER_LENGTH); + warning_at (DECL_SOURCE_LOCATION (decl), 0, + "using num_workers (%E), ignoring %E", + use, adims[GOMP_DIM_WORKER]); + adims[GOMP_DIM_WORKER] = use; + } + /* Set defaults. */ for (ix = 0; ix != GOMP_DIM_MAX; ix++) if (!adims[ix]) Index: gcc/config/nvptx/nvptx.md =================================================================== --- gcc/config/nvptx/nvptx.md (revision 226605) +++ gcc/config/nvptx/nvptx.md (working copy) @@ -1578,9 +1578,10 @@ (match_operand:SI 1 "const_int_operand" "i")] UNSPECV_UNLOCK) (match_operand:SI 2 "register_operand" "=R") - (match_operand:BI 3 "register_operand" "=R")])] + (match_operand:BI 3 "register_operand" "=R") + (label_ref (match_operand 4 "" ""))])] "" - "1:\\t.atom%R1.cas.b32 %2,%0,0,1;setp.ne.u32 %3,%2,0;@%3 bra.uni 1b;") + "%4:\\t.atom%R1.cas.b32 %2,%0,0,1;setp.ne.u32 %3,%2,0;@%3 bra.uni %4;") (define_insn "nvptx_spinunlock" [(unspec_volatile [(match_operand:SI 0 "memory_operand" "m")