From patchwork Wed Oct 11 13:58:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cesar Philippidis X-Patchwork-Id: 824432 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-463944-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="bXf2oi5D"; 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 3yBwZV65s3z9s82 for ; Thu, 12 Oct 2017 00:59:13 +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 :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=kwq6J/srXncEUiS3pteUWfCwlha8xG2c790qF+2eQCLN8HZjEx9Qf jFqVl0W2iqD4fB6ADtX0po3qEnZPlDOvbP1KwGV91vdL8lKucj6CAutEHER5JAOc GZ9nR1xFWw6Xg2rDKgzyklwSSx52g8lYf7QIPV+qX02lZB+MBOG+WM= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=gPNf8Tq1L1+4ACRCq3XLOzNw2Ik=; b=bXf2oi5DZY/NkkA2x34B sKCeqoGYRP1V5Ktl1sf7dNW1FD6izoIBrGljtu9sFWt6NVI5c8k8534TparZVvBB CUNWvuEDJxAxLK9BdXNXigyJeSqehIVgqMy4iFRVgm40qOfAyHzif+CkqlFrwbfT 83KHrn4RaiC/Iu9e5sCBk1E= Received: (qmail 39571 invoked by alias); 11 Oct 2017 13:59:06 -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 39028 invoked by uid 89); 11 Oct 2017 13:59:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=possess X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Oct 2017 13:59:04 +0000 Received: from svr-orw-mbx-02.mgc.mentorg.com ([147.34.90.202]) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1e2HXJ-00071U-DJ from Cesar_Philippidis@mentor.com for gcc-patches@gcc.gnu.org; Wed, 11 Oct 2017 06:59:01 -0700 Received: from [127.0.0.1] (147.34.91.1) by svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 11 Oct 2017 06:58:59 -0700 From: Cesar Philippidis Subject: [og7] Allow the accelerator to have more offloaded functions than the host To: "gcc-patches@gcc.gnu.org" Message-ID: <711d1dba-0574-c7e6-0639-e49c105ee18b@codesourcery.com> Date: Wed, 11 Oct 2017 06:58:58 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To svr-orw-mbx-02.mgc.mentorg.com (147.34.90.202) Consider the following example: Let lib1.c contain function f1. Let lib2.c contain function f2. Both f1 and f2 contain offloaded functions. Create a static library with both lib1.o and lib2.o. Next create a program which using that static library, but only calls f1. If you build this program without program-wide -flto, this will cause the nvptx linker to embed the offloaded functions for both f1 and f2 in the host's executable, whereas the host will only have the offloaded function for f1. This is a problem because the libgomp expects both the host and accelerator to have the same number of offloaded functions. As a temporary workaround, this patch teaches libgomp to allow the accelerator to possess more offloaded functions than the host. I've applied this patch to openacc-gcc-7-branch. Is it also suitable for trunk? Cesar 2017-10-11 Cesar Philippidis libgomp/ * target.c (gomp_load_image_to_device): Allow the accelerator to possess more offloaded functions than the host. diff --git a/libgomp/target.c b/libgomp/target.c index a55c8f074d9..336581d2196 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -1452,7 +1452,7 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version, = devicep->load_image_func (devicep->target_id, version, target_data, &target_table); - if (num_target_entries != num_funcs + num_vars) + if (num_target_entries < num_funcs + num_vars) { gomp_mutex_unlock (&devicep->lock); if (is_register_lock)