Commit 2a21ff19 by Nathan Sidwell Committed by Nathan Sidwell

libgomp.map: Add 4.0.2 version.

	libgomp/
	* libgomp.map: Add 4.0.2 version.
	* target.c (offload_image_descr): Add version field.
	(gomp_load_image_to_device): Add version argument.  Adjust plugin
	call.  Improve load mismatch diagnostic.
	(gomp_unload_image_from_device): Add version argument.  Adjust plugin
	call.
	(GOMP_offload_regster): Make stub function, move bulk to ...
	(GOMP_offload_register_ver): ... here.  Process version argument.
	(GOMP_offload_unregister): Make stub function, move bulk to ...
	(GOMP_offload_unregister_ver): ... here.  Process version argument.
	(gomp_init_device): Process version field.
	(gomp_unload_device): Process version field.
	(gomp_load_plugin_for_device): Reimplement DLSYM & DLSYM_OPT
	macros.  Check plugin version.
	* libgomp.h (gomp_device_descr): Add version function field.  Adjust
	loader and unloader types.
	* oacc-host.c: Include gomp-constants.h.
	(host_version): New.
	(host_load_image, host_unload_image): Adjust.
	(host_dispatch): Add host_version.
	* plugin/plugin-nvptx.c: Include gomp-constants.h.
	(GOMP_OFFLOAD_version): New.
	(GOMP_OFFLOAD_load_image): Add version arg and check it.
	(GOMP_OFFLOAD_unload_image): Likewise.
	* plugin/plugin-host.c: Include gomp-constants.h.
	(GOMP_OFFLOAD_version): New.
	(GOMP_OFFLOAD_load_image): Add version arg.
	(GOMP_OFFLOAD_unload_image): Likewise.

	liboffloadmic/
	* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_version): New.
	(GOMP_OFFLOAD_load_image): Add version arg and check it.
	(GOMP_OFFLOAD_unload_image): Likewise.

	include/
	* gomp-constants.h (GOMP_VERSION, GOMP_VERSION_NVIDIA_PTX,
	GOMP_VERSION_INTEL_MIC): New.
	(GOMP_VERSION_PACK, GOMP_VERSION_LIB, GOMP_VERSION_DEV): New.

	gcc/
	* config/nvptx/mkoffload.c (process): Replace
	GOMP_offload_{,un}register with GOMP_offload_{,un}register_ver.

From-SVN: r227137
parent 5cdf54b7
2015-08-24 Nathan Sidwell <nathan@codesourcery.com>
* config/nvptx/mkoffload.c (process): Replace
GOMP_offload_{,un}register with GOMP_offload_{,un}register_ver.
2015-08-24 H.J. Lu <hongjiu.lu@intel.com>
PR target/67329
......
......@@ -881,10 +881,10 @@ process (FILE *in, FILE *out)
"extern \"C\" {\n"
"#endif\n");
fprintf (out, "extern void GOMP_offload_register"
" (const void *, int, const void *);\n");
fprintf (out, "extern void GOMP_offload_unregister"
" (const void *, int, const void *);\n");
fprintf (out, "extern void GOMP_offload_register_ver"
" (unsigned, const void *, int, const void *);\n");
fprintf (out, "extern void GOMP_offload_unregister_ver"
" (unsigned, const void *, int, const void *);\n");
fprintf (out, "#ifdef __cplusplus\n"
"}\n"
......@@ -894,15 +894,19 @@ process (FILE *in, FILE *out)
fprintf (out, "static __attribute__((constructor)) void init (void)\n"
"{\n"
" GOMP_offload_register (__OFFLOAD_TABLE__, %d/*NVIDIA_PTX*/,\n"
" &target_data);\n"
"};\n", GOMP_DEVICE_NVIDIA_PTX);
" GOMP_offload_register_ver (%#x, __OFFLOAD_TABLE__,"
"%d/*NVIDIA_PTX*/, &target_data);\n"
"};\n",
GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_NVIDIA_PTX),
GOMP_DEVICE_NVIDIA_PTX);
fprintf (out, "static __attribute__((destructor)) void fini (void)\n"
"{\n"
" GOMP_offload_unregister (__OFFLOAD_TABLE__, %d/*NVIDIA_PTX*/,\n"
" &target_data);\n"
"};\n", GOMP_DEVICE_NVIDIA_PTX);
" GOMP_offload_unregister_ver (%#x, __OFFLOAD_TABLE__,"
"%d/*NVIDIA_PTX*/, &target_data);\n"
"};\n",
GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_NVIDIA_PTX),
GOMP_DEVICE_NVIDIA_PTX);
}
static void
......
2015-08-24 Nathan Sidwell <nathan@codesourcery.com>
* gomp-constants.h (GOMP_VERSION, GOMP_VERSION_NVIDIA_PTX,
GOMP_VERSION_INTEL_MIC): New.
(GOMP_VERSION_PACK, GOMP_VERSION_LIB, GOMP_VERSION_DEV): New.
2015-08-14 Pierre-Marie de Rodat <derodat@adacore.com>
* dwarf2.def (DW_AT_GNU_bias): New attribute.
......
......@@ -113,4 +113,13 @@ enum gomp_map_kind
#define GOMP_DEVICE_ICV -1
#define GOMP_DEVICE_HOST_FALLBACK -2
/* Versions of libgomp and device-specific plugins. */
#define GOMP_VERSION 0
#define GOMP_VERSION_NVIDIA_PTX 0
#define GOMP_VERSION_INTEL_MIC 0
#define GOMP_VERSION_PACK(LIB, DEV) (((LIB) << 16) | (DEV))
#define GOMP_VERSION_LIB(PACK) (((PACK) >> 16) & 0xffff)
#define GOMP_VERSION_DEV(PACK) ((PACK) & 0xffff)
#endif
2015-08-24 Nathan Sidwell <nathan@codesourcery.com>
libgomp/
* libgomp.map: Add 4.0.2 version.
* target.c (offload_image_descr): Add version field.
(gomp_load_image_to_device): Add version argument. Adjust plugin
call. Improve load mismatch diagnostic.
(gomp_unload_image_from_device): Add version argument. Adjust plugin
call.
(GOMP_offload_regster): Make stub function, move bulk to ...
(GOMP_offload_register_ver): ... here. Process version argument.
(GOMP_offload_unregister): Make stub function, move bulk to ...
(GOMP_offload_unregister_ver): ... here. Process version argument.
(gomp_init_device): Process version field.
(gomp_unload_device): Process version field.
(gomp_load_plugin_for_device): Reimplement DLSYM & DLSYM_OPT
macros. Check plugin version.
* libgomp.h (gomp_device_descr): Add version function field. Adjust
loader and unloader types.
* oacc-host.c: Include gomp-constants.h.
(host_version): New.
(host_load_image, host_unload_image): Adjust.
(host_dispatch): Add host_version.
* plugin/plugin-nvptx.c: Include gomp-constants.h.
(GOMP_OFFLOAD_version): New.
(GOMP_OFFLOAD_load_image): Add version arg and check it.
(GOMP_OFFLOAD_unload_image): Likewise.
* plugin/plugin-host.c: Include gomp-constants.h.
(GOMP_OFFLOAD_version): New.
(GOMP_OFFLOAD_load_image): Add version arg.
(GOMP_OFFLOAD_unload_image): Likewise.
2015-08-24 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/65468
......
......@@ -748,8 +748,9 @@ 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, const void *, struct addr_pair **);
void (*unload_image_func) (int, const void *);
unsigned (*version_func) (void);
int (*load_image_func) (int, unsigned, const void *, struct addr_pair **);
void (*unload_image_func) (int, unsigned, const void *);
void *(*alloc_func) (int, size_t);
void (*free_func) (int, void *);
void *(*dev2host_func) (int, void *, const void *, size_t);
......
......@@ -234,6 +234,12 @@ GOMP_4.0.1 {
GOMP_offload_unregister;
} GOMP_4.0;
GOMP_4.0.2 {
global:
GOMP_offload_register_ver;
GOMP_offload_unregister_ver;
} GOMP_4.0.1;
OACC_2.0 {
global:
acc_get_num_devices;
......
......@@ -28,6 +28,7 @@
#include "libgomp.h"
#include "oacc-int.h"
#include "gomp-constants.h"
#include <stdbool.h>
#include <stddef.h>
......@@ -69,8 +70,15 @@ host_fini_device (int n __attribute__ ((unused)))
{
}
static unsigned
host_version (void)
{
return GOMP_VERSION;
}
static int
host_load_image (int n __attribute__ ((unused)),
unsigned v __attribute__ ((unused)),
const void *t __attribute__ ((unused)),
struct addr_pair **r __attribute__ ((unused)))
{
......@@ -79,6 +87,7 @@ host_load_image (int n __attribute__ ((unused)),
static void
host_unload_image (int n __attribute__ ((unused)),
unsigned v __attribute__ ((unused)),
const void *t __attribute__ ((unused)))
{
}
......@@ -206,6 +215,7 @@ static struct gomp_device_descr host_dispatch =
.get_num_devices_func = host_get_num_devices,
.init_device_func = host_init_device,
.fini_device_func = host_fini_device,
.version_func = host_version,
.load_image_func = host_load_image,
.unload_image_func = host_unload_image,
.alloc_func = host_alloc,
......
......@@ -36,6 +36,7 @@
#include "libgomp-plugin.h"
#include "oacc-ptx.h"
#include "oacc-plugin.h"
#include "gomp-constants.h"
#include <pthread.h>
#include <cuda.h>
......@@ -1570,11 +1571,20 @@ typedef struct nvptx_tdata
size_t fn_num;
} nvptx_tdata_t;
/* Return the libgomp version number we're compatible with. There is
no requirement for cross-version compatibility. */
unsigned
GOMP_OFFLOAD_version (void)
{
return GOMP_VERSION;
}
/* Load the (partial) program described by TARGET_DATA to device
number ORD. Allocate and return TARGET_TABLE. */
int
GOMP_OFFLOAD_load_image (int ord, const void *target_data,
GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
struct addr_pair **target_table)
{
CUmodule module;
......@@ -1587,6 +1597,11 @@ GOMP_OFFLOAD_load_image (int ord, const void *target_data,
struct ptx_image_data *new_image;
struct ptx_device *dev;
if (GOMP_VERSION_DEV (version) > GOMP_VERSION_NVIDIA_PTX)
GOMP_PLUGIN_fatal ("Offload data incompatible with PTX plugin"
" (expected %u, received %u)",
GOMP_VERSION_NVIDIA_PTX, GOMP_VERSION_DEV (version));
GOMP_OFFLOAD_init_device (ord);
dev = ptx_devices[ord];
......@@ -1656,11 +1671,14 @@ GOMP_OFFLOAD_load_image (int ord, const void *target_data,
function descriptors allocated by G_O_load_image. */
void
GOMP_OFFLOAD_unload_image (int ord, const void *target_data)
GOMP_OFFLOAD_unload_image (int ord, unsigned version, const void *target_data)
{
struct ptx_image_data *image, **prev_p;
struct ptx_device *dev = ptx_devices[ord];
if (GOMP_VERSION_DEV (version) > GOMP_VERSION_NVIDIA_PTX)
return;
pthread_mutex_lock (&dev->image_lock);
for (prev_p = &dev->images; (image = *prev_p) != 0; prev_p = &image->next)
if (image->target_data == target_data)
......
2015-08-24 Nathan Sidwell <nathan@codesourcery.com>
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_version): New.
(GOMP_OFFLOAD_load_image): Add version arg and check it.
(GOMP_OFFLOAD_unload_image): Likewise.
2015-08-24 Thomas Schwinge <thomas@codesourcery.com>
* plugin/Makefile.am (include_src_dir): Set.
......
......@@ -328,12 +328,26 @@ offload_image (const void *target_image)
free (image);
}
/* Return the libgomp version number we're compatible with. There is
no requirement for cross-version compatibility. */
extern "C" unsigned
GOMP_OFFLOAD_version (void)
{
return GOMP_VERSION;
}
extern "C" int
GOMP_OFFLOAD_load_image (int device, const void *target_image,
addr_pair **result)
GOMP_OFFLOAD_load_image (int device, const unsigned version,
void *target_image, addr_pair **result)
{
TRACE ("(device = %d, target_image = %p)", device, target_image);
if (GOMP_VERSION_DEV (version) > GOMP_VERSION_INTEL_MIC)
GOMP_PLUGIN_fatal ("Offload data incompatible with intelmic plugin"
" (expected %u, received %u)",
GOMP_VERSION_INTEL_MIC, GOMP_VERSION_DEV (version));
/* If target_image is already present in address_table, then there is no need
to offload it. */
if (address_table->count (target_image) == 0)
......@@ -354,8 +368,12 @@ GOMP_OFFLOAD_load_image (int device, const void *target_image,
}
extern "C" void
GOMP_OFFLOAD_unload_image (int device, const void *target_image)
GOMP_OFFLOAD_unload_image (int device, unsigned version,
const void *target_image)
{
if (GOMP_VERSION_DEV (version) > GOMP_VERSION_INTEL_MIC)
return;
TRACE ("(device = %d, target_image = %p)", device, target_image);
/* TODO: Currently liboffloadmic doesn't support __offload_unregister_image
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment