From patchwork Thu Nov 8 19:44:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 995160 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-489453-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Z5sx7Ugm"; 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 42rYdV2qCmz9sDC for ; Fri, 9 Nov 2018 06:44:28 +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:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=T7TWqo4rUwftzfH5tlpu0FTWYPRViqP5ZxWA7dPSJei oetRA92xU1PV0HY4KoE79egROG2e48+jDnWmTKv1SQRgBPs4mXIvcKxZOqA18xmP sPGuQWj2ejSJKdg6mtOO+8NEfQ/vR3orR2Su5jtqlhJMP/cMDmfqyDjv0oXtem2g = 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:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=djhPl7rEzBZaEPOS7ct9wOQflas=; b=Z5sx7UgmxjF9dHHuA +cpRQzXEgejlDsWgf/br51C7LHPBbMQucDfma4eUeNIHDTKID0DimECKT8PCIixw LozR8Vnn9dUh/wgW29EngIUXvuKrZkFXwHaPenFxVyC6b/Him+/IHCdd0m7YkKJE b+au2sIJni3eauBK17wq05eWG8= Received: (qmail 104762 invoked by alias); 8 Nov 2018 19:44:21 -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 104749 invoked by uid 89); 8 Nov 2018 19:44:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=taskloop, in_reduction, tasks X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 08 Nov 2018 19:44:19 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 85277312E9D1 for ; Thu, 8 Nov 2018 19:44:15 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 207D95D9CA for ; Thu, 8 Nov 2018 19:44:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id wA8JiDtq022441 for ; Thu, 8 Nov 2018 20:44:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id wA8JiCPx022440 for gcc-patches@gcc.gnu.org; Thu, 8 Nov 2018 20:44:12 +0100 Date: Thu, 8 Nov 2018 20:44:11 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix task-reduction-8.c Message-ID: <20181108194411.GV11625@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes Hi! I've noticed this test fails intermittently. The problem is that it wasn't correct, without the in_reduction clause this patch adds (or e.g. without #pragma omp atomic) there is a data race, multiple tasks can update concurrently the same variable. Tested on x86_64-linux, previously it would fail every 10-100 runs here, now it doesn't fail in 10000 of them. Committed to trunk. 2018-11-08 Jakub Jelinek * testsuite/libgomp.c-c++-common/task-reduction-8.c (bar): Add in_reduction clause for s[0]. Jakub --- libgomp/testsuite/libgomp.c-c++-common/task-reduction-8.c.jj 2018-11-08 18:08:04.178942068 +0100 +++ libgomp/testsuite/libgomp.c-c++-common/task-reduction-8.c 2018-11-08 20:31:32.824942285 +0100 @@ -45,7 +45,8 @@ unsigned long long int bar (int z, int *a, unsigned long long int *b, int *s) { unsigned long long int x = 1; - #pragma omp taskloop reduction (*:x) in_reduction (*:b[0]) + #pragma omp taskloop reduction (*:x) in_reduction (*:b[0]) \ + in_reduction (+:s[0]) for (int i = z; i < z + 8; i++) { #pragma omp task in_reduction (*:x)