From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [170.10.133.74]) by sourceware.org (Postfix) with ESMTPS id 2B8343858434 for ; Thu, 5 May 2022 09:51:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B8343858434 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-540-kZocdLx9PXyi__1aJCCygA-1; Thu, 05 May 2022 05:51:27 -0400 X-MC-Unique: kZocdLx9PXyi__1aJCCygA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A3563C138A9; Thu, 5 May 2022 09:51:27 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C6AF340D1B9E; Thu, 5 May 2022 09:51:26 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 2459pOwZ1706674 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 5 May 2022 11:51:24 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 2459pNEh1706673; Thu, 5 May 2022 11:51:23 +0200 Date: Thu, 5 May 2022 11:51:22 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: Marcel Vollweiler , Tobias Burnus , gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: Re: [Patch] OpenMP, libgomp: Add new runtime routine omp_target_is_accessible. Message-ID: Reply-To: Jakub Jelinek References: <7fa4a70c-60e7-fa18-0fcd-98301c0b3344@codesourcery.com> <1b53e970-a0a7-66bc-4b2e-828e881cce73@codesourcery.com> <31be8262-626b-e3be-60d8-14bdf2911f64@codesourcery.com> <7dec977d-8ef7-e028-d1f8-2b2d21d75795@mentor.com> MIME-Version: 1.0 In-Reply-To: <7dec977d-8ef7-e028-d1f8-2b2d21d75795@mentor.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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:51:34 -0000 On Thu, May 05, 2022 at 11:45:19AM +0200, Tobias Burnus wrote: > > On Mon, Mar 14, 2022 at 04:42:14PM +0100, Marcel Vollweiler wrote: > > > + interface > > > + function omp_target_is_accessible (ptr, size, device_num) bind(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' != '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 "/= 0" is ugly! Yeah, but for the APIs that don't have any iso_c_binding arguments we just use wrappers rather than bind(c) and it allows for more Fortran-like callers. So, if omp_target_is_accessible had the *_ wrapper (or alias if we determine logical ir the same as c_int in the ABI passing), people could avoid the /= 0 stuff. Anyway, that is just a thought for future APIs that if they return false/true only bind(c) isn't always a good idea. Jakub