+2018-04-26 Tom de Vries <tom@codesourcery.com>
+
+ PR libgomp/84020
+ * plugin/cuda/cuda.h (CUjit_option): Add CU_JIT_OPTIMIZATION_LEVEL.
+ * plugin/plugin-nvptx.c (_GNU_SOURCE): Define.
+ (process_GOMP_NVPTX_JIT): New function.
+ (link_ptx): Use process_GOMP_NVPTX_JIT.
+
2018-04-26 Richard Biener <rguenther@suse.de>
Tom de Vries <tom@codesourcery.com>
is not clear as to what that state might be. Or how one might
propagate it from one thread to another. */
+#define _GNU_SOURCE
#include "openacc.h"
#include "config.h"
#include "libgomp-plugin.h"
# define init_cuda_lib() true
#endif
+#include "secure_getenv.h"
+
/* Convenience macros for the frequently used CUDA library call and
error handling sequence as well as CUDA library calls that
do the error checking themselves or don't do it at all. */
GOMP_PLUGIN_debug (0, "%s: '%s'\n", var_name, env_var);
}
+static void
+process_GOMP_NVPTX_JIT (intptr_t *gomp_nvptx_o)
+{
+ const char *var_name = "GOMP_NVPTX_JIT";
+ const char *env_var = secure_getenv (var_name);
+ notify_var (var_name, env_var);
+
+ if (env_var == NULL)
+ return;
+
+ const char *c = env_var;
+ while (*c != '\0')
+ {
+ while (*c == ' ')
+ c++;
+
+ if (c[0] == '-' && c[1] == 'O'
+ && '0' <= c[2] && c[2] <= '4'
+ && (c[3] == '\0' || c[3] == ' '))
+ {
+ *gomp_nvptx_o = c[2] - '0';
+ c += 3;
+ continue;
+ }
+
+ GOMP_PLUGIN_error ("Error parsing %s", var_name);
+ break;
+ }
+}
+
static bool
link_ptx (CUmodule *module, const struct targ_ptx_obj *ptx_objs,
unsigned num_objs)
{
- CUjit_option opts[6];
- void *optvals[6];
+ CUjit_option opts[7];
+ void *optvals[7];
float elapsed = 0.0;
char elog[1024];
char ilog[16384];
opts[5] = CU_JIT_LOG_VERBOSE;
optvals[5] = (void *) 1;
- CUDA_CALL (cuLinkCreate, 6, opts, optvals, &linkstate);
+ static intptr_t gomp_nvptx_o = -1;
+
+ static bool init_done = false;
+ if (!init_done)
+ {
+ process_GOMP_NVPTX_JIT (&gomp_nvptx_o);
+ init_done = true;
+ }
+
+ int nopts = 6;
+ if (gomp_nvptx_o != -1)
+ {
+ opts[nopts] = CU_JIT_OPTIMIZATION_LEVEL;
+ optvals[nopts] = (void *) gomp_nvptx_o;
+ nopts++;
+ }
+
+ CUDA_CALL (cuLinkCreate, nopts, opts, optvals, &linkstate);
for (; num_objs--; ptx_objs++)
{