This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] add support for placing variables in shared memory
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: Nathan Sidwell <nathan at acm dot org>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 22 Apr 2016 17:04:52 +0300 (MSK)
- Subject: Re: [PATCH] add support for placing variables in shared memory
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LNX dot 2 dot 20 dot 1604201957570 dot 14803 at monopod dot intra dot ispras dot ru> <5718DCF0 dot 5000808 at acm dot org> <alpine dot LNX dot 2 dot 20 dot 1604211708150 dot 20393 at monopod dot intra dot ispras dot ru> <571A226B dot 9020906 at acm dot org>
On Fri, 22 Apr 2016, Nathan Sidwell wrote:
> On 04/21/16 10:25, Alexander Monakov wrote:
> > On Thu, 21 Apr 2016, Nathan Sidwell wrote:
> > > What is the rationale for a new attribute, rather than leveraging the
> > > existing section(".shared") machinery?
> >
> > Section switching does not work at all on NVPTX in GCC at present. PTX
> > assembly has no notion of different data sections, so the backend does not
> > advertise section switching capability to the middle end.
>
> Correct. How is that relevant? Look at DECL_SECTION_NAME in
> encode_section_info.
Middle end rejects the "section" attribute:
echo 'int v __attribute__((section("foo")));' |
x86_64-pc-linux-gnu-accel-nvptx-none-gcc -xc - -o /dev/null
<stdin>:1:5: error: section attributes are not supported for this target
> > I avoided using 'static' because it applies to external declarations as
> > well.
> > Other backends use "%qE attribute not allowed with auto storage class"; I'll
> > be happy to switch to that for consistency.
>
>
> Why can it not be applied to external declarations? Doesn't '.extern .shared
> whatever' work?
It can and it does; the point was to avoid ambiguity; the precise variable
class would be 'variables with static storage duration' (doesn't matter with
external or internal linkage, defined or declared), but due to possible
confusion with variables declared with 'static' keyword, it's useful to avoid
that wording.
> Why can it not apply to variables of auto storage? I.e. function scope,
> function lifetime? That would seem to be a useful property.
Because PTX does not support auto storage semantics for .shared data. It's
statically allocated at link time.
> What happens if an initializer is present, is it silently ignored?
GCC accepts and reemits it in assembly output (if non-zero), and ptxas rejects
it ("syntax error").
Alexander