This patch adds some unit tests for omp-tools.h header. It also adds some simple functions related to OMPD API versions. It also partially defines the OMPD initialization function.
2020-06-23 Tony Sim <y2s1...@gmail.com> libgomp/ChangeLog: * Makefile.am (toolexeclib_LTLIBRARIES and related): Add libgompd.la. * Makefile.in: Regenerate. * config/darwin/plugin-suffix.h (SONAME_SUFFIX): Removed (). * config/hpux/plugin-suffix.h (SONAME_SUFFIX): Removed (). * config/posix/plugin-suffix.h (SONAME_SUFFIX): Removed (). * testsuite/Makefile.in: Regenerate. * libgompd.c: New file. * libgompd.h: 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 | 8 +++- libgomp/Makefile.in | 20 ++++++-- libgomp/config/darwin/plugin-suffix.h | 2 +- libgomp/config/hpux/plugin-suffix.h | 2 +- libgomp/config/posix/plugin-suffix.h | 2 +- libgomp/libgompd.c | 46 +++++++++++++++++++ libgomp/libgompd.h | 7 +++ libgomp/testsuite/Makefile.in | 1 + libgomp/testsuite/libgomp.ompd/header-1.c | 6 +++ .../testsuite/libgomp.ompd/header-order-1.c | 7 +++ .../testsuite/libgomp.ompd/header-order-2.c | 7 +++ libgomp/testsuite/libgomp.ompd/ompd.exp | 38 +++++++++++++++ 12 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 libgomp/libgompd.c create mode 100644 libgomp/libgompd.h 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 diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am index 4d31f4cef46..c26c26c59a4 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 @@ -67,6 +67,12 @@ 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_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \ + $(lt_host_flags) +libgompd_la_DEPENDENCIES = $(libgomp_version_dep) +libgompd_la_LINK = $(LINK) $(libgomp_la_LDFLAGS) +libgompd_la_SOURCES = libgompd.c + include $(top_srcdir)/plugin/Makefrag.am if USE_FORTRAN diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in index 3ca1be0d73e..c4c9e437e94 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 = libgompd.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. @@ -576,6 +580,12 @@ 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_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script) \ + $(lt_host_flags) + +libgompd_la_DEPENDENCIES = $(libgomp_version_dep) +libgompd_la_LINK = $(LINK) $(libgomp_la_LDFLAGS) +libgompd_la_SOURCES = libgompd.c # Nvidia PTX OpenACC plugin. @PLUGIN_NVPTX_TRUE@libgomp_plugin_nvptx_version_info = -version-info $(libtool_VERSION) @@ -758,6 +768,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) @@ -783,6 +796,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgomp_plugin_gcn_la-plugin-gcn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgomp_plugin_hsa_la-plugin-hsa.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgomp_plugin_nvptx_la-plugin-nvptx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libgompd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lock.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loop.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loop_ull.Plo@am__quote@ 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/libgompd.c b/libgomp/libgompd.c new file mode 100644 index 00000000000..e77e43d9c7a --- /dev/null +++ b/libgomp/libgompd.c @@ -0,0 +1,46 @@ +#include <string.h> +#include <stdlib.h> +#include "omp-tools.h" +#include "libgompd.h" +//#include "plugin-suffix.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 = str(OMPD_VERSION); + return ompd_rc_ok; +} + +ompd_rc_t ompd_initialize ( ompd_word_t api_version, const ompd_callbacks_t *callbacks ) +{ + /* initialized flag */ + static int ompd_initialized = 0; + + if (ompd_initialized) + return ompd_rc_error; + + /* compute library name and locations */ + const char *prefix = "libgompd."; + const char *suffix = SONAME_SUFFIX (1); + size_t prefix_len, suffix_len; + prefix_len = strlen(prefix); + suffix_len = strlen(suffix); + char *ompd_name = (char *) malloc (prefix_len + suffix_len + 1); + memcpy (ompd_name, prefix, prefix_len); + memcpy (ompd_name + prefix_len, suffix, suffix_len + 1); + + /* set dll locations */ + const char *my_dll_locations[2] = {ompd_name, NULL}; + + ompd_dll_locations = my_dll_locations; + + /* set initialized flag */ + ompd_initialized = 1; + + return ompd_rc_ok; +} diff --git a/libgomp/libgompd.h b/libgomp/libgompd.h new file mode 100644 index 00000000000..d4547690f20 --- /dev/null +++ b/libgomp/libgompd.h @@ -0,0 +1,7 @@ + +#ifndef LIBGOMPD_H +#define LIBGOMPD_H 1 + +#define OMPD_VERSION 201811 + +#endif /* LIBGOMPD_H */ 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..264aa0af762 --- /dev/null +++ b/libgomp/testsuite/libgomp.ompd/header-1.c @@ -0,0 +1,6 @@ +/* Test that the omp-tools.h will compile successfully. */ + +/* { dg-do run } */ +#include "omp-tools.h" + +int main(void){ 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..456385c1414 --- /dev/null +++ b/libgomp/testsuite/libgomp.ompd/header-order-1.c @@ -0,0 +1,7 @@ +/* Test that the omp-tools.h will compile successfully with omp.h . */ + +/* { dg-do run } */ +#include "omp-tools.h" +#include "omp.h" + +int main(void){ 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..00082f7cf95 --- /dev/null +++ b/libgomp/testsuite/libgomp.ompd/header-order-2.c @@ -0,0 +1,7 @@ +/* Test that the omp-tools.h will compile successfully with omp.h . */ + +/* { dg-do run } */ +#include "omp.h" +#include "omp-tools.h" + +int main(void){ 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 -- 2.26.2