From: Tobias Burnus <tobias@codesourcery.com>
To: Thomas Schwinge <thomas@codesourcery.com>,
Hafiz Abid Qadeer <abidh@codesourcery.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
Tobias Burnus <tobias@codesourcery.com>,
<gcc-patches@gcc.gnu.org>, <fortran@gcc.gnu.org>
Subject: Re: [PATCH] [gfortran] Add support for allocate clause (OpenMP 5.0).
Date: Fri, 21 Jan 2022 18:43:45 +0100 [thread overview]
Message-ID: <48d8c123-fa4f-d4a3-17de-b082de32f0bf@codesourcery.com> (raw)
In-Reply-To: <8735lh6mcx.fsf@euler.schwinge.homeip.net>
On 21.01.22 18:15, Thomas Schwinge wrote:
> source-gcc/libgomp/testsuite/libgomp.fortran/allocate-1.f90:11:47:
>
> 11 | integer(c_int) function is_64bit_aligned (a) bind(C)
> | 1
> Warning: Variable ‘a’ at (1) is a dummy argument of the BIND(C) procedure ‘is_64bit_aligned’ but may not be C interoperable [-Wc-binding-type]
>
> Is that something to worry about?
I think it is not very elegant – but should be okay.
On the Fortran side:
integer(c_int) function is_64bit_aligned (a) bind(C)
import :: c_int
integer :: a
end
that matches 'int is_64bit_aligned (int *a);'
While 'integer' in principle may not be 'int',
the call by reference makes this independent of the
actually used integer kind.
HOWEVER: That interface it not used! While it
defines that interface in 'module m', there is
no 'use m' in 'subroutine foo'.
(or alternatively: 'foo' being after 'contains' inside
the 'module m' - and then 'use m' in the main program)
That means that 'is_64bit_aligned(...)' gets implicitly
types as 'integer' with unknown arguments, which get
passed by value. By gfortran convention, that function
has a tailing underscore.
That matches the C side, which such an underscore:
int
is_64bit_aligned_ (uintptr_t a)
{
return ( (a & 0x3f) == 0);
}
With pass by reference, a pointer is passed, which
should be handled by 'uintptr_t'.
* * *
Side remark: I really recommend 'implicit none'
when writing Fortran code - which disables implicit
typing. I personally have started to use
implicit none (type, external)
which also rejects 'call something()' unless
'something' has been explicitly declared, e.g. by
an interface block.
* * *
Side remark: A Fortran-only variant has been used in
libgomp/testsuite/libgomp.fortran/alloc-11.f90:
if (mod (TRANSFER (p, iptr), 64) /= 0)
As optimization, also 'iand(..., z'3f') == 0' would work ;-)
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
next prev parent reply other threads:[~2022-01-21 17:43 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20211022130502.2211568-1-abidh@codesourcery.com>
2021-10-22 13:28 ` Tobias Burnus
[not found] ` <20211102162714.GF304296@tucnak>
[not found] ` <e3c9083c-0906-699a-b437-84a49ece33b8@mentor.com>
[not found] ` <20211220200650.GN2646553@tucnak>
[not found] ` <fddcdfcf-3fab-1674-722e-2756a1d6aef8@mentor.com>
2022-01-14 9:10 ` Thomas Schwinge
2022-01-14 11:45 ` Tobias Burnus
2022-01-14 11:55 ` Jakub Jelinek
2022-01-14 12:20 ` Tobias Burnus
2022-01-17 14:01 ` Hafiz Abid Qadeer
2022-01-21 17:15 ` Thomas Schwinge
2022-01-21 17:43 ` Tobias Burnus [this message]
2022-01-24 8:45 ` Tobias Burnus
2022-01-24 12:54 ` Hafiz Abid Qadeer
2022-01-25 9:19 ` Thomas Schwinge
2022-01-25 10:32 ` Tobias Burnus
2022-01-31 19:13 ` Hafiz Abid Qadeer
2022-02-04 9:46 ` Thomas Schwinge
2022-02-04 11:25 ` Hafiz Abid Qadeer
2022-02-05 19:09 ` Hafiz Abid Qadeer
2022-02-16 10:29 ` Hafiz Abid Qadeer
2022-02-04 9:37 ` Thomas Schwinge
2022-02-04 13:57 ` [committed] libgomp.fortran/allocate-1.f90: Minor cleanup (was: Re: [PATCH] [gfortran] Add support for allocate clause (OpenMP 5.0).) Tobias Burnus
2022-02-04 15:33 ` Thomas Schwinge
2022-02-04 16:34 ` Tobias Burnus
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=48d8c123-fa4f-d4a3-17de-b082de32f0bf@codesourcery.com \
--to=tobias@codesourcery.com \
--cc=abidh@codesourcery.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=thomas@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).