From: Ahmed Sayed Mousse <ahmedsayedmousse@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [patch] libgompd: Add thread handles
Date: Fri, 1 Jul 2022 02:00:38 +0200 [thread overview]
Message-ID: <a06b303c-a59c-b411-0c30-eb9826f4a14c@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 464 bytes --]
/This patch is the initial implementation of OpenMP-API specs book section //20.5.5 with title "Thread Handles". /libgomp/ChangeLog /2022-07-01
Ahmed Sayed <ahmedsayedmousse@gmail.com> // * Makefile.am
(libgompd_la_SOURCES): Add ompd-threads.c.///* Makefile.in: Regenerate. * team.c ( gomp_free_thread ): Called
ompd_bp_thread_end ()./* ompd-support.c ( gompd_thread_initial_tls_bias
): New Variable. (gompd_load): Initialize gompd_thread_initial_tls_bias.///
[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 25990 bytes --]
diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
index 6d913a93e7f..23f5bede1bf 100644
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -94,7 +94,7 @@ libgomp_la_SOURCES = alloc.c atomic.c barrier.c critical.c env.c error.c \
priority_queue.c affinity-fmt.c teams.c allocator.c oacc-profiling.c \
oacc-target.c ompd-support.c
-libgompd_la_SOURCES = ompd-init.c ompd-helper.c ompd-icv.c
+libgompd_la_SOURCES = ompd-init.c ompd-helper.c ompd-icv.c ompd-threads.c
include $(top_srcdir)/plugin/Makefrag.am
diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in
index 40f896b5f03..8bbc46cca25 100644
--- a/libgomp/Makefile.in
+++ b/libgomp/Makefile.in
@@ -133,21 +133,8 @@ target_triplet = @target@
@USE_FORTRAN_TRUE@am__append_7 = openacc.f90
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
- $(top_srcdir)/../config/ax_count_cpus.m4 \
- $(top_srcdir)/../config/depstand.m4 \
- $(top_srcdir)/../config/enable.m4 \
- $(top_srcdir)/../config/futex.m4 \
- $(top_srcdir)/../config/lead-dot.m4 \
- $(top_srcdir)/../config/lthostflags.m4 \
- $(top_srcdir)/../config/multi.m4 \
- $(top_srcdir)/../config/override.m4 \
- $(top_srcdir)/../config/tls.m4 \
- $(top_srcdir)/../config/toolexeclibdir.m4 \
- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
- $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
- $(top_srcdir)/../config/cet.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../config/cet.m4 \
$(top_srcdir)/plugin/configfrag.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -233,7 +220,8 @@ am_libgomp_la_OBJECTS = alloc.lo atomic.lo barrier.lo critical.lo \
affinity-fmt.lo teams.lo allocator.lo oacc-profiling.lo \
oacc-target.lo ompd-support.lo $(am__objects_1)
libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS)
-am_libgompd_la_OBJECTS = ompd-init.lo ompd-helper.lo ompd-icv.lo
+am_libgompd_la_OBJECTS = ompd-init.lo ompd-helper.lo ompd-icv.lo \
+ ompd-threads.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@)
@@ -485,7 +473,6 @@ dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
exec_prefix = @exec_prefix@
-get_gcc_base_ver = @get_gcc_base_ver@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -501,10 +488,8 @@ libtool_VERSION = @libtool_VERSION@
link_gomp = @link_gomp@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_host_flags = @lt_host_flags@
mandir = @mandir@
mkdir_p = @mkdir_p@
-multi_basedir = @multi_basedir@
offload_additional_lib_paths = @offload_additional_lib_paths@
offload_additional_options = @offload_additional_options@
offload_plugins = @offload_plugins@
@@ -514,6 +499,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -583,7 +569,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 ompd-support.c $(am__append_7)
-libgompd_la_SOURCES = ompd-init.c ompd-helper.c ompd-icv.c
+libgompd_la_SOURCES = ompd-init.c ompd-helper.c ompd-icv.c ompd-threads.c
# Nvidia PTX OpenACC plugin.
@PLUGIN_NVPTX_TRUE@libgomp_plugin_nvptx_version_info = -version-info $(libtool_VERSION)
@@ -801,6 +787,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-icv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-init.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-support.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ompd-threads.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@
diff --git a/libgomp/aclocal.m4 b/libgomp/aclocal.m4
index 55d9d71895a..41915216beb 100644
--- a/libgomp/aclocal.m4
+++ b/libgomp/aclocal.m4
@@ -626,6 +626,25 @@ if test x"${install_sh+set}" != xset; then
fi
AC_SUBST([install_sh])])
+# Copyright (C) 2003-2017 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
@@ -1167,19 +1186,4 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
-m4_include([../config/acx.m4])
-m4_include([../config/ax_count_cpus.m4])
-m4_include([../config/depstand.m4])
-m4_include([../config/enable.m4])
-m4_include([../config/futex.m4])
-m4_include([../config/lead-dot.m4])
-m4_include([../config/lthostflags.m4])
-m4_include([../config/multi.m4])
-m4_include([../config/override.m4])
-m4_include([../config/tls.m4])
-m4_include([../config/toolexeclibdir.m4])
-m4_include([../ltoptions.m4])
-m4_include([../ltsugar.m4])
-m4_include([../ltversion.m4])
-m4_include([../lt~obsolete.m4])
m4_include([acinclude.m4])
diff --git a/libgomp/configure b/libgomp/configure
index b251a389d89..9682a836029 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -720,7 +720,6 @@ am__nodep
AMDEPBACKSLASH
AMDEP_FALSE
AMDEP_TRUE
-am__quote
am__include
DEPDIR
OBJEXT
@@ -811,7 +810,8 @@ PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
-SHELL'
+SHELL
+am__quote'
ac_subst_files=''
ac_user_opts='
enable_option_checking
@@ -2870,7 +2870,7 @@ target_alias=${target_alias-$host_alias}
# -Wall: turns on all automake warnings...
# -Wno-portability: ...except this one, since GNU make is required.
# -Wno-override: ... and this one, since we do want this in testsuite.
-am__api_version='1.15'
+am__api_version='1.16'
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
@@ -3386,8 +3386,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
-# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
-# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+# <https://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <https://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
mkdir_p='$(MKDIR_P)'
# We need awk for the "check" target (and possibly the TAP driver). The
@@ -3438,7 +3438,7 @@ END
Aborting the configuration process, to ensure you take notice of the issue.
You can download and install GNU coreutils to get an 'rm' implementation
-that behaves properly: <http://www.gnu.org/software/coreutils/>.
+that behaves properly: <https://www.gnu.org/software/coreutils/>.
If you want to complete the configuration process using your problematic
'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
@@ -4399,45 +4399,45 @@ DEPDIR="${am__leading_dot}deps"
ac_config_commands="$ac_config_commands depfiles"
-
-am_make=${MAKE-make}
-cat > confinc << 'END'
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5
+$as_echo_n "checking whether ${MAKE-make} supports the include directive... " >&6; }
+cat > confinc.mk << 'END'
am__doit:
- @echo this is the am__doit target
+ @echo this is the am__doit target >confinc.out
.PHONY: am__doit
END
-# If we don't find an include directive, just comment out the code.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
-$as_echo_n "checking for style of include used by $am_make... " >&6; }
am__include="#"
am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from 'make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
- am__include=include
- am__quote=
- _am_result=GNU
- ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
- echo '.include "confinc"' > confmf
- case `$am_make -s -f confmf 2> /dev/null` in #(
- *the\ am__doit\ target*)
- am__include=.include
- am__quote="\""
- _am_result=BSD
+# BSD make does it like this.
+echo '.include "confinc.mk" # ignored' > confmf.BSD
+# Other make implementations (GNU, Solaris 10, AIX) do it like this.
+echo 'include confinc.mk # ignored' > confmf.GNU
+_am_result=no
+for s in GNU BSD; do
+ { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5
+ (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ case $?:`cat confinc.out 2>/dev/null` in #(
+ '0:this is the am__doit target') :
+ case $s in #(
+ BSD) :
+ am__include='.include' am__quote='"' ;; #(
+ *) :
+ am__include='include' am__quote='' ;;
+esac ;; #(
+ *) :
;;
- esac
-fi
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
-$as_echo "$_am_result" >&6; }
-rm -f confinc confmf
+esac
+ if test "$am__include" != "#"; then
+ _am_result="yes ($s style)"
+ break
+ fi
+done
+rm -f confinc.* confmf.*
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5
+$as_echo "${_am_result}" >&6; }
# Check whether --enable-dependency-tracking was given.
if test "${enable_dependency_tracking+set}" = set; then :
@@ -17759,7 +17759,7 @@ CC="$CC"
CXX="$CXX"
GFORTRAN="$GFORTRAN"
GDC="$GDC"
-AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"
# The HP-UX ksh and POSIX shell print the target directory to stdout
@@ -18751,29 +18751,35 @@ esac ;;
# Older Autoconf quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
- case $CONFIG_FILES in
- *\'*) eval set x "$CONFIG_FILES" ;;
- *) set x $CONFIG_FILES ;;
- esac
+ # TODO: see whether this extra hack can be removed once we start
+ # requiring Autoconf 2.70 or later.
+ case $CONFIG_FILES in #(
+ *\'*) :
+ eval set x "$CONFIG_FILES" ;; #(
+ *) :
+ set x $CONFIG_FILES ;; #(
+ *) :
+ ;;
+esac
shift
- for mf
+ # Used to flag and report bootstrapping failures.
+ am_rc=0
+ for am_mf
do
# Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
- # Check whether this is an Automake generated Makefile or not.
- # We used to match only the files named 'Makefile.in', but
- # some people rename them; so instead we look at the file content.
- # Grep'ing the first line is not enough: some people post-process
- # each Makefile.in and add a new line on top of each file to say so.
- # Grep'ing the whole file is not good either: AIX grep has a line
+ am_mf=`$as_echo "$am_mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile which includes
+ # dependency-tracking related rules and includes.
+ # Grep'ing the whole file directly is not great: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
- if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
- dirpart=`$as_dirname -- "$mf" ||
-$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$mf" : 'X\(//\)[^/]' \| \
- X"$mf" : 'X\(//\)$' \| \
- X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$mf" |
+ sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
+ || continue
+ am_dirpart=`$as_dirname -- "$am_mf" ||
+$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$am_mf" : 'X\(//\)[^/]' \| \
+ X"$am_mf" : 'X\(//\)$' \| \
+ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$am_mf" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
@@ -18791,53 +18797,48 @@ $as_echo X"$mf" |
q
}
s/.*/./; q'`
- else
- continue
- fi
- # Extract the definition of DEPDIR, am__include, and am__quote
- # from the Makefile without running 'make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "$am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
- for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
- # Make sure the directory exists.
- test -f "$dirpart/$file" && continue
- fdir=`$as_dirname -- "$file" ||
-$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$file" : 'X\(//\)[^/]' \| \
- X"$file" : 'X\(//\)$' \| \
- X"$file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
+ am_filepart=`$as_basename -- "$am_mf" ||
+$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$am_mf" : 'X\(//\)$' \| \
+ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$am_mf" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
s//\1/
q
}
- /^X\(\/\/\)$/{
+ /^X\/\(\/\/\)$/{
s//\1/
q
}
- /^X\(\/\).*/{
+ /^X\/\(\/\).*/{
s//\1/
q
}
s/.*/./; q'`
- as_dir=$dirpart/$fdir; as_fn_mkdir_p
- # echo "creating $dirpart/$file"
- echo '# dummy' > "$dirpart/$file"
- done
+ { echo "$as_me:$LINENO: cd "$am_dirpart" \
+ && sed -e '/# am--include-marker/d' "$am_filepart" \
+ | $MAKE -f - am--depfiles" >&5
+ (cd "$am_dirpart" \
+ && sed -e '/# am--include-marker/d' "$am_filepart" \
+ | $MAKE -f - am--depfiles) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } || am_rc=$?
done
+ if test $am_rc -ne 0; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "Something went wrong bootstrapping makefile fragments
+ for automatic dependency tracking. Try re-running configure with the
+ '--disable-dependency-tracking' option to at least be able to build
+ the package (albeit without support for automatic dependency tracking).
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ { am_dirpart=; unset am_dirpart;}
+ { am_filepart=; unset am_filepart;}
+ { am_mf=; unset am_mf;}
+ { am_rc=; unset am_rc;}
+ rm -f conftest-deps.mk
}
;;
"libtool":C)
diff --git a/libgomp/ompd-support.c b/libgomp/ompd-support.c
index 27c5ad148e0..e769e55fd0f 100644
--- a/libgomp/ompd-support.c
+++ b/libgomp/ompd-support.c
@@ -33,6 +33,8 @@ const unsigned short gompd_sizeof_gomp_thread_handle
__attribute__ ((used)) OMPD_SECTION = 0;
#endif
+unsigned long gompd_thread_initial_tls_bias __attribute__ ((used));
+
/* Get offset of the member m in struct t. */
#define gompd_get_offset(t, m) \
const unsigned short gompd_access_##t##_##m __attribute__ ((used)) \
@@ -67,6 +69,9 @@ gompd_load (void)
gompd_state |= OMPD_ENABLED;
ompd_dll_locations = &ompd_dll_locations_array[0];
ompd_dll_locations_valid ();
+
+ gompd_thread_initial_tls_bias = (unsigned long) ((char *) &gomp_tls_data
+ - (char *) pthread_self ());
}
#ifndef __ELF__
diff --git a/libgomp/ompd-threads.c b/libgomp/ompd-threads.c
new file mode 100644
index 00000000000..436a7d617fe
--- /dev/null
+++ b/libgomp/ompd-threads.c
@@ -0,0 +1,216 @@
+/* Copyright (C) The GNU Toolchain Authors.
+ Contributed by Ahmed Sayed <ahmedsayedmousse@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 the implementation of functions defined in
+ Section 5.5 ThreadHandles. */
+
+
+#include "ompd-helper.h"
+
+ompd_rc_t
+ompd_get_thread_in_parallel (ompd_parallel_handle_t *parallel_handle,
+ int thread_num,
+ ompd_thread_handle_t **thread_handle)
+{
+
+ if (parallel_handle == NULL)
+ return ompd_rc_stale_handle;
+ CHECK (parallel_handle->ah);
+
+ ompd_address_space_context_t *context = parallel_handle->ah->context;
+ ompd_rc_t ret;
+
+ ompd_word_t team_size_var = 1;
+ if (parallel_handle->th.address)
+ gompd_get_team_size(parallel_handle, &team_size_var);
+
+ if (thread_num < 0 || thread_num >= team_size_var)
+ return ompd_rc_bad_input;
+
+ ompd_word_t temp_offset;
+ ompd_address_t temp_symbol_addr, symbol_addr = {OMPD_SEGMENT_UNSPECIFIED, 0};
+ ompd_addr_t temp_addr;
+
+ ACCESS_VALUE (context, NULL, "gompd_access_gomp_thread_pool_threads",
+ temp_offset, 1, ret, symbol_addr, temp_symbol_addr, temp_addr);
+
+ symbol_addr.address += thread_num * target_sizes.sizeof_pointer;
+
+ DEREFERENCE (context, NULL, symbol_addr, target_sizes.sizeof_pointer, 1,
+ temp_addr, ret, 1);
+
+ ret = callbacks->alloc_memory (sizeof (ompd_thread_handle_t),
+ (void **) thread_handle);
+
+ CHECK_RET (ret);
+
+ if (symbol_addr.address == 0)
+ return ompd_rc_unsupported;
+
+ (*thread_handle)->th = symbol_addr;
+ (*thread_handle)->ah = parallel_handle->ah;
+ return ret;
+}
+
+/* The ompd_get_thread_handle function that maps a native thread to an
+ OMPD thread handle. */
+
+ompd_rc_t
+ompd_get_thread_handle (ompd_address_space_handle_t *handle,
+ ompd_thread_id_t kind, ompd_size_t sizeof_thread_id,
+ const void *thread_id,
+ ompd_thread_handle_t **thread_handle)
+{
+ CHECK (handle);
+ if (kind != OMPD_THREAD_ID_PTHREAD)
+ return ompd_rc_unsupported;
+
+ ompd_address_space_context_t *context = handle->context;
+ ompd_thread_context_t *tcontext;
+ ompd_rc_t ret;
+
+ ret = callbacks->get_thread_context_for_thread_id (context, kind,
+ sizeof_thread_id,
+ thread_id, &tcontext);
+ CHECK_RET (ret);
+
+ ompd_size_t temp_symbol_size, symbol_size;
+ ompd_address_t temp_symbol_addr, symbol_addr = {OMPD_SEGMENT_UNSPECIFIED, 0};
+
+ GET_VALUE (context, NULL, "gompd_sizeof_gomp_thread", symbol_size,
+ temp_symbol_size, target_sizes.sizeof_short, 1, ret,
+ temp_symbol_addr);
+
+ GET_VALUE (context, tcontext, "gomp_tls_data", symbol_addr.address,
+ temp_symbol_addr.address, symbol_size, 1, ret, symbol_addr);
+
+ ret = callbacks->alloc_memory (sizeof (ompd_thread_handle_t),
+ (void **) thread_handle);
+
+ CHECK_RET (ret);
+
+ (*thread_handle)->ah = handle;
+ (*thread_handle)->th = symbol_addr;
+ (*thread_handle)->thread_context = tcontext;
+ return ret;
+}
+
+
+ompd_rc_t
+ompd_rel_thread_handle (ompd_thread_handle_t *thread_handle)
+{
+ if (thread_handle == NULL)
+ return ompd_rc_stale_handle;
+
+ ompd_rc_t ret;
+ ret = callbacks->free_memory ((void *) thread_handle);
+ if (ret != ompd_rc_ok)
+ return ret;
+
+ return ompd_rc_ok;
+}
+
+
+/* return -1, 0 or 1 for thread_handle_1 <, == or > thread_handle_2. */
+ompd_rc_t
+ompd_thread_handle_compare (ompd_thread_handle_t *thread_handle_1,
+ ompd_thread_handle_t *thread_handle_2,
+ int *cmp_value )
+{
+
+ if (thread_handle_1 == NULL || thread_handle_2 == NULL)
+ return ompd_rc_stale_handle;
+ if (cmp_value == NULL)
+ return ompd_rc_bad_input;
+ if (thread_handle_1->ah->kind != thread_handle_2->ah->kind)
+ return ompd_rc_bad_input;
+
+ *cmp_value = thread_handle_1->th.address - thread_handle_2->th.address;
+ return ompd_rc_ok;
+}
+
+
+ompd_rc_t
+ompd_get_thread_id (ompd_thread_handle_t *thread_handle, ompd_thread_id_t kind,
+ ompd_size_t sizeof_thread_id, void *thread_id)
+{
+ if (kind != OMPD_THREAD_ID_PTHREAD)
+ return ompd_rc_unsupported;
+ if (thread_id == NULL)
+ return ompd_rc_bad_input;
+ if (thread_handle == NULL)
+ return ompd_rc_stale_handle;
+
+ CHECK (thread_handle->ah);
+ ompd_address_space_context_t *context = thread_handle->ah->context;
+
+ ompd_rc_t ret;
+ ompd_address_t taddr = thread_handle->th;
+ ompd_address_t temp_symbol_addr, symbol_addr = {OMPD_SEGMENT_UNSPECIFIED, 0};
+ ompd_size_t temp_symbol_size, symbol_size;
+ ompd_word_t temp_offset, offset;
+
+ GET_VALUE (context, NULL, "gompd_sizeof_gomp_thread_handle", symbol_size,
+ temp_symbol_size, target_sizes.sizeof_short, 1, ret, symbol_addr);
+
+ if (symbol_size == 0)
+ goto use_tls_bias;
+
+ if (sizeof_thread_id != symbol_size)
+ return ompd_rc_bad_input;
+
+ GET_VALUE (context, NULL, "gompd_access_gomp_thread_handle", offset,
+ temp_offset, target_sizes.sizeof_short, 1, ret, symbol_addr);
+ taddr.address += offset;
+
+ ret = callbacks->read_memory (context, NULL, &taddr, symbol_size, thread_id);
+ return ret;
+
+use_tls_bias:
+
+ GET_VALUE (context, NULL, "gompd_thread_initial_tls_bias", offset, temp_offset,
+ target_sizes.sizeof_long, 1, ret, symbol_addr);
+
+ ret = callbacks->symbol_addr_lookup (context, NULL,"gomp_tls_data",
+ &symbol_addr, NULL);
+ ret = callbacks->device_to_host (context, &temp_symbol_addr.address,
+ target_sizes.sizeof_long_long, 1,
+ &symbol_addr.address);
+ CHECK_RET (ret);
+
+ taddr.address = symbol_addr.address + offset;
+ ret = callbacks->read_memory (context, NULL, &taddr,
+ target_sizes.sizeof_long_long, thread_id);
+ return ret;
+}
+
+
+/* OMPD doesn't support GPUs for now. */
+ompd_rc_t ompd_get_device_from_thread (ompd_thread_handle_t *thread_handle,
+ ompd_address_space_handle_t **device)
+{
+ if (thread_handle == NULL)
+ return ompd_rc_stale_handle;
+ return ompd_rc_unsupported;
+}
diff --git a/libgomp/team.c b/libgomp/team.c
index d53246961b7..8e18fd6af63 100644
--- a/libgomp/team.c
+++ b/libgomp/team.c
@@ -77,6 +77,7 @@ gomp_thread_start (void *xdata)
void *local_data;
ompd_bp_thread_begin ();
+
#if defined HAVE_TLS || defined USE_EMUTLS
thr = &gomp_tls_data;
#else
@@ -313,6 +314,9 @@ gomp_free_thread (void *arg __attribute__((unused)))
gomp_end_task ();
free (task);
}
+
+ ompd_bp_thread_end ();
+
}
/* Launch a team. */
diff --git a/libgomp/testsuite/Makefile.in b/libgomp/testsuite/Makefile.in
index 048844f0a40..76cd09b0faf 100644
--- a/libgomp/testsuite/Makefile.in
+++ b/libgomp/testsuite/Makefile.in
@@ -90,21 +90,8 @@ host_triplet = @host@
target_triplet = @target@
subdir = testsuite
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
- $(top_srcdir)/../config/ax_count_cpus.m4 \
- $(top_srcdir)/../config/depstand.m4 \
- $(top_srcdir)/../config/enable.m4 \
- $(top_srcdir)/../config/futex.m4 \
- $(top_srcdir)/../config/lead-dot.m4 \
- $(top_srcdir)/../config/lthostflags.m4 \
- $(top_srcdir)/../config/multi.m4 \
- $(top_srcdir)/../config/override.m4 \
- $(top_srcdir)/../config/tls.m4 \
- $(top_srcdir)/../config/toolexeclibdir.m4 \
- $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
- $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
- $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
- $(top_srcdir)/../config/cet.m4 \
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../config/cet.m4 \
$(top_srcdir)/plugin/configfrag.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -249,7 +236,6 @@ dvidir = @dvidir@
enable_shared = @enable_shared@
enable_static = @enable_static@
exec_prefix = @exec_prefix@
-get_gcc_base_ver = @get_gcc_base_ver@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
@@ -265,10 +251,8 @@ libtool_VERSION = @libtool_VERSION@
link_gomp = @link_gomp@
localedir = @localedir@
localstatedir = @localstatedir@
-lt_host_flags = @lt_host_flags@
mandir = @mandir@
mkdir_p = @mkdir_p@
-multi_basedir = @multi_basedir@
offload_additional_lib_paths = @offload_additional_lib_paths@
offload_additional_options = @offload_additional_options@
offload_plugins = @offload_plugins@
@@ -278,6 +262,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
next reply other threads:[~2022-07-01 0:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 0:00 Ahmed Sayed Mousse [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-09-27 1:12 Ahmed Sayed Mousse
2022-09-27 1:20 ` Ahmed Sayed Mousse
2022-09-27 6:40 ` Bernhard Reutner-Fischer
2022-07-04 20:34 Ahmed Sayed Mousse
2022-07-27 12:11 ` Mohamed Atef
2022-07-29 11:22 ` Jakub Jelinek
2022-06-06 22:21 Ahmed Sayed Mousse
2022-06-07 9:56 ` Jakub Jelinek
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=a06b303c-a59c-b411-0c30-eb9826f4a14c@gmail.com \
--to=ahmedsayedmousse@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/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).