From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id C41B43857018; Thu, 5 May 2022 09:45:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C41B43857018 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.91,200,1647331200"; d="scan'208";a="75364929" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 05 May 2022 01:45:24 -0800 IronPort-SDR: JBj9nXydLVRru+TziCF8sw4hI2JG6HGRZVFBubfQP0SjkVDXz6jFNqxIi0F1xsbaWPHTE7/swY TGZ1LyxYRr/eDk+NyqhDd7jitUPpqeoBXjRFE6AwstCoxoJ0PKt3J6bkFFWbF6FU71j6louwD7 PNoyFWg/6jli9DcbDX76vahrMLyVb52BtjVyiJVUmZNnd1WIaPatFVENtB//hIn060bEUKUBoG MeduB91CwSTH+NHc5l0K9QTnnOA0m/v5viz+wmZFwkwo80PV9kAniut64ml4kTqv96nK+mlH4x 0Bc= Message-ID: <7dec977d-8ef7-e028-d1f8-2b2d21d75795@mentor.com> Date: Thu, 5 May 2022 11:45:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [Patch] OpenMP, libgomp: Add new runtime routine omp_target_is_accessible. Content-Language: en-US To: Jakub Jelinek , Marcel Vollweiler CC: Tobias Burnus , , References: <7fa4a70c-60e7-fa18-0fcd-98301c0b3344@codesourcery.com> <1b53e970-a0a7-66bc-4b2e-828e881cce73@codesourcery.com> <31be8262-626b-e3be-60d8-14bdf2911f64@codesourcery.com> From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, 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: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 May 2022 09:45:27 -0000 Hi, On 05.05.22 11:33, Jakub Jelinek via Gcc-patches wrote: > On Mon, Mar 14, 2022 at 04:42:14PM +0100, Marcel Vollweiler wrote: >> + interface >> + function omp_target_is_accessible (ptr, size, device_num) bin= d(c) >> + use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t, c_= int >> + integer(c_int) :: omp_target_is_accessible > The function returning integer(c_int) rather than logical seems like > a screw up in the standard, but too late to fix that :(. I think the idea is that it can directly call the C function without needing a wrapper. And as default-kind 'logical' !=3D 'integer(c_int)' in general, it cannot return logical. (In case of GCC, just claiming that it is logical would work. But some Fortran compilers use -1 for .true. and only flip a single bit for .not. For those, "if(.not.omp_target_is_accessible(..)) will not work properly, if the C function returns 1. But I concur that requiring "/=3D 0" is ugly! > OT, tried to look how libomptarget implements it and they don't at least > on llvm-project trunk, but while looking at that, noticed that for > omp_target_is_present they do return false from omp_target_is_present > while we return true. It is unclear if NULL has corresponding storage > on the device (NULL always corresponds to NULL on the device) or not. Regarding NULL: no idea what's the best semantic =E2=80=93 we could ask for clarification. Regarding target: I think "false" from on device makes more sense in general, especially if the device number points to a different device. It might work in some cases =E2=80=93 but false simply plays save. Note that the spec states: "When called from within a target region the effect is unspecified." Thus, either behavior is fine. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955