From: Chung-Lin Tang <chunglin_tang@mentor.com>
To: Thomas Schwinge <thomas@codesourcery.com>,
Chung-Lin Tang <cltang@codesourcery.com>,
Jakub Jelinek <jakub@redhat.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 1/6, OpenACC, libgomp] Async re-work, interfaces (revised, v2)
Date: Tue, 18 Dec 2018 15:01:00 -0000 [thread overview]
Message-ID: <0f61e865-d218-ad0d-7770-197106f756b5@mentor.com> (raw)
In-Reply-To: <yxfp36r0uhbf.fsf@hertz.schwinge.homeip.net>
[-- Attachment #1: Type: text/plain, Size: 2623 bytes --]
On 2018/12/15 1:52 AM, Thomas Schwinge wrote:
> As for the following changes, will you please make sure that there is one
> common order for these, used in "libgomp/libgomp-plugin.h" function
> prototypes, "libgomp/libgomp.h:acc_dispatch_t",
> "libgomp/target.c:gomp_load_plugin_for_device", "libgomp/oacc-host.c"
> function definitions as well as in "host_dispatch", and the
> libgomp-plugin(s) themselves (that's all, I think?).
>
>> --- a/libgomp/libgomp-plugin.h
>> +++ b/libgomp/libgomp-plugin.h
>> @@ -93,22 +107,31 @@ 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);
>> + void **, unsigned *, void *);
>> +extern void GOMP_OFFLOAD_openacc_async_exec (void (*) (void *), size_t, void **,
>> + void **, unsigned *, void *,
>> + struct goacc_asyncqueue *);
>> +extern struct goacc_asyncqueue *GOMP_OFFLOAD_openacc_async_construct (void);
>> +extern bool GOMP_OFFLOAD_openacc_async_destruct (struct goacc_asyncqueue *);
>> +extern int GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *);
>> +extern void GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *);
>> +extern void GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *,
>> + struct goacc_asyncqueue *);
>> +extern void GOMP_OFFLOAD_openacc_async_queue_callback (struct goacc_asyncqueue *,
>> + void (*)(void *), void *);
>> +extern bool GOMP_OFFLOAD_openacc_async_host2dev (int, void *, const void *, size_t,
>> + struct goacc_asyncqueue *);
>> +extern bool GOMP_OFFLOAD_openacc_async_dev2host (int, void *, const void *, size_t,
>> + struct goacc_asyncqueue *);
This patch revises the ordering of the above functions/hooks to be consistent
across libgomp, and un-deletes goacc_async_unmap_vars in libgomp.map.
Chung-Lin
[-- Attachment #2: async-01.libgomp-interfaces.v2.patch --]
[-- Type: text/plain, Size: 7551 bytes --]
Index: libgomp/libgomp.h
===================================================================
--- libgomp/libgomp.h (revision 267226)
+++ libgomp/libgomp.h (working copy)
@@ -949,25 +949,29 @@ typedef struct acc_dispatch_t
/* Execute. */
__typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
- /* Async cleanup callback registration. */
- __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
- *register_async_cleanup_func;
-
- /* Asynchronous routines. */
- __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. */
__typeof (GOMP_OFFLOAD_openacc_create_thread_data) *create_thread_data_func;
__typeof (GOMP_OFFLOAD_openacc_destroy_thread_data)
*destroy_thread_data_func;
+
+ struct {
+ gomp_mutex_t lock;
+ int nasyncqueue;
+ struct goacc_asyncqueue **asyncqueue;
+ struct goacc_asyncqueue_list *active;
+ __typeof (GOMP_OFFLOAD_openacc_async_construct) *construct_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_destruct) *destruct_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_test) *test_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_synchronize) *synchronize_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_serialize) *serialize_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_queue_callback) *queue_callback_func;
+
+ __typeof (GOMP_OFFLOAD_openacc_async_exec) *exec_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_dev2host) *dev2host_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_host2dev) *host2dev_func;
+ } async;
+
/* NVIDIA target specific routines. */
struct {
__typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device)
@@ -1053,17 +1057,33 @@ enum gomp_map_vars_kind
GOMP_MAP_VARS_ENTER_DATA
};
-extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *);
+extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *, int);
extern void gomp_acc_remove_pointer (void *, size_t, bool, int, int, int);
extern void gomp_acc_declare_allocate (bool, size_t, void **, size_t *,
unsigned short *);
+struct gomp_coalesce_buf;
+extern void gomp_copy_host2dev (struct gomp_device_descr *,
+ struct goacc_asyncqueue *, void *, const void *,
+ size_t, struct gomp_coalesce_buf *);
+extern void gomp_copy_dev2host (struct gomp_device_descr *,
+ struct goacc_asyncqueue *, void *, const void *,
+ size_t);
extern struct target_mem_desc *gomp_map_vars (struct gomp_device_descr *,
size_t, void **, void **,
size_t *, void *, bool,
enum gomp_map_vars_kind);
+extern struct target_mem_desc *gomp_map_vars_async (struct gomp_device_descr *,
+ struct goacc_asyncqueue *,
+ size_t, void **, void **,
+ size_t *, void *, bool,
+ enum gomp_map_vars_kind);
+extern void gomp_unmap_tgt (struct target_mem_desc *);
extern void gomp_unmap_vars (struct target_mem_desc *, bool);
+extern void gomp_unmap_vars_async (struct target_mem_desc *, bool,
+ struct goacc_asyncqueue *);
extern void gomp_init_device (struct gomp_device_descr *);
+extern bool gomp_fini_device (struct gomp_device_descr *);
extern void gomp_free_memmap (struct splay_tree_s *);
extern void gomp_unload_device (struct gomp_device_descr *);
extern bool gomp_remove_var (struct gomp_device_descr *, splay_tree_key);
Index: libgomp/libgomp.map
===================================================================
--- libgomp/libgomp.map (revision 267226)
+++ libgomp/libgomp.map (working copy)
@@ -464,8 +464,12 @@ OACC_2.5 {
acc_delete_finalize_async_32_h_;
acc_delete_finalize_async_64_h_;
acc_delete_finalize_async_array_h_;
+ acc_get_default_async;
+ acc_get_default_async_h_;
acc_memcpy_from_device_async;
acc_memcpy_to_device_async;
+ acc_set_default_async;
+ acc_set_default_async_h_;
acc_update_device_async;
acc_update_device_async_32_h_;
acc_update_device_async_64_h_;
Index: libgomp/libgomp-plugin.h
===================================================================
--- libgomp/libgomp-plugin.h (revision 267226)
+++ libgomp/libgomp-plugin.h (working copy)
@@ -53,6 +53,20 @@ enum offload_target_type
OFFLOAD_TARGET_TYPE_HSA = 7
};
+/* Opaque type to represent plugin-dependent implementation of an
+ OpenACC asynchronous queue. */
+struct goacc_asyncqueue;
+
+/* Used to keep a list of active asynchronous queues. */
+struct goacc_asyncqueue_list
+{
+ struct goacc_asyncqueue *aq;
+ struct goacc_asyncqueue_list *next;
+};
+
+typedef struct goacc_asyncqueue *goacc_aq;
+typedef struct goacc_asyncqueue_list *goacc_aq_list;
+
/* Auxiliary struct, used for transferring pairs of addresses from plugin
to libgomp. */
struct addr_pair
@@ -93,22 +107,31 @@ extern bool GOMP_OFFLOAD_dev2dev (int, void *, con
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);
+ void **, unsigned *, void *);
extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
+extern struct goacc_asyncqueue *GOMP_OFFLOAD_openacc_async_construct (void);
+extern bool GOMP_OFFLOAD_openacc_async_destruct (struct goacc_asyncqueue *);
+extern int GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *);
+extern void GOMP_OFFLOAD_openacc_async_synchronize (struct goacc_asyncqueue *);
+extern void GOMP_OFFLOAD_openacc_async_serialize (struct goacc_asyncqueue *,
+ struct goacc_asyncqueue *);
+extern void GOMP_OFFLOAD_openacc_async_queue_callback (struct goacc_asyncqueue *,
+ void (*)(void *), void *);
+extern void GOMP_OFFLOAD_openacc_async_exec (void (*) (void *), size_t, void **,
+ void **, unsigned *, void *,
+ struct goacc_asyncqueue *);
+extern bool GOMP_OFFLOAD_openacc_async_dev2host (int, void *, const void *, size_t,
+ struct goacc_asyncqueue *);
+extern bool GOMP_OFFLOAD_openacc_async_host2dev (int, void *, const void *, size_t,
+ struct goacc_asyncqueue *);
extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
-extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (int);
-extern int GOMP_OFFLOAD_openacc_cuda_set_stream (int, void *);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (struct goacc_asyncqueue *);
+extern int GOMP_OFFLOAD_openacc_cuda_set_stream (struct goacc_asyncqueue *,
+ void *);
#ifdef __cplusplus
}
[-- Attachment #3: 01.libgomp-interfaces.v1-v2.diff --]
[-- Type: text/plain, Size: 3560 bytes --]
diff -ru trunk-orig/libgomp/libgomp.h trunk-work/libgomp/libgomp.h
--- trunk-orig/libgomp/libgomp.h 2018-12-14 18:31:07.487203770 +0800
+++ trunk-work/libgomp/libgomp.h 2018-12-18 22:24:06.351190428 +0800
@@ -949,6 +949,11 @@
/* Execute. */
__typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
+ /* Create/destroy TLS data. */
+ __typeof (GOMP_OFFLOAD_openacc_create_thread_data) *create_thread_data_func;
+ __typeof (GOMP_OFFLOAD_openacc_destroy_thread_data)
+ *destroy_thread_data_func;
+
struct {
gomp_mutex_t lock;
int nasyncqueue;
@@ -963,15 +968,10 @@
__typeof (GOMP_OFFLOAD_openacc_async_queue_callback) *queue_callback_func;
__typeof (GOMP_OFFLOAD_openacc_async_exec) *exec_func;
- __typeof (GOMP_OFFLOAD_openacc_async_host2dev) *host2dev_func;
__typeof (GOMP_OFFLOAD_openacc_async_dev2host) *dev2host_func;
+ __typeof (GOMP_OFFLOAD_openacc_async_host2dev) *host2dev_func;
} async;
- /* Create/destroy TLS data. */
- __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 {
__typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device)
diff -ru trunk-orig/libgomp/libgomp.map trunk-work/libgomp/libgomp.map
--- trunk-orig/libgomp/libgomp.map 2018-12-14 18:31:07.487203770 +0800
+++ trunk-work/libgomp/libgomp.map 2018-12-18 22:28:18.103210976 +0800
@@ -506,6 +506,7 @@
GOMP_PLUGIN_debug;
GOMP_PLUGIN_error;
GOMP_PLUGIN_fatal;
+ GOMP_PLUGIN_async_unmap_vars;
GOMP_PLUGIN_acc_thread;
};
diff -ru trunk-orig/libgomp/libgomp-plugin.h trunk-work/libgomp/libgomp-plugin.h
--- trunk-orig/libgomp/libgomp-plugin.h 2018-12-14 18:31:07.487203770 +0800
+++ trunk-work/libgomp/libgomp-plugin.h 2018-12-18 22:56:12.338389017 +0800
@@ -110,9 +110,8 @@
extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
void **, unsigned *, void *);
-extern void GOMP_OFFLOAD_openacc_async_exec (void (*) (void *), size_t, void **,
- void **, unsigned *, void *,
- struct goacc_asyncqueue *);
+extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
+extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
extern struct goacc_asyncqueue *GOMP_OFFLOAD_openacc_async_construct (void);
extern bool GOMP_OFFLOAD_openacc_async_destruct (struct goacc_asyncqueue *);
extern int GOMP_OFFLOAD_openacc_async_test (struct goacc_asyncqueue *);
@@ -121,12 +120,13 @@
struct goacc_asyncqueue *);
extern void GOMP_OFFLOAD_openacc_async_queue_callback (struct goacc_asyncqueue *,
void (*)(void *), void *);
-extern bool GOMP_OFFLOAD_openacc_async_host2dev (int, void *, const void *, size_t,
- struct goacc_asyncqueue *);
+extern void GOMP_OFFLOAD_openacc_async_exec (void (*) (void *), size_t, void **,
+ void **, unsigned *, void *,
+ struct goacc_asyncqueue *);
extern bool GOMP_OFFLOAD_openacc_async_dev2host (int, void *, const void *, size_t,
struct goacc_asyncqueue *);
-extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
-extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
+extern bool GOMP_OFFLOAD_openacc_async_host2dev (int, void *, const void *, size_t,
+ struct goacc_asyncqueue *);
extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (struct goacc_asyncqueue *);
prev parent reply other threads:[~2018-12-18 15:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-25 13:11 [PATCH 1/6, OpenACC, libgomp] Async re-work, interfaces Chung-Lin Tang
2018-12-14 17:52 ` Thomas Schwinge
2018-12-17 10:27 ` Chung-Lin Tang
2018-12-18 12:36 ` Jakub Jelinek
2018-12-18 14:03 ` Chung-Lin Tang
2018-12-18 15:01 ` Chung-Lin Tang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f61e865-d218-ad0d-7770-197106f756b5@mentor.com \
--to=chunglin_tang@mentor.com \
--cc=cltang@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=thomas@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).