From patchwork Fri Jan 27 09:19:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 720530 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v8tXj1nb5z9t1L for ; Fri, 27 Jan 2017 20:19:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="DLYVvwu9"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=gpmLPTJSENZRbn14 GCUdmP/fCJONVeHIC7Vr+JCFU6FipIW5+zszVAFoLYpPsM3v0/FqBkQcmpDpZ9w1 cYmcx6PmxyrjBTh47g6ua/dDhdW7btIaBtMFnv1VOvPz2fACC4OYdgGTbCVeqUTx axc/2IXcbRoissdxQo7aBbmOWKM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=b5TqDFmhW9J0f++qbVymE+ dbPt8=; b=DLYVvwu9eW4PBuvP9Vn/vqUhP2ZuHsW0jtLlV2xLB1sZ1EpWWgS0bZ hp53+TqJn5j47aHfVFsASWKbXMlO5xVoHOiXZVJs4mBQZNMF0Ua7yafXne654HPh 7Hcx/0LVjOkm7uzoIz3WC91s6IBWNWijnlrn0tCQFFKEce83LPQCY= Received: (qmail 6894 invoked by alias); 27 Jan 2017 09:19:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 6870 invoked by uid 89); 27 Jan 2017 09:19:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy=UD:stdbool.h, stdbool.h, stdboolh, plugin-hsa.c X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Jan 2017 09:19:27 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1cX2gm-0004Ys-0a from Thomas_Schwinge@mentor.com ; Fri, 27 Jan 2017 01:19:24 -0800 Received: from hertz.schwinge.homeip.net (137.202.0.87) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 27 Jan 2017 09:19:20 +0000 From: Thomas Schwinge To: Jakub Jelinek , Subject: libgomp: Provide prototypes for functions implemented by libgomp plugins User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Fri, 27 Jan 2017 10:19:18 +0100 Message-ID: <874m0kx3l5.fsf@hertz.schwinge.homeip.net> MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Hi! During development, I had been changing the libgomp plugin API, which should have caused build failures in unmodified plugins -- but it didn't. Here is patch to address that. OK for trunk? Should this also go into release branches? commit 01828b7ec25f2087548b5c75568b545aa0d16c3b Author: Thomas Schwinge Date: Thu Jan 26 21:03:57 2017 +0100 libgomp: Provide prototypes for functions implemented by libgomp plugins libgomp/ * libgomp-plugin.h: #include . Add prototypes for GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps, GOMP_OFFLOAD_get_type, GOMP_OFFLOAD_get_num_devices, GOMP_OFFLOAD_init_device, GOMP_OFFLOAD_fini_device, GOMP_OFFLOAD_version, GOMP_OFFLOAD_load_image, GOMP_OFFLOAD_unload_image, GOMP_OFFLOAD_alloc, GOMP_OFFLOAD_free, GOMP_OFFLOAD_dev2host, GOMP_OFFLOAD_host2dev, GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_can_run, GOMP_OFFLOAD_run, GOMP_OFFLOAD_async_run, GOMP_OFFLOAD_openacc_exec, GOMP_OFFLOAD_openacc_register_async_cleanup, GOMP_OFFLOAD_openacc_async_test, GOMP_OFFLOAD_openacc_async_test_all, GOMP_OFFLOAD_openacc_async_wait, GOMP_OFFLOAD_openacc_async_wait_async, GOMP_OFFLOAD_openacc_async_wait_all, GOMP_OFFLOAD_openacc_async_wait_all_async, GOMP_OFFLOAD_openacc_async_set_async, GOMP_OFFLOAD_openacc_create_thread_data, GOMP_OFFLOAD_openacc_destroy_thread_data, GOMP_OFFLOAD_openacc_get_current_device, GOMP_OFFLOAD_openacc_get_current_context, GOMP_OFFLOAD_openacc_get_stream, GOMP_OFFLOAD_openacc_set_stream. * libgomp.h (struct acc_dispatch_t, struct gomp_device_descr): Use these. * plugin/plugin-hsa.c (GOMP_OFFLOAD_load_image) (GOMP_OFFLOAD_unload_image): Fix argument types. liboffloadmic/ * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix return type. (GOMP_OFFLOAD_load_image): Fix argument types. --- libgomp/libgomp-plugin.h | 43 ++++++++++++++-- libgomp/libgomp.h | 65 ++++++++++++------------ libgomp/plugin/plugin-hsa.c | 4 +- liboffloadmic/plugin/libgomp-plugin-intelmic.cpp | 4 +- 4 files changed, 76 insertions(+), 40 deletions(-) Grüße Thomas diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h index 107117b..de362ae 100644 --- libgomp/libgomp-plugin.h +++ libgomp/libgomp-plugin.h @@ -1,4 +1,6 @@ -/* Copyright (C) 2014-2017 Free Software Foundation, Inc. +/* The libgomp plugin API. + + Copyright (C) 2014-2017 Free Software Foundation, Inc. Contributed by Mentor Embedded. @@ -24,11 +26,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ -/* An interface to various libgomp-internal functions for use by plugins. */ - #ifndef LIBGOMP_PLUGIN_H #define LIBGOMP_PLUGIN_H 1 +#include #include #include @@ -73,6 +74,42 @@ extern void GOMP_PLUGIN_error (const char *, ...) extern void GOMP_PLUGIN_fatal (const char *, ...) __attribute__ ((noreturn, format (printf, 1, 2))); +/* Prototypes for functions implemented by libgomp plugins. */ +extern const char *GOMP_OFFLOAD_get_name (void); +extern unsigned int GOMP_OFFLOAD_get_caps (void); +extern int GOMP_OFFLOAD_get_type (void); +extern int GOMP_OFFLOAD_get_num_devices (void); +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 **); +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 *); +extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t); +extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t); +extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t); +extern bool GOMP_OFFLOAD_can_run (void *); +extern void GOMP_OFFLOAD_run (int, void *, void *, void **); +extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *); +extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **, + void **, int, unsigned *, void *); +extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int); +extern int GOMP_OFFLOAD_openacc_async_test (int); +extern int GOMP_OFFLOAD_openacc_async_test_all (void); +extern void GOMP_OFFLOAD_openacc_async_wait (int); +extern void GOMP_OFFLOAD_openacc_async_wait_async (int, int); +extern void GOMP_OFFLOAD_openacc_async_wait_all (void); +extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int); +extern void GOMP_OFFLOAD_openacc_async_set_async (int); +extern void *GOMP_OFFLOAD_openacc_create_thread_data (int); +extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *); +extern void *GOMP_OFFLOAD_openacc_get_current_device (void); +extern void *GOMP_OFFLOAD_openacc_get_current_context (void); +extern void *GOMP_OFFLOAD_openacc_get_stream (int); +extern int GOMP_OFFLOAD_openacc_set_stream (int, void *); + #ifdef __cplusplus } #endif diff --git libgomp/libgomp.h libgomp/libgomp.h index 78d8adc..eaa2303 100644 --- libgomp/libgomp.h +++ libgomp/libgomp.h @@ -882,31 +882,30 @@ typedef struct acc_dispatch_t struct target_mem_desc *data_environ; /* Execute. */ - void (*exec_func) (void (*) (void *), size_t, void **, void **, int, - unsigned *, void *); + typeof (GOMP_OFFLOAD_openacc_exec) *exec_func; /* Async cleanup callback registration. */ - void (*register_async_cleanup_func) (void *, int); + typeof (GOMP_OFFLOAD_openacc_register_async_cleanup) *register_async_cleanup_func; /* Asynchronous routines. */ - int (*async_test_func) (int); - int (*async_test_all_func) (void); - void (*async_wait_func) (int); - void (*async_wait_async_func) (int, int); - void (*async_wait_all_func) (void); - void (*async_wait_all_async_func) (int); - void (*async_set_async_func) (int); + typeof (GOMP_OFFLOAD_openacc_async_test) *async_test_func; + typeof (GOMP_OFFLOAD_openacc_async_test_all) *async_test_all_func; + typeof (GOMP_OFFLOAD_openacc_async_wait) *async_wait_func; + typeof (GOMP_OFFLOAD_openacc_async_wait_async) *async_wait_async_func; + typeof (GOMP_OFFLOAD_openacc_async_wait_all) *async_wait_all_func; + typeof (GOMP_OFFLOAD_openacc_async_wait_all_async) *async_wait_all_async_func; + typeof (GOMP_OFFLOAD_openacc_async_set_async) *async_set_async_func; /* Create/destroy TLS data. */ - void *(*create_thread_data_func) (int); - void (*destroy_thread_data_func) (void *); + typeof (GOMP_OFFLOAD_openacc_create_thread_data) *create_thread_data_func; + typeof (GOMP_OFFLOAD_openacc_destroy_thread_data) *destroy_thread_data_func; /* NVIDIA target specific routines. */ struct { - void *(*get_current_device_func) (void); - void *(*get_current_context_func) (void); - void *(*get_stream_func) (int); - int (*set_stream_func) (int, void *); + typeof (GOMP_OFFLOAD_openacc_get_current_device) *get_current_device_func; + typeof (GOMP_OFFLOAD_openacc_get_current_context) *get_current_context_func; + typeof (GOMP_OFFLOAD_openacc_get_stream) *get_stream_func; + typeof (GOMP_OFFLOAD_openacc_set_stream) *set_stream_func; } cuda; } acc_dispatch_t; @@ -940,23 +939,23 @@ struct gomp_device_descr enum offload_target_type type; /* Function handlers. */ - const char *(*get_name_func) (void); - unsigned int (*get_caps_func) (void); - int (*get_type_func) (void); - int (*get_num_devices_func) (void); - bool (*init_device_func) (int); - bool (*fini_device_func) (int); - unsigned (*version_func) (void); - int (*load_image_func) (int, unsigned, const void *, struct addr_pair **); - bool (*unload_image_func) (int, unsigned, const void *); - void *(*alloc_func) (int, size_t); - bool (*free_func) (int, void *); - bool (*dev2host_func) (int, void *, const void *, size_t); - bool (*host2dev_func) (int, void *, const void *, size_t); - bool (*dev2dev_func) (int, void *, const void *, size_t); - bool (*can_run_func) (void *); - void (*run_func) (int, void *, void *, void **); - void (*async_run_func) (int, void *, void *, void **, void *); + typeof (GOMP_OFFLOAD_get_name) *get_name_func; + typeof (GOMP_OFFLOAD_get_caps) *get_caps_func; + typeof (GOMP_OFFLOAD_get_type) *get_type_func; + typeof (GOMP_OFFLOAD_get_num_devices) *get_num_devices_func; + typeof (GOMP_OFFLOAD_init_device) *init_device_func; + typeof (GOMP_OFFLOAD_fini_device) *fini_device_func; + typeof (GOMP_OFFLOAD_version) *version_func; + typeof (GOMP_OFFLOAD_load_image) *load_image_func; + typeof (GOMP_OFFLOAD_unload_image) *unload_image_func; + typeof (GOMP_OFFLOAD_alloc) *alloc_func; + typeof (GOMP_OFFLOAD_free) *free_func; + typeof (GOMP_OFFLOAD_dev2host) *dev2host_func; + typeof (GOMP_OFFLOAD_host2dev) *host2dev_func; + typeof (GOMP_OFFLOAD_dev2dev) *dev2dev_func; + typeof (GOMP_OFFLOAD_can_run) *can_run_func; + typeof (GOMP_OFFLOAD_run) *run_func; + typeof (GOMP_OFFLOAD_async_run) *async_run_func; /* Splay tree containing information about mapped memory regions. */ struct splay_tree_s mem_map; diff --git libgomp/plugin/plugin-hsa.c libgomp/plugin/plugin-hsa.c index 9757fc6..9cc243d 100644 --- libgomp/plugin/plugin-hsa.c +++ libgomp/plugin/plugin-hsa.c @@ -891,7 +891,7 @@ init_basic_kernel_info (struct kernel_info *kernel, in TARGET_TABLE. */ int -GOMP_OFFLOAD_load_image (int ord, unsigned version, void *target_data, +GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data, struct addr_pair **target_table) { if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA) @@ -1726,7 +1726,7 @@ destroy_module (struct module_info *module) TRUE on success. */ bool -GOMP_OFFLOAD_unload_image (int n, unsigned version, void *target_data) +GOMP_OFFLOAD_unload_image (int n, unsigned version, const void *target_data) { if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA) { diff --git liboffloadmic/plugin/libgomp-plugin-intelmic.cpp liboffloadmic/plugin/libgomp-plugin-intelmic.cpp index 26d68b4..d1678d0 100644 --- liboffloadmic/plugin/libgomp-plugin-intelmic.cpp +++ liboffloadmic/plugin/libgomp-plugin-intelmic.cpp @@ -159,7 +159,7 @@ GOMP_OFFLOAD_get_caps (void) return res; } -extern "C" enum offload_target_type +extern "C" int GOMP_OFFLOAD_get_type (void) { enum offload_target_type res = OFFLOAD_TARGET_TYPE_INTEL_MIC; @@ -345,7 +345,7 @@ GOMP_OFFLOAD_version (void) extern "C" int GOMP_OFFLOAD_load_image (int device, const unsigned version, - void *target_image, addr_pair **result) + const void *target_image, addr_pair **result) { TRACE ("(device = %d, target_image = %p)", device, target_image);