From patchwork Sat Aug 24 15:13:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1976395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=sx/LRq3V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WrgSy4tGFz1yXd for ; Sun, 25 Aug 2024 01:14:10 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EB843386480A for ; Sat, 24 Aug 2024 15:14:08 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 9A86B3858408 for ; Sat, 24 Aug 2024 15:13:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A86B3858408 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9A86B3858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724512425; cv=none; b=bx8oKXnihIkNMGtuPTXwFy7F3xtURSoa5vMExW1xMYS/1nQBteLQuROUO7S+WWOoO/P4RUPbQshPLavmk9kqU30uR5WZzwxhaFaZS2SEYiVTdUvKS3aFRrwiXfHCoz3hUHf/gIVzoZXPRhCpF/4Z22JvvR6LxsZ0G+yN9H2i6Y4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724512425; c=relaxed/simple; bh=mOkhSrkS3QZEMvdy++YLDz0Ru3SJm+spVDT4Dbr4bSc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=dflIorxdp/XgUkux+J/p7QYrGDuTpl4ijB07xwX74y60A2gsxRlzR1ckTCMNW5nsLp/3hHDfextTFKjQAg9q7aHLo9UK9+hD7201WLNv/9xKMVMAqaqu87VxxjZsPQOcwYL0mLwNJxmFQxMLHzy6E9eCzv46PuSA9qmB9SlPEW0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-428243f928cso24332645e9.3 for ; Sat, 24 Aug 2024 08:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1724512421; x=1725117221; darn=gcc.gnu.org; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=XwZ3T0V0Qc+J4q8eDngi+6ru+w/bd2ir5jC520BOKsI=; b=sx/LRq3V0dEofk7OeQGD8TA+Yn6h9GRez1bAs02u6N+48MCE6ywzfKG2iE985u0XWR Ny0BEMh2copN4shb7jf4BF0kqwMxPQwRONJpeiQMS3vA4F7p/6K21iqDIUQkANPfRJs/ 1hVXeYZJjF0YH0ONBvbpAuO2S9gMTZCBgoeWs7g5d3G0o02N0a6WTODfK2dyInkxZCA+ 5a3lgg4/bym2NDYlwhrN5k9M8e76iRdCEkgfOXsxbHb/SmEDtNSEwEPLe/5dm74iATuh 85BatPSQ9QdnMaGe+ehL79Ja4ISapan9j4GLBtakKd6Xt99ELCxBbc8F6N4E/wpkToDm N7Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724512421; x=1725117221; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XwZ3T0V0Qc+J4q8eDngi+6ru+w/bd2ir5jC520BOKsI=; b=MtNlWk+euAebV4Y3nbV4oe3+omj1wigoz7NT9EnkWZIp4lbQbJohEkC9rs4NHb0wqG ZAWkrD1dOWsokg1TY1FJ5lLja9440gb9Jwhl0KJqTD5Ua+fT8kanetAAFmtGU5NKhiNH DaiUssup8i/2ph2hrn7IcZXyACBEe7jN0YoRvxDVrpgWKKj0bNSf+eprH4lbo5Y5tfQl +uHHgZvovp0okJpLJSnLlj69ryibp9lWGb4u2H/xYJBOxP/kvZTlRME8eL1UkCs4XWL9 r6NmqzZGNqMMm0QgQKzlfwJvezsUKI0nNJj23qM+2tJ3+mSiEzgwMNzO1Avjeeg47Nqu g2aw== X-Gm-Message-State: AOJu0YxbkuDgEyP8PdQx46EO0HZeXQaNwRTRDUZR8ZlAO2YeuKzGabWN 03AHSz8Q47soL2rBDKTSM3L5+C4owSueEGt8Q0uImXJLeMze2HfkwKa9T1sX2WtfK6X3NhCet98 g X-Google-Smtp-Source: AGHT+IGD7zJj/R/Wr4E4T1G97a+2ROp7SXakNvpzyGa45VKWgR87vfXc0+8C88Q9tm6KqRztWwmI3w== X-Received: by 2002:a05:600c:1990:b0:428:e09d:3c with SMTP id 5b1f17b1804b1-42acca00901mr35598855e9.33.1724512420883; Sat, 24 Aug 2024 08:13:40 -0700 (PDT) Received: from ?IPV6:2001:16b8:3d5b:2700:d97e:3de7:536f:e520? ([2001:16b8:3d5b:2700:d97e:3de7:536f:e520]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac21cd620sm115658835e9.37.2024.08.24.08.13.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 24 Aug 2024 08:13:39 -0700 (PDT) Message-ID: <4a424b69-d3c3-4ca2-869f-519150468d3f@baylibre.com> Date: Sat, 24 Aug 2024 17:13:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches , Sandra Loosemore , Jakub Jelinek , Thomas Schwinge , Andrew Stubbs From: Tobias Burnus Subject: [patch] libgomp.texi: Document supported OpenMP 'interop' types for nvptx and gcn X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.30 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 This patch comes on top of "[patch][v2] libgomp.texi: Document OpenMP's Interoperability Routines", https://gcc.gnu.org/pipermail/gcc-patches/2024-August/661314.html But it documents the code added at "[patch][rfc] libgomp: Add OpenMP interop support to nvptx + gcn plugin", https://gcc.gnu.org/pipermail/gcc-patches/2024-August/661207.html As remarked there: While the code in the plugin should handle the advertised foreign runtimes (cuda, cuda_driver, hip, hsa) correctly, it has not been extensively been tested and it only becomes real available once the 'interop' directive has been implemented in the compiler itself. Tobias libgomp.texi: Document supported OpenMP 'interop' types for nvptx and gcn libgomp/ChangeLog: * libgomp.texi (omp_get_interop_int, omp_get_interop_str, omp_get_interop_ptr, omp_get_interop_type_desc): Add @ref to Offload-Target Specifics. (Offload-Target Specifics): Document the supported OpenMP interop types. libgomp/libgomp.texi | 118 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 4 deletions(-) diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi index b36b58b6d10..9d76948812a 100644 --- a/libgomp/libgomp.texi +++ b/libgomp/libgomp.texi @@ -2980,7 +2980,7 @@ not affect the usage of the function when GCC's @code{omp_lib} module or @item @emph{See also}: @ref{omp_get_interop_ptr}, @ref{omp_get_interop_str}, @ref{omp_get_interop_rc_desc} -@c @ref{Offload-Target Specifics} +@ref{Offload-Target Specifics} @item @emph{Reference}: @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.12.2, @@ -3026,7 +3026,7 @@ not affect the usage of the function when GCC's @code{omp_lib} module or @item @emph{See also}: @ref{omp_get_interop_int}, @ref{omp_get_interop_str}, @ref{omp_get_interop_rc_desc} -@c @ref{Offload-Target Specifics} +@ref{Offload-Target Specifics} @item @emph{Reference}: @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.12.3, @@ -3071,7 +3071,7 @@ affect the usage of the function when GCC's @code{omp_lib} module or @item @emph{See also}: @ref{omp_get_interop_int}, @ref{omp_get_interop_ptr}, @ref{omp_get_interop_rc_desc} -@c @ref{Offload-Target Specifics} +@ref{Offload-Target Specifics} @item @emph{Reference}: @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.12.4, @@ -3155,7 +3155,7 @@ affect the usage of the function when GCC's @code{omp_lib} module or @item @emph{See also}: @ref{omp_get_num_interop_properties}, @ref{omp_get_interop_name} -@c @ref{Offload-Target Specifics} +@ref{Offload-Target Specifics} @item @emph{Reference}: @uref{https://www.openmp.org, OpenMP specification v5.1}, Section 3.12.6, @@ -6747,6 +6747,10 @@ The following sections present notes on the offload-target specifics @node AMD Radeon @section AMD Radeon (GCN) +@menu +* Foreign-runtime support for AMD GPUs:: +@end menu + On the hardware side, there is the hierarchy (fine to coarse): @itemize @item work item (thread) @@ -6816,11 +6820,58 @@ The implementation remark: pool is exhausted. @end itemize +@node Foreign-runtime support for AMD GPUs +@subsection OpenMP @code{interop} -- Foreign-Runtime Support for AMD GPUs + +An interoperability object of OpenMP @code{interop} type can be obtained using +the @code{interop} directive; supported as foreign runtimes are HIP +(C++ Heterogeneous-Compute Interface for Portability) and HSA (Heterogeneous +System Architecture). If no @code{prefer_type} argument has been specified, +HIP is used. + +The following properties can then be extracted using the @ref{Interoperability +Routines}. Each listed property name has an associated named constant, +consisting of @code{omp_ipr_} followed by the property name. The following +table uses ``@emph{int}'', ``@emph{str}'' and ``@emph{ptr}'' to denote the +routine to be used to obtain the property value. + +Available properties for an HIP interop object: +@multitable @columnfractions .30 .30 .30 +@headitem Property @tab data type @tab value (if constant) +@item @code{fr_id} @tab @samp{omp_interop_fr_t} @emph{(int)} @tab @samp{omp_fr_hip} +@item @code{fr_name} @tab @samp{const char *} @emph{(str)} @tab @samp{hip} +@item @code{vendor} @tab @samp{int} @emph{(int)} @tab @samp{1} +@item @code{vendor_name} @tab @samp{const char *} @emph{(str)} @tab @samp{amd} +@item @code{device_num} @tab @samp{int} @emph{(int)} @tab +@item @code{platform} @tab N/A @tab +@item @code{device} @tab @samp{hipDevice_t} @emph{(int)} @tab +@item @code{device_context} @tab @samp{hipCtx_t} @emph{(ptr)} @tab +@item @code{targetsync} @tab @samp{hipStream_t} @emph{(ptr)} @tab +@end multitable + +Available properties for an HSA interop object: +@multitable @columnfractions .30 .30 .30 +@headitem Property @tab data type @tab value (if constant) +@item @code{fr_id} @tab @samp{omp_interop_fr_t} @emph{(int)} @tab @samp{omp_fr_hsa} +@item @code{fr_name} @tab @samp{const char *} @emph{(str)} @tab @samp{hsa} +@item @code{vendor} @tab @samp{int} @emph{(int)} @tab @samp{1} +@item @code{vendor_name} @tab @samp{const char *} @emph{(str)} @tab @samp{amd} +@item @code{device_num} @tab @samp{int} @emph{(int)} @tab +@item @code{platform} @tab N/A @tab +@item @code{device} @tab @samp{hsa_agent *} @emph{(ptr)} @tab +@item @code{device_context} @tab N/A @tab +@item @code{targetsync} @tab @samp{hsa_queue *} @emph{(ptr)} @tab +@end multitable + @node nvptx @section nvptx +@menu +* Foreign-runtime support for Nvidia GPUs:: +@end menu + On the hardware side, there is the hierarchy (fine to coarse): @itemize @item thread @@ -6903,6 +6954,65 @@ The implementation remark: pool is exhausted. @end itemize +@node Foreign-runtime support for Nvidia GPUs +@subsection OpenMP @code{interop} -- Foreign-Runtime Support for Nvidia GPUs + +An interoperability object of OpenMP @code{interop} type can be obtained using +the @code{interop} directive; supported as foreign runtimes are the CUDA +runtime API, the CUDA driver API, and the C++ Heterogeneous-Compute Interface +for Portability (HIP), which is -- for CUDA-based systems -- a very thin layer +on top of the CUDA APIs. If no @code{prefer_type} argument has been specified, +the CUDA runtime API is used. + +The following properties can then be extracted using the @ref{Interoperability +Routines}. Each listed property name has an associated named constant, +consisting of @code{omp_ipr_} followed by the property name. The following +table uses ``@emph{int}'', ``@emph{str}'' and ``@emph{ptr}'' to denote the +routine to be used to obtain the property value. + +Available properties for a CUDA runtime API interop object: +@multitable @columnfractions .30 .30 .30 +@headitem Property @tab data type @tab value (if constant) +@item @code{fr_id} @tab @samp{omp_interop_fr_t} @emph{(int)} @tab @samp{omp_fr_cuda} +@item @code{fr_name} @tab @samp{const char *} @emph{(str)} @tab @samp{cuda} +@item @code{vendor} @tab @samp{int} @emph{(int)} @tab @samp{11} +@item @code{vendor_name} @tab @samp{const char *} @emph{(str)} @tab @samp{nvidia} +@item @code{device_num} @tab @samp{int} @emph{(int)} @tab +@item @code{platform} @tab N/A @tab +@item @code{device} @tab @samp{int} @emph{(int)} @tab +@item @code{device_context} @tab N/A @tab +@item @code{targetsync} @tab @samp{cudaStream_t} @emph{(ptr)} @tab +@end multitable + +Available properties for a CUDA driver API interop object: +@multitable @columnfractions .30 .30 .30 +@headitem Property @tab data type @tab value (if constant) +@item @code{fr_id} @tab @samp{omp_interop_fr_t} @emph{(int)} @tab @samp{omp_fr_cuda_driver} +@item @code{fr_name} @tab @samp{const char *} @emph{(str)} @tab @samp{cuda_driver} +@item @code{vendor} @tab @samp{int} @emph{(int)} @tab @samp{11} +@item @code{vendor_name} @tab @samp{const char *} @emph{(str)} @tab @samp{nvidia} +@item @code{device_num} @tab @samp{int} @emph{(int)} @tab +@item @code{platform} @tab N/A @tab +@item @code{device} @tab @samp{CUdevice} @emph{(int)} @tab +@item @code{device_context} @tab @samp{CUcontext} @emph{(ptr)} @tab +@item @code{targetsync} @tab @samp{CUstream} @emph{(ptr)} @tab +@end multitable + +Available properties for an HIP interop object: +@multitable @columnfractions .30 .30 .30 +@headitem Property @tab data type @tab value (if constant) +@item @code{fr_id} @tab @samp{omp_interop_fr_t} @emph{(int)} @tab @samp{omp_fr_hip} +@item @code{fr_name} @tab @samp{const char *} @emph{(str)} @tab @samp{hip} +@item @code{vendor} @tab @samp{int} @emph{(int)} @tab @samp{11} +@item @code{vendor_name} @tab @samp{const char *} @emph{(str)} @tab @samp{nvidia} +@item @code{device_num} @tab @samp{int} @emph{(int)} @tab +@item @code{platform} @tab N/A @tab +@item @code{device} @tab @samp{hipDevice_t} @emph{(int)} @tab +@item @code{device_context} @tab @samp{hipCtx_t} @emph{(ptr)} @tab +@item @code{targetsync} @tab @samp{hipStream_t} @emph{(ptr)} @tab +@end multitable + + @c --------------------------------------------------------------------- @c The libgomp ABI