public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Dave Love via Fortran <fortran@gcc.gnu.org>
Cc: rep.dot.nop@gmail.com, Dave Love <dave.love@manchester.ac.uk>
Subject: Re: adding attributes
Date: Sun, 30 Oct 2022 08:48:39 +0100	[thread overview]
Message-ID: <20221030084839.118ef0c8@nbbrfq> (raw)
In-Reply-To: <87pmecdni6.fsf@manchester.ac.uk>

On Fri, 28 Oct 2022 15:35:45 +0100
Dave Love via Fortran <fortran@gcc.gnu.org> wrote:

> Assuming there's no technical reason not to, can someone say what would
> be involved in adding relevant attributes (at least function ones) like
> those for C?  I'm thinking particularly of target_clones, but others
> probably make sense.

Well we already have
!GCC$ ATTRIBUTES attribute-list :: var-name [, var-name] ...

See https://gcc.gnu.org/onlinedocs/gfortran/ATTRIBUTES-directive.html

> 
> I don't know my way around, but I had a quick look, and it at least
> wouldn't be as straightforward as I hoped.

See gcc/fortran/decl.cc gfc_match_gcc_* 

For example the CDECL attribute probably comes close to target_clones:
subroutine mysub1()
!GCC$ ATTRIBUTES CDECL :: mysub1
! body of mysub1 here

For target_clones you would most likely need a slightly different parser
for you need the user to specify the actual target_clones somehow. You
would probably make a suggestion and discuss the proposal here.
Ideally the syntax would be the same as in C.

Finally you would have to lower the target_clones, not sure offhand who
creates the ifunc dispatcher, the frontend or the middle-end. There is
expand_target_clones in gcc/multiple_target.cc that probably comes into play.
So yes, that seems to create the ifuncs if i read that correctly.
Hence the implementation in the frontend should not be all too
complicated, it seems.

To your initial remark about a technical reason not to support it i
would point you to what Tobias said to me some time ago and which i
certainly told other people more than once, too:
https://patchwork.ozlabs.org/comment/958570/
---8<---
In general, I prefer to stick to standard methods
(which are portable) and think that those user knobs often make things
slower than faster (as they tend to stay for years, even after the hard-
ware as moved on - or they are even inserted blindly).
---8<---

In former times, you would compile your library multiple times
and provide a distinct, optimized version for each of the CPUs.
Maybe that would work for you equally well, without target_clones?

HTH

  reply	other threads:[~2022-10-30  7:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 14:35 Dave Love
2022-10-30  7:48 ` Bernhard Reutner-Fischer [this message]
2022-10-31 21:19   ` Dave Love
2022-11-02 23:19     ` Bernhard Reutner-Fischer
2022-11-04 20:59       ` Bernhard Reutner-Fischer
2022-11-05  7:40         ` Thomas Koenig
2022-11-05 10:54           ` Bernhard Reutner-Fischer
2022-11-06 13:44             ` Thomas Koenig
2022-11-07 11:06               ` Dave Love
2023-02-24 12:24             ` Dave Love
2022-11-07 11:04       ` Dave Love
2022-11-10 12:25         ` Bernhard Reutner-Fischer

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=20221030084839.118ef0c8@nbbrfq \
    --to=rep.dot.nop@gmail.com \
    --cc=dave.love@manchester.ac.uk \
    --cc=fortran@gcc.gnu.org \
    /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).