This patch adds a partial omp-tools.h from OpenMP which describes function
prototypes and data types used for OMPD.

All feedback has been addressed.

2020-06-13  Tony Sim  <y2s1...@gmail.com>

libgomp/ChangeLog:

        * Makefile.am (nodist_libsubinclude_HEADERS): Add omp-tools.h.
        * Makefile.in: Regenerate.
        * omp-tools.h: New file.

---
 libgomp/Makefile.am |   2 +-
 libgomp/Makefile.in |   8 +-
 libgomp/omp-tools.h | 295 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 300 insertions(+), 5 deletions(-)
 create mode 100644 libgomp/omp-tools.h

diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index b84156291e8..217e6728d1c 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -74,7 +74,7 @@ libgomp_la_SOURCES += openacc.f90
 endif
 
 nodist_noinst_HEADERS = libgomp_f.h
-nodist_libsubinclude_HEADERS = omp.h openacc.h acc_prof.h
+nodist_libsubinclude_HEADERS = omp.h omp-tools.h openacc.h acc_prof.h
 if USE_FORTRAN
 nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod omp_lib_kinds.mod \
        openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 5ff2ac14db9..c844afd7f0d 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -16,7 +16,7 @@
 
 # Plugins for offload execution, Makefile.am fragment.
 #
-# Copyright (C) 2014-2019 Free Software Foundation, Inc.
+# Copyright (C) 2014-2020 Free Software Foundation, Inc.
 #
 # Contributed by Mentor Embedded.
 #
@@ -573,8 +573,8 @@ libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c 
env.c \
        affinity.c target.c splay-tree.c libgomp-plugin.c \
        oacc-parallel.c oacc-host.c oacc-init.c oacc-mem.c \
        oacc-async.c oacc-plugin.c oacc-cuda.c priority_queue.c \
-       affinity-fmt.c teams.c allocator.c oacc-profiling.c oacc-target.c \
-       $(am__append_4)
+       affinity-fmt.c teams.c allocator.c oacc-profiling.c \
+       oacc-target.c $(am__append_4)
 
 # Nvidia PTX OpenACC plugin.
 @PLUGIN_NVPTX_TRUE@libgomp_plugin_nvptx_version_info = -version-info 
$(libtool_VERSION)
@@ -610,7 +610,7 @@ libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c 
env.c \
 @PLUGIN_GCN_TRUE@libgomp_plugin_gcn_la_LIBADD = libgomp.la $(PLUGIN_GCN_LIBS)
 @PLUGIN_GCN_TRUE@libgomp_plugin_gcn_la_LIBTOOLFLAGS = --tag=disable-static
 nodist_noinst_HEADERS = libgomp_f.h
-nodist_libsubinclude_HEADERS = omp.h openacc.h acc_prof.h
+nodist_libsubinclude_HEADERS = omp.h omp-tools.h openacc.h acc_prof.h
 @USE_FORTRAN_TRUE@nodist_finclude_HEADERS = omp_lib.h omp_lib.f90 omp_lib.mod 
omp_lib_kinds.mod \
 @USE_FORTRAN_TRUE@     openacc_lib.h openacc.f90 openacc.mod openacc_kinds.mod
 
diff --git a/libgomp/omp-tools.h b/libgomp/omp-tools.h
new file mode 100644
index 00000000000..394c33e40dd
--- /dev/null
+++ b/libgomp/omp-tools.h
@@ -0,0 +1,295 @@
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Yoosuk Sim <y2s1...@gmail.com>.
+
+   This file is part of the GNU Offloading and Multi Processing Library
+   (libgomp).
+
+   Libgomp is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* This file contains prototypes of functions and data types defined
+   in the OMPD standard.  */
+
+#ifndef _OMP_TOOLS_H
+#define _OMP_TOOLS_H
+
+#ifdef __cplusplus
+extern "C" {
+# define __GOMPD_NOTHROW throw ()
+#else
+# define __GOMPD_NOTHROW __attribute__((__nothrow__))
+#endif
+
+typedef __UINT64_TYPE__ ompd_size_t;
+
+typedef __UINT64_TYPE__ ompd_wait_id_t;
+
+typedef __UINT64_TYPE__ ompd_addr_t;
+typedef __INT64_TYPE__ ompd_word_t;
+typedef __UINT64_TYPE__ ompd_seg_t;
+
+typedef __UINT64_TYPE__ ompd_device_t;
+
+typedef __UINT64_TYPE__ ompd_thread_id_t;
+
+typedef enum ompd_scope_t {
+  ompd_scope_global = 1,
+  ompd_scope_address_space = 2,
+  ompd_scope_thread = 3,
+  ompd_scope_parallel = 4,
+  ompd_scope_implicit_task = 5,
+  ompd_scope_task = 6
+} ompd_scope_t;
+
+typedef __UINT64_TYPE__ ompd_icv_id_t;
+
+typedef enum ompd_rc_t {
+  ompd_rc_ok = 0,
+  ompd_rc_unavailable = 1,
+  ompd_rc_stale_handle = 2,
+  ompd_rc_bad_input = 3,
+  ompd_rc_error = 4,
+  ompd_rc_unsupported = 5,
+  ompd_rc_needs_state_tracking = 6,
+  ompd_rc_incompatible = 7,
+  ompd_rc_device_read_error = 8,
+  ompd_rc_device_write_error = 9,
+  ompd_rc_nomem = 10,
+} ompd_rc_t;
+
+typedef struct ompd_address_t {
+  ompd_seg_t segment;
+  ompd_addr_t address;
+} ompd_address_t;
+
+typedef struct ompd_frame_info_t {
+  ompd_address_t frame_address;
+  ompd_word_t frame_flag;
+} ompd_frame_info_t;
+
+typedef struct _ompd_aspace_handle ompd_address_space_handle_t;
+typedef struct _ompd_thread_handle ompd_thread_handle_t;
+typedef struct _ompd_parallel_handle ompd_parallel_handle_t;
+typedef struct _ompd_task_handle ompd_task_handle_t;
+
+typedef struct _ompd_aspace_cont ompd_address_space_context_t;
+typedef struct _ompd_thread_cont ompd_thread_context_t;
+
+typedef struct ompd_device_type_sizes_t {
+  __UINT8_TYPE__ sizeof_char;
+  __UINT8_TYPE__ sizeof_short;
+  __UINT8_TYPE__ sizeof_int;
+  __UINT8_TYPE__ sizeof_long;
+  __UINT8_TYPE__ sizeof_long_long;
+  __UINT8_TYPE__ sizeof_pointer;
+} ompd_device_type_sizes_t;
+
+
+const char **ompd_dll_locations;
+
+void ompd_dll_locations_valid (void) __GOMPD_NOTHROW;
+
+typedef ompd_rc_t (*ompd_callback_memory_alloc_fn_t) (ompd_size_t, void **);
+
+typedef ompd_rc_t (*ompd_callback_memory_free_fn_t) (void *);
+
+typedef ompd_rc_t (*ompd_callback_get_thread_context_for_thread_id_fn_t)
+    (ompd_address_space_context_t *, ompd_thread_id_t,
+    ompd_size_t, const void *,
+    ompd_thread_context_t **);
+
+typedef ompd_rc_t (*ompd_callback_sizeof_fn_t)
+    (ompd_address_space_context_t *,
+    ompd_device_type_sizes_t *);
+
+typedef ompd_rc_t (*ompd_callback_symbol_addr_fn_t)
+    (ompd_address_space_context_t *,
+    ompd_thread_context_t *, const char *,
+    ompd_address_t *, const char *);
+
+typedef ompd_rc_t (*ompd_callback_memory_read_fn_t)
+    (ompd_address_space_context_t *,
+    ompd_thread_context_t *, const ompd_address_t *,
+    ompd_size_t, void *);
+
+typedef ompd_rc_t (*ompd_callback_memory_write_fn_t)
+    (ompd_address_space_context_t *,
+    ompd_thread_context_t *, const ompd_address_t *,
+    ompd_size_t, const void *);
+
+typedef ompd_rc_t (*ompd_callback_device_host_fn_t)
+    (ompd_address_space_context_t *, const void *,
+    ompd_size_t, ompd_size_t, void *);
+
+typedef ompd_rc_t (*ompd_callback_print_string_fn_t) (const char *, int);
+
+typedef struct ompd_callbacks_t {
+  ompd_callback_memory_alloc_fn_t alloc_memory;
+  ompd_callback_memory_free_fn_t free_memory;
+  ompd_callback_print_string_fn_t print_string;
+  ompd_callback_sizeof_fn_t sizeof_type;
+  ompd_callback_symbol_addr_fn_t symbol_addr_lookup;
+  ompd_callback_memory_read_fn_t read_memory;
+  ompd_callback_memory_write_fn_t write_memory;
+  ompd_callback_memory_read_fn_t read_string;
+  ompd_callback_device_host_fn_t device_to_host;
+  ompd_callback_device_host_fn_t host_to_device;
+  ompd_callback_get_thread_context_for_thread_id_fn_t
+      get_thread_context_for_thread_id;
+} ompd_callbacks_t;
+
+void ompd_bp_parallel_begin (void) __GOMPD_NOTHROW;
+
+void ompd_bp_parallel_end (void) __GOMPD_NOTHROW;
+
+void ompd_bp_task_begin (void) __GOMPD_NOTHROW;
+
+void ompd_bp_task_end (void) __GOMPD_NOTHROW;
+
+void ompd_bp_thread_begin (void) __GOMPD_NOTHROW;
+
+void ompd_bp_thread_end (void) __GOMPD_NOTHROW;
+
+void ompd_bp_device_begin (void) __GOMPD_NOTHROW;
+
+void ompd_bp_device_end (void) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_initialize (ompd_word_t,
+                         const ompd_callbacks_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_api_version (ompd_word_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_version_string (const char **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_finalize (void) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_process_initialize (ompd_address_space_context_t *,
+                               ompd_address_space_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_device_initialize (ompd_address_space_handle_t *,
+                                ompd_address_space_context_t *,
+                                ompd_device_t, ompd_size_t, void *,
+                               ompd_address_space_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_rel_address_space_handle
+                               (ompd_address_space_handle_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_omp_version (ompd_address_space_handle_t *,
+                              ompd_word_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_get_omp_version_string (ompd_address_space_handle_t *,
+                           const char **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_thread_in_parallel (ompd_parallel_handle_t *, int,
+                                     ompd_thread_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_thread_handle (ompd_address_space_handle_t *,
+                                ompd_thread_id_t,
+                                ompd_size_t, const void *,
+                                ompd_thread_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_rel_thread_handle (ompd_thread_handle_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_thread_handle_compare (ompd_thread_handle_t *,
+                               ompd_thread_handle_t *, int *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_thread_id (ompd_thread_handle_t *,
+                            ompd_thread_id_t,
+                            ompd_size_t, void *) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_get_curr_parallel_handle (ompd_thread_handle_t *,
+                             ompd_parallel_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_enclosing_parallel_handle
+    (ompd_parallel_handle_t *,
+    ompd_parallel_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_get_task_parallel_handle (ompd_task_handle_t *,
+                             ompd_parallel_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_rel_parallel_handle (ompd_parallel_handle_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_parallel_handle_compare (ompd_parallel_handle_t *,
+                            ompd_parallel_handle_t *, int *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_curr_task_handle (ompd_thread_handle_t *,
+                                   ompd_task_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_get_generating_task_handle (ompd_task_handle_t *,
+                               ompd_task_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_get_scheduling_task_handle (ompd_task_handle_t *,
+                               ompd_task_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_task_in_parallel (ompd_parallel_handle_t *, int,
+                                   ompd_task_handle_t **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_rel_task_handle (ompd_task_handle_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_task_handle_compare (ompd_task_handle_t *,
+                                  ompd_task_handle_t *, int *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_task_function (ompd_task_handle_t *,
+                                ompd_address_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_task_frame (ompd_task_handle_t *,
+                             ompd_frame_info_t *,
+                             ompd_frame_info_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_enumerate_states (ompd_address_space_handle_t *,
+                     ompd_word_t, ompd_word_t *,
+                     const char **, ompd_word_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_state (ompd_thread_handle_t *,
+                        ompd_word_t *, ompd_wait_id_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t
+ompd_get_display_control_vars (ompd_address_space_handle_t *,
+                             const char *const **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_rel_display_control_vars (const char *const **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_enumerate_icvs (ompd_address_space_handle_t *,
+                             ompd_icv_id_t, ompd_icv_id_t *, const char **,
+                             ompd_scope_t *, int *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_icv_from_scope (void *, ompd_scope_t,
+                                 ompd_icv_id_t, ompd_word_t *) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_icv_string_from_scope (void *, ompd_scope_t,
+                                 ompd_icv_id_t, const char **) __GOMPD_NOTHROW;
+
+ompd_rc_t ompd_get_tool_data (void *, ompd_scope_t,
+                            ompd_word_t *, ompd_address_t *) __GOMPD_NOTHROW;
+
+
+#define ompd_segment_none 0
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif
-- 
2.26.2

Reply via email to