[{"id":3676616,"web_url":"http://patchwork.ozlabs.org/comment/3676616/","msgid":"<b2f85e05-cbac-4e46-8d98-52face33fdae@baylibre.com>","list_archive_url":null,"date":"2026-04-13T09:52:36","subject":"Re: [PATCH] libgomp: fix omp_target_is_present and\n omp_get_mapped_ptr: Fix up 'libgomp.c/omp_target_is_present.c'","submitter":{"id":87873,"url":"http://patchwork.ozlabs.org/api/people/87873/","name":"Tobias Burnus","email":"tburnus@baylibre.com"},"content":"Thomas Schwinge wrote:\n> It's probably a general issue that we don't 'omp_target_disassociate_ptr' after\n> 'omp_target_associate_ptr', but in a multi-device setting, this results in an\n> execution test FAIL.\n\nI had expected that it would just work with some stale device data until\nthe program ends - similar to 'target enter data' without 'target exit data',\nbut it definitely makes sense to clean up afterwards - and it seems as if\nit makes here a difference - even though I fail to see why. (But I didn't try\nhard to understand it.)\n\nIn terms of the spec: it requires that the lifetime of a host variable\nis at least as long as the one of the mapped variable, i.e. a conforming\nprogram definitely needs to do this. - 'B' is located on the stack.\n\n* * *\n\n> --- a/libgomp/testsuite/libgomp.c/omp_target_is_present.c\n> +++ b/libgomp/testsuite/libgomp.c/omp_target_is_present.c\n> @@ -180,6 +180,9 @@ void check_routines (int dev)\n> +  if (!!omp_target_disassociate_ptr (&B, dev)\n> +      != (self_mapping || initial_dev || invalid_dev))\n> +    __builtin_abort ();\n\nEffectively, this change is fine (LGTM) - at least in the\nGCC implementation.\n\nFormally, there is the issue that\n\"A call to this routine on a pointer that is not NULL and does\n  not have associated data on the given device results in\n  unspecified behavior.\"\nAnd as &B != NULL and no associated memory is created on the\ninitial device, for omp_invalid_device and with self mapping,\nthere is UB.\n\nHowever, GCC's routine checks whether there is an assoc pointer,\nif not or the device is invalid, it returns EINVAL. Thus, in terms\nof GCC (and as used), there should be IMHO no unspecified behavior.\n\nThus: LGTM.\n\nTobias","headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=baylibre-com.20251104.gappssmtp.com\n header.i=@baylibre-com.20251104.gappssmtp.com header.a=rsa-sha256\n header.s=20251104 header.b=TXHj0cQA;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=baylibre-com.20251104.gappssmtp.com\n header.i=@baylibre-com.20251104.gappssmtp.com header.a=rsa-sha256\n header.s=20251104 header.b=TXHj0cQA","sourceware.org;\n dmarc=none (p=none dis=none) header.from=baylibre.com","sourceware.org; spf=pass smtp.mailfrom=baylibre.com","server2.sourceware.org;\n arc=none smtp.remote-ip=209.85.221.49"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvN520dd0z1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 19:53:10 +1000 (AEST)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 408B14BA2E10\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 09:53:08 +0000 (GMT)","from mail-wr1-f49.google.com (mail-wr1-f49.google.com\n [209.85.221.49])\n by sourceware.org (Postfix) with ESMTPS id E625D4BA2E04\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 09:52:38 +0000 (GMT)","by mail-wr1-f49.google.com with SMTP id\n ffacd0b85a97d-43cf5ad500fso3588371f8f.0\n for <gcc-patches@gcc.gnu.org>; Mon, 13 Apr 2026 02:52:38 -0700 (PDT)","from ?IPV6:2001:16b8:3d98:8500:86f7:ef:2f3a:3118?\n ([2001:16b8:3d98:8500:86f7:ef:2f3a:3118])\n by smtp.gmail.com with ESMTPSA id\n ffacd0b85a97d-43d63e5061fsm32254817f8f.30.2026.04.13.02.52.36\n (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n Mon, 13 Apr 2026 02:52:37 -0700 (PDT)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 408B14BA2E10","OpenDKIM Filter v2.11.0 sourceware.org E625D4BA2E04"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org E625D4BA2E04","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org E625D4BA2E04","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1776073959; cv=none;\n b=HX91sOav+CTdG8Ychsj2kNluF8sOM/JVjQAdueJH129sXVMyXyF52+xyOQujPE3PnKWC27l4/7AHqD1sjoehiCvJAox/+CHBqvzOAEvTyRYTtY9Z2yfqF0ydxGVP1mZ2XRDbJtRZpiWmQiKX6I7LED+Mto5bcBGskYMgGvOpfwE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1776073959; c=relaxed/simple;\n bh=Xv3Txp6BuMPL9CxE+jFwRjaB/JpAUZJylt5LTsivwkQ=;\n h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From;\n b=Tmq6wt35HGSP73ZQVMI17eABWm9ZU0Q6w54dledF3NrOz6dsd8Vh345/ov3JQsUM+48h1ErrhplW7hA0t4BjDsDvZ7MSdXANk1sGTD3ba99GJ0aP4Tn8i7Q1rTPTePVlTzI7rG8U1gIMfjfU4ykS27vhJ8+iKDip49K49NkhWkM=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=baylibre-com.20251104.gappssmtp.com; s=20251104; t=1776073958;\n x=1776678758;\n darn=gcc.gnu.org;\n h=in-reply-to:from:content-language:references:to:subject:user-agent\n :mime-version:date:message-id:from:to:cc:subject:date:message-id\n :reply-to; bh=dgHXQt1gdLTiqsgbTOeN8Y0pPLwJM9r9OT2D9GBoqnw=;\n b=TXHj0cQAsXxlBo37LA6sfDhWqvOOnMpTrX650uZ2iaBBYL25fv+m0fTXEfdraDeXiH\n zuBTwsfpHgr5HSnT3FjO8NyIU+BHn6ZXan6KOsR5z6p+XBAq35lvN4TH7WUKlz0pAfHb\n BcOIuPWKQhTs1dmPPXSvAuXn7OZh3QTUtBluEsNpn3Wv7N261eq3u1IOiWCKCntzfUsb\n VhihaAEW41miH1k4IdknUEBFBgfJYkP84dmhClFuPV0U8zcDrhqTbMzMaVg++eD06xoc\n NQW4fwk4GWGG1V5/16SRsoZFHp6dvfpM8jfcgobEG+mW/2Zgs9JD4tRyefjyG9KwM/iT\n 3QHA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776073958; x=1776678758;\n h=in-reply-to:from:content-language:references:to:subject:user-agent\n :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=dgHXQt1gdLTiqsgbTOeN8Y0pPLwJM9r9OT2D9GBoqnw=;\n b=slLV+k8uGF7l/1Z1XS99abSzvopdXZ5lPYqFzubizLEEQQ/jIaKllvYiWdhvQFsP2h\n tGAtppwyD1QcztYp+ky14cDg9gVn3llWQ7a5tx4ktQWKGtLJ5UClFnqew9IjVLdKMljd\n kHYIv0haSyYOWGA2GbwBw+ascTV9sznBru1JNK+ZumdHupNKaSPBhfGbW21S12wj+cSG\n Vr8O+u1Af/PieC+LmX8FYFNH/PKi0zSk73wBLDrfkSIsBNYzVBnzuwG3ase+pyukLlsf\n 6iWGROoD5P1xKCg+3QWtlGAeW3yeoBs82q3W1FDjbGD5KZJwa2rQjRMMTc619mZyjGhS\n 7pIg==","X-Forwarded-Encrypted":"i=1;\n AFNElJ92rn0jOqpYz+vkRKkEtSEndgeU8XQrWv9hsJb2/+qz+L2po/2xW5oUx61SSj5+TBCwxmrXZVqVnDPQGA==@gcc.gnu.org","X-Gm-Message-State":"AOJu0Yxx0LlgENNN+crtwlu7nCiwHVRgKhE9BaPSbwkUC2hXMGgRLWMK\n 8ENqlz+na9OaHjo6wDCxDk+ETCJBWlPr7flOaJ8sWc7AkbsnJv8uG0erqq8dWNcSoLY=","X-Gm-Gg":"AeBDievNAEHktZ8kjBKV0DyLTr63+m8Wxigm1b5dgPIuVtJp7LYlNvsjgZBKcpK4CFV\n 8Hjd7O+gjovTxDdDFaZKKhOxw98rZNxRjJeAZkrw4aR5lZJhywKSdwxmih0tcynZMznvjh3oVCI\n lNfgZi4Jrn3YKdxRCdSMNATakulFgpGQSQskSQ/V9zKLp+3bxWeVOlBK6exCDgbaymR6Dyi72Hi\n 8gPCRnq7ty10qCPCzz5kUdld4BilfPcRpyXZiDUCeM89rFTWTOWY8SgBfhYZ2Uuuek3CzYNZAbN\n HbeXy2rTB0jaGAQ/VaZw0+kGAeAKU/u1msFEuSW9gPpiv2UktIKIdHCjr0DL6apYxFK2NzN1oXu\n pKejn9mTf6prPxy1tMSTu8BZ2Q/5b9L+wcy5ViDVV2c4B3YGXfvMftcOnmpeBUL1qJLQmVINcS5\n C/cbVxMyro4Iiw8nMF71ocsO8WUgh8kYz8pv1cIWUWXbsBhgGBURQoyV0NtTVIvMOX5n/K","X-Received":"by 2002:a05:6000:22c5:b0:43d:73ff:fd59 with SMTP id\n ffacd0b85a97d-43d73fffe60mr7489004f8f.10.1776073957717;\n Mon, 13 Apr 2026 02:52:37 -0700 (PDT)","Content-Type":"multipart/alternative;\n boundary=\"------------Uro0XMFtg0JENeB1ShHvfAqv\"","Message-ID":"<b2f85e05-cbac-4e46-8d98-52face33fdae@baylibre.com>","Date":"Mon, 13 Apr 2026 11:52:36 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH] libgomp: fix omp_target_is_present and\n omp_get_mapped_ptr: Fix up 'libgomp.c/omp_target_is_present.c'","To":"Thomas Schwinge <tschwinge@baylibre.com>, gcc-patches@gcc.gnu.org","References":"<2cdb2430-557a-447f-b6da-27ce2373194f@baylibre.com>\n <20260410150506.2397157-1-tschwinge@baylibre.com>","Content-Language":"en-US","From":"Tobias Burnus <tburnus@baylibre.com>","In-Reply-To":"<20260410150506.2397157-1-tschwinge@baylibre.com>","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"}}]