From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <Tobias_Burnus@mentor.com>
Cc: Marcel Vollweiler <marcel@codesourcery.com>,
Tobias Burnus <tobias@codesourcery.com>,
gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org
Subject: Re: [Patch] OpenMP, libgomp: Add new runtime routine omp_target_is_accessible.
Date: Thu, 5 May 2022 11:51:22 +0200 [thread overview]
Message-ID: <YnOeGu5OyNtk0KKI@tucnak> (raw)
In-Reply-To: <7dec977d-8ef7-e028-d1f8-2b2d21d75795@mentor.com>
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
next prev parent reply other threads:[~2022-05-05 9:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 12:30 Marcel Vollweiler
2022-03-11 14:12 ` Tobias Burnus
2022-03-14 15:42 ` Marcel Vollweiler
2022-05-05 9:33 ` Jakub Jelinek
2022-05-05 9:45 ` Tobias Burnus
2022-05-05 9:51 ` Jakub Jelinek [this message]
2022-05-06 11:14 ` Marcel Vollweiler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YnOeGu5OyNtk0KKI@tucnak \
--to=jakub@redhat.com \
--cc=Tobias_Burnus@mentor.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=marcel@codesourcery.com \
--cc=tobias@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).