libgomp: added simple functions and tests for OMPD

Message ID 20200625215823.2948893-1-y2s1982@gmail.com
State New
Headers show
Series
  • libgomp: added simple functions and tests for OMPD
Related show

Commit Message

Patrick Palka via Gcc-patches June 25, 2020, 9:58 p.m.
From: y2s82 <1997371+y2s82@users.noreply.github.com>


This patch adds some unit tests for omp-tools.h header. It also adds some simple
functions variables related to OMPD API versions and dll locations.
It also partially defines the OMPD initialization function.
More OMPD configuration is also added into Makefile.am.

This patch addresses all feedbacks.

2020-06-25  Tony Sim  <y2s1982@gmail.com>

libgomp/ChangeLog:

	* Makefile.am(toolexeclib_LTLIBRARIES): Add libgompd.la.
        (libgompd_la_LDFLAGS, libgompd_la_DEPENDENCIES, libgompd_la_LINK,
        libgompd_la_SOURCES, libgompd_version_dep, libgompd_version_script,
        libgompd.ver-sun, libgompd.ver, libgompd_version_info): Set.
	* Makefile.in: Regenerate.
	* config/darwin/plugin-suffix.h (SONAME_SUFFIX): Remove ().
	* config/hpux/plugin-suffix.h (SONAME_SUFFIX): Remove ().
	* config/posix/plugin-suffix.h (SONAME_SUFFIX): Remove ().
	* env.c(ompd_dll_locations_valid): Define with no compiler optimization.
	(initialize_env): Call ompd_dll_locations_valid as needed.
	(strong_alias): Alias ompd_dll_locations_valid to initialize_env
	when possible.
	* libgomp.map: Add OMPD_5.0 symbols version.
	* omp-tools.h: Declare ompd_dll_locations as an extern.
	* testsuite/Makefile.in: Regenerate.
	* libgompd.h: New file.
	* libgompd.map: New file.
	* ompd-lib.c: New file.
	* testsuite/libgomp.ompd/header-1.c: New test.
	* testsuite/libgomp.ompd/header-order-1.c: New test.
	* testsuite/libgomp.ompd/header-order-2.c: New test.
	* testsuite/libgomp.ompd/ompd.exp: New test.

---
 libgomp/Makefile.am                           | 29 ++++++++-
 libgomp/Makefile.in                           | 39 +++++++++++-
 libgomp/config/darwin/plugin-suffix.h         |  2 +-
 libgomp/config/hpux/plugin-suffix.h           |  2 +-
 libgomp/config/posix/plugin-suffix.h          |  2 +-
 libgomp/env.c                                 | 21 +++++++
 libgomp/libgomp.map                           |  6 ++
 libgomp/libgompd.h                            | 37 +++++++++++
 libgomp/libgompd.map                          | 49 +++++++++++++++
 libgomp/omp-tools.h                           |  2 +-
 libgomp/ompd-lib.c                            | 61 +++++++++++++++++++
 libgomp/testsuite/Makefile.in                 |  1 +
 libgomp/testsuite/libgomp.ompd/header-1.c     | 10 +++
 .../testsuite/libgomp.ompd/header-order-1.c   | 11 ++++
 .../testsuite/libgomp.ompd/header-order-2.c   | 11 ++++
 libgomp/testsuite/libgomp.ompd/ompd.exp       | 38 ++++++++++++
 16 files changed, 312 insertions(+), 9 deletions(-)
 create mode 100644 libgomp/libgompd.h
 create mode 100644 libgomp/libgompd.map
 create mode 100644 libgomp/ompd-lib.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-1.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-order-1.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/header-order-2.c
 create mode 100644 libgomp/testsuite/libgomp.ompd/ompd.exp

-- 
2.27.0

Comments

Patrick Palka via Gcc-patches June 26, 2020, 9:02 a.m. | #1
Thanks, just nits, no need to repost, just commit it after you make those
changes.

On Thu, Jun 25, 2020 at 05:58:23PM -0400, y2s1982 via Gcc-patches wrote:

> 	* Makefile.am(toolexeclib_LTLIBRARIES): Add libgompd.la.


Missing space between am and (.

>         (libgompd_la_LDFLAGS, libgompd_la_DEPENDENCIES, libgompd_la_LINK,

>         libgompd_la_SOURCES, libgompd_version_dep, libgompd_version_script,

>         libgompd.ver-sun, libgompd.ver, libgompd_version_info): Set.


These lines are wrongly indented, should use tab instead of 8 spaces.

> 	* env.c(ompd_dll_locations_valid): Define with no compiler optimization.


Again, missing space.

> --- /dev/null

> +++ b/libgomp/libgompd.map

> @@ -0,0 +1,49 @@

> +OMPD_5.0 {

> +  global:

> +	ompd_dll_locations_valid;


ompd_dll_locations_valid is exported from libgomp.so.1, not libgompd.so.1,
so doesn't belong here.

> +ompd_rc_t

> +ompd_get_version_string (const char **string)

> +{

  *string = "GNU OpenMP Runtime implementing OpenMP 5.0 "
		ompd_stringify (OMPD_VERSION);

Please align ompd_stringify below "GNU.

	Jakub
Patrick Palka via Gcc-patches June 26, 2020, 4:57 p.m. | #2
Hello,

On Fri, Jun 26, 2020 at 5:03 AM Jakub Jelinek <jakub@redhat.com> wrote:

> Thanks, just nits, no need to repost, just commit it after you make those

> changes.

>

> On Thu, Jun 25, 2020 at 05:58:23PM -0400, y2s1982 via Gcc-patches wrote:

>

> >       * Makefile.am(toolexeclib_LTLIBRARIES): Add libgompd.la.

>

> Missing space between am and (.

>

> >       * env.c(ompd_dll_locations_valid): Define with no compiler

> optimization.

>

> Again, missing space.

>

> The contrib/mklog.py, which I use to generate these messages, seems to

generate the statement without a space after the filename and before the (.
It seems like an easy fix of just adding a space like the following:
  diff --git a/contrib/mklog.py b/contrib/mklog.py
  index 243edbb15c5..0b01cde6fca 100755
  --- a/contrib/mklog.py
  +++ b/contrib/mklog.py
  @@ -215,7 +215,7 @@ def generate_changelog(data, no_functions=False,
fill_pr_titles=False):
                   if functions:
                       out += '\t* %s (%s):\n' % (relative_path,
functions[0])
                       for fn in functions[1:]:
  -                        out += '\t(%s):\n' % fn
  +                       out += '\t (%s):\n' % fn
                   else:
                      out += '\t* %s:\n' % relative_path
          out += '\n'

Would it be okay for me to make this patch? I wasn't sure of the exact
procedure that I might have to do prior to sending in a patch.

Cheers,

Tony Sim


>         Jakub

>

>
Patrick Palka via Gcc-patches June 26, 2020, 5:08 p.m. | #3
On Fri, Jun 26, 2020 at 12:57:59PM -0400, y2s1982 . wrote:
> > >       * env.c(ompd_dll_locations_valid): Define with no compiler

> > optimization.

> >

> > Again, missing space.

> >

> > The contrib/mklog.py, which I use to generate these messages, seems to

> generate the statement without a space after the filename and before the (.

> It seems like an easy fix of just adding a space like the following:

>   diff --git a/contrib/mklog.py b/contrib/mklog.py

>   index 243edbb15c5..0b01cde6fca 100755

>   --- a/contrib/mklog.py

>   +++ b/contrib/mklog.py

>   @@ -215,7 +215,7 @@ def generate_changelog(data, no_functions=False,

> fill_pr_titles=False):

>                    if functions:

>                        out += '\t* %s (%s):\n' % (relative_path,

> functions[0])

>                        for fn in functions[1:]:

>   -                        out += '\t(%s):\n' % fn

>   +                       out += '\t (%s):\n' % fn

>                    else:

>                       out += '\t* %s:\n' % relative_path

>           out += '\n'


That is strange.  The missing space I'm complaining about, e.g. between
env.c and (, is there in the above snippet, that is
'\t* %s (%s):\n'
       ^--------- this one
and the space you are adding to mklog.py is undesirable, when one modifies
multiple functions, it should look like:
	* env.c (foo): Something.
	(bar): Something else.
rather than
	* env.c (foo): Something.
	 (bar): Something else.

	Jakub
Patrick Palka via Gcc-patches June 26, 2020, 5:21 p.m. | #4
Hello,

On Fri, Jun 26, 2020 at 1:08 PM Jakub Jelinek <jakub@redhat.com> wrote:

> On Fri, Jun 26, 2020 at 12:57:59PM -0400, y2s1982 . wrote:

> > > >       * env.c(ompd_dll_locations_valid): Define with no compiler

> > > optimization.

> > >

> > > Again, missing space.

> > >

> > > The contrib/mklog.py, which I use to generate these messages, seems to

> > generate the statement without a space after the filename and before the

> (.

> > It seems like an easy fix of just adding a space like the following:

> >   diff --git a/contrib/mklog.py b/contrib/mklog.py

> >   index 243edbb15c5..0b01cde6fca 100755

> >   --- a/contrib/mklog.py

> >   +++ b/contrib/mklog.py

> >   @@ -215,7 +215,7 @@ def generate_changelog(data, no_functions=False,

> > fill_pr_titles=False):

> >                    if functions:

> >                        out += '\t* %s (%s):\n' % (relative_path,

> > functions[0])

> >                        for fn in functions[1:]:

> >   -                        out += '\t(%s):\n' % fn

> >   +                       out += '\t (%s):\n' % fn

> >                    else:

> >                       out += '\t* %s:\n' % relative_path

> >           out += '\n'

>

> That is strange.  The missing space I'm complaining about, e.g. between

> env.c and (, is there in the above snippet, that is

> '\t* %s (%s):\n'

>        ^--------- this one

> and the space you are adding to mklog.py is undesirable, when one modifies

> multiple functions, it should look like:

>         * env.c (foo): Something.

>         (bar): Something else.

> rather than

>         * env.c (foo): Something.

>          (bar): Something else.

>


I see. I was thinking that doesn't make much sense, too, but when tested,
it placed
a space between the filename and the (.  I wasn't sure what to make of it.
Maybe my editor is somehow manipulating spaces and tabs when loading the
patch
for final editing or maybe the script I made is doing something more than
just pasting
the output of the contrib/mklog.py to the patch.
Thanks for pointing it out. I will investigate further.

Cheers,

Tony Sim

>

>         Jakub

>

>

Patch

diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 4d31f4cef46..e15a838e55c 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -20,7 +20,7 @@  AM_CPPFLAGS = $(addprefix -I, $(search_path))
 AM_CFLAGS = $(XCFLAGS)
 AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
 
-toolexeclib_LTLIBRARIES = libgomp.la
+toolexeclib_LTLIBRARIES = libgomp.la libgompd.la
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB
@@ -31,14 +31,21 @@  PREPROCESS = $(subst -Wc$(comma), , $(COMPILE)) -E
 libgomp.ver: $(top_srcdir)/libgomp.map
 	$(EGREP) -v '#(#| |$$)' $< | \
 	  $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
+libgompd.ver: $(top_srcdir)/libgompd.map
+	$(EGREP) -v '#(#| |$$)' $< | \
+	  $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB_GNU
 libgomp_version_script = -Wl,--version-script,libgomp.ver
+libgompd_version_script = -Wl,--version-script,libgompd.ver
 libgomp_version_dep = libgomp.ver
+libgompd_version_dep = libgompd.ver
 endif
 if LIBGOMP_BUILD_VERSIONED_SHLIB_SUN
 libgomp_version_script = -Wl,-M,libgomp.ver-sun
+libgompd_version_script = -Wl,-M,libgompd.ver-sun
 libgomp_version_dep = libgomp.ver-sun
+libgompd_version_dep = libgompd.ver-sun
 libgomp.ver-sun : libgomp.ver \
 		$(top_srcdir)/../contrib/make_sunver.pl \
 		$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
@@ -48,16 +55,32 @@  libgomp.ver-sun : libgomp.ver \
 	 `echo $(libgomp_la_LIBADD) | \
 	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
 	 > $@ || (rm -f $@ ; exit 1)
+libgompd.ver-sun : libgompd.ver \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libgompd_la_OBJECTS) $(libgompd_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  libgompd.ver \
+	  $(libgompd_la_OBJECTS:%.lo=.libs/%.o) \
+	 `echo $(libgompd_la_LIBADD) | \
+	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+	 > $@ || (rm -f $@ ; exit 1)
 endif
 else
 libgomp_version_script =
+libgompd_version_script =
 libgomp_version_dep =
+libgompd_version_dep =
 endif
 libgomp_version_info = -version-info $(libtool_VERSION)
+libgompd_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
-        $(lt_host_flags)
+	$(lt_host_flags)
+libgompd_la_LDFLAGS = $(libgompd_version_info) $(libgompd_version_script) \
+	$(lt_host_flags)
 libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
+libgompd_la_DEPENDENCIES = $(libgompd_version_dep)
 libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
+libgompd_la_LINK = $(LINK) $(libgompd_la_LDFLAGS)
 
 libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.c error.c \
 	icv.c icv-device.c iter.c iter_ull.c loop.c loop_ull.c ordered.c \
@@ -67,6 +90,8 @@  libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.c error.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
 
+libgompd_la_SOURCES = ompd-lib.c
+
 include $(top_srcdir)/plugin/Makefrag.am
 
 if USE_FORTRAN
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 3ca1be0d73e..af897d6c6ba 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -234,6 +234,9 @@  am_libgomp_la_OBJECTS = alloc.lo atomic.lo barrier.lo critical.lo \
 	teams.lo allocator.lo oacc-profiling.lo oacc-target.lo \
 	$(am__objects_1)
 libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS)
+libgompd_la_LIBADD =
+am_libgompd_la_OBJECTS = ompd-lib.lo
+libgompd_la_OBJECTS = $(am_libgompd_la_OBJECTS)
 AM_V_P = $(am__v_P_@AM_V@)
 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -282,7 +285,8 @@  am__v_FCLD_0 = @echo "  FCLD    " $@;
 am__v_FCLD_1 = 
 SOURCES = $(libgomp_plugin_gcn_la_SOURCES) \
 	$(libgomp_plugin_hsa_la_SOURCES) \
-	$(libgomp_plugin_nvptx_la_SOURCES) $(libgomp_la_SOURCES)
+	$(libgomp_plugin_nvptx_la_SOURCES) $(libgomp_la_SOURCES) \
+	$(libgompd_la_SOURCES)
 AM_V_DVIPS = $(am__v_DVIPS_@AM_V@)
 am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@)
 am__v_DVIPS_0 = @echo "  DVIPS   " $@;
@@ -548,8 +552,8 @@  libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
 AM_CPPFLAGS = $(addprefix -I, $(search_path))
 AM_CFLAGS = $(XCFLAGS)
 AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
-toolexeclib_LTLIBRARIES = libgomp.la $(am__append_1) $(am__append_2) \
-	$(am__append_3)
+toolexeclib_LTLIBRARIES = libgomp.la libgompd.la $(am__append_1) \
+	$(am__append_2) $(am__append_3)
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 # -Wc is only a libtool option.
@@ -558,15 +562,27 @@  nodist_toolexeclib_HEADERS = libgomp.spec
 @LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgomp_version_script = 
 @LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_script = -Wl,--version-script,libgomp.ver
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_script = -Wl,-M,libgomp.ver-sun
+@LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgompd_version_script = 
+@LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_script = -Wl,--version-script,libgompd.ver
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_script = -Wl,-M,libgompd.ver-sun
 @LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgomp_version_dep = 
 @LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep = libgomp.ver
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp_version_dep = libgomp.ver-sun
+@LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@libgompd_version_dep = 
+@LIBGOMP_BUILD_VERSIONED_SHLIB_GNU_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_dep = libgompd.ver
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd_version_dep = libgompd.ver-sun
 libgomp_version_info = -version-info $(libtool_VERSION)
+libgompd_version_info = -version-info $(libtool_VERSION)
 libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \
         $(lt_host_flags)
 
+libgompd_la_LDFLAGS = $(libgompd_version_info) $(libgompd_version_script) \
+        $(lt_host_flags)
+
 libgomp_la_DEPENDENCIES = $(libgomp_version_dep)
+libgompd_la_DEPENDENCIES = $(libgompd_version_dep)
 libgomp_la_LINK = $(LINK) $(libgomp_la_LDFLAGS)
+libgompd_la_LINK = $(LINK) $(libgompd_la_LDFLAGS)
 libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.c \
 	error.c icv.c icv-device.c iter.c iter_ull.c loop.c loop_ull.c \
 	ordered.c parallel.c sections.c single.c task.c team.c work.c \
@@ -576,6 +592,7 @@  libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.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)
+libgompd_la_SOURCES = ompd-lib.c
 
 # Nvidia PTX OpenACC plugin.
 @PLUGIN_NVPTX_TRUE@libgomp_plugin_nvptx_version_info = -version-info $(libtool_VERSION)
@@ -758,6 +775,9 @@  libgomp-plugin-nvptx.la: $(libgomp_plugin_nvptx_la_OBJECTS) $(libgomp_plugin_nvp
 libgomp.la: $(libgomp_la_OBJECTS) $(libgomp_la_DEPENDENCIES) $(EXTRA_libgomp_la_DEPENDENCIES) 
 	$(AM_V_GEN)$(libgomp_la_LINK) -rpath $(toolexeclibdir) $(libgomp_la_OBJECTS) $(libgomp_la_LIBADD) $(LIBS)
 
+libgompd.la: $(libgompd_la_OBJECTS) $(libgompd_la_DEPENDENCIES) $(EXTRA_libgompd_la_DEPENDENCIES) 
+	$(AM_V_GEN)$(libgompd_la_LINK) -rpath $(toolexeclibdir) $(libgompd_la_OBJECTS) $(libgompd_la_LIBADD) $(LIBS)
+
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
 
@@ -796,6 +816,7 @@  distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oacc-plugin.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oacc-profiling.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oacc-target.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-lib.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordered.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/priority_queue.Plo@am__quote@
@@ -1404,6 +1425,9 @@  vpath % $(strip $(search_path))
 @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp.ver: $(top_srcdir)/libgomp.map
 @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	$(EGREP) -v '#(#| |$$)' $< | \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	  $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
+@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd.ver: $(top_srcdir)/libgompd.map
+@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	$(EGREP) -v '#(#| |$$)' $< | \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	  $(PREPROCESS) -P -include config.h - > $@ || (rm -f $@ ; exit 1)
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgomp.ver-sun : libgomp.ver \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@		$(top_srcdir)/../contrib/make_sunver.pl \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@		$(libgomp_la_OBJECTS) $(libgomp_la_LIBADD)
@@ -1413,6 +1437,15 @@  vpath % $(strip $(search_path))
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	 `echo $(libgomp_la_LIBADD) | \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
 @LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	 > $@ || (rm -f $@ ; exit 1)
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@libgompd.ver-sun : libgompd.ver \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@		$(top_srcdir)/../contrib/make_sunver.pl \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@		$(libgompd_la_OBJECTS) $(libgompd_la_LIBADD)
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	perl $(top_srcdir)/../contrib/make_sunver.pl \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	  libgompd.ver \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	  $(libgompd_la_OBJECTS:%.lo=.libs/%.o) \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	 `echo $(libgompd_la_LIBADD) | \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	    sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+@LIBGOMP_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@	 > $@ || (rm -f $@ ; exit 1)
 
 omp_lib_kinds.mod: omp_lib.mod
 	:
diff --git a/libgomp/config/darwin/plugin-suffix.h b/libgomp/config/darwin/plugin-suffix.h
index 171a7a8113e..19e6ebeb04a 100644
--- a/libgomp/config/darwin/plugin-suffix.h
+++ b/libgomp/config/darwin/plugin-suffix.h
@@ -23,4 +23,4 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define SONAME_SUFFIX(n) ("." #n ".dylib")
+#define SONAME_SUFFIX(n) "." #n ".dylib"
diff --git a/libgomp/config/hpux/plugin-suffix.h b/libgomp/config/hpux/plugin-suffix.h
index 29e1f12726c..71c062ec696 100644
--- a/libgomp/config/hpux/plugin-suffix.h
+++ b/libgomp/config/hpux/plugin-suffix.h
@@ -23,4 +23,4 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define SONAME_SUFFIX(n) (".sl." #n)
+#define SONAME_SUFFIX(n) ".sl." #n
diff --git a/libgomp/config/posix/plugin-suffix.h b/libgomp/config/posix/plugin-suffix.h
index d111e529b84..20c4ab8f988 100644
--- a/libgomp/config/posix/plugin-suffix.h
+++ b/libgomp/config/posix/plugin-suffix.h
@@ -23,4 +23,4 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-#define SONAME_SUFFIX(n) (".so." #n)
+#define SONAME_SUFFIX(n) ".so." #n
diff --git a/libgomp/env.c b/libgomp/env.c
index c0c4730d47c..c29bd5d0954 100644
--- a/libgomp/env.c
+++ b/libgomp/env.c
@@ -32,6 +32,8 @@ 
 #include <limits.h>
 #ifndef LIBGOMP_OFFLOADED_ONLY
 #include "libgomp_f.h"
+#include "libgompd.h"
+#include "plugin-suffix.h"
 #include "oacc-int.h"
 #include <ctype.h>
 #include <stdlib.h>
@@ -1350,6 +1352,15 @@  handle_omp_display_env (unsigned long stacksize, int wait_policy)
   fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr);
 }
 
+static const char *gompd_dll_locations[2] = { "libgompd" SONAME_SUFFIX (1), NULL };
+const char **ompd_dll_locations = gompd_dll_locations;
+
+#ifndef HAVE_ATTRIBUTE_ALIAS
+void __attribute__((noipa))
+ompd_dll_locations_valid (void)
+{
+}
+#endif
 
 static void __attribute__((constructor))
 initialize_env (void)
@@ -1357,6 +1368,11 @@  initialize_env (void)
   unsigned long thread_limit_var, stacksize = GOMP_DEFAULT_STACKSIZE;
   int wait_policy;
 
+
+#ifndef HAVE_ATTRIBUTE_ALIAS
+  ompd_dll_locations_valid ();
+#endif
+
   /* Do a compile time check that mkomp_h.pl did good job.  */
   omp_check_defines ();
 
@@ -1486,4 +1502,9 @@  initialize_env (void)
 
   goacc_profiling_initialize ();
 }
+
+#ifdef HAVE_ATTRIBUTE_ALIAS
+strong_alias (initialize_env, ompd_dll_locations_valid)
+#endif
+
 #endif /* LIBGOMP_OFFLOADED_ONLY */
diff --git a/libgomp/libgomp.map b/libgomp/libgomp.map
index 012e3d645fe..b35f8d4368f 100644
--- a/libgomp/libgomp.map
+++ b/libgomp/libgomp.map
@@ -553,3 +553,9 @@  GOMP_PLUGIN_1.3 {
 	GOMP_PLUGIN_goacc_profiling_dispatch;
 	GOMP_PLUGIN_goacc_thread;
 } GOMP_PLUGIN_1.2;
+
+OMPD_5.0 {
+  global:
+	ompd_dll_locations;
+	ompd_dll_locations_valid;
+};
diff --git a/libgomp/libgompd.h b/libgomp/libgompd.h
new file mode 100644
index 00000000000..9782828bff5
--- /dev/null
+++ b/libgomp/libgompd.h
@@ -0,0 +1,37 @@ 
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Yoosuk Sim <y2s1982@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 various macros and auxiliary function declarations
+   for OMPD library.  */
+
+#ifndef LIBGOMPD_H
+#define LIBGOMPD_H 1
+
+#define ompd_stringify(x) ompd_str2(x)
+#define ompd_str2(x) #x
+
+#define OMPD_VERSION 201811
+
+#endif /* LIBGOMPD_H */
diff --git a/libgomp/libgompd.map b/libgomp/libgompd.map
new file mode 100644
index 00000000000..b70c3ca43e5
--- /dev/null
+++ b/libgomp/libgompd.map
@@ -0,0 +1,49 @@ 
+OMPD_5.0 {
+  global:
+	ompd_dll_locations_valid;
+	ompd_bp_parallel_begin;
+	ompd_bp_parallel_end;
+	ompd_bp_task_begin;
+	ompd_bp_task_end;
+	ompd_bp_thread_begin;
+	ompd_bp_thread_end;
+	ompd_bp_device_begin;
+	ompd_bp_device_end;
+	ompd_initialize;
+	ompd_get_api_version;
+	ompd_get_version_string;
+	ompd_get_finalize;
+	ompd_process_initialize;
+	ompd_device_initialize;
+	ompd_rel_address_space_handle;
+	ompd_get_omp_version;
+	ompd_get_omp_version_string;
+	ompd_get_thread_in_parallel;
+	ompd_get_thread_handle;
+	ompd_rel_thread_handle;
+	ompd_thread_handle_compare;
+	ompd_get_thread_id;
+	ompd_get_curr_parallel_handle;
+	ompd_get_enclosing_parallel_handle;
+	ompd_get_task_parallel_handle;
+	ompd_rel_parallel_handle;
+	ompd_parallel_handle_compare;
+	ompd_get_curr_task_handle;
+	ompd_get_generating_task_handle;
+	ompd_get_scheduling_task_handle;
+	ompd_get_task_in_parallel;
+	ompd_rel_task_handle;
+	ompd_task_handle_compare;
+	ompd_get_task_function;
+	ompd_get_task_frame;
+	ompd_enumerate_states;
+	ompd_get_state;
+	ompd_get_display_control_vars;
+	ompd_rel_display_control_vars;
+	ompd_enumerate_icvs;
+	ompd_get_icv_from_scope;
+	ompd_get_icv_string_from_scope;
+	ompd_get_tool_data;
+  local:
+	*;
+};
diff --git a/libgomp/omp-tools.h b/libgomp/omp-tools.h
index 394c33e40dd..571ba72e22a 100644
--- a/libgomp/omp-tools.h
+++ b/libgomp/omp-tools.h
@@ -101,7 +101,7 @@  typedef struct ompd_device_type_sizes_t {
 } ompd_device_type_sizes_t;
 
 
-const char **ompd_dll_locations;
+extern const char **ompd_dll_locations;
 
 void ompd_dll_locations_valid (void) __GOMPD_NOTHROW;
 
diff --git a/libgomp/ompd-lib.c b/libgomp/ompd-lib.c
new file mode 100644
index 00000000000..c268eb9d93d
--- /dev/null
+++ b/libgomp/ompd-lib.c
@@ -0,0 +1,61 @@ 
+/* Copyright (C) 2020 Free Software Foundation, Inc.
+   Contributed by Yoosuk Sim <y2s1982@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 function definitions for OMPD's per-library functions
+   defined in the OpenMP 5.0 API Documentation, 5.5.1.  */
+
+#include "omp-tools.h"
+#include "libgompd.h"
+
+ompd_rc_t
+ompd_get_api_version (ompd_word_t *version)
+{
+  *version = OMPD_VERSION;
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+ompd_get_version_string (const char **string)
+{
+  *string = "GNU OpenMP Runtime implementing OpenMP 5.0 "
+		ompd_stringify (OMPD_VERSION);
+  return ompd_rc_ok;
+}
+
+ompd_rc_t
+ompd_initialize (ompd_word_t api_version, const ompd_callbacks_t *callbacks)
+{
+  static int ompd_initialized = 0;
+
+  if (ompd_initialized)
+    return ompd_rc_error;
+
+  (void) api_version;
+  (void) callbacks;
+
+  ompd_initialized = 1;
+
+  return ompd_rc_ok;
+}
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 52aa6c5fbc9..845dedc80b6 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -295,6 +295,7 @@  target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
+tmake_file = @tmake_file@
 toolexecdir = @toolexecdir@
 toolexeclibdir = @toolexeclibdir@
 top_build_prefix = @top_build_prefix@
diff --git a/libgomp/testsuite/libgomp.ompd/header-1.c b/libgomp/testsuite/libgomp.ompd/header-1.c
new file mode 100644
index 00000000000..5fb20d40402
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/header-1.c
@@ -0,0 +1,10 @@ 
+/*  Test that the omp-tools.h will compile successfully.  */
+
+/* { dg-do compile } */
+#include "omp-tools.h"
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.ompd/header-order-1.c b/libgomp/testsuite/libgomp.ompd/header-order-1.c
new file mode 100644
index 00000000000..a3aa60166ec
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/header-order-1.c
@@ -0,0 +1,11 @@ 
+/*  Test that the omp-tools.h will compile successfully with omp.h .  */
+
+/* { dg-do compile } */
+#include "omp-tools.h"
+#include "omp.h"
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.ompd/header-order-2.c b/libgomp/testsuite/libgomp.ompd/header-order-2.c
new file mode 100644
index 00000000000..12a5da3dfc6
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/header-order-2.c
@@ -0,0 +1,11 @@ 
+/*  Test that the omp-tools.h will compile successfully with omp.h .  */
+
+/* { dg-do compile } */
+#include "omp.h"
+#include "omp-tools.h"
+
+int
+main ()
+{
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.ompd/ompd.exp b/libgomp/testsuite/libgomp.ompd/ompd.exp
new file mode 100644
index 00000000000..1df981c186e
--- /dev/null
+++ b/libgomp/testsuite/libgomp.ompd/ompd.exp
@@ -0,0 +1,38 @@ 
+if [info exists lang_library_path] then {
+    unset lang_library_path
+    unset lang_link_flags
+}
+if [info exists lang_test_file] then {
+    unset lang_test_file
+}
+if [info exists lang_include_flags] then {
+    unset lang_include_flags
+}
+
+load_lib libgomp-dg.exp
+load_gcc_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS "-O2"
+}
+
+# Initialize dg.
+dg-init
+
+# Turn on OpenMP.
+lappend ALWAYS_CFLAGS "additional_flags=-fopenmp"
+
+# Gather a list of all tests.
+set tests [lsort [concat \
+		      [find $srcdir/$subdir *.c]]]
+
+set ld_library_path $always_ld_library_path
+append ld_library_path [gcc-set-multilib-library-path $GCC_UNDER_TEST]
+set_ld_library_path_env_vars
+
+# Main loop.
+dg-runtest $tests "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish