public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH,PTX] Add support for CUDA 9
@ 2017-12-19 23:25 Cesar Philippidis
  2017-12-20  0:40 ` Tom de Vries
  0 siblings, 1 reply; 13+ messages in thread
From: Cesar Philippidis @ 2017-12-19 23:25 UTC (permalink / raw)
  To: Tom de Vries, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

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

[-- Attachment #2: og7-ptx-cuda9.diff --]
[-- Type: text/x-patch, Size: 1358 bytes --]

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;
+}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-19 23:25 [PATCH,PTX] Add support for CUDA 9 Cesar Philippidis
@ 2017-12-20  0:40 ` Tom de Vries
  2017-12-20 22:59   ` Cesar Philippidis
  2018-01-19  4:27   ` Cesar Philippidis
  0 siblings, 2 replies; 13+ messages in thread
From: Tom de Vries @ 2017-12-20  0:40 UTC (permalink / raw)
  To: Cesar Philippidis; +Cc: gcc-patches

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;
> +}
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-20  0:40 ` Tom de Vries
@ 2017-12-20 22:59   ` Cesar Philippidis
  2017-12-20 23:15     ` Tom de Vries
  2018-01-19  4:27   ` Cesar Philippidis
  1 sibling, 1 reply; 13+ messages in thread
From: Cesar Philippidis @ 2017-12-20 22:59 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-20 22:59   ` Cesar Philippidis
@ 2017-12-20 23:15     ` Tom de Vries
  2017-12-21 17:19       ` Cesar Philippidis
  0 siblings, 1 reply; 13+ messages in thread
From: Tom de Vries @ 2017-12-20 23:15 UTC (permalink / raw)
  To: Cesar Philippidis; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-20 23:15     ` Tom de Vries
@ 2017-12-21 17:19       ` Cesar Philippidis
  2017-12-27  9:16         ` Tom de Vries
  0 siblings, 1 reply; 13+ messages in thread
From: Cesar Philippidis @ 2017-12-21 17:19 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-21 17:19       ` Cesar Philippidis
@ 2017-12-27  9:16         ` Tom de Vries
  2018-01-17 17:31           ` Cesar Philippidis
  0 siblings, 1 reply; 13+ messages in thread
From: Tom de Vries @ 2017-12-27  9:16 UTC (permalink / raw)
  To: Cesar Philippidis; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-27  9:16         ` Tom de Vries
@ 2018-01-17 17:31           ` Cesar Philippidis
  2018-01-17 23:23             ` Tom de Vries
  0 siblings, 1 reply; 13+ messages in thread
From: Cesar Philippidis @ 2018-01-17 17:31 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

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

[-- Attachment #2: og7-ptx-cuda9.diff --]
[-- Type: text/x-patch, Size: 1358 bytes --]

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;
+}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2018-01-17 17:31           ` Cesar Philippidis
@ 2018-01-17 23:23             ` Tom de Vries
  0 siblings, 0 replies; 13+ messages in thread
From: Tom de Vries @ 2018-01-17 23:23 UTC (permalink / raw)
  To: Cesar Philippidis; +Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2017-12-20  0:40 ` Tom de Vries
  2017-12-20 22:59   ` Cesar Philippidis
@ 2018-01-19  4:27   ` Cesar Philippidis
  2018-01-19  8:46     ` Tom de Vries
  1 sibling, 1 reply; 13+ messages in thread
From: Cesar Philippidis @ 2018-01-19  4:27 UTC (permalink / raw)
  To: Tom de Vries; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2578 bytes --]

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

[-- Attachment #2: trunk-cuda9.diff --]
[-- Type: text/x-patch, Size: 1363 bytes --]

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;
+}

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2018-01-19  4:27   ` Cesar Philippidis
@ 2018-01-19  8:46     ` Tom de Vries
  2018-02-27 14:08       ` Thomas Schwinge
  0 siblings, 1 reply; 13+ messages in thread
From: Tom de Vries @ 2018-01-19  8:46 UTC (permalink / raw)
  To: Cesar Philippidis; +Cc: gcc-patches

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;
> +}
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2018-01-19  8:46     ` Tom de Vries
@ 2018-02-27 14:08       ` Thomas Schwinge
  2018-02-27 14:12         ` Richard Biener
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Schwinge @ 2018-02-27 14:08 UTC (permalink / raw)
  To: gcc-patches, Richard Biener; +Cc: Tom de Vries, Cesar Philippidis

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2018-02-27 14:08       ` Thomas Schwinge
@ 2018-02-27 14:12         ` Richard Biener
  2018-03-02  8:45           ` Thomas Schwinge
  0 siblings, 1 reply; 13+ messages in thread
From: Richard Biener @ 2018-02-27 14:12 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches, Tom de Vries, Cesar Philippidis

[-- Attachment #1: Type: text/plain, Size: 2550 bytes --]

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)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH,PTX] Add support for CUDA 9
  2018-02-27 14:12         ` Richard Biener
@ 2018-03-02  8:45           ` Thomas Schwinge
  0 siblings, 0 replies; 13+ messages in thread
From: Thomas Schwinge @ 2018-03-02  8:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener, Tom de Vries, Cesar Philippidis

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-03-02  8:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-19 23:25 [PATCH,PTX] Add support for CUDA 9 Cesar Philippidis
2017-12-20  0:40 ` Tom de Vries
2017-12-20 22:59   ` Cesar Philippidis
2017-12-20 23:15     ` Tom de Vries
2017-12-21 17:19       ` Cesar Philippidis
2017-12-27  9:16         ` Tom de Vries
2018-01-17 17:31           ` Cesar Philippidis
2018-01-17 23:23             ` Tom de Vries
2018-01-19  4:27   ` Cesar Philippidis
2018-01-19  8:46     ` Tom de Vries
2018-02-27 14:08       ` Thomas Schwinge
2018-02-27 14:12         ` Richard Biener
2018-03-02  8:45           ` Thomas Schwinge

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).