aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config/nvptx
diff options
context:
space:
mode:
Diffstat (limited to 'libgcc/config/nvptx')
-rw-r--r--libgcc/config/nvptx/crt0.c12
-rw-r--r--libgcc/config/nvptx/mgomp.c32
-rw-r--r--libgcc/config/nvptx/t-nvptx3
3 files changed, 46 insertions, 1 deletions
diff --git a/libgcc/config/nvptx/crt0.c b/libgcc/config/nvptx/crt0.c
index 3b7382d..5a7dbf6 100644
--- a/libgcc/config/nvptx/crt0.c
+++ b/libgcc/config/nvptx/crt0.c
@@ -24,6 +24,14 @@ int *__exitval_ptr;
extern void __attribute__((noreturn)) exit (int status);
extern int main (int, void **);
+/* Always setup soft stacks to allow testing with -msoft-stack but without
+ -mgomp. 32 is the maximum number of warps in a CTA: the definition here
+ must match the external declaration emitted by the compiler. */
+void *__nvptx_stacks[32] __attribute__((shared,nocommon));
+
+/* Likewise for -muniform-simt. */
+unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
+
void __attribute__((kernel))
__main (int *rval_ptr, int argc, void **argv)
{
@@ -33,5 +41,9 @@ __main (int *rval_ptr, int argc, void **argv)
if (rval_ptr)
*rval_ptr = 255;
+ static char stack[131072] __attribute__((aligned(8)));
+ __nvptx_stacks[0] = stack + sizeof stack;
+ __nvptx_uni[0] = 0;
+
exit (main (argc, argv));
}
diff --git a/libgcc/config/nvptx/mgomp.c b/libgcc/config/nvptx/mgomp.c
new file mode 100644
index 0000000..d8ca581
--- /dev/null
+++ b/libgcc/config/nvptx/mgomp.c
@@ -0,0 +1,32 @@
+/* Define shared memory arrays for -msoft-stack and -muniform-simt.
+
+ Copyright (C) 2015-2016 Free Software Foundation, Inc.
+
+ This file is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 3, or (at your option) any
+ later version.
+
+ This file is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ Under Section 7 of GPL version 3, you are granted additional
+ permissions described in the GCC Runtime Library Exception, version
+ 3.1, as published by the Free Software Foundation.
+
+ You should have received a copy of the GNU General Public License and
+ a copy of the GCC Runtime Library Exception along with this program;
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* OpenACC offloading does not use these symbols; thus, they are exposed
+ only for the -mgomp multilib. The same definitions are also provided
+ in crt0.c for the case of non-offloading compilation. 32 is the maximum
+ number of warps in a CTA. */
+
+#if defined(__nvptx_softstack__) && defined(__nvptx_unisimt__)
+void *__nvptx_stacks[32] __attribute__((shared,nocommon));
+unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
+#endif
diff --git a/libgcc/config/nvptx/t-nvptx b/libgcc/config/nvptx/t-nvptx
index daf252f..c4d20c9 100644
--- a/libgcc/config/nvptx/t-nvptx
+++ b/libgcc/config/nvptx/t-nvptx
@@ -1,4 +1,5 @@
-LIB2ADD=$(srcdir)/config/nvptx/reduction.c
+LIB2ADD=$(srcdir)/config/nvptx/reduction.c \
+ $(srcdir)/config/nvptx/mgomp.c
LIB2ADDEH=
LIB2FUNCS_EXCLUDE=__main