From afb2d80bc57bddd52bb04869861bf40503a3e89d Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 17 Jul 2015 14:07:53 +0000 Subject: [PATCH] mkoffload.c (process): Constify target data. gcc/ * config/nvptx/mkoffload.c (process): Constify target data. * config/i386/intelmic-mkoffload.c (generate_target_descr_file): Constify target data. (generate_target_offloadend_file): Likewise. libgomp/ * libgomp.h (gomp_device_descr): Constify target data arguments. * target.c (struct offload_image_descr): Constify target_data. (gomp_offload_image_to_device): Likewise. (GOMP_offload_register): Likewise. (GOMP_offload_unrefister): Likewise. * plugin/plugin-host.c (GOMP_OFFLOAD_load_image, GOMP_OFFLOAD_unload_image): Constify target data. * plugin/plugin-nvptx.c (struct ptx_image_data): Constify target data. (GOMP_OFFLOAD_load_image, GOMP_OFFLOAD_unload_image): Likewise. liboffloadmic/ * plugin/libgomp-plugin-intelmic.cpp (ImgDevAddrMap): Constify. (offload_image, GOMP_OFFLOAD_load_image, OMP_OFFLOAD_unload_image): Constify target data. From-SVN: r225936 --- gcc/ChangeLog | 7 ++++++ gcc/config/i386/intelmic-mkoffload.c | 24 +++++++++---------- gcc/config/nvptx/mkoffload.c | 5 ++-- libgomp/ChangeLog | 12 ++++++++++ libgomp/libgomp.h | 4 ++-- libgomp/plugin/plugin-host.c | 4 ++-- libgomp/plugin/plugin-nvptx.c | 11 +++++---- libgomp/target.c | 8 +++---- liboffloadmic/ChangeLog | 7 ++++++ .../plugin/libgomp-plugin-intelmic.cpp | 9 +++---- 10 files changed, 60 insertions(+), 31 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33279aa2a41..d36d6b57b7b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-07-17 Nathan Sidwell + + * config/nvptx/mkoffload.c (process): Constify target data. + * config/i386/intelmic-mkoffload.c (generate_target_descr_file): + Constify target data. + (generate_target_offloadend_file): Likewise. + 2015-07-17 Yuri Rumyantsev * tree-vect-loop-manip.c (rename_variables_in_bb): Add argument diff --git a/gcc/config/i386/intelmic-mkoffload.c b/gcc/config/i386/intelmic-mkoffload.c index e5e5c35fc43..a3b0a5cc1ac 100644 --- a/gcc/config/i386/intelmic-mkoffload.c +++ b/gcc/config/i386/intelmic-mkoffload.c @@ -241,18 +241,18 @@ generate_target_descr_file (const char *target_compiler) fatal_error (input_location, "cannot open '%s'", src_filename); fprintf (src_file, - "extern void *__offload_funcs_end[];\n" - "extern void *__offload_vars_end[];\n\n" + "extern const void *const __offload_funcs_end[];\n" + "extern const void *const __offload_vars_end[];\n\n" - "void *__offload_func_table[0]\n" + "const void *const __offload_func_table[0]\n" "__attribute__ ((__used__, visibility (\"hidden\"),\n" "section (\".gnu.offload_funcs\"))) = { };\n\n" - "void *__offload_var_table[0]\n" + "const void *const __offload_var_table[0]\n" "__attribute__ ((__used__, visibility (\"hidden\"),\n" "section (\".gnu.offload_vars\"))) = { };\n\n" - "void *__OFFLOAD_TARGET_TABLE__[]\n" + "const void *const __OFFLOAD_TARGET_TABLE__[]\n" "__attribute__ ((__used__, visibility (\"hidden\"))) = {\n" " &__offload_func_table, &__offload_funcs_end,\n" " &__offload_var_table, &__offload_vars_end\n" @@ -301,11 +301,11 @@ generate_target_offloadend_file (const char *target_compiler) fatal_error (input_location, "cannot open '%s'", src_filename); fprintf (src_file, - "void *__offload_funcs_end[0]\n" + "const void *const __offload_funcs_end[0]\n" "__attribute__ ((__used__, visibility (\"hidden\"),\n" "section (\".gnu.offload_funcs\"))) = { };\n\n" - "void *__offload_vars_end[0]\n" + "const void *const __offload_vars_end[0]\n" "__attribute__ ((__used__, visibility (\"hidden\"),\n" "section (\".gnu.offload_vars\"))) = { };\n"); fclose (src_file); @@ -339,10 +339,10 @@ generate_host_descr_file (const char *host_compiler) fprintf (src_file, "extern void *__OFFLOAD_TABLE__;\n" - "extern void *__offload_image_intelmic_start;\n" - "extern void *__offload_image_intelmic_end;\n\n" + "extern const void *const __offload_image_intelmic_start;\n" + "extern const void *const __offload_image_intelmic_end;\n\n" - "static const void *__offload_target_data[] = {\n" + "static const void *const __offload_target_data[] = {\n" " &__offload_image_intelmic_start, &__offload_image_intelmic_end\n" "};\n\n"); @@ -350,11 +350,11 @@ generate_host_descr_file (const char *host_compiler) "#ifdef __cplusplus\n" "extern \"C\"\n" "#endif\n" - "void GOMP_offload_register (void *, int, void *);\n" + "void GOMP_offload_register (void *, int, const void *);\n" "#ifdef __cplusplus\n" "extern \"C\"\n" "#endif\n" - "void GOMP_offload_unregister (void *, int, void *);\n\n" + "void GOMP_offload_unregister (void *, int, const void *);\n\n" "__attribute__((constructor))\n" "static void\n" diff --git a/gcc/config/nvptx/mkoffload.c b/gcc/config/nvptx/mkoffload.c index ca13e096f5c..52f8bd91144 100644 --- a/gcc/config/nvptx/mkoffload.c +++ b/gcc/config/nvptx/mkoffload.c @@ -863,7 +863,7 @@ process (FILE *in, FILE *out) fprintf (out, "};\n\n"); fprintf (out, - "static struct nvptx_tdata {\n" + "static const struct nvptx_tdata {\n" " const char *ptx_src;\n" " const char *const *var_names;\n" " __SIZE_TYPE__ var_num;\n" @@ -880,7 +880,8 @@ process (FILE *in, FILE *out) fprintf (out, "#ifdef __cplusplus\n" "extern \"C\" {\n" "#endif\n"); - fprintf (out, "extern void GOMP_offload_register (void *, int, void *);\n"); + fprintf (out, "extern void GOMP_offload_register" + " (void *, int, const void *);\n"); fprintf (out, "#ifdef __cplusplus\n" "}\n" "#endif\n"); diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 6b15776accb..129e78b7df9 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,15 @@ +2015-07-17 Nathan Sidwell + + * libgomp.h (gomp_device_descr): Constify target data arguments. + * target.c (struct offload_image_descr): Constify target_data. + (gomp_offload_image_to_device): Likewise. + (GOMP_offload_register): Likewise. + (GOMP_offload_unrefister): Likewise. + * plugin/plugin-host.c (GOMP_OFFLOAD_load_image, + GOMP_OFFLOAD_unload_image): Constify target data. + * plugin/plugin-nvptx.c (struct ptx_image_data): Constify target data. + (GOMP_OFFLOAD_load_image, GOMP_OFFLOAD_unload_image): Likewise. + 2015-07-16 Nathan Sidwell * plugin/plugin-nvptx.c (link_ptx): Constify string argument. diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index 5ed0f78484a..420ac83e9e7 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -748,8 +748,8 @@ struct gomp_device_descr int (*get_num_devices_func) (void); void (*init_device_func) (int); void (*fini_device_func) (int); - int (*load_image_func) (int, void *, struct addr_pair **); - void (*unload_image_func) (int, void *); + int (*load_image_func) (int, const void *, struct addr_pair **); + void (*unload_image_func) (int, const void *); void *(*alloc_func) (int, size_t); void (*free_func) (int, void *); void *(*dev2host_func) (int, void *, const void *, size_t); diff --git a/libgomp/plugin/plugin-host.c b/libgomp/plugin/plugin-host.c index 3cb4dab3778..da3c5f4cdb7 100644 --- a/libgomp/plugin/plugin-host.c +++ b/libgomp/plugin/plugin-host.c @@ -111,7 +111,7 @@ GOMP_OFFLOAD_fini_device (int n __attribute__ ((unused))) STATIC int GOMP_OFFLOAD_load_image (int n __attribute__ ((unused)), - void *i __attribute__ ((unused)), + const void *t __attribute__ ((unused)), struct addr_pair **r __attribute__ ((unused))) { return 0; @@ -119,7 +119,7 @@ GOMP_OFFLOAD_load_image (int n __attribute__ ((unused)), STATIC void GOMP_OFFLOAD_unload_image (int n __attribute__ ((unused)), - void *i __attribute__ ((unused))) + const void *t __attribute__ ((unused))) { } diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index cfb143bc068..ba6bf0111f3 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -334,7 +334,7 @@ struct ptx_event struct ptx_image_data { - void *target_data; + const void *target_data; CUmodule module; struct ptx_image_data *next; }; @@ -1633,7 +1633,7 @@ typedef struct nvptx_tdata } nvptx_tdata_t; int -GOMP_OFFLOAD_load_image (int ord, void *target_data, +GOMP_OFFLOAD_load_image (int ord, const void *target_data, struct addr_pair **target_table) { CUmodule module; @@ -1641,7 +1641,7 @@ GOMP_OFFLOAD_load_image (int ord, void *target_data, unsigned int fn_entries, var_entries, i, j; CUresult r; struct targ_fn_descriptor *targ_fns; - nvptx_tdata_t const *img_header = (nvptx_tdata_t const *) target_data; + const nvptx_tdata_t *img_header = (const nvptx_tdata_t *) target_data; struct ptx_image_data *new_image; GOMP_OFFLOAD_init_device (ord); @@ -1704,9 +1704,10 @@ GOMP_OFFLOAD_load_image (int ord, void *target_data, } void -GOMP_OFFLOAD_unload_image (int tid __attribute__((unused)), void *target_data) +GOMP_OFFLOAD_unload_image (int tid __attribute__((unused)), + const void *target_data) { - void **img_header = (void **) target_data; + const void *const *img_header = (const void *const *) target_data; struct targ_fn_descriptor *targ_fns = (struct targ_fn_descriptor *) img_header[0]; struct ptx_image_data *image, *prev = NULL, *newhd = NULL; diff --git a/libgomp/target.c b/libgomp/target.c index 6e82792c819..b11c4f2fa6c 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -58,7 +58,7 @@ static gomp_mutex_t register_lock; struct offload_image_descr { enum offload_target_type type; void *host_table; - void *target_data; + const void *target_data; }; /* Array of descriptors of offload images. */ @@ -642,7 +642,7 @@ gomp_update (struct gomp_device_descr *devicep, size_t mapnum, void **hostaddrs, static void gomp_offload_image_to_device (struct gomp_device_descr *devicep, - void *host_table, void *target_data, + void *host_table, const void *target_data, bool is_register_lock) { void **host_func_table = ((void ***) host_table)[0]; @@ -731,7 +731,7 @@ gomp_offload_image_to_device (struct gomp_device_descr *devicep, void GOMP_offload_register (void *host_table, enum offload_target_type target_type, - void *target_data) + const void *target_data) { int i; gomp_mutex_lock (®ister_lock); @@ -765,7 +765,7 @@ GOMP_offload_register (void *host_table, enum offload_target_type target_type, void GOMP_offload_unregister (void *host_table, enum offload_target_type target_type, - void *target_data) + const void *target_data) { void **host_func_table = ((void ***) host_table)[0]; void **host_funcs_end = ((void ***) host_table)[1]; diff --git a/liboffloadmic/ChangeLog b/liboffloadmic/ChangeLog index b0f9e90187f..a641dd39db8 100644 --- a/liboffloadmic/ChangeLog +++ b/liboffloadmic/ChangeLog @@ -1,3 +1,10 @@ +2015-07-17 Nathan Sidwell + Ilya Verbin + + * plugin/libgomp-plugin-intelmic.cpp (ImgDevAddrMap): Constify. + (offload_image, GOMP_OFFLOAD_load_image, + OMP_OFFLOAD_unload_image): Constify target data. + 2015-07-08 Thomas Schwinge * plugin/Makefile.am (main_target_image.h): Change type of data diff --git a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp index a2d61b15783..a6e5e1c7756 100644 --- a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp +++ b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp @@ -61,7 +61,7 @@ typedef std::vector AddrVect; typedef std::vector DevAddrVect; /* Addresses for all images and all devices. */ -typedef std::map ImgDevAddrMap; +typedef std::map ImgDevAddrMap; /* Total number of available devices. */ @@ -255,7 +255,7 @@ get_target_table (int device, int &num_funcs, int &num_vars, void **&table) corresponding target addresses. */ static void -offload_image (void *target_image) +offload_image (const void *target_image) { struct TargetImage { int64_t size; @@ -328,7 +328,8 @@ offload_image (void *target_image) } extern "C" int -GOMP_OFFLOAD_load_image (int device, void *target_image, addr_pair **result) +GOMP_OFFLOAD_load_image (int device, const void *target_image, + addr_pair **result) { TRACE ("(device = %d, target_image = %p)", device, target_image); @@ -352,7 +353,7 @@ GOMP_OFFLOAD_load_image (int device, void *target_image, addr_pair **result) } extern "C" void -GOMP_OFFLOAD_unload_image (int device, void *target_image) +GOMP_OFFLOAD_unload_image (int device, const void *target_image) { TRACE ("(device = %d, target_image = %p)", device, target_image);