From patchwork Thu May 4 07:54:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1776766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QBmL94klqz20fg for ; Thu, 4 May 2023 17:54:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E82023856DC5 for ; Thu, 4 May 2023 07:54:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id A30433858D28 for ; Thu, 4 May 2023 07:54:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A30433858D28 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.99,249,1677571200"; d="scan'208,223";a="4833382" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 03 May 2023 23:54:10 -0800 IronPort-SDR: EmXVBxgbMPcUx6Oj6kRpChkKePMZdnKc2xxxtI1y7gOrFKZ57spFyI0muSSM/CpusYTg8qSo3M X+cNS1n21dUKdIJeCdiUdOvFudWzN+e3/wpGl9IRdg3uFtEDtAX9o3BzDuQr0b+oxwuL/JHjdn UzGPs2YBXVb/zYpGAIIGe/m09IaYKHueJxW1Ioefy0qBenVEtEt/NrsWZ6Z34TpHtLnJ7M51kG 7U/S0MafPihaulkzOn1P7QgdmXikeoXRk0EQFSJWSHP7i1QHXfd2mlL7qxeX6BhrxvO0k8DrMF 9qs= From: Thomas Schwinge To: Jakub Jelinek , CC: Tobias Burnus Subject: libgomp C++ testsuite: Use 'lang_include_flags' instead of 'libstdcxx_includes' (was: [PATCH] libgomp: Add openacc_{cuda,cublas,cudart} effective targets and use them in openacc testsuite) In-Reply-To: <20210526120653.GA113911@tucnak> References: <20210526120653.GA113911@tucnak> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/28.2 (x86_64-pc-linux-gnu) Date: Thu, 4 May 2023 09:54:03 +0200 Message-ID: <87r0rwbkh0.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-13.mgc.mentorg.com (139.181.222.13) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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! On 2021-05-26T14:06:53+0200, Jakub Jelinek via Gcc-patches wrote: > When gcc is configured for nvptx offloading [...] > and full CUDA isn't installed, many libgomp.oacc-*/* tests fail, > some of them because cuda.h header can't be found, others because > the tests can't be linked against -lcuda, -lcudart or -lcublas. > I usually only have akmod-nvidia and xorg-x11-drv-nvidia-cuda rpms > installed, so libcuda.so.1 can be dlopened and the offloading works, > but linking against those libraries isn't possible nor are the > headers around [...] > The following patch adds 3 new effective targets and uses them in tests that > needs those. > --- libgomp/testsuite/lib/libgomp.exp.jj 2021-05-25 13:43:02.800121273 +0200 > +++ libgomp/testsuite/lib/libgomp.exp 2021-05-26 12:18:56.562556244 +0200 > +# Return 1 if cuda.h and -lcuda are available. > + > +proc check_effective_target_openacc_cuda { } { > + return [check_no_compiler_messages openacc_cuda executable { > +#include > +[...] > +} } "-lcuda" ] > +} > + > +# Return 1 if cublas_v2.h and -lcublas are available. > + > +proc check_effective_target_openacc_cublas { } { > + return [check_no_compiler_messages openacc_cublas executable { > +#include > +#include > +[...] > +} } "-lcuda -lcublas" ] > +} > + > +# Return 1 if cuda_runtime_api.h and -lcudart are available. > + > +proc check_effective_target_openacc_cudart { } { > + return [check_no_compiler_messages openacc_cudart executable { > +#include > +#include > +[...] > +} } "-lcuda -lcudart" ] > +} OK to push the attached "libgomp C++ testsuite: Use 'lang_include_flags' instead of 'libstdcxx_includes'"? This does not adjust the 'libstdcxx_includes' usage in libitm and libvtv testsuites -- maybe those should also get 'lang_include_flags' ported (separately)? 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 9bb4ffee6932ee5f917344535026f75c3eadc093 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Thu, 4 May 2023 09:07:35 +0200 Subject: [PATCH] libgomp C++ testsuite: Use 'lang_include_flags' instead of 'libstdcxx_includes' With nvptx offloading configured, and supported, and CUDA available: $ make check-target-libgomp RUNTESTFLAGS="--all c.exp=context-1.c c++.exp=context-1.c" [...] Running [...]/libgomp.oacc-c/c.exp ... PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O0 (test for excess errors) PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O0 execution test PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O2 (test for excess errors) PASS: libgomp.oacc-c/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O2 execution test UNSUPPORTED: libgomp.oacc-c/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_host=1 -DACC_MEM_SHARED=1 -foffload=disable -O2 Running [...]/libgomp.oacc-c++/c++.exp ... PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O0 (test for excess errors) PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O0 execution test PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O2 (test for excess errors) PASS: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O2 execution test UNSUPPORTED: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_host=1 -DACC_MEM_SHARED=1 -foffload=disable -O2 [...] ..., but for 'c++.exp=context-1.c' alone, we currently get all-UNSUPPORTED: $ make check-target-libgomp RUNTESTFLAGS_="--all c++.exp=context-1.c" [...] Running [...]/libgomp.oacc-c++/c++.exp ... UNSUPPORTED: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O0 UNSUPPORTED: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none -O2 UNSUPPORTED: libgomp.oacc-c++/../libgomp.oacc-c-c++-common/context-1.c -DACC_DEVICE_TYPE_host=1 -DACC_MEM_SHARED=1 -foffload=disable -O2 [...] That is, if 'c.exp' executes first, it does successfully evaluate 'dg-require-effective-target openacc_cublas' -- and does cache this result (so it isn't reevaluated for 'c++.exp'). However, for 'c++.exp' alone (that is, without the 'c.exp' result cached), we run into: spawn -ignore SIGHUP [xgcc] [...] -x c++ openacc_cublas2311907.c [...] In file included from /usr/include/cuda_fp16.h:3673, from /usr/include/cublas_api.h:75, from /usr/include/cublas_v2.h:65, from openacc_cublas2311907.c:3: /usr/include/cuda_fp16.hpp:67:10: fatal error: utility: No such file or directory We're missing include paths to C++/libstdc++ build-tree headers. Fix this by using the mechanism introduced for Fortran in r212268 (commit f707da16f714f7fe5a42391748212c84dfec639b) re "libgomp.fortran/fortran.exp - add -fintrinsic-modules-path ${blddir}". libgomp/ * testsuite/libgomp.c++/c++.exp: Use 'lang_include_flags' instead of 'libstdcxx_includes'. * testsuite/libgomp.oacc-c++/c++.exp: Likewise. --- libgomp/testsuite/libgomp.c++/c++.exp | 7 +++---- libgomp/testsuite/libgomp.oacc-c++/c++.exp | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libgomp/testsuite/libgomp.c++/c++.exp b/libgomp/testsuite/libgomp.c++/c++.exp index f4884e2ffa7..5b9a5924ff3 100644 --- a/libgomp/testsuite/libgomp.c++/c++.exp +++ b/libgomp/testsuite/libgomp.c++/c++.exp @@ -66,13 +66,12 @@ if { $lang_test_file_found } { set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" if { [file exists $flags_file] } { - set libstdcxx_includes [exec sh $flags_file --build-includes] - } else { - set libstdcxx_includes "" + set lang_source_re {^.*\.[cC]$} + set lang_include_flags [exec sh $flags_file --build-includes] } # Main loop. - dg-runtest $tests "" "$libstdcxx_includes $DEFAULT_CFLAGS" + dg-runtest $tests "" $DEFAULT_CFLAGS } # See above. diff --git a/libgomp/testsuite/libgomp.oacc-c++/c++.exp b/libgomp/testsuite/libgomp.oacc-c++/c++.exp index 42e0395f9a5..0b235ba47f3 100644 --- a/libgomp/testsuite/libgomp.oacc-c++/c++.exp +++ b/libgomp/testsuite/libgomp.oacc-c++/c++.exp @@ -72,9 +72,8 @@ if { $lang_test_file_found } { set flags_file "${blddir}/../libstdc++-v3/scripts/testsuite_flags" if { [file exists $flags_file] } { - set libstdcxx_includes [exec sh $flags_file --build-includes] - } else { - set libstdcxx_includes "" + set lang_source_re {^.*\.[cC]$} + set lang_include_flags [exec sh $flags_file --build-includes] } # Test with all available offload targets, and with offloading disabled. @@ -147,7 +146,7 @@ if { $lang_test_file_found } { } } - gcc-dg-runtest $tests "$tagopt" "$libstdcxx_includes" + gcc-dg-runtest $tests "$tagopt" "" } unset offload_target } else { -- 2.34.1