From patchwork Wed Dec 17 22:31:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 422390 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 56B3B1400E9 for ; Thu, 18 Dec 2014 09:32:41 +1100 (AEDT) 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:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=E+JSkvrJLCt7KKW+ URPUDkWfWKbgsyeb4BEwMv9RzphfEpw7WJbsMOR0RQXM5i7OlyJ5vSczV33ZsLWt gMFIFhUCUWGYgDVNTM2ryx0tHeT+BQztpktcctUwVH9n9dXthsdV+FgzmARJSMlf UiHHWPpN6bHOFEfcHke49Yr8VVQ= 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:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=bOX0noHXZKpr9SZAGyXu7K l+oqw=; b=sBtGrDsoxCyajpjPB6iWVDzIg55blawhFA8qi5oSIZlgSzkj9bYQKc lK5YPrRpb5LFlRl/GDJ4cujfxHfq+kuL+fdf3UcWYnBlb58pIv52FN9w7BgoRJu4 PyKcuMd40bCUA304GIjjKymSr8Z+lervs8LCJjXy8Nc5nU63u8Sz4= Received: (qmail 18252 invoked by alias); 17 Dec 2014 22:32:34 -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 18243 invoked by uid 89); 17 Dec 2014 22:32:33 -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 autolearn=ham version=3.3.2 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; Wed, 17 Dec 2014 22:32:31 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Y1N8t-0005v9-Er from Thomas_Schwinge@mentor.com ; Wed, 17 Dec 2014 14:32:28 -0800 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.181.6; Wed, 17 Dec 2014 22:32:25 +0000 From: Thomas Schwinge To: Jakub Jelinek , CC: Julian Brown Subject: Re: [gomp4] libgomp updates In-Reply-To: <87oar1ud7y.fsf@schwinge.name> References: <87oar1ud7y.fsf@schwinge.name> User-Agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-pc-linux-gnu) Date: Wed, 17 Dec 2014 23:31:56 +0100 Message-ID: <87h9wtucv7.fsf@schwinge.name> MIME-Version: 1.0 Hi! On Wed, 17 Dec 2014 23:24:17 +0100, I wrote: > Committed to gomp-4_0-branch in r218839: > > commit 1c4f05a68c6d0d5b6137bb6d85a293d16727b389 > Author: tschwinge > Date: Wed Dec 17 22:23:02 2014 +0000 > > libgomp updates. This has broken libgomp/libgomp_target.h usage from liboffloadmic/plugin. Committed to gomp-4_0-branch in r218841: commit db16ceabfcaaa6c9e41c01e289201e6a9fbe3b26 Author: tschwinge Date: Wed Dec 17 22:30:30 2014 +0000 libgomp: Again make libgomp_target.h safe to use "from outside". libgomp/ * libgomp_g.h: Move internal stuff from here... * libgomp_target.h: ..., and here... * libgomp.h: ... into here. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@218841 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgomp/ChangeLog.gomp | 4 ++ libgomp/libgomp.h | 167 +++++++++++++++++++++++++++++++++++++++++++++ libgomp/libgomp_g.h | 5 -- libgomp/libgomp_target.h | 172 ----------------------------------------------- libgomp/splay-tree.h | 6 +- 5 files changed, 174 insertions(+), 180 deletions(-) Grüße, Thomas diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp index dd37326..97eb045 100644 --- libgomp/ChangeLog.gomp +++ libgomp/ChangeLog.gomp @@ -1,5 +1,9 @@ 2014-12-17 Thomas Schwinge + * libgomp_g.h: Move internal stuff from here... + * libgomp_target.h: ..., and here... + * libgomp.h: ... into here. + * Makefile.am: Don't add ../include/gomp-constants.h to nodist_libsubinclude_HEADERS. diff --git libgomp/libgomp.h libgomp/libgomp.h index dbf1628..78de0b4 100644 --- libgomp/libgomp.h +++ libgomp/libgomp.h @@ -632,6 +632,173 @@ extern void gomp_free_thread (void *); extern void gomp_init_targets_once (void); extern int gomp_get_num_devices (void); +#include "libgomp_target.h" +#include "splay-tree.h" + +struct target_mem_desc { + /* Reference count. */ + uintptr_t refcount; + /* All the splay nodes allocated together. */ + splay_tree_node array; + /* Start of the target region. */ + uintptr_t tgt_start; + /* End of the targer region. */ + uintptr_t tgt_end; + /* Handle to free. */ + void *to_free; + /* Previous target_mem_desc. */ + struct target_mem_desc *prev; + /* Number of items in following list. */ + size_t list_count; + + /* Corresponding target device descriptor. */ + struct gomp_device_descr *device_descr; + + /* Memory mapping info for the thread that created this descriptor. */ + struct gomp_memory_mapping *mem_map; + + /* List of splay keys to remove (or decrease refcount) + at the end of region. */ + splay_tree_key list[]; +}; + +#define TARGET_CAP_SHARED_MEM 1 +#define TARGET_CAP_NATIVE_EXEC 2 +#define TARGET_CAP_OPENMP_400 4 +#define TARGET_CAP_OPENACC_200 8 + +/* Information about mapped memory regions (per device/context). */ + +struct gomp_memory_mapping +{ + /* Splay tree containing information about mapped memory regions. */ + struct splay_tree_s splay_tree; + + /* Mutex for operating with the splay tree and other shared structures. */ + gomp_mutex_t lock; + + /* True when tables have been added to this memory map. */ + bool is_initialized; +}; + +typedef struct acc_dispatch_t +{ + /* This is a linked list of data mapped using the + acc_map_data/acc_unmap_data or "acc enter data"/"acc exit data" pragmas + (TODO). Unlike mapped_data in the goacc_thread struct, unmapping can + happen out-of-order with respect to mapping. */ + struct target_mem_desc *data_environ; + + /* Open or close a device instance. */ + void *(*open_device_func) (int n); + int (*close_device_func) (void *h); + + /* Set or get the device number. */ + int (*get_device_num_func) (void); + void (*set_device_num_func) (int); + + /* Execute. */ + void (*exec_func) (void (*) (void *), size_t, void **, void **, size_t *, + unsigned short *, int, int, int, int, void *); + + /* Async cleanup callback registration. */ + void (*register_async_cleanup_func) (void *); + + /* 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); + + /* Create/destroy TLS data. */ + void *(*create_thread_data_func) (void *); + void (*destroy_thread_data_func) (void *); + + /* 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 *); + } cuda; +} acc_dispatch_t; + +/* This structure describes accelerator device. + It contains name of the corresponding libgomp plugin, function handlers for + interaction with the device, ID-number of the device, and information about + mapped memory. */ +struct gomp_device_descr +{ + /* The name of the device. */ + const char *name; + + /* Capabilities of device (supports OpenACC, OpenMP). */ + unsigned int capabilities; + + /* This is the ID number of device. It could be specified in DEVICE-clause of + TARGET construct. */ + int id; + + /* This is the ID number of device among devices of the same type. */ + int target_id; + + /* This is the TYPE of device. */ + enum offload_target_type type; + + /* Set to true when device is initialized. */ + bool is_initialized; + + /* True when offload regions have been registered with this device. */ + bool offload_regions_registered; + + /* 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); + void (*register_image_func) (void *, void *); + void (*init_device_func) (int); + void (*fini_device_func) (int); + int (*get_table_func) (int, struct mapping_table **); + void *(*alloc_func) (int, size_t); + void (*free_func) (int, void *); + void *(*dev2host_func) (int, void *, const void *, size_t); + void *(*host2dev_func) (int, void *, const void *, size_t); + void (*run_func) (int, void *, void *); + + /* OpenACC-specific functions. */ + acc_dispatch_t openacc; + + /* Memory-mapping info for this device instance. */ + struct gomp_memory_mapping mem_map; + + /* Extra information required for a device instance by a given target. */ + void *target_data; +}; + +extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *); +extern void gomp_acc_remove_pointer (void *, bool, int, int); + +extern struct target_mem_desc *gomp_map_vars (struct gomp_device_descr *, + size_t, void **, void **, + size_t *, void *, bool, bool); + +extern void gomp_copy_from_async (struct target_mem_desc *); + +extern void gomp_unmap_vars (struct target_mem_desc *, bool); + +extern void gomp_init_device (struct gomp_device_descr *); + +extern void gomp_init_tables (const struct gomp_device_descr *, + struct gomp_memory_mapping *); + +extern void gomp_fini_device (struct gomp_device_descr *); + +extern void gomp_free_memmap (struct gomp_device_descr *); + /* work.c */ extern void gomp_init_work_share (struct gomp_work_share *, bool, unsigned); diff --git libgomp/libgomp_g.h libgomp/libgomp_g.h index 4206d51..07d1666 100644 --- libgomp/libgomp_g.h +++ libgomp/libgomp_g.h @@ -234,9 +234,4 @@ extern void GOACC_wait (int, int, ...); extern int GOACC_get_num_threads (void); extern int GOACC_get_thread_num (void); -/* oacc-mem.c */ - -extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *); -extern void gomp_acc_remove_pointer (void *, bool, int, int); - #endif /* LIBGOMP_G_H */ diff --git libgomp/libgomp_target.h libgomp/libgomp_target.h index 4d658cc..b6723fe 100644 --- libgomp/libgomp_target.h +++ libgomp/libgomp_target.h @@ -25,8 +25,6 @@ #ifndef LIBGOMP_TARGET_H #define LIBGOMP_TARGET_H 1 -#include "gomp-constants.h" - /* Type of offload target device. Keep in sync with include/gomp-constants.h. */ enum offload_target_type { @@ -46,174 +44,4 @@ struct mapping_table uintptr_t tgt_end; }; -#include "splay-tree.h" - -struct target_mem_desc { - /* Reference count. */ - uintptr_t refcount; - /* All the splay nodes allocated together. */ - splay_tree_node array; - /* Start of the target region. */ - uintptr_t tgt_start; - /* End of the targer region. */ - uintptr_t tgt_end; - /* Handle to free. */ - void *to_free; - /* Previous target_mem_desc. */ - struct target_mem_desc *prev; - /* Number of items in following list. */ - size_t list_count; - - /* Corresponding target device descriptor. */ - struct gomp_device_descr *device_descr; - - /* Memory mapping info for the thread that created this descriptor. */ - struct gomp_memory_mapping *mem_map; - - /* List of splay keys to remove (or decrease refcount) - at the end of region. */ - splay_tree_key list[]; -}; - -#define TARGET_CAP_SHARED_MEM 1 -#define TARGET_CAP_NATIVE_EXEC 2 -#define TARGET_CAP_OPENMP_400 4 -#define TARGET_CAP_OPENACC_200 8 - -/* Information about mapped memory regions (per device/context). */ - -struct gomp_memory_mapping -{ - /* Splay tree containing information about mapped memory regions. */ - struct splay_tree_s splay_tree; - - /* Mutex for operating with the splay tree and other shared structures. */ - gomp_mutex_t lock; - - /* True when tables have been added to this memory map. */ - bool is_initialized; -}; - -typedef struct acc_dispatch_t -{ - /* This is a linked list of data mapped using the - acc_map_data/acc_unmap_data or "acc enter data"/"acc exit data" pragmas - (TODO). Unlike mapped_data in the goacc_thread struct, unmapping can - happen out-of-order with respect to mapping. */ - struct target_mem_desc *data_environ; - - /* Open or close a device instance. */ - void *(*open_device_func) (int n); - int (*close_device_func) (void *h); - - /* Set or get the device number. */ - int (*get_device_num_func) (void); - void (*set_device_num_func) (int); - - /* Execute. */ - void (*exec_func) (void (*) (void *), size_t, void **, void **, size_t *, - unsigned short *, int, int, int, int, void *); - - /* Async cleanup callback registration. */ - void (*register_async_cleanup_func) (void *); - - /* 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); - - /* Create/destroy TLS data. */ - void *(*create_thread_data_func) (void *); - void (*destroy_thread_data_func) (void *); - - /* 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 *); - } cuda; -} acc_dispatch_t; - -/* This structure describes accelerator device. - It contains name of the corresponding libgomp plugin, function handlers for - interaction with the device, ID-number of the device, and information about - mapped memory. */ -struct gomp_device_descr -{ - /* The name of the device. */ - const char *name; - - /* Capabilities of device (supports OpenACC, OpenMP). */ - unsigned int capabilities; - - /* This is the ID number of device. It could be specified in DEVICE-clause of - TARGET construct. */ - int id; - - /* This is the ID number of device among devices of the same type. */ - int target_id; - - /* This is the TYPE of device. */ - enum offload_target_type type; - - /* Set to true when device is initialized. */ - bool is_initialized; - - /* True when offload regions have been registered with this device. */ - bool offload_regions_registered; - - /* 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); - void (*register_image_func) (void *, void *); - void (*init_device_func) (int); - void (*fini_device_func) (int); - int (*get_table_func) (int, struct mapping_table **); - void *(*alloc_func) (int, size_t); - void (*free_func) (int, void *); - void *(*dev2host_func) (int, void *, const void *, size_t); - void *(*host2dev_func) (int, void *, const void *, size_t); - void (*run_func) (int, void *, void *); - - /* OpenACC-specific functions. */ - acc_dispatch_t openacc; - - /* Memory-mapping info for this device instance. */ - struct gomp_memory_mapping mem_map; - - /* Extra information required for a device instance by a given target. */ - void *target_data; -}; - -extern struct target_mem_desc * -gomp_map_vars (struct gomp_device_descr *devicep, size_t mapnum, - void **hostaddrs, void **devaddrs, size_t *sizes, void *kinds, - bool is_openacc, bool is_target); - -extern void -gomp_copy_from_async (struct target_mem_desc *tgt); - -extern void -gomp_unmap_vars (struct target_mem_desc *tgt, bool); - -extern attribute_hidden void -gomp_init_device (struct gomp_device_descr *devicep); - -extern attribute_hidden void -gomp_init_tables (const struct gomp_device_descr *devicep, - struct gomp_memory_mapping *mm); - -extern attribute_hidden void -gomp_fini_device (struct gomp_device_descr *devicep); - -extern attribute_hidden void -gomp_free_memmap (struct gomp_device_descr *devicep); - #endif /* LIBGOMP_TARGET_H */ diff --git libgomp/splay-tree.h libgomp/splay-tree.h index 2afbbc2..ffe5822 100644 --- libgomp/splay-tree.h +++ libgomp/splay-tree.h @@ -81,8 +81,8 @@ struct splay_tree_s { splay_tree_node root; }; -attribute_hidden splay_tree_key splay_tree_lookup (splay_tree, splay_tree_key); -attribute_hidden void splay_tree_insert (splay_tree, splay_tree_node); -attribute_hidden void splay_tree_remove (splay_tree, splay_tree_key); +extern splay_tree_key splay_tree_lookup (splay_tree, splay_tree_key); +extern void splay_tree_insert (splay_tree, splay_tree_node); +extern void splay_tree_remove (splay_tree, splay_tree_key); #endif /* _SPLAY_TREE_H */