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

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