From patchwork Fri Nov 12 15:16:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 47534 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D59883858430 for ; Fri, 12 Nov 2021 15:17:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D59883858430 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636730239; bh=0jwyR/sskMdql37T1721wZ0BKIFRO33WCsCK3cUbaCc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=kmX3LbpR7zDs/t3aDF2MsBs1HdmDeIKX1SOc7qVx/5xb4mM5uwVZm1Yx43LSzfNMd d4D2EZhWJK46VHX7b9NoRg3F7F+DFL2jvsaDsiMbcNCROEMXryITChUyZhOWr0UhQD tOyvky5Ao5gPN3HkT6p+X9OmHenQJtcvEQHbbfsg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C54313858402 for ; Fri, 12 Nov 2021 15:16:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C54313858402 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-24-jJSf8RBMNe22Ou2NswHnug-1; Fri, 12 Nov 2021 10:16:47 -0500 X-MC-Unique: jJSf8RBMNe22Ou2NswHnug-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78F9D10B7464; Fri, 12 Nov 2021 15:16:46 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA9F719EF9; Fri, 12 Nov 2021 15:16:45 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1ACFGgCV283742 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 12 Nov 2021 16:16:43 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1ACFGg8x283741; Fri, 12 Nov 2021 16:16:42 +0100 Date: Fri, 12 Nov 2021 16:16:42 +0100 To: gcc-patches@gcc.gnu.org Subject: [committed] libgomp: Unbreak gcn offload build Message-ID: <20211112151642.GF2710@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Tobias Burnus , Andrew Stubbs Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! My recent libgomp change apparently broke libgomp build for gcn offloading. The problem is that gcn, unlike nvptx, doesn't override teams.c source file and the patch I've committed assumed all the non-LIBGOMP_USE_PTHREADS targets do not use it. My understanding is that gcn included omp_get_num_teams and omp_get_team_num definitions in both icv-device.o and teams.o, with the definitions only in the former working correctly. This patch brings gcn into sync with how nvptx does it, that teams.c is overridden, provides a dummy GOMP_teams_reg and omp_get_{num_teams,team_num} definitions and icv-device.c doesn't provide those. Tobias said he has build-tested this with gcn offloading. Committed to trunk. 2021-11-12 Jakub Jelinek PR target/103201 * config/gcn/icv-device.c (omp_get_num_teams, omp_get_team_num): Move to ... * config/gcn/teams.c: ... here. New file. Jakub --- libgomp/config/gcn/icv-device.c.jj 2021-08-05 17:30:59.085260610 +0200 +++ libgomp/config/gcn/icv-device.c 2021-11-12 10:37:19.249351143 +0100 @@ -52,18 +52,6 @@ omp_get_num_devices (void) } int -omp_get_num_teams (void) -{ - return gomp_num_teams_var + 1; -} - -int __attribute__ ((__optimize__ ("O2"))) -omp_get_team_num (void) -{ - return __builtin_gcn_dim_pos (0); -} - -int omp_is_initial_device (void) { /* AMD GCN is an accelerator-only target. */ @@ -84,7 +72,5 @@ ialias (omp_set_default_device) ialias (omp_get_default_device) ialias (omp_get_initial_device) ialias (omp_get_num_devices) -ialias (omp_get_num_teams) -ialias (omp_get_team_num) ialias (omp_is_initial_device) ialias (omp_get_device_num) --- libgomp/config/gcn/teams.c.jj 2021-11-12 10:37:47.227951052 +0100 +++ libgomp/config/gcn/teams.c 2021-11-12 10:39:34.010426094 +0100 @@ -0,0 +1,54 @@ +/* Copyright (C) 2015-2021 Free Software Foundation, Inc. + + This file is part of the GNU Offloading and Multi Processing Library + (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* This file defines OpenMP API entry points that accelerator targets are + expected to replace. */ + +#include "libgomp.h" + +void +GOMP_teams_reg (void (*fn) (void *), void *data, unsigned int num_teams, + unsigned int thread_limit, unsigned int flags) +{ + (void) fn; + (void) data; + (void) flags; + (void) num_teams; + (void) thread_limit; +} + +int +omp_get_num_teams (void) +{ + return gomp_num_teams_var + 1; +} + +int __attribute__ ((__optimize__ ("O2"))) +omp_get_team_num (void) +{ + return __builtin_gcn_dim_pos (0); +} + +ialias (omp_get_num_teams) +ialias (omp_get_team_num)