From patchwork Tue Aug 13 21:37:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1146678 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-506860-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Rgp3+RY4"; 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 467R0R6gXzz9sML for ; Wed, 14 Aug 2019 07:38:15 +1000 (AEST) 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:in-reply-to:references :mime-version:content-transfer-encoding:content-type; q=dns; s= default; b=kaevycMngHm7ccxtfZnH0Y2/0y2zGG4U9e0PEBeUvMOLVBm/81gI6 FFdbfueRHABQJ+VwgNhtykloivRRaGaBvtRW/G/t2IKPzTMNn9lRFPpBXaWUDKgf buhKVdtQAfxpsmI4yEHyBIGiff/5NZmtnh5LiHQ7adYj9wpvwrFW90= 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:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=default; bh=Qh03voLe2FyaFwYMjzvyuRA3DYQ=; b=Rgp3+RY4TzhRgpfMn4FISju2VinC JiJaJmFI+lbjFli8FpLe1gjYPdUedZGG6+PGaZnNil3Y8AT7FMjxMYYuPM4U3NOx PHmY/qAIYkr+fRRT8Md/ichv30Vte5hgcXhKIJXS/P4zcN3Pk6cuRCzTbOTK9nCh eXOYZbiITxGqXmE= Received: (qmail 48915 invoked by alias); 13 Aug 2019 21:37:42 -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 48869 invoked by uid 89); 13 Aug 2019 21:37:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=agent, HContent-Transfer-Encoding:8bit X-HELO: esa2.mentor.iphmx.com Received: from esa2.mentor.iphmx.com (HELO esa2.mentor.iphmx.com) (68.232.141.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Aug 2019 21:37:40 +0000 IronPort-SDR: XTdBh4U6MiPFJ/PrQq5WGgWbE5KRy53KKi08/7n2V2xehYkSyr3Uqb/DQ0Ipmqvo9VWPUgD7OO x+jdPXHYGFE/87kOIyAPz58ovnAb2DHrTLxIOGJT7YaZOQy/W30RCY2K4WWettadtOzCzFTjNt Zszj19hHvz6sZTLsPFKDgc/ZDBs6PhtPzRqqG2k78UkBQNbQavwNVDURFELmDzabLk0AZ87iVt zQawCFEKjcWR4o27XW3e6PLolLGDcq0RlTl4RB7qkRLxTbC5slnniRNe27ZLar1RjvaKF5lLcH UYY= Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 13 Aug 2019 13:37:40 -0800 IronPort-SDR: Cz8zCuNokM1TIjYY33YiNWeA/Tmr1nJLuU3Q9OcwXkojc6nKXpP7j3Qc5wOQw9k/k2aC83AHA5 QH4eBJW0ul0FeeYTd267JkstRISi7U10R31GltiOE2EvJrFL3aetSMAeIa89OtByfjq1PDFFiA klDcIvG69Jo2fKbyst5omicJdiZolmGy2JztUK+NVU3Outl0ez+gL2E6zcVyHOnMuF+/vP2aMn 75QNpFbj1OfmJb4vqTdw2lbmnu0WHf554aJW/TvJvScMqJzuAoni5Trfw9bZ1yc7Xsqd51aKXS M90= From: Julian Brown To: CC: Andrew Stubbs , Jakub Jelinek Subject: [PATCH 3/3] [og9] Wait on queue-full condition in AMD GCN libgomp offloading plugin Date: Tue, 13 Aug 2019 14:37:15 -0700 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-IsSubscribed: yes This patch lets the AMD GCN libgomp plugin wait for asynchronous queues to have some space to push new operations when they are full, rather than just erroring out immediately on that condition. This fixes the libgomp.oacc-c-c++-common/da-4.c test. Julian ChangeLog libgomp/ * plugin/plugin-gcn.c (queue_push_callback): Wait on queue-full condition. --- libgomp/ChangeLog.openacc | 5 +++++ libgomp/plugin/plugin-gcn.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libgomp/ChangeLog.openacc b/libgomp/ChangeLog.openacc index 2a9a7f18ca2..f9d8e6ecd39 100644 --- a/libgomp/ChangeLog.openacc +++ b/libgomp/ChangeLog.openacc @@ -1,3 +1,8 @@ +2019-08-13 Julian Brown + + * plugin/plugin-gcn.c (queue_push_callback): Wait on queue-full + condition. + 2019-08-13 Julian Brown * plugin/plugin-gcn.c (struct copy_data): Add using_src_copy field. diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index 65690e643ed..099f70b647c 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -1416,8 +1416,15 @@ queue_push_callback (struct goacc_asyncqueue *aq, void (*fn)(void *), void *data) { if (aq->queue_n == ASYNC_QUEUE_SIZE) - GOMP_PLUGIN_fatal ("Async thread %d:%d: error: queue overflowed", - aq->agent->device_id, aq->id); + { + pthread_mutex_lock (&aq->mutex); + + /* Queue is full. Wait for it to not be full. */ + while (aq->queue_n == ASYNC_QUEUE_SIZE) + pthread_cond_wait (&aq->queue_cond_out, &aq->mutex); + + pthread_mutex_unlock (&aq->mutex); + } pthread_mutex_lock (&aq->mutex);