From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 31DC5384D1BD; Mon, 12 Sep 2022 07:22:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31DC5384D1BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662967332; bh=mPyP4WzZKuUzUt4TuNhruY5kO+G817xPC1uXT+DXXEY=; h=From:To:Subject:Date:From; b=Yvuz6VJ/L7c1MnUpIttlRM8mhNYlgz65+tYcwK0NyWq1yXhD3v0PcgFkH+HoZYck6 FbR7VQkz+vxXNuDK7MdRzKZ9aeE8xMEmjJDd/ig6EW1YFKhNBQ+QJ3/j4mXb167v1L OVeJQyLejoajz8VUrr/cKhQiaJsfieT1eeuw5ndw= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] libgomp: Prepare for reverse offload fn lookup X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: 0010ad7047c47e6ee7fb469753d8776ae8d9b9b3 X-Git-Newrev: fd867dd6cc71abaed4afe3bb029b3abc7177421e Message-Id: <20220912072212.31DC5384D1BD@sourceware.org> Date: Mon, 12 Sep 2022 07:22:12 +0000 (GMT) List-Id: https://gcc.gnu.org/g:fd867dd6cc71abaed4afe3bb029b3abc7177421e commit fd867dd6cc71abaed4afe3bb029b3abc7177421e Author: Tobias Burnus Date: Mon Sep 12 09:13:04 2022 +0200 libgomp: Prepare for reverse offload fn lookup Prepare for reverse-offloading function-pointer lookup by passing a rev_fn_table argument to GOMP_OFFLOAD_load_image. The argument will be NULL, unless GOMP_REQUIRES_REVERSE_OFFLOAD is requested and devices not supported it, are filtered out. (Up to and including this commit, no non-host device claims such support and the caller currently always passes NULL.) libgomp/ChangeLog: * libgomp-plugin.h (GOMP_OFFLOAD_load_image): Add 'uint64_t **rev_fn_table' argument. * oacc-host.c (host_load_image): Likewise. * plugin/plugin-gcn.c (GOMP_OFFLOAD_load_image): Likewise; currently unused. * plugin/plugin-nvptx.c (GOMP_OFFLOAD_load_image): Likewise. * target.c (gomp_load_image_to_device): Update call but pass NULL for now. liboffloadmic/ChangeLog: * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_load_image): Add (unused) uint64_t **rev_fn_table argument. (cherry picked from commit 0fcc0cf9dca9f11acbbc94c9437759bdfbd297f2) Diff: --- libgomp/ChangeLog.omp | 14 ++++++++++++++ libgomp/libgomp-plugin.h | 2 +- libgomp/oacc-host.c | 3 ++- libgomp/plugin/plugin-gcn.c | 7 +++++-- libgomp/plugin/plugin-nvptx.c | 7 +++++-- libgomp/target.c | 2 +- liboffloadmic/ChangeLog.omp | 8 ++++++++ liboffloadmic/plugin/libgomp-plugin-intelmic.cpp | 3 ++- 8 files changed, 38 insertions(+), 8 deletions(-) diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index df32c355610..943e872aecf 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,17 @@ +2022-09-12 Tobias Burnus + + Backport from mainline: + 2022-09-09 Tobias Burnus + + * libgomp-plugin.h (GOMP_OFFLOAD_load_image): Add + 'uint64_t **rev_fn_table' argument. + * oacc-host.c (host_load_image): Likewise. + * plugin/plugin-gcn.c (GOMP_OFFLOAD_load_image): Likewise; + currently unused. + * plugin/plugin-nvptx.c (GOMP_OFFLOAD_load_image): Likewise. + * target.c (gomp_load_image_to_device): Update call but pass + NULL for now. + 2022-09-09 Tobias Burnus Backport from mainline: diff --git a/libgomp/libgomp-plugin.h b/libgomp/libgomp-plugin.h index 757d953a28e..161bea7b955 100644 --- a/libgomp/libgomp-plugin.h +++ b/libgomp/libgomp-plugin.h @@ -130,7 +130,7 @@ extern bool GOMP_OFFLOAD_init_device (int); extern bool GOMP_OFFLOAD_fini_device (int); extern unsigned GOMP_OFFLOAD_version (void); extern int GOMP_OFFLOAD_load_image (int, unsigned, const void *, - struct addr_pair **); + struct addr_pair **, uint64_t **); extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *); extern void *GOMP_OFFLOAD_alloc (int, size_t); extern bool GOMP_OFFLOAD_free (int, void *); diff --git a/libgomp/oacc-host.c b/libgomp/oacc-host.c index e3ef5f2efc6..33cb41467f4 100644 --- a/libgomp/oacc-host.c +++ b/libgomp/oacc-host.c @@ -81,7 +81,8 @@ static int host_load_image (int n __attribute__ ((unused)), unsigned v __attribute__ ((unused)), const void *t __attribute__ ((unused)), - struct addr_pair **r __attribute__ ((unused))) + struct addr_pair **r __attribute__ ((unused)), + uint64_t **f __attribute__ ((unused))) { return 0; } diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c index 8fcb915e5b2..a051c2a9b2b 100644 --- a/libgomp/plugin/plugin-gcn.c +++ b/libgomp/plugin/plugin-gcn.c @@ -3348,11 +3348,14 @@ GOMP_OFFLOAD_init_device (int n) /* Load GCN object-code module described by struct gcn_image_desc in TARGET_DATA and return references to kernel descriptors in TARGET_TABLE. - If there are any constructors then run them. */ + If there are any constructors then run them. If not NULL, REV_FN_TABLE will + contain the on-device addresses of the functions for reverse offload. To be + freed by the caller. */ int GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data, - struct addr_pair **target_table) + struct addr_pair **target_table, + uint64_t **rev_fn_table __attribute__((unused))) { if (GOMP_VERSION_DEV (version) != GOMP_VERSION_GCN) { diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 16959ae798f..b90e52c26b1 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -1300,11 +1300,14 @@ nvptx_set_clocktick (CUmodule module, struct ptx_device *dev) } /* Load the (partial) program described by TARGET_DATA to device - number ORD. Allocate and return TARGET_TABLE. */ + number ORD. Allocate and return TARGET_TABLE. If not NULL, REV_FN_TABLE + will contain the on-device addresses of the functions for reverse offload. + To be freed by the caller. */ int GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data, - struct addr_pair **target_table) + struct addr_pair **target_table, + uint64_t **rev_fn_table __attribute__((unused))) { CUmodule module; const char *const *var_names; diff --git a/libgomp/target.c b/libgomp/target.c index 1b66f1b6d32..613f4f7ae25 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -2386,7 +2386,7 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version, num_target_entries = devicep->load_image_func (devicep->target_id, version, - target_data, &target_table); + target_data, &target_table, NULL); if (num_target_entries != num_funcs + num_vars /* "+1" due to the additional ICV struct. */ diff --git a/liboffloadmic/ChangeLog.omp b/liboffloadmic/ChangeLog.omp index e4ce22a3f00..6ac078eead0 100644 --- a/liboffloadmic/ChangeLog.omp +++ b/liboffloadmic/ChangeLog.omp @@ -1,3 +1,11 @@ +2022-09-12 Tobias Burnus + + Backport from mainline: + 2022-09-09 Tobias Burnus + + * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_load_image): + Add (unused) uint64_t **rev_fn_table argument. + 2022-07-05 Tobias Burnus Backport from mainline: diff --git a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp index 33bae0650b4..7be27f0459d 100644 --- a/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp +++ b/liboffloadmic/plugin/libgomp-plugin-intelmic.cpp @@ -349,7 +349,8 @@ GOMP_OFFLOAD_version (void) extern "C" int GOMP_OFFLOAD_load_image (int device, const unsigned version, - const void *target_image, addr_pair **result) + const void *target_image, addr_pair **result, + uint64_t ** /* rev_fn_table */) { TRACE ("(device = %d, target_image = %p)", device, target_image);