From patchwork Wed Jan 12 09:43:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marcel Vollweiler X-Patchwork-Id: 1578954 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYjLN1sQ2z9s0r for ; Wed, 12 Jan 2022 20:43:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00F8E393A414 for ; Wed, 12 Jan 2022 09:43:36 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 6BD073858416 for ; Wed, 12 Jan 2022 09:43:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6BD073858416 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: XHuSE+I08KnJ7s5v6NM1LBvRMC46spd3uyELZE+DdPhxoSMlSGRRgSGBeV+VwbH2M8y8mjsqmd y+mOsVGNX+T31Ipg6bjjXZ3pDRlEp9qmnYKSBYZY4v88ZAKdNDFW5ge/lXv7bpZ8wnTsmRrtAm VDgRisHnHVToE2NxcMr7uI0dsq8Yy6/FsKVbUadyh0tzOIi8nfR54muJzdAPDOJGEuP9oPfEmU cCwE+FixQC2Lbpdm1Fmr+sR9lOSM9ElTxzJ9NuvMtGhkLsD7rx5JKPIp9ePHXbgwQyBMwaBYfv DYrG9VgSypB/wRVsiuMQj+mb X-IronPort-AV: E=Sophos;i="5.88,282,1635235200"; d="diff'?scan'208";a="70529148" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 12 Jan 2022 01:43:11 -0800 IronPort-SDR: 07JJdm/m+0SNd6vtW0c2DUepoM4BVfl+Skc5tyK3GLTszowJ1d2uhDYOjB6jlYo3h49m4y4NGn YJ0F8WGtxvIZCVgSJUgRJVWgk5UE6dFkqZxCkotkxaDDQbz31ArIeLOHUDk80IIBDVqzFm1yUi ZW2cJIE+dZ7yY8dfnNqBA7WPQLHBAMwr5j8UnlZfiJos4pbOvJmINqFiSlH0+bsX14dHzfoVbY 6m3izSHpwDxidhAr9aFqCbRaI+ai1ziIvbBsuCMGGtE+BILMwKacLcAYmuXl4mDIAu8bcUWMN9 jvA= Message-ID: <42b806a0-55a2-7fea-3e69-2d82bfc18007@codesourcery.com> Date: Wed, 12 Jan 2022 10:43:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 To: From: Marcel Vollweiler Subject: [PATCH] libgomp, OpenMP: Fix issue for omp_get_device_num on gfx targets. X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-09.mgc.mentorg.com (139.181.222.9) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, Currently omp_get_device_num does not work on gcn targets with more than one offload device. The reason is that GOMP_DEVICE_NUM_VAR is static in icv-device.c and thus "__gomp_device_num" is not visible in the offload image. This patch removes "static" such that "__gomp_device_num" is now part of the offload image and can now be found in GOMP_OFFLOAD_load_image in the plugin. This is not an issue for nvptx. There, "__gomp_device_num" is in the offload image even with "static". The patch was tested on x86_64-linux with amdgcn offloading with no regressions. Marcel ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 libgomp, OpenMP: Fix issue for omp_get_device_num on gcn targets. Currently omp_get_device_num does not work on gcn targets with more than one offload device. The reason is that GOMP_DEVICE_NUM_VAR is static in icv-device.c and thus "__gomp_device_num" is not visible in the offload image. This patch removes "static" such that "__gomp_device_num" is now part of the offload image and can now be found in GOMP_OFFLOAD_load_image in the plugin. This is not an issue for nvptx. There, "__gomp_device_num" is in the offload image even with "static". libgomp/ChangeLog: * config/gcn/icv-device.c: Make GOMP_DEVICE_NUM_VAR public (remove "static") to make the device num available in the offload image. diff --git a/libgomp/config/gcn/icv-device.c b/libgomp/config/gcn/icv-device.c index fcfa0f3..f70b7e6 100644 --- a/libgomp/config/gcn/icv-device.c +++ b/libgomp/config/gcn/icv-device.c @@ -60,7 +60,7 @@ omp_is_initial_device (void) /* This is set to the device number of current GPU during device initialization, when the offload image containing this libgomp portion is loaded. */ -static volatile int GOMP_DEVICE_NUM_VAR; +volatile int GOMP_DEVICE_NUM_VAR; int omp_get_device_num (void)