From patchwork Wed Apr 6 12:39:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1613945 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 4KYPGl0Ffrz9sFr for ; Wed, 6 Apr 2022 22:39:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79C89385E447 for ; Wed, 6 Apr 2022 12:39:39 +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 F1C49385840C for ; Wed, 6 Apr 2022 12:39:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1C49385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208,223";a="73924710" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 06 Apr 2022 04:39:27 -0800 IronPort-SDR: qJwNf4JDlr+/dN6Tx8G9QLFkZHdEf5B/SJpbNa7vBjpLFGgpqEnmc6pAXHP3E7acTVpfUVxDhl N7A5xgw45mb08trjeP7o5Pdo1ox5DIJ7VjcBFQccFMtyRPUSjmOTDLK4hTDwwWaVunDce+gBdr dUfKQn3HHN71XZQCOStG+CKldu+K5lZt89iGUbznz4q23BD21SyCTuhej3joUFGU0Di/SJA174 TjsEvFL9oOAsYapzulZqPuI0VkRu+bIP4wY0jtxiKQBH3PydalOrzit71FyT/CH9dYycvxnon6 u2Q= From: Thomas Schwinge To: Jakub Jelinek , Subject: Move 'libgomp/plugin/cuda/cuda.h' to 'include/cuda/cuda.h' (was: [PATCH] Allow building GCC with PTX offloading even without CUDA being installed (gcc and nvptx-tools patches)) In-Reply-To: <20170113181123.GA1867@tucnak> References: <20170113181123.GA1867@tucnak> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Wed, 6 Apr 2022 14:39:18 +0200 Message-ID: <875ynmtmh5.fsf@dem-tschwing-1.ger.mentorg.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-09.mgc.mentorg.com (139.181.222.9) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: , Cc: Alexander Monakov , Jeff Law Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2017-01-13T19:11:23+0100, Jakub Jelinek wrote: > Especially for distributions it is undesirable to need to have proprietary > CUDA libraries and headers installed when building GCC. > I've talked to our lawyers and they said that the cuda.h header included > in this patch doesn't infringe anyone's copyright or is otherwise a fair > use, it has been created by gathering all the cu*/CU* symbols from the > current and older nvptx plugin and some oacc tests, then stubbing the > pointer-ish typedefs, grabing most enum values and function prototypes from > https://raw.githubusercontent.com/shinpei0208/gdev/master/cuda/driver/cuda.h > and verifying assembly with that header against assembly when compiled > against NVidia's cuda.h. ..., and later accordingly was slightly extended, as necessary to use further CUDA features in libgomp's nvptx plugin. > --- libgomp/plugin/cuda/cuda.h.jj 2017-01-13 15:58:00.966544147 +0100 > +++ libgomp/plugin/cuda/cuda.h 2017-01-13 17:02:47.355817896 +0100 > @@ -0,0 +1,174 @@ > +/* CUDA API description. > + Copyright (C) 2017 Free Software Foundation, Inc. > + > +This file is part of GCC. > + > +GCC 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. > + > +GCC 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. > + > +You should have received a copy of the GNU General Public License > +along with GCC; see the file COPYING3. If not see > +. > + > +This header provides the minimum amount of typedefs, enums and function > +declarations to be able to compile plugin-nvptx.c if cuda.h and > +libcuda.so.1 are not available. */ > + > +#ifndef GCC_CUDA_H > +#define GCC_CUDA_H > +[...] > +#endif /* GCC_CUDA_H */ OK to push the attached "Move 'libgomp/plugin/cuda/cuda.h' to 'include/cuda/cuda.h'", so that I'm also able to use that file in the nvptx-tools, which inherit GCC's 'include' directory? Grüße Thomas ----------------- 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 From a6f9d53277ff8408cdbd7b89f3e7595e40333d48 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Wed, 6 Apr 2022 14:12:29 +0200 Subject: [PATCH] Move 'libgomp/plugin/cuda/cuda.h' to 'include/cuda/cuda.h' ... so that it may be used by other projects that inherit GCC's 'include' directory. include/ * cuda/cuda.h: New file. libgomp/ * plugin/cuda/cuda.h: Remove file. * plugin/plugin-nvptx.c [PLUGIN_NVPTX_DYNAMIC]: Include "cuda/cuda.h" instead of . * plugin/configfrag.ac : Don't set 'PLUGIN_NVPTX_CPPFLAGS'. * configure: Regenerate. --- {libgomp/plugin => include}/cuda/cuda.h | 7 +++---- libgomp/configure | 1 - libgomp/plugin/configfrag.ac | 1 - libgomp/plugin/plugin-nvptx.c | 6 +++++- 4 files changed, 8 insertions(+), 7 deletions(-) rename {libgomp/plugin => include}/cuda/cuda.h (97%) diff --git a/libgomp/plugin/cuda/cuda.h b/include/cuda/cuda.h similarity index 97% rename from libgomp/plugin/cuda/cuda.h rename to include/cuda/cuda.h index 5c679c1767a..5c813ad2cf8 100644 --- a/libgomp/plugin/cuda/cuda.h +++ b/include/cuda/cuda.h @@ -1,4 +1,4 @@ -/* CUDA API description. +/* CUDA Driver API description. Copyright (C) 2017-2022 Free Software Foundation, Inc. This file is part of GCC. @@ -22,9 +22,8 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . -This header provides the minimum amount of typedefs, enums and function -declarations to be able to compile plugin-nvptx.c if cuda.h and -libcuda.so.1 are not available. */ +This header provides parts of the CUDA Driver API, without having to rely on +the proprietary CUDA toolkit. */ #ifndef GCC_CUDA_H #define GCC_CUDA_H diff --git a/libgomp/configure b/libgomp/configure index b1b620cabc3..f863aa2ead4 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -15297,7 +15297,6 @@ rm -f core conftest.err conftest.$ac_objext \ && (test "x$CUDA_DRIVER_LIB" = x \ || test "x$CUDA_DRIVER_LIB" = xno); then PLUGIN_NVPTX=1 - PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' PLUGIN_NVPTX_LIBS='-ldl' PLUGIN_NVPTX_DYNAMIC=1 else diff --git a/libgomp/plugin/configfrag.ac b/libgomp/plugin/configfrag.ac index fc298391d4c..54d4b675c4e 100644 --- a/libgomp/plugin/configfrag.ac +++ b/libgomp/plugin/configfrag.ac @@ -156,7 +156,6 @@ if test x"$enable_offload_targets" != x; then && (test "x$CUDA_DRIVER_LIB" = x \ || test "x$CUDA_DRIVER_LIB" = xno); then PLUGIN_NVPTX=1 - PLUGIN_NVPTX_CPPFLAGS='-I$(srcdir)/plugin/cuda' PLUGIN_NVPTX_LIBS='-ldl' PLUGIN_NVPTX_DYNAMIC=1 else diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index b4f0a84d77a..b28dfca00fa 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -41,7 +41,11 @@ #include "oacc-int.h" #include -#include +#if PLUGIN_NVPTX_DYNAMIC +# include "cuda/cuda.h" +#else +# include +#endif #include #include #include -- 2.25.1