mirror of git://gcc.gnu.org/git/gcc.git
mkoffload.c (process): Change offload data format.
gcc/ * config/nvptx/mkoffload.c (process): Change offload data format. libgomp/ * plugin/plugin-nvptx.c (targ_fn_launch): Use GOMP_DIM_MAX. (struct targ_ptx_obj): New. (nvptx_tdata): Move earlier, change data format. (link_ptx): Take targ_ptx_obj ptr and count. Allow multiple objects. (GOMP_OFFLOAD_load_image): Adjust. Co-Authored-By: Bernd Schmidt <bernds@codesourcery.com> From-SVN: r228308
This commit is contained in:
parent
c57173b69a
commit
cc3cd79bc2
|
|
@ -1,3 +1,7 @@
|
||||||
|
2015-09-30 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
|
||||||
|
* config/nvptx/mkoffload.c (process): Change offload data format.
|
||||||
|
|
||||||
2015-09-30 Jeff Law <law@redhat.com>
|
2015-09-30 Jeff Law <law@redhat.com>
|
||||||
|
|
||||||
* tree-ssa-dom.c (optimize_stmt): Collapse control flow statements
|
* tree-ssa-dom.c (optimize_stmt): Collapse control flow statements
|
||||||
|
|
|
||||||
|
|
@ -843,39 +843,53 @@ process (FILE *in, FILE *out)
|
||||||
Token *tok = tokenize (input);
|
Token *tok = tokenize (input);
|
||||||
const char *comma;
|
const char *comma;
|
||||||
id_map const *id;
|
id_map const *id;
|
||||||
|
unsigned obj_count = 0;
|
||||||
|
unsigned ix;
|
||||||
|
|
||||||
do
|
do
|
||||||
tok = parse_file (tok);
|
tok = parse_file (tok);
|
||||||
while (tok->kind);
|
while (tok->kind);
|
||||||
|
|
||||||
fprintf (out, "static const char ptx_code[] = \n");
|
fprintf (out, "static const char ptx_code_%u[] = \n", obj_count++);
|
||||||
write_stmts (out, rev_stmts (decls));
|
write_stmts (out, rev_stmts (decls));
|
||||||
write_stmts (out, rev_stmts (vars));
|
write_stmts (out, rev_stmts (vars));
|
||||||
write_stmts (out, rev_stmts (fns));
|
write_stmts (out, rev_stmts (fns));
|
||||||
fprintf (out, ";\n\n");
|
fprintf (out, ";\n\n");
|
||||||
|
|
||||||
|
/* Dump out array of pointers to ptx object strings. */
|
||||||
|
fprintf (out, "static const struct ptx_obj {\n"
|
||||||
|
" const char *code;\n"
|
||||||
|
" __SIZE_TYPE__ size;\n"
|
||||||
|
"} ptx_objs[] = {");
|
||||||
|
for (comma = "", ix = 0; ix != obj_count; comma = ",", ix++)
|
||||||
|
fprintf (out, "%s\n\t{ptx_code_%u, sizeof (ptx_code_%u)}", comma, ix, ix);
|
||||||
|
fprintf (out, "\n};\n\n");
|
||||||
|
|
||||||
|
/* Dump out variable idents. */
|
||||||
fprintf (out, "static const char *const var_mappings[] = {");
|
fprintf (out, "static const char *const var_mappings[] = {");
|
||||||
for (comma = "", id = var_ids; id; comma = ",", id = id->next)
|
for (comma = "", id = var_ids; id; comma = ",", id = id->next)
|
||||||
fprintf (out, "%s\n\t%s", comma, id->ptx_name);
|
fprintf (out, "%s\n\t%s", comma, id->ptx_name);
|
||||||
fprintf (out, "\n};\n\n");
|
fprintf (out, "\n};\n\n");
|
||||||
|
|
||||||
|
/* Dump out function idents. */
|
||||||
fprintf (out, "static const struct nvptx_fn {\n"
|
fprintf (out, "static const struct nvptx_fn {\n"
|
||||||
" const char *name;\n"
|
" const char *name;\n"
|
||||||
" unsigned short dim[3];\n"
|
" unsigned short dim[%d];\n"
|
||||||
"} func_mappings[] = {\n");
|
"} func_mappings[] = {\n", GOMP_DIM_MAX);
|
||||||
for (comma = "", id = func_ids; id; comma = ",", id = id->next)
|
for (comma = "", id = func_ids; id; comma = ",", id = id->next)
|
||||||
fprintf (out, "%s\n\t{%s}", comma, id->ptx_name);
|
fprintf (out, "%s\n\t{%s}", comma, id->ptx_name);
|
||||||
fprintf (out, "\n};\n\n");
|
fprintf (out, "\n};\n\n");
|
||||||
|
|
||||||
fprintf (out,
|
fprintf (out,
|
||||||
"static const struct nvptx_tdata {\n"
|
"static const struct nvptx_tdata {\n"
|
||||||
" const char *ptx_src;\n"
|
" const struct ptx_obj *ptx_objs;\n"
|
||||||
|
" unsigned ptx_num;\n"
|
||||||
" const char *const *var_names;\n"
|
" const char *const *var_names;\n"
|
||||||
" __SIZE_TYPE__ var_num;\n"
|
" unsigned var_num;\n"
|
||||||
" const struct nvptx_fn *fn_names;\n"
|
" const struct nvptx_fn *fn_names;\n"
|
||||||
" __SIZE_TYPE__ fn_num;\n"
|
" unsigned fn_num;\n"
|
||||||
"} target_data = {\n"
|
"} target_data = {\n"
|
||||||
" ptx_code,\n"
|
" ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n"
|
||||||
" var_mappings,"
|
" var_mappings,"
|
||||||
" sizeof (var_mappings) / sizeof (var_mappings[0]),\n"
|
" sizeof (var_mappings) / sizeof (var_mappings[0]),\n"
|
||||||
" func_mappings,"
|
" func_mappings,"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,13 @@
|
||||||
|
2015-09-30 Nathan Sidwell <nathan@codesourcery.com>
|
||||||
|
Bernd Schmidt <bernds@codesourcery.com>
|
||||||
|
|
||||||
|
* plugin/plugin-nvptx.c (targ_fn_launch): Use GOMP_DIM_MAX.
|
||||||
|
(struct targ_ptx_obj): New.
|
||||||
|
(nvptx_tdata): Move earlier, change data format.
|
||||||
|
(link_ptx): Take targ_ptx_obj ptr and count. Allow multiple
|
||||||
|
objects.
|
||||||
|
(GOMP_OFFLOAD_load_image): Adjust.
|
||||||
|
|
||||||
2015-09-30 Thomas Schwinge <thomas@codesourcery.com>
|
2015-09-30 Thomas Schwinge <thomas@codesourcery.com>
|
||||||
|
|
||||||
* testsuite/libgomp.oacc-c-c++-common/abort-1.c: Add checkpoint.
|
* testsuite/libgomp.oacc-c-c++-common/abort-1.c: Add checkpoint.
|
||||||
|
|
|
||||||
|
|
@ -224,9 +224,31 @@ map_push (struct ptx_stream *s, int async, size_t size, void **h, void **d)
|
||||||
struct targ_fn_launch
|
struct targ_fn_launch
|
||||||
{
|
{
|
||||||
const char *fn;
|
const char *fn;
|
||||||
unsigned short dim[3];
|
unsigned short dim[GOMP_DIM_MAX];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Target PTX object information. */
|
||||||
|
|
||||||
|
struct targ_ptx_obj
|
||||||
|
{
|
||||||
|
const char *code;
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Target data image information. */
|
||||||
|
|
||||||
|
typedef struct nvptx_tdata
|
||||||
|
{
|
||||||
|
const struct targ_ptx_obj *ptx_objs;
|
||||||
|
unsigned ptx_num;
|
||||||
|
|
||||||
|
const char *const *var_names;
|
||||||
|
unsigned var_num;
|
||||||
|
|
||||||
|
const struct targ_fn_launch *fn_descs;
|
||||||
|
unsigned fn_num;
|
||||||
|
} nvptx_tdata_t;
|
||||||
|
|
||||||
/* Descriptor of a loaded function. */
|
/* Descriptor of a loaded function. */
|
||||||
|
|
||||||
struct targ_fn_descriptor
|
struct targ_fn_descriptor
|
||||||
|
|
@ -688,7 +710,8 @@ nvptx_get_num_devices (void)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
link_ptx (CUmodule *module, const char *ptx_code)
|
link_ptx (CUmodule *module, const struct targ_ptx_obj *ptx_objs,
|
||||||
|
unsigned num_objs)
|
||||||
{
|
{
|
||||||
CUjit_option opts[7];
|
CUjit_option opts[7];
|
||||||
void *optvals[7];
|
void *optvals[7];
|
||||||
|
|
@ -702,8 +725,6 @@ link_ptx (CUmodule *module, const char *ptx_code)
|
||||||
void *linkout;
|
void *linkout;
|
||||||
size_t linkoutsize __attribute__ ((unused));
|
size_t linkoutsize __attribute__ ((unused));
|
||||||
|
|
||||||
GOMP_PLUGIN_debug (0, "attempting to load:\n---\n%s\n---\n", ptx_code);
|
|
||||||
|
|
||||||
opts[0] = CU_JIT_WALL_TIME;
|
opts[0] = CU_JIT_WALL_TIME;
|
||||||
optvals[0] = &elapsed;
|
optvals[0] = &elapsed;
|
||||||
|
|
||||||
|
|
@ -758,25 +779,37 @@ link_ptx (CUmodule *module, const char *ptx_code)
|
||||||
cuda_error (r));
|
cuda_error (r));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cuLinkAddData's 'data' argument erroneously omits the const qualifier. */
|
for (; num_objs--; ptx_objs++)
|
||||||
r = cuLinkAddData (linkstate, CU_JIT_INPUT_PTX, (char *)ptx_code,
|
{
|
||||||
strlen (ptx_code) + 1, 0, 0, 0, 0);
|
/* cuLinkAddData's 'data' argument erroneously omits the const
|
||||||
|
qualifier. */
|
||||||
|
GOMP_PLUGIN_debug (0, "Loading:\n---\n%s\n---\n", ptx_objs->code);
|
||||||
|
r = cuLinkAddData (linkstate, CU_JIT_INPUT_PTX, (char*)ptx_objs->code,
|
||||||
|
ptx_objs->size, 0, 0, 0, 0);
|
||||||
if (r != CUDA_SUCCESS)
|
if (r != CUDA_SUCCESS)
|
||||||
{
|
{
|
||||||
GOMP_PLUGIN_error ("Link error log %s\n", &elog[0]);
|
GOMP_PLUGIN_error ("Link error log %s\n", &elog[0]);
|
||||||
GOMP_PLUGIN_fatal ("cuLinkAddData (ptx_code) error: %s", cuda_error (r));
|
GOMP_PLUGIN_fatal ("cuLinkAddData (ptx_code) error: %s",
|
||||||
|
cuda_error (r));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GOMP_PLUGIN_debug (0, "Linking\n");
|
||||||
r = cuLinkComplete (linkstate, &linkout, &linkoutsize);
|
r = cuLinkComplete (linkstate, &linkout, &linkoutsize);
|
||||||
if (r != CUDA_SUCCESS)
|
|
||||||
GOMP_PLUGIN_fatal ("cuLinkComplete error: %s", cuda_error (r));
|
|
||||||
|
|
||||||
GOMP_PLUGIN_debug (0, "Link complete: %fms\n", elapsed);
|
GOMP_PLUGIN_debug (0, "Link complete: %fms\n", elapsed);
|
||||||
GOMP_PLUGIN_debug (0, "Link log %s\n", &ilog[0]);
|
GOMP_PLUGIN_debug (0, "Link log %s\n", &ilog[0]);
|
||||||
|
|
||||||
|
if (r != CUDA_SUCCESS)
|
||||||
|
GOMP_PLUGIN_fatal ("cuLinkComplete error: %s", cuda_error (r));
|
||||||
|
|
||||||
r = cuModuleLoadData (module, linkout);
|
r = cuModuleLoadData (module, linkout);
|
||||||
if (r != CUDA_SUCCESS)
|
if (r != CUDA_SUCCESS)
|
||||||
GOMP_PLUGIN_fatal ("cuModuleLoadData error: %s", cuda_error (r));
|
GOMP_PLUGIN_fatal ("cuModuleLoadData error: %s", cuda_error (r));
|
||||||
|
|
||||||
|
r = cuLinkDestroy (linkstate);
|
||||||
|
if (r != CUDA_SUCCESS)
|
||||||
|
GOMP_PLUGIN_fatal ("cuLinkDestory error: %s", cuda_error (r));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -1502,19 +1535,6 @@ GOMP_OFFLOAD_fini_device (int n)
|
||||||
pthread_mutex_unlock (&ptx_dev_lock);
|
pthread_mutex_unlock (&ptx_dev_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data emitted by mkoffload. */
|
|
||||||
|
|
||||||
typedef struct nvptx_tdata
|
|
||||||
{
|
|
||||||
const char *ptx_src;
|
|
||||||
|
|
||||||
const char *const *var_names;
|
|
||||||
size_t var_num;
|
|
||||||
|
|
||||||
const struct targ_fn_launch *fn_descs;
|
|
||||||
size_t fn_num;
|
|
||||||
} nvptx_tdata_t;
|
|
||||||
|
|
||||||
/* Return the libgomp version number we're compatible with. There is
|
/* Return the libgomp version number we're compatible with. There is
|
||||||
no requirement for cross-version compatibility. */
|
no requirement for cross-version compatibility. */
|
||||||
|
|
||||||
|
|
@ -1553,7 +1573,7 @@ GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
|
||||||
|
|
||||||
nvptx_attach_host_thread_to_device (ord);
|
nvptx_attach_host_thread_to_device (ord);
|
||||||
|
|
||||||
link_ptx (&module, img_header->ptx_src);
|
link_ptx (&module, img_header->ptx_objs, img_header->ptx_num);
|
||||||
|
|
||||||
/* The mkoffload utility emits a struct of pointers/integers at the
|
/* The mkoffload utility emits a struct of pointers/integers at the
|
||||||
start of each offload image. The array of kernel names and the
|
start of each offload image. The array of kernel names and the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue