@@ -90,7 +90,7 @@ 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 ompd-proc.c
+libgompd_la_SOURCES = ompd-lib.c ompd-proc.c ompd-addr.c
include $(top_srcdir)/plugin/Makefrag.am
@@ -235,7 +235,7 @@ am_libgomp_la_OBJECTS = alloc.lo atomic.lo barrier.lo critical.lo \
$(am__objects_1)
libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS)
libgompd_la_LIBADD =
-am_libgompd_la_OBJECTS = ompd-lib.lo ompd-proc.lo
+am_libgompd_la_OBJECTS = ompd-lib.lo ompd-proc.lo ompd-addr.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@)
@@ -592,7 +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 ompd-proc.c
+libgompd_la_SOURCES = ompd-lib.c ompd-proc.c ompd-addr.c
# Nvidia PTX OpenACC plugin.
@PLUGIN_NVPTX_TRUE@libgomp_plugin_nvptx_version_info = -version-info $(libtool_VERSION)
@@ -816,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-addr.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-lib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-proc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ordered.Plo@am__quote@
@@ -38,6 +38,20 @@
extern ompd_callbacks_t gompd_callbacks;
+typedef struct gompd_environment_variables
+{
+ /* TODO: when the struct is better defined, turn it into a compact form.
+ LINK: https://gcc.gnu.org/pipermail/gcc-patches/2020-July/549698.html
+ For now, keep it as a struct. */
+
+ /* Environment set version number. */
+ ompd_word_t gompd_env_version;
+ /* Represents _OPENMP that is in yyyymm format. */
+ ompd_word_t openmp_version;
+} gompd_env;
+
+ompd_rc_t gompd_set_environment (gompd_env **) __GOMPD_NOTHROW;
+
typedef struct _ompd_aspace_handle {
ompd_address_space_context_t *context;
ompd_device_t kind;
@@ -45,6 +59,7 @@ typedef struct _ompd_aspace_handle {
void *id;
ompd_address_space_handle_t *process_reference;
ompd_size_t ref_count;
+ gompd_env *env;
} ompd_address_space_handle_t;
#endif /* LIBGOMPD_H */
new file mode 100644
@@ -0,0 +1,83 @@
+/* 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 Address Space Information
+ functions defined in the OpenMP 5.0 API Documentation, 5.5.4. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "omp-tools.h"
+#include "libgompd.h"
+
+ompd_rc_t
+ompd_get_omp_version (ompd_address_space_handle_t *address_space,
+ ompd_word_t *omp_version)
+{
+ if (omp_version == NULL)
+ return ompd_rc_bad_input;
+ if (address_space == NULL)
+ return ompd_rc_stale_handle;
+
+ /* TODO: once environment values are encoded, make a function to decode
+ and fetch variables. */
+ *omp_version = address_space->env->openmp_version;
+
+ return ompd_rc_ok;
+}
+
+ompd_rc_t
+ompd_get_omp_version_string (ompd_address_space_handle_t *address_space,
+ const char **string)
+{
+ if (string == NULL)
+ return ompd_rc_bad_input;
+
+ if (address_space == NULL)
+ return ompd_rc_stale_handle;
+
+ ompd_size_t macro_length = strlen ("yyyymm");
+ ompd_word_t omp_version;
+ ompd_rc_t ret = ompd_get_omp_version (address_space, &omp_version);
+ if (ret != ompd_rc_ok)
+ return ret;
+
+ char *description = "GNU OpenMP Runtime implementing OpenMP 5.0 ";
+ ompd_size_t description_length = strlen (description);
+
+ size_t total_length = description_length + macro_length + 1;
+
+ char *t = NULL;
+ ret = gompd_callbacks.alloc_memory (total_length, (void *) t);
+ if (ret != ompd_rc_ok)
+ return ret;
+
+ memcpy (t, description, description_length);
+ snprintf (t + description_length, macro_length, "%ld", omp_version);
+
+ *string = t;
+
+ return ret;
+}
@@ -54,10 +54,21 @@ ompd_process_initialize (ompd_address_space_context_t *context,
(*handle)->sizeof_id = 0;
(*handle)->process_reference = NULL;
(*handle)->ref_count = 0;
+ gompd_set_environment (&(*handle)->env);
return ret;
}
+ompd_rc_t
+gompd_set_environment (gompd_env **env)
+{
+ /* TODO: Turn this placeholder function to handle OMPD environment variables
+ when it becomes compact. */
+ gompd_env temp_env = { 202007, 201811 };
+ **env = temp_env;
+ return ompd_rc_ok;
+}
+
ompd_rc_t
ompd_device_initialize (ompd_address_space_handle_t *process_handle,
ompd_address_space_context_t *device_context,