Since OpenMP offloading requires both soft-stacks and "uniform SIMT", both non-traditional codegen variants, I'm building a multilib variant with those enabled. This patch adds option -mgomp which enables -msoft-stack plus -muniform-simt, and builds a multilib with it.
* config/nvptx/nvptx.c (nvptx_option_override): Handle TARGET_GOMP. * config/nvptx/nvptx.opt (mgomp): New option. * config/nvptx/t-nvptx (MULTILIB_OPTIONS): New. * doc/invoke.texi (mgomp): Document. --- gcc/config/nvptx/nvptx.c | 3 +++ gcc/config/nvptx/nvptx.opt | 4 ++++ gcc/config/nvptx/t-nvptx | 2 ++ gcc/doc/invoke.texi | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 3bd3cf7..48ee96e 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -153,6 +153,9 @@ nvptx_option_override (void) worker_red_sym = gen_rtx_SYMBOL_REF (Pmode, worker_red_name); worker_red_align = GET_MODE_ALIGNMENT (SImode) / BITS_PER_UNIT; + + if (TARGET_GOMP) + target_flags |= MASK_SOFT_STACK | MASK_UNIFORM_SIMT; } /* Return the mode to be used when declaring a ptx object for OBJ. diff --git a/gcc/config/nvptx/nvptx.opt b/gcc/config/nvptx/nvptx.opt index 47e811e..8826659 100644 --- a/gcc/config/nvptx/nvptx.opt +++ b/gcc/config/nvptx/nvptx.opt @@ -36,3 +36,7 @@ Use custom stacks instead of local memory for automatic storage. muniform-simt Target Report Mask(UNIFORM_SIMT) Generate code that executes all threads in a warp as if one was active. + +mgomp +Target Report Mask(GOMP) +Generate code for OpenMP offloading: enables -msoft-stack and -muniform-simt. diff --git a/gcc/config/nvptx/t-nvptx b/gcc/config/nvptx/t-nvptx index e2580c9..6c1010d 100644 --- a/gcc/config/nvptx/t-nvptx +++ b/gcc/config/nvptx/t-nvptx @@ -8,3 +8,5 @@ ALL_HOST_OBJS += mkoffload.o mkoffload$(exeext): mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBDEPS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ mkoffload.o collect-utils.o libcommon-target.a $(LIBIBERTY) $(LIBS) + +MULTILIB_OPTIONS = mgomp diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 46cd2e9..7e7f3b4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -18956,6 +18956,11 @@ all-ones bitmasks for each warp, indicating current mode (0 outside of SIMD regions). Each thread can bitwise-and the bitmask at position @code{tid.y} with current lane index to compute the master lane index. +@item -mgomp +@opindex mgomp +Generate code for use in OpenMP offloading: enables @option{-msoft-stack} and +@option{-muniform-simt} options, and selects corresponding multilib variant. + @end table @node PDP-11 Options