From patchwork Fri May 24 19:57:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kwok Cheung Yeung X-Patchwork-Id: 1939078 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=BtdB/d+L; dkim-atps=neutral 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=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 [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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VmG8B6CLNz20dW for ; Sat, 25 May 2024 05:59:04 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DF563858C41 for ; Fri, 24 May 2024 19:59:02 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 6E1ED3858D29 for ; Fri, 24 May 2024 19:58:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E1ED3858D29 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 6E1ED3858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::430 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716580724; cv=none; b=gnnWtrOlSeitIJ0RQ/Y7+4/ZIJktbqpAJdwQYQXSmp2ZO0H+8DidJQBzD2FrmyQN0sx+PNdshmmuPXpXDxlad9jFzqIy7P/YpXGxYNFW5kvrXMqcOkItTNdnci4ICQ8ZZLr4GSs1+Xm64EVHGPEXGhWPfkXrdY4GORl35xD8ToI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716580724; c=relaxed/simple; bh=h2WbOw+b7LT2xm7lza+OmORfchmOWkN2cUTiDXU1aTE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=jjgfLggZ9pU9PmdN3puMHT8SYjYs8QOg+nGpn74fVB0EbnucIKOvg68kgU1oRr/WM+o43pKl2q9VUDmhGOkFeiB/Bolzg7yj2WgTtK//zHxxFr9Dtefn4jwvEZhjqI94iEEI5fvoJp/bPp1XS/AJeUm+92r4F2nbhNOFoApM7jY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-35507a3a038so810227f8f.0 for ; Fri, 24 May 2024 12:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1716580720; x=1717185520; darn=gcc.gnu.org; h=content-transfer-encoding:to:content-language:subject:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=CGggXJlrg0/mWmDWpDK4vbdxmaqe9IjIWbQQlWw1Cfg=; b=BtdB/d+LdYTJIfDguvqf+XolTuQKykVmTSF4EtAUGbXnX4bA5AZXMh+4qroFGlz++W 0OcmZjlxl3ifdALAUX9iRBGASDX6sAWarQ+9R8NwlYzE1Ui38XOI4uzHrraSdy5dfOT/ NQ/l7pMDpvHDaqfIpmkE9wkOopqkvw+q+mLrvOdBk9pYMx6e6De7NbOowqkrcvmOPvgX 4t4omX5mmqJmYQOnRDKhD7I/RTgX/Q7oDom0kY1pxHxvau+snDj6/wavl2QtdL1UoPRR YE+cHc5ov2PS8iVRnVi1VhtXtSijyCQFGt6hGvutEwe3OWrcc27aubN2jj6PDWA2BqIY MFXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716580720; x=1717185520; h=content-transfer-encoding:to:content-language:subject:from :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=CGggXJlrg0/mWmDWpDK4vbdxmaqe9IjIWbQQlWw1Cfg=; b=w/uADZWdtB7pxnzqT1EpejC5vsAXefUFZkOgaYlTVTb5RvemcCB81OeP97MO3jYGBJ +Ax1gZln4jtadAWOvIZX+2dHIdGFRLy2bLs1zm80qPEdQ2wAR5vySqr/zignUjc5Hzcu u/+zrHu+8ayS4HNfXQfgFkkSMO9m4xgd+p+tsuFkvOexZB7Ub1tWl6dSYAwDP3toYNEc jAgl3ryHJO96MB12WiFMC5yo1Tiz1b3GpoN9UoBkNlz/XhC9Q8OEb9pgdb6kiw9htvGd vGmUL2rDhvivOmDR/n5T7z9jkw8J3VcCaFq0e2R1PzO7AsliakG/5zfAnImTeDH8h9Dd YuCg== X-Forwarded-Encrypted: i=1; AJvYcCVvDL/tMqNIRLnY4JfshHVySIGtRm4UZtkDqDuS9duOMFLY3TdMSGwhNtG6YT96yXiDsQxb5YyjYqvCpVkS7hvb9Cn1h/NlwQ== X-Gm-Message-State: AOJu0Yz7RHgzlXHUPtxteA9VEB6vuTaG4UoVN7ZKJynSEqae/Qm1WOmZ BEKq7FftMle9cqB4TgIg3y1gr/aCFrqxIHnrwWYRhrmohKK66yQzzJeFLNMUrDo= X-Google-Smtp-Source: AGHT+IHTv0rhMwbk7WUu5XOTH8VhWsf3QyIdPR384EYw6stGrxqe8Xs7rm4ncgPPL3WhH1lBkpQ1gQ== X-Received: by 2002:a05:6000:248:b0:354:f6a9:8f42 with SMTP id ffacd0b85a97d-35526c69ad1mr2539794f8f.39.1716580719872; Fri, 24 May 2024 12:58:39 -0700 (PDT) Received: from ?IPV6:2a00:23c6:88e9:8c01:a4cf:c86c:d8f4:e5b8? ([2a00:23c6:88e9:8c01:a4cf:c86c:d8f4:e5b8]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3557a1c9363sm2282139f8f.72.2024.05.24.12.58.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 May 2024 12:58:39 -0700 (PDT) Message-ID: Date: Fri, 24 May 2024 20:57:49 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Kwok Cheung Yeung Subject: [PATCH 0/3] openmp: Add support for iterators in OpenMP mapping clauses (C/C++) Content-Language: en-GB To: Jakub Jelinek , Tobias Burnus , gcc-patches X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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 series of patches adds support for OpenMP iterators in the 'map' clause of the 'target' construct (and it's derivatives such as 'target enter data'), and the 'to' and 'from' constructs of the 'target update' construct, currently for C and C++ only. The approach in this patch differs from Tobias' WFC patch (https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586237.html) in that it does not rely on generating a callback function - instead, during Gimplification it generates loop(s) to evaluate every iteration of the iterator expression, and the results (i.e. addresses, as the expression should be an lvalue) are placed into a new array. This array is then used as the 'hostaddrs' entry for that particular map. Libgomp detects this (the corresponding size entry is set to SIZE_MAX, which shouldn't normally occur) and inserts the contents of the array into the map information before continuing on as normal. Caveats: - In section 2.21.7.1 of the OpenMP 5.1 standard, it states that 'If an expression that is used to form a list item in a map clause contains an iterator identifier, the list item instances that would result from different values of the iterator must not have the same containing array and must not have base pointers that share original storage' - this is currently not enforced (it would prohibit something like map (iterator(i=0:10), to: x[i]) while x is an int[]). As the expression in the iterator is more-or-less unbound, it would be very difficult to determine this at compile time. At runtime in libgomp, I suppose we could check every iterator-derived mapping to ensure that they all access unique entries in mem_map? - The clause finishing currently generates spurious firstprivate maps - the patch currently just ignores them when in iterator clauses, but is there a better way of doing this? - Clause reordering does not work too well with iterators. I believe the current approach to reordering on trunk is a bit buggy in the first place, so I just added enough to get the clauses through the pass without ICEing. The GCC gomp tests and all the libgomp tests have been run without regressions on an x86-64 host with NVPTX offloading. Testing on AMD GCN to follow. Kwok