[PTX] Add support for CUDA 9

Message ID 002bf03f-baad-5809-6e9a-2fdffa0c1e2c@codesourcery.com
State New
Headers show
Series
  • [PTX] Add support for CUDA 9
Related show

Commit Message

Cesar Philippidis Dec. 19, 2017, 11:25 p.m.
In CUDA 9, Nvidia removed support for treating the labels of functions
as generic address spaces as part of their PTX 6.0 changes. More
specifically,
<http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#changes-in-ptx-isa-version-6-0>:

  Support for taking address of labels, using labels in initializers
  which was unimplemented has been removed from the spec.

Despite targeting PTX 3.0, the ptxas assembler shipped with CUDA 9 no
longer support that legacy functionality. Consequently, this prevented
newlib from building. This patch fixes that problem by not using a
generic address space when initializing variables using a label address.

Is this OK for trunk?

Thanks,
Cesar

Comments

Tom de Vries Dec. 20, 2017, 12:39 a.m. | #1
On 12/20/2017 12:25 AM, Cesar Philippidis wrote:
> In CUDA 9, Nvidia removed support for treating the labels of functions

> as generic address spaces as part of their PTX 6.0 changes. More

> specifically,

> <http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#changes-in-ptx-isa-version-6-0>:

> 

>    Support for taking address of labels, using labels in initializers

>    which was unimplemented has been removed from the spec.

> 

> Despite targeting PTX 3.0, the ptxas assembler shipped with CUDA 9 no

> longer support that legacy functionality. Consequently, this prevented

> newlib from building. This patch fixes that problem by not using a

> generic address space when initializing variables using a label address.

> 


What is the effect for pre-9.0 cudas?

> Is this OK for trunk?

> 


How did you test this?

> Thanks,

> Cesar

> 

> 

> og7-ptx-cuda9.diff

> 

> 

> 2017-12-19  Cesar Philippidis  <cesar@codesourcery.com>

> 

> 	gcc/

> 	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address

> 	spaces for function labels.

> 

> 	gcc/testsuite/

> 	* gcc.target/nvptx/indirect_call.c: New test.

> 

> 

> diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c

> index dfb27ef..a7b4c09 100644

> --- a/gcc/config/nvptx/nvptx.c

> +++ b/gcc/config/nvptx/nvptx.c

> @@ -1894,9 +1894,15 @@ output_init_frag (rtx sym)

>     

>     if (sym)

>       {

> -      fprintf (asm_out_file, "generic(");

> +      bool function = SYMBOL_REF_DECL (sym)

> +	&& (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL);


Please indent using parentheses like this:

bool function = (SYMBOL_REF_DECL (sym)
                  && (TREE_CODE (SYMBOL_REF_DECL (sym)) == ...));


> +      if (!function)

> +	fprintf (asm_out_file, "generic(");

>         output_address (VOIDmode, sym);

> -      fprintf (asm_out_file, val ? ") + " : ")");

> +      if (!function)

> +	fprintf (asm_out_file, val ? ") + " : ")");

> +      else if (val)

> +	fprintf (asm_out_file, " + ");



Please use:

       if (!function)
	fprintf (asm_out_file, ")");
       if (val)
	fprintf (asm_out_file, " + ");

>       }

>   

>     if (!sym || val)

> diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> new file mode 100644

> index 0000000..39992a7

> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> @@ -0,0 +1,19 @@

> +/* { dg-options "-O2 -msoft-stack" } */

> +/* { dg-do run } */

> +

> +int

> +f1 (int a)

> +{

> +  return a + 1;

> +}

> +

> +int (*f2)(int) = f1;

> +

> +int

> +main ()

> +{

> +  if (f2 (100) != 101)

> +    __builtin_abort();

> +

> +  return 0;

> +}

>
Cesar Philippidis Dec. 20, 2017, 10:59 p.m. | #2
On 12/19/2017 04:39 PM, Tom de Vries wrote:
> On 12/20/2017 12:25 AM, Cesar Philippidis wrote:

>> In CUDA 9, Nvidia removed support for treating the labels of functions

>> as generic address spaces as part of their PTX 6.0 changes. More

>> specifically,

>> <http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#changes-in-ptx-isa-version-6-0>:

>>

>>

>>    Support for taking address of labels, using labels in initializers

>>    which was unimplemented has been removed from the spec.

>>

>> Despite targeting PTX 3.0, the ptxas assembler shipped with CUDA 9 no

>> longer support that legacy functionality. Consequently, this prevented

>> newlib from building. This patch fixes that problem by not using a

>> generic address space when initializing variables using a label address.

>>

> 

> What is the effect for pre-9.0 cudas?


No change in the libgomp execution test suite as an accelerator.

>> Is this OK for trunk?

>>

> 

> How did you test this?


Just libgomp as an accelerator for now. I'm trying to get standalone
nvptx working right now. Which testsuites do you usually run? I only see
the test results for check-gcc-c in your nightly build bot.

By the way, do you know what caused the recent nvptx breakage in trunk?

Cesar
Tom de Vries Dec. 20, 2017, 11:15 p.m. | #3
On 12/20/2017 11:59 PM, Cesar Philippidis wrote:
> On 12/19/2017 04:39 PM, Tom de Vries wrote:

>> On 12/20/2017 12:25 AM, Cesar Philippidis wrote:

>>> In CUDA 9, Nvidia removed support for treating the labels of functions

>>> as generic address spaces as part of their PTX 6.0 changes. More

>>> specifically,

>>> <http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#changes-in-ptx-isa-version-6-0>:

>>>

>>>

>>>     Support for taking address of labels, using labels in initializers

>>>     which was unimplemented has been removed from the spec.

>>>

>>> Despite targeting PTX 3.0, the ptxas assembler shipped with CUDA 9 no

>>> longer support that legacy functionality. Consequently, this prevented

>>> newlib from building. This patch fixes that problem by not using a

>>> generic address space when initializing variables using a label address.

>>>

>>

>> What is the effect for pre-9.0 cudas?

> 

> No change in the libgomp execution test suite as an accelerator.

> 

>>> Is this OK for trunk?

>>>

>>

>> How did you test this?

> 

> Just libgomp as an accelerator for now. I'm trying to get standalone

> nvptx working right now.


Indeed, you should test that as well, both with 9.0 and pre 9.0 cuda.

> Which testsuites do you usually run? I only see

> the test results for check-gcc-c in your nightly build bot.

> 


The gcc test suite should be enough.

Thanks,
- Tom
Cesar Philippidis Dec. 21, 2017, 5:19 p.m. | #4
On 12/20/2017 03:15 PM, Tom de Vries wrote:
> On 12/20/2017 11:59 PM, Cesar Philippidis wrote:

>> On 12/19/2017 04:39 PM, Tom de Vries wrote:

>>> On 12/20/2017 12:25 AM, Cesar Philippidis wrote:

>>>> In CUDA 9, Nvidia removed support for treating the labels of functions

>>>> as generic address spaces as part of their PTX 6.0 changes. More

>>>> specifically,

>>>> <http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#changes-in-ptx-isa-version-6-0>:

>>>>

>>>>

>>>>

>>>>     Support for taking address of labels, using labels in initializers

>>>>     which was unimplemented has been removed from the spec.

>>>>

>>>> Despite targeting PTX 3.0, the ptxas assembler shipped with CUDA 9 no

>>>> longer support that legacy functionality. Consequently, this prevented

>>>> newlib from building. This patch fixes that problem by not using a

>>>> generic address space when initializing variables using a label

>>>> address.

>>>>

>>>

>>> What is the effect for pre-9.0 cudas?

>>

>> No change in the libgomp execution test suite as an accelerator.

>>

>>>> Is this OK for trunk?

>>>>

>>>

>>> How did you test this?

>>

>> Just libgomp as an accelerator for now. I'm trying to get standalone

>> nvptx working right now.

> 

> Indeed, you should test that as well, both with 9.0 and pre 9.0 cuda.

> 

>> Which testsuites do you usually run? I only see

>> the test results for check-gcc-c in your nightly build bot.

>>

> 

> The gcc test suite should be enough.


My test results are somewhat inconsistent. On MG's build servers, there
are no regressions in CUDA 8. On my laptop, there are fewer regressions
in CUDA 9, than CUDA 8. However, I think some of those failures are due
to premature timeouts on my laptop (I'm setting dejagnu to timeout after
90s instead of 5m locally).

I know your on vacation, so I'll commit this patch to og7. We can
revisit the patch for trunk and other backports later.

Thanks,
Cesar
Tom de Vries Dec. 27, 2017, 9:16 a.m. | #5
On 12/21/2017 06:19 PM, Cesar Philippidis wrote:
> My test results are somewhat inconsistent. On MG's build servers, there

> are no regressions in CUDA 8. 


Ack.

> On my laptop, there are fewer regressions

> in CUDA 9, than CUDA 8.


If the patch causes regressions for either cuda 8 or cuda 9, then they 
need to be analyzed and fixed.

Please clarify what you think it means if in one case there are less 
regressions than in the other.

> However, I think some of those failures are due

> to premature timeouts on my laptop (I'm setting dejagnu to timeout after

> 90s instead of 5m locally).


If you have flawed test results due to a local change you made, you need 
to undo the local change and rerun the test, and report the sane test 
results instead of reporting flawed test results.

> I know your on vacation, so I'll commit this patch to og7. We can

> revisit the patch for trunk and other backports later.


If you don't have time to do the testing now, then please file a PR for 
this issue and attach the patch with the updates that address my comments.

Thanks,
- Tom
Cesar Philippidis Jan. 17, 2018, 5:29 p.m. | #6
On 12/27/2017 01:16 AM, Tom de Vries wrote:
> On 12/21/2017 06:19 PM, Cesar Philippidis wrote:

>> My test results are somewhat inconsistent. On MG's build servers, there

>> are no regressions in CUDA 8. 

> 

> Ack.

> 

>> On my laptop, there are fewer regressions

>> in CUDA 9, than CUDA 8.

> 

> If the patch causes regressions for either cuda 8 or cuda 9, then they

> need to be analyzed and fixed.

> 

> Please clarify what you think it means if in one case there are less

> regressions than in the other.

> 

>> However, I think some of those failures are due

>> to premature timeouts on my laptop (I'm setting dejagnu to timeout after

>> 90s instead of 5m locally).

> 

> If you have flawed test results due to a local change you made, you need

> to undo the local change and rerun the test, and report the sane test

> results instead of reporting flawed test results.

> 

>> I know your on vacation, so I'll commit this patch to og7. We can

>> revisit the patch for trunk and other backports later.

> 

> If you don't have time to do the testing now, then please file a PR for

> this issue and attach the patch with the updates that address my comments.


Sorry for taking so long to respond. I finally had a chance to analyze
the results. There are no regressions with this patch. In fact, using
the unpatched CUDA8 build as a baseline, after the CUDA9 patch, 66
additional tests pass in CUDA 8 and 73 tests additional tests pass in
CUDA 9.

Is this patch OK for trunk?

Cesar
2017-12-19  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address
	spaces for function labels.

	gcc/testsuite/
	* gcc.target/nvptx/indirect_call.c: New test.


diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index dfb27ef..a7b4c09 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -1894,9 +1894,15 @@ output_init_frag (rtx sym)
   
   if (sym)
     {
-      fprintf (asm_out_file, "generic(");
+      bool function = SYMBOL_REF_DECL (sym)
+	&& (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL);
+      if (!function)
+	fprintf (asm_out_file, "generic(");
       output_address (VOIDmode, sym);
-      fprintf (asm_out_file, val ? ") + " : ")");
+      if (!function)
+	fprintf (asm_out_file, val ? ") + " : ")");
+      else if (val)
+	fprintf (asm_out_file, " + ");
     }
 
   if (!sym || val)
diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c
new file mode 100644
index 0000000..39992a7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c
@@ -0,0 +1,19 @@
+/* { dg-options "-O2 -msoft-stack" } */
+/* { dg-do run } */
+
+int
+f1 (int a)
+{
+  return a + 1;
+}
+  
+int (*f2)(int) = f1;
+
+int
+main ()
+{
+  if (f2 (100) != 101)
+    __builtin_abort();
+
+  return 0;
+}
Tom de Vries Jan. 17, 2018, 10:25 p.m. | #7
On 01/17/2018 06:29 PM, Cesar Philippidis wrote:
> Is this patch OK for trunk?


You haven't made the changes I've asked for, this is the same patch as 
before.

Thanks,
- Tom
Cesar Philippidis Jan. 19, 2018, 12:59 a.m. | #8
On 12/19/2017 04:39 PM, Tom de Vries wrote:
> On 12/20/2017 12:25 AM, Cesar Philippidis wrote:

>> og7-ptx-cuda9.diff

>>

>>

>> 2017-12-19  Cesar Philippidis  <cesar@codesourcery.com>

>>

>>     gcc/

>>     * config/nvptx/nvptx.c (output_init_frag): Don't use generic address

>>     spaces for function labels.

>>

>>     gcc/testsuite/

>>     * gcc.target/nvptx/indirect_call.c: New test.

>>

>>

>> diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c

>> index dfb27ef..a7b4c09 100644

>> --- a/gcc/config/nvptx/nvptx.c

>> +++ b/gcc/config/nvptx/nvptx.c

>> @@ -1894,9 +1894,15 @@ output_init_frag (rtx sym)

>>         if (sym)

>>       {

>> -      fprintf (asm_out_file, "generic(");

>> +      bool function = SYMBOL_REF_DECL (sym)

>> +    && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL);

> 

> Please indent using parentheses like this:

> 

> bool function = (SYMBOL_REF_DECL (sym)

>                  && (TREE_CODE (SYMBOL_REF_DECL (sym)) == ...));


Done.

>> +      if (!function)

>> +    fprintf (asm_out_file, "generic(");

>>         output_address (VOIDmode, sym);

>> -      fprintf (asm_out_file, val ? ") + " : ")");

>> +      if (!function)

>> +    fprintf (asm_out_file, val ? ") + " : ")");

>> +      else if (val)

>> +    fprintf (asm_out_file, " + ");

> 

> 

> Please use:

> 

>       if (!function)

>     fprintf (asm_out_file, ")");

>       if (val)

>     fprintf (asm_out_file, " + ");


Done.

>>       }

>>       if (!sym || val)

>> diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c

>> b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

>> new file mode 100644

>> index 0000000..39992a7

>> --- /dev/null

>> +++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

>> @@ -0,0 +1,19 @@

>> +/* { dg-options "-O2 -msoft-stack" } */

>> +/* { dg-do run } */

>> +

>> +int

>> +f1 (int a)

>> +{

>> +  return a + 1;

>> +}

>> +

>> +int (*f2)(int) = f1;

>> +

>> +int

>> +main ()

>> +{

>> +  if (f2 (100) != 101)

>> +    __builtin_abort();

>> +

>> +  return 0;

>> +}

>>


Here's the updated patch with the changes that you requested. There are
no new regressions in trunk. I tested it on my desktop running driver
387.34 on a Pascal GPU.

Is this OK for trunk?

Cesar
2018-01-18  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address
	spaces for function labels.

	gcc/testsuite/
	* gcc.target/nvptx/indirect_call.c: New test.

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 86fc13f4fc0..4cb87c8ad07 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -1899,9 +1899,15 @@ output_init_frag (rtx sym)
   
   if (sym)
     {
-      fprintf (asm_out_file, "generic(");
+      bool function = (SYMBOL_REF_DECL (sym)
+		       && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL));
+      if (!function)
+	fprintf (asm_out_file, "generic(");
       output_address (VOIDmode, sym);
-      fprintf (asm_out_file, val ? ") + " : ")");
+      if (!function)
+	fprintf (asm_out_file, ")");
+      if (val)
+	fprintf (asm_out_file, " + ");
     }
 
   if (!sym || val)
diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c
new file mode 100644
index 00000000000..39992a7137b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c
@@ -0,0 +1,19 @@
+/* { dg-options "-O2 -msoft-stack" } */
+/* { dg-do run } */
+
+int
+f1 (int a)
+{
+  return a + 1;
+}
+  
+int (*f2)(int) = f1;
+
+int
+main ()
+{
+  if (f2 (100) != 101)
+    __builtin_abort();
+
+  return 0;
+}
Tom de Vries Jan. 19, 2018, 8:42 a.m. | #9
On 01/19/2018 01:59 AM, Cesar Philippidis wrote:
> Here's the updated patch with the changes that you requested. There are

> no new regressions in trunk. I tested it on my desktop running driver

> 387.34 on a Pascal GPU.

> 

> Is this OK for trunk?


OK with 'PR target/83790' added to the changelog entry.

Thanks,
- Tom

> 

> trunk-cuda9.diff

> 

> 

> 2018-01-18  Cesar Philippidis  <cesar@codesourcery.com>

> 

> 	gcc/

> 	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address

> 	spaces for function labels.

> 

> 	gcc/testsuite/

> 	* gcc.target/nvptx/indirect_call.c: New test.

> 

> diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c

> index 86fc13f4fc0..4cb87c8ad07 100644

> --- a/gcc/config/nvptx/nvptx.c

> +++ b/gcc/config/nvptx/nvptx.c

> @@ -1899,9 +1899,15 @@ output_init_frag (rtx sym)

>     

>     if (sym)

>       {

> -      fprintf (asm_out_file, "generic(");

> +      bool function = (SYMBOL_REF_DECL (sym)

> +		       && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL));

> +      if (!function)

> +	fprintf (asm_out_file, "generic(");

>         output_address (VOIDmode, sym);

> -      fprintf (asm_out_file, val ? ") + " : ")");

> +      if (!function)

> +	fprintf (asm_out_file, ")");

> +      if (val)

> +	fprintf (asm_out_file, " + ");

>       }

>   

>     if (!sym || val)

> diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> new file mode 100644

> index 00000000000..39992a7137b

> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> @@ -0,0 +1,19 @@

> +/* { dg-options "-O2 -msoft-stack" } */

> +/* { dg-do run } */

> +

> +int

> +f1 (int a)

> +{

> +  return a + 1;

> +}

> +

> +int (*f2)(int) = f1;

> +

> +int

> +main ()

> +{

> +  if (f2 (100) != 101)

> +    __builtin_abort();

> +

> +  return 0;

> +}

>
Thomas Schwinge Feb. 27, 2018, 2:08 p.m. | #10
Hi!

Given that several users have run into this, is this (trunk r256891) OK
to commit to open release branches, too?

On Fri, 19 Jan 2018 09:42:08 +0100, Tom de Vries <Tom_deVries@mentor.com> wrote:
> On 01/19/2018 01:59 AM, Cesar Philippidis wrote:

> > Here's the updated patch with the changes that you requested. There are

> > no new regressions in trunk. I tested it on my desktop running driver

> > 387.34 on a Pascal GPU.

> > 

> > Is this OK for trunk?

> 

> OK with 'PR target/83790' added to the changelog entry.

> 

> Thanks,

> - Tom

> 

> > 

> > trunk-cuda9.diff

> > 

> > 

> > 2018-01-18  Cesar Philippidis  <cesar@codesourcery.com>

> > 

> > 	gcc/

> > 	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address

> > 	spaces for function labels.

> > 

> > 	gcc/testsuite/

> > 	* gcc.target/nvptx/indirect_call.c: New test.

> > 

> > diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c

> > index 86fc13f4fc0..4cb87c8ad07 100644

> > --- a/gcc/config/nvptx/nvptx.c

> > +++ b/gcc/config/nvptx/nvptx.c

> > @@ -1899,9 +1899,15 @@ output_init_frag (rtx sym)

> >     

> >     if (sym)

> >       {

> > -      fprintf (asm_out_file, "generic(");

> > +      bool function = (SYMBOL_REF_DECL (sym)

> > +		       && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL));

> > +      if (!function)

> > +	fprintf (asm_out_file, "generic(");

> >         output_address (VOIDmode, sym);

> > -      fprintf (asm_out_file, val ? ") + " : ")");

> > +      if (!function)

> > +	fprintf (asm_out_file, ")");

> > +      if (val)

> > +	fprintf (asm_out_file, " + ");

> >       }

> >   

> >     if (!sym || val)

> > diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> > new file mode 100644

> > index 00000000000..39992a7137b

> > --- /dev/null

> > +++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> > @@ -0,0 +1,19 @@

> > +/* { dg-options "-O2 -msoft-stack" } */

> > +/* { dg-do run } */

> > +

> > +int

> > +f1 (int a)

> > +{

> > +  return a + 1;

> > +}

> > +

> > +int (*f2)(int) = f1;

> > +

> > +int

> > +main ()

> > +{

> > +  if (f2 (100) != 101)

> > +    __builtin_abort();

> > +

> > +  return 0;

> > +}



Grüße
 Thomas
Richard Biener Feb. 27, 2018, 2:12 p.m. | #11
On Tue, 27 Feb 2018, Thomas Schwinge wrote:

> Hi!

> 

> Given that several users have run into this, is this (trunk r256891) OK

> to commit to open release branches, too.


Sure.

> On Fri, 19 Jan 2018 09:42:08 +0100, Tom de Vries <Tom_deVries@mentor.com> wrote:

> > On 01/19/2018 01:59 AM, Cesar Philippidis wrote:

> > > Here's the updated patch with the changes that you requested. There are

> > > no new regressions in trunk. I tested it on my desktop running driver

> > > 387.34 on a Pascal GPU.

> > > 

> > > Is this OK for trunk?

> > 

> > OK with 'PR target/83790' added to the changelog entry.

> > 

> > Thanks,

> > - Tom

> > 

> > > 

> > > trunk-cuda9.diff

> > > 

> > > 

> > > 2018-01-18  Cesar Philippidis  <cesar@codesourcery.com>

> > > 

> > > 	gcc/

> > > 	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address

> > > 	spaces for function labels.

> > > 

> > > 	gcc/testsuite/

> > > 	* gcc.target/nvptx/indirect_call.c: New test.

> > > 

> > > diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c

> > > index 86fc13f4fc0..4cb87c8ad07 100644

> > > --- a/gcc/config/nvptx/nvptx.c

> > > +++ b/gcc/config/nvptx/nvptx.c

> > > @@ -1899,9 +1899,15 @@ output_init_frag (rtx sym)

> > >     

> > >     if (sym)

> > >       {

> > > -      fprintf (asm_out_file, "generic(");

> > > +      bool function = (SYMBOL_REF_DECL (sym)

> > > +		       && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL));

> > > +      if (!function)

> > > +	fprintf (asm_out_file, "generic(");

> > >         output_address (VOIDmode, sym);

> > > -      fprintf (asm_out_file, val ? ") + " : ")");

> > > +      if (!function)

> > > +	fprintf (asm_out_file, ")");

> > > +      if (val)

> > > +	fprintf (asm_out_file, " + ");

> > >       }

> > >   

> > >     if (!sym || val)

> > > diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> > > new file mode 100644

> > > index 00000000000..39992a7137b

> > > --- /dev/null

> > > +++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c

> > > @@ -0,0 +1,19 @@

> > > +/* { dg-options "-O2 -msoft-stack" } */

> > > +/* { dg-do run } */

> > > +

> > > +int

> > > +f1 (int a)

> > > +{

> > > +  return a + 1;

> > > +}

> > > +

> > > +int (*f2)(int) = f1;

> > > +

> > > +int

> > > +main ()

> > > +{

> > > +  if (f2 (100) != 101)

> > > +    __builtin_abort();

> > > +

> > > +  return 0;

> > > +}

> 

> 

> Grüße

>  Thomas

> 

> 


-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)
Thomas Schwinge March 2, 2018, 8:45 a.m. | #12
Hi!

On Tue, 27 Feb 2018 15:12:47 +0100, Richard Biener <rguenther@suse.de> wrote:
> On Tue, 27 Feb 2018, Thomas Schwinge wrote:

> > Given that several users have run into this, is this (trunk r256891) OK

> > to commit to open release branches, too.

> 

> Sure.


Committed to gcc-7-branch in r258126:

commit f0888f115525785d8876d1718fcb0580996e2f30
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Mar 2 08:39:31 2018 +0000

    [nvptx] Add support for CUDA 9
    
    Backport trunk r256891:
    
            gcc/
            2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
    
            PR target/83790
            * config/nvptx/nvptx.c (output_init_frag): Don't use generic address
            spaces for function labels.
    
            gcc/testsuite/
            2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
    
            PR target/83790
            * gcc.target/nvptx/indirect_call.c: New test.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@258126 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                                  |  9 +++++++++
 gcc/config/nvptx/nvptx.c                       | 10 ++++++++--
 gcc/testsuite/ChangeLog                        |  8 ++++++++
 gcc/testsuite/gcc.target/nvptx/indirect_call.c | 19 +++++++++++++++++++
 4 files changed, 44 insertions(+), 2 deletions(-)

diff --git gcc/ChangeLog gcc/ChangeLog
index def6171..5390d49 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,3 +1,12 @@
+2017-03-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r256891:
+	2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
+
+	PR target/83790
+	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address
+	spaces for function labels.
+
 2018-02-26  Carl Love  <cel@us.ibm.com>
 
 	Backport from mainline: commit 257747 on 2018-02-16.
diff --git gcc/config/nvptx/nvptx.c gcc/config/nvptx/nvptx.c
index e89b314..70a8f0d 100644
--- gcc/config/nvptx/nvptx.c
+++ gcc/config/nvptx/nvptx.c
@@ -1875,9 +1875,15 @@ output_init_frag (rtx sym)
   
   if (sym)
     {
-      fprintf (asm_out_file, "generic(");
+      bool function = (SYMBOL_REF_DECL (sym)
+		       && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL));
+      if (!function)
+	fprintf (asm_out_file, "generic(");
       output_address (VOIDmode, sym);
-      fprintf (asm_out_file, val ? ") + " : ")");
+      if (!function)
+	fprintf (asm_out_file, ")");
+      if (val)
+	fprintf (asm_out_file, " + ");
     }
 
   if (!sym || val)
diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index 359cbac..2d94cd1 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r256891:
+	2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
+
+	PR target/83790
+	* gcc.target/nvptx/indirect_call.c: New test.
+
 2017-03-01  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
 	Backport from mainline
diff --git gcc/testsuite/gcc.target/nvptx/indirect_call.c gcc/testsuite/gcc.target/nvptx/indirect_call.c
new file mode 100644
index 0000000..39992a7
--- /dev/null
+++ gcc/testsuite/gcc.target/nvptx/indirect_call.c
@@ -0,0 +1,19 @@
+/* { dg-options "-O2 -msoft-stack" } */
+/* { dg-do run } */
+
+int
+f1 (int a)
+{
+  return a + 1;
+}
+  
+int (*f2)(int) = f1;
+
+int
+main ()
+{
+  if (f2 (100) != 101)
+    __builtin_abort();
+
+  return 0;
+}

Committed to gcc-6-branch in r258127:

commit 5eec276cf6e2721ba60e187edeb00af5f6b7565f
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Mar 2 08:40:04 2018 +0000

    [nvptx] Add support for CUDA 9
    
    Backport trunk r256891:
    
            gcc/
            2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
    
            PR target/83790
            * config/nvptx/nvptx.c (output_init_frag): Don't use generic address
            spaces for function labels.
    
            gcc/testsuite/
            2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
    
            PR target/83790
            * gcc.target/nvptx/indirect_call.c: New test.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@258127 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                                  |  9 +++++++++
 gcc/config/nvptx/nvptx.c                       | 10 ++++++++--
 gcc/testsuite/ChangeLog                        |  8 ++++++++
 gcc/testsuite/gcc.target/nvptx/indirect_call.c | 19 +++++++++++++++++++
 4 files changed, 44 insertions(+), 2 deletions(-)

diff --git gcc/ChangeLog gcc/ChangeLog
index cebcf85..23296f2 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,3 +1,12 @@
+2017-03-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r256891:
+	2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
+
+	PR target/83790
+	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address
+	spaces for function labels.
+
 2018-02-21  Sudakshina Das  <sudi.das@arm.com>
 
 	Backport from trunk
diff --git gcc/config/nvptx/nvptx.c gcc/config/nvptx/nvptx.c
index 2262005..16e80421 100644
--- gcc/config/nvptx/nvptx.c
+++ gcc/config/nvptx/nvptx.c
@@ -1483,9 +1483,15 @@ output_init_frag (rtx sym)
   
   if (sym)
     {
-      fprintf (asm_out_file, "generic(");
+      bool function = (SYMBOL_REF_DECL (sym)
+		       && (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL));
+      if (!function)
+	fprintf (asm_out_file, "generic(");
       output_address (VOIDmode, sym);
-      fprintf (asm_out_file, val ? ") + " : ")");
+      if (!function)
+	fprintf (asm_out_file, ")");
+      if (val)
+	fprintf (asm_out_file, " + ");
     }
 
   if (!sym || val)
diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index b1abb94..e2c0b7a 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2017-03-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r256891:
+	2018-01-19  Cesar Philippidis  <cesar@codesourcery.com>
+
+	PR target/83790
+	* gcc.target/nvptx/indirect_call.c: New test.
+
 2018-02-28  Alan Modra  <amodra@gmail.com>
 
 	* lib/prune.exp (prune_gcc_output): Match lower case "in function"
diff --git gcc/testsuite/gcc.target/nvptx/indirect_call.c gcc/testsuite/gcc.target/nvptx/indirect_call.c
new file mode 100644
index 0000000..5ac939e
--- /dev/null
+++ gcc/testsuite/gcc.target/nvptx/indirect_call.c
@@ -0,0 +1,19 @@
+/* { dg-options "-O2" } */
+/* { dg-do run } */
+
+int
+f1 (int a)
+{
+  return a + 1;
+}
+  
+int (*f2)(int) = f1;
+
+int
+main ()
+{
+  if (f2 (100) != 101)
+    __builtin_abort();
+
+  return 0;
+}


Grüße
 Thomas

Patch

2017-12-19  Cesar Philippidis  <cesar@codesourcery.com>

	gcc/
	* config/nvptx/nvptx.c (output_init_frag): Don't use generic address
	spaces for function labels.

	gcc/testsuite/
	* gcc.target/nvptx/indirect_call.c: New test.


diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index dfb27ef..a7b4c09 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -1894,9 +1894,15 @@  output_init_frag (rtx sym)
   
   if (sym)
     {
-      fprintf (asm_out_file, "generic(");
+      bool function = SYMBOL_REF_DECL (sym)
+	&& (TREE_CODE (SYMBOL_REF_DECL (sym)) == FUNCTION_DECL);
+      if (!function)
+	fprintf (asm_out_file, "generic(");
       output_address (VOIDmode, sym);
-      fprintf (asm_out_file, val ? ") + " : ")");
+      if (!function)
+	fprintf (asm_out_file, val ? ") + " : ")");
+      else if (val)
+	fprintf (asm_out_file, " + ");
     }
 
   if (!sym || val)
diff --git a/gcc/testsuite/gcc.target/nvptx/indirect_call.c b/gcc/testsuite/gcc.target/nvptx/indirect_call.c
new file mode 100644
index 0000000..39992a7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/nvptx/indirect_call.c
@@ -0,0 +1,19 @@ 
+/* { dg-options "-O2 -msoft-stack" } */
+/* { dg-do run } */
+
+int
+f1 (int a)
+{
+  return a + 1;
+}
+  
+int (*f2)(int) = f1;
+
+int
+main ()
+{
+  if (f2 (100) != 101)
+    __builtin_abort();
+
+  return 0;
+}