Changes to OTF:
- otfprofile: fixed build error when using the IBM XL C++ compiler Changes to VT: - configure: - use AC_CHECK_TYPES instead of AC_CHECK_DECLS to check for PAPI's long_long type - use AC_C_INLINE to check whether C 'inline' is present - VT libs: - set CUPTI tracing as default, if CUDA runtime wrapper has not been built - added a common interface for all NVIDIA CUPTI interfaces (events, activity, callbacks) - added support for concurrent kernel tracing (since CUDA 5.0) - removed almost unused VT_DEBUG env. variable - replaced calls to vt_debug_msg(DBG_LEVEL,...) by vt_cntl_msg (DBG_LEVEL+10,...) - added some more ifdefs to new CUDA 5 features - added several guards for internal malloc() and free() calls in CUDA related source files - revised memory allocation tracing: - intercept memory (de)alloaction functions by library wrapping (replaces deprecated hook technique from the GNU C library) - added support for multi-threaded applications - added wrapper functions for memalign, posix_memalign, and valloc - revised exec,system,fork tracing - retitled to "Child Process Execution Tracing" - introduced env. variable VT_EXECTRACE (marked VT_LIBCTRACE as deprecated) - added wrapper functions for execvpe, fexecve, waitid, wait3, and wait4 - changes default function group name for - memory (de)allocation functions: "MEM" -> "LIBC-MALLOC" - I/O functions: "I/O" -> "LIBC-I/O" - child process execution: "LIBC" -> "LIBC-EXEC" - plugin counter interface: - added check for initialized vt_plugin_cntr_info.info - vtdyn: - added missing header includes for Dyninst 8 - vtrun: - do not preload the Dyninst Runtime library; it is loaded by Dyninst itself This commit was SVN r27679.
Этот коммит содержится в:
родитель
8e304f0fb5
Коммит
9f9fded4de
@ -1,9 +1,20 @@
|
||||
5.14.1openmpi
|
||||
- updated version of internal OTF to 1.12.2openmpi
|
||||
(see extlib/otf/ChangeLog)
|
||||
- added support for recording concurrent CUDA kernels with CUPTI (CUDA 5.0)
|
||||
- append "/vampirtrace" to DATADIR, if configuring inside Open MPI and
|
||||
DATADIR doesn't points to the default (=DATAROOTDIR)
|
||||
(prevents conflicts with the libtool RPM)
|
||||
- fixed build issues when using the IBM XL compiler on AIX
|
||||
- fixed build issues with Dyninst 8
|
||||
- revised memory allocation tracing:
|
||||
- intercept memory (de)allocation functions by library wrapping
|
||||
(replaces deprecated hook technique from the GNU C library)
|
||||
- added support for multi-threaded applications
|
||||
- changed default function group name for
|
||||
- memory (de)allocation functions : "MEM" -> "LIBC-MALLOC"
|
||||
- I/O functions : "I/O" -> "LIBC-I/O"
|
||||
- child process execution (e.g. execl): "LIBC" -> "LIBC-EXEC"
|
||||
|
||||
5.14openmpi
|
||||
- updated version of internal OTF to 1.12.1openmpi
|
||||
|
@ -1,395 +1 @@
|
||||
|
||||
How to install and configure VampirTrace
|
||||
========================================
|
||||
|
||||
Basics
|
||||
------
|
||||
|
||||
Building VampirTrace is typically a combination of running "configure"
|
||||
and "make". Execute the following commands to install VampirTrace from
|
||||
within the directory at the top of the tree:
|
||||
|
||||
$ ./configure --prefix=/where/to/install
|
||||
[...lots of output...]
|
||||
$ make all install
|
||||
|
||||
If you need special access to install, then you can execute "make
|
||||
all" as a user with write permissions in the build tree, and a
|
||||
separate "make install" as a user with write permissions to the
|
||||
install tree.
|
||||
|
||||
However, for more details, read also the following instructions. Sometimes
|
||||
it might be necessary to provide ./configure with options, e.g.
|
||||
specifications of paths or compilers.
|
||||
|
||||
VampirTrace comes with example programs written in C, C++, and Fortran.
|
||||
They can be used to test different instrumentation types of the
|
||||
VampirTrace installation.
|
||||
You can find them in the directory examples of the VampirTrace package.
|
||||
|
||||
|
||||
Configure Options
|
||||
-----------------
|
||||
|
||||
* Compilers and Options
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
|
||||
* Installation Names
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', /usr/local/include', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
|
||||
* Optional Features
|
||||
|
||||
--enable-compinst=LIST
|
||||
enable support for compiler instrumentation,
|
||||
(gnu,intel,pathscale,pgi,pgi9,craycce,xl,necsx,
|
||||
open64,openuh)
|
||||
A VampirTrace installation can handle different
|
||||
compilers. The first item in the list is the
|
||||
run-time default.
|
||||
default: automatically by configure
|
||||
|
||||
--enable-dyninst
|
||||
enable support for Dyninst instrumentation,
|
||||
default: enable if found by configure
|
||||
Note: Requires Dyninst version 6.1 or higher!
|
||||
|
||||
--enable-dyninst-attlib
|
||||
build shared library which attaches Dyninst to
|
||||
the running application, default: enable if
|
||||
Dyninst found by configure and system supports
|
||||
shared libraries
|
||||
|
||||
--enable-iotrace
|
||||
enable LIBC's I/O tracing support, default: enable
|
||||
if libdl found by configure
|
||||
|
||||
--enable-libctrace
|
||||
enable tracing support for several LIBC functions,
|
||||
default: enable if libdl found by configure
|
||||
|
||||
--enable-memtrace
|
||||
enable memory tracing support, default: enable if
|
||||
found by configure
|
||||
|
||||
--enable-cpuidtrace
|
||||
enable CPU ID tracing support, default: enable if
|
||||
found by configure
|
||||
|
||||
--enable-rutrace
|
||||
enable resource usage tracing support, default:
|
||||
enable if found by configure
|
||||
|
||||
|
||||
--enable-metrics=TYPE
|
||||
enable support for hardware performance counter
|
||||
(papi,cpc,necsx), default: automatically by
|
||||
configure
|
||||
|
||||
--enable-zlib
|
||||
enable ZLIB trace compression support, default:
|
||||
enable if found by configure
|
||||
|
||||
--enable-mpi
|
||||
enable MPI support, default: enable if
|
||||
MPI found by configure
|
||||
|
||||
--enable-fmpi-lib
|
||||
build the MPI Fortran support library, in case your
|
||||
system does not have a MPI Fortran library.
|
||||
default: enable if no MPI Fortran library
|
||||
found by configure
|
||||
|
||||
--enable-fmpi-handle-convert
|
||||
do convert MPI handles, default: enable if MPI
|
||||
conversion functions found by configure
|
||||
|
||||
--enable-mpi2-thread
|
||||
enable MPI-2 Thread support, default: enable if
|
||||
found by configure
|
||||
|
||||
--enable-mpi2-1sided
|
||||
enable MPI-2 One-Sided Communication support,
|
||||
default: enable if found by configure
|
||||
|
||||
--enable-mpi2-extcoll
|
||||
enable MPI-2 Extended Collective Operation support,
|
||||
default: enable if found by configure
|
||||
|
||||
--enable-mpi2-io
|
||||
enable MPI-2 I/O support, default: enable if found
|
||||
by configure
|
||||
|
||||
--enable-mpicheck
|
||||
enable support for Universal MPI Correctness
|
||||
Interface (UniMCI), default: enable if
|
||||
unimci-config found by configure
|
||||
|
||||
--enable-etimesync
|
||||
enable enhanced timer synchronization support,
|
||||
default: enable if C-LAPACK found by configure
|
||||
|
||||
--enable-threads=LIST
|
||||
enable support for threads (pthread, omp), default:
|
||||
automatically by configure
|
||||
|
||||
--enable-java
|
||||
enable Java support, default: enable if JVMTI
|
||||
found by configure
|
||||
|
||||
|
||||
* Important Optional Packages
|
||||
|
||||
This a summary of the most important optional features. For a full list
|
||||
of all available features run `./configure --help'.
|
||||
|
||||
--with-platform=PLATFORM
|
||||
configure for given platform
|
||||
(altix,bgl,bgp,crayt3e,crayx1,crayxt,ibm,linux,
|
||||
macos,necsx,origin,sicortex,sun,generic),
|
||||
default: automatically by configure
|
||||
|
||||
--with-bitmode=<32|64>
|
||||
specify bit mode
|
||||
|
||||
--with-options=FILE
|
||||
load options from FILE, default: configure
|
||||
searches for a config file in config/defaults
|
||||
based on given platform and bitmode
|
||||
|
||||
--with-local-tmp-dir=DIR
|
||||
give the path for node-local temporary directory,
|
||||
default: /tmp
|
||||
|
||||
Specify name of (SMP) node-local directory that can be used to store
|
||||
temporary trace files.
|
||||
|
||||
If you would like to use an external version of OTF library, set
|
||||
--with-extern-otf
|
||||
use external OTF library, default: not seta
|
||||
|
||||
--with-extern-otf-dir=OTFDIR
|
||||
give the path for OTF, default: /usr
|
||||
|
||||
--with-otf-flags=FLAGS
|
||||
pass FLAGS to the OTF distribution configuration
|
||||
(only for internal OTF version)
|
||||
|
||||
--with-otf-lib=OTFLIB
|
||||
use given otf lib, default: -lotf -lz
|
||||
|
||||
If used OTF library was built without zlib support, then it will do
|
||||
to set OTFLIB to '-lotf'.
|
||||
|
||||
--with-dyninst-dir=DYNIDIR
|
||||
give the path for DYNINST, default: /usr
|
||||
|
||||
--with-dyninst-inc-dir=DYNIINCDIR
|
||||
give the path for Dyninst-include files,
|
||||
default: DYNIDIR/include
|
||||
|
||||
--with-dyninst-lib-dir=DYNILIBDIR
|
||||
give the path for Dyninst-libraries,
|
||||
default: DYNIDIR/lib
|
||||
|
||||
--with-dyninst-lib=DYNILIB
|
||||
use given Dyninst lib, default: -ldyninstAPI
|
||||
|
||||
--with-tau-instrumentor=TAUINSTUMENTOR
|
||||
give the command for the TAU instrumentor,
|
||||
default: tau_instrumentor
|
||||
|
||||
--with-pdt-cparse=PDTCPARSE
|
||||
give the command for PDT C source code parser,
|
||||
default: cparse
|
||||
|
||||
--with-pdt-cxxparse=PDTCXXPARSE
|
||||
give the command for PDT C++ source code parser,
|
||||
default: cxxparse
|
||||
|
||||
--with-pdt-fparse=PDTFPARSE
|
||||
give the command for PDT Fortran source code parser,
|
||||
default: f95parse, f90parse, or gfparse
|
||||
|
||||
--with-pdt-comment=PDTCOMMENT
|
||||
give the command for PDT comment parser,
|
||||
default: pdbcomment
|
||||
|
||||
--with-papi-dir=PAPIDIR
|
||||
give the path for PAPI, default: /usr
|
||||
|
||||
--with-cpc-dir=CPCDIR
|
||||
give the path for CPC, default: /usr
|
||||
|
||||
If you don't have specified the environment variable MPICC
|
||||
(MPI compiler command), use following options to set location
|
||||
of your MPI installation:
|
||||
|
||||
--with-mpi-dir=MPIDIR
|
||||
give the path for MPI, default: /usr
|
||||
|
||||
--with-mpi-inc-dir=MPIINCDIR
|
||||
give the path for MPI-include-files, default:
|
||||
MPIDIR/include
|
||||
|
||||
--with-mpi-lib-dir=MPILIBDIR
|
||||
give the path for MPI-libraries, default:
|
||||
MPIDIR/lib
|
||||
|
||||
--with-mpi-lib
|
||||
use given mpi lib
|
||||
|
||||
--with-pmpi-lib
|
||||
use given pmpi lib
|
||||
|
||||
If your system does not have a MPI Fortran library,
|
||||
set '--enable-fmpi-lib' (see above), otherwise set
|
||||
|
||||
--with-fmpi-lib
|
||||
use given fmpi lib
|
||||
|
||||
Use the following options to specify your MPI-implementation
|
||||
|
||||
--with-hpmpi set MPI-libs for HP MPI
|
||||
|
||||
--with-intelmpi set MPI-libs for Intel MPI
|
||||
|
||||
--with-intelmpi2 set MPI-libs for Intel MPI2
|
||||
|
||||
--with-lam set MPI-libs for LAM/MPI
|
||||
|
||||
--with-mpibgl set MPI-libs for IBM BG/L
|
||||
|
||||
--with-mpibgp set MPI-libs for IBM BG/P
|
||||
|
||||
--with-mpich set MPI-libs for MPICH
|
||||
|
||||
--with-mpich2 set MPI-libs for MPICH2
|
||||
|
||||
--with-mvapich set MPI-libs for MVAPICH
|
||||
|
||||
--with-mvapich2 set MPI-libs for MVAPICH2
|
||||
|
||||
--with-mpisx set MPI-libs for NEC MPI/SX
|
||||
|
||||
--with-mpisx-ew set MPI-libs for NEC MPI/SX with
|
||||
8 Byte Fortran Integer
|
||||
|
||||
--with-openmpi set MPI-libs for Open MPI
|
||||
|
||||
--with-sgimpt set MPI-libs for SGI MPT
|
||||
|
||||
--with-sunmpi set MPI-libs for SUN MPI
|
||||
|
||||
--with-sunmpi-mt set MPI-libs for SUN MPI-MT
|
||||
|
||||
To enable enhanced timer synchronization a LAPACK library with C wrapper
|
||||
support is needed:
|
||||
|
||||
--with-clapack-dir=LAPACKDIR
|
||||
set the path for CLAPACK,
|
||||
default: /usr
|
||||
|
||||
--with-clapack-lib
|
||||
set CLAPACK-libs, default:
|
||||
-lclapack -lcblas -lf2c
|
||||
|
||||
--with-clapack-acml set CLAPACK-libs for ACML
|
||||
|
||||
--with-clapack-essl set CLAPACK-libs for ESSL
|
||||
|
||||
--with-clapack-mkl set CLAPACK-libs for MKL
|
||||
|
||||
--with-clapack-sunperf set CLAPACK-libs for SUN Performance Library
|
||||
|
||||
To enable Java support the JVM Tool Interface (JVMTI) version 1.0 or
|
||||
higher is needed:
|
||||
|
||||
--with-jvmti-dir=JVMTIDIR
|
||||
give the path for JVMTI, default: JAVA_HOME
|
||||
|
||||
--with-jvmti-inc-dir=JVMTIINCDIR
|
||||
give the path for JVMTI-include files, default:
|
||||
JVMTI/include
|
||||
|
||||
|
||||
Cross Compilation
|
||||
-----------------
|
||||
|
||||
Building VampirTrace on cross compilation platforms needs some special attention.
|
||||
The compiler wrappers, OPARI, and the Library Wrapper Generator are built for the
|
||||
front-end (build system) whereas the VampirTrace libraries, vtdyn, vtunify, and
|
||||
vtfilter are built for the back-end (host system). Some configure options which are
|
||||
of interest for cross compilation are shown below:
|
||||
|
||||
* Set CC, CXX, and FC to the cross compilers installed on the front-end.
|
||||
|
||||
* Set CC_FOR_BUILD and CXX_FOR_BUILD to the native compilers of the front-end.
|
||||
|
||||
* Set --host= to the output of config.guess on the back-end.
|
||||
|
||||
* Set --with-cross-prefix= to a prefix which will be prepended to the executables
|
||||
of the compiler wrappers and OPARI (default: cross-)
|
||||
|
||||
* Maybe you also need to set additional commands and flags for the back-end
|
||||
(e.g. RANLIB, AR, MPICC, CXXFLAGS).
|
||||
|
||||
Examples:
|
||||
BlueGene/P and BlueGene/Q:
|
||||
% ./configure --host=powerpc64-ibm-linux-gnu
|
||||
|
||||
Cray XK6:
|
||||
% ./configure --host=x86_64-cray-linux-gnu
|
||||
CC_FOR_BUILD=craycc
|
||||
CXX_FOR_BUILD=crayc++
|
||||
|
||||
NEC SX6:
|
||||
% ./configure --host=sx6-nec-superux14.1
|
||||
|
||||
|
||||
Set up the Environment
|
||||
----------------------
|
||||
|
||||
Add the bin subdirectory of the installation directory to your PATH
|
||||
environment variable. To use VampirTrace with Dyninst, you will also need
|
||||
to add the lib subdirectory to your LD_LIBRARY_PATH environment variable:
|
||||
|
||||
for csh and tcsh:
|
||||
|
||||
> setenv PATH <vampirtrace-install>/bin:$PATH
|
||||
> setenv LD_LIBRARY_PATH <vampirtrace-install>/lib:$LD_LIBRARY_PATH
|
||||
|
||||
for bash and sh:
|
||||
|
||||
$ export PATH=<vampirtrace-install>/bin:$PATH
|
||||
$ export LD_LIBRARY_PATH=<vampirtrace-install>/lib:$LD_LIBRARY_PATH
|
||||
|
||||
|
||||
Notes for Developers
|
||||
--------------------
|
||||
|
||||
* Build from CVS
|
||||
|
||||
If you have checked out a DEVELOPER'S COPY of VampirTrace (i.e. you
|
||||
checked out from CVS), you should first run:
|
||||
|
||||
$ ./bootstrap [--otf-package <package>] [--version <version>]
|
||||
|
||||
Note that GNU Autoconf >= 2.60 and GNU Automake >= 1.9.6 is required.
|
||||
You can download them from http://www.gnu.org/software/autoconf and
|
||||
http://www.gnu.org/software/automake.
|
||||
|
||||
See doc/UserManual.pdf appendix A on how to install VampirTrace.
|
||||
|
@ -8,22 +8,22 @@ m4_include(config/m4/acinclude.csfs.m4)
|
||||
m4_include(config/m4/acinclude.ctool.m4)
|
||||
m4_include(config/m4/acinclude.cuda.m4)
|
||||
m4_include(config/m4/acinclude.cupti.m4)
|
||||
m4_include(config/m4/acinclude.cudawrap.m4)
|
||||
m4_include(config/m4/acinclude.cudartwrap.m4)
|
||||
m4_include(config/m4/acinclude.cxxrtlib.m4)
|
||||
m4_include(config/m4/acinclude.dl.m4)
|
||||
m4_include(config/m4/acinclude.dyninst.m4)
|
||||
m4_include(config/m4/acinclude.etimesync.m4)
|
||||
m4_include(config/m4/acinclude.execwrap.m4)
|
||||
m4_include(config/m4/acinclude.getcpu.m4)
|
||||
m4_include(config/m4/acinclude.iofsl.m4)
|
||||
m4_include(config/m4/acinclude.iowrap.m4)
|
||||
m4_include(config/m4/acinclude.java.m4)
|
||||
m4_include(config/m4/acinclude.jvmti.m4)
|
||||
m4_include(config/m4/acinclude.libcwrap.m4)
|
||||
m4_include(config/m4/acinclude.liberty.m4)
|
||||
m4_include(config/m4/acinclude.libwrap.m4)
|
||||
m4_include(config/m4/acinclude.ltmpdir.m4)
|
||||
m4_include(config/m4/acinclude.mallocwrap.m4)
|
||||
m4_include(config/m4/acinclude.math.m4)
|
||||
m4_include(config/m4/acinclude.memhooks.m4)
|
||||
m4_include(config/m4/acinclude.metrics.m4)
|
||||
m4_include(config/m4/acinclude.mpi.m4)
|
||||
m4_include(config/m4/acinclude.omp.m4)
|
||||
|
@ -8,5 +8,4 @@ OPENMP_CFLAGS="-qsmp=omp"
|
||||
PTHREAD_CFLAGS="-D_THREAD_SAFE"
|
||||
PTHREAD_LIBS="-lpthreads"
|
||||
enable_shared="no"
|
||||
enable_memtrace="no"
|
||||
enable_cpuidtrace="no"
|
||||
|
@ -10,5 +10,4 @@ OPENMP_CFLAGS="-qsmp=omp"
|
||||
PTHREAD_CFLAGS="-D_THREAD_SAFE"
|
||||
PTHREAD_LIBS="-lpthreads"
|
||||
enable_shared="no"
|
||||
enable_memtrace="no"
|
||||
enable_cpuidtrace="no"
|
||||
|
@ -17,7 +17,6 @@ CXXFLAGS_FOR_BUILD="-O2"
|
||||
OPENMP_CFLAGS="-Popenmp"
|
||||
PTHREAD_LIBS="-lpthread"
|
||||
enable_shared="no"
|
||||
enable_memtrace="no"
|
||||
enable_libtrace="no"
|
||||
enable_cpuidtrace="no"
|
||||
enable_metrics="necsx"
|
||||
|
@ -7,5 +7,4 @@ FCFLAGS="-xO3"
|
||||
OPENMP_CFLAGS="-xopenmp -xO3 -D_REENTRANT"
|
||||
PTHREAD_CFLAGS="-D_REENTRANT"
|
||||
PTHREAD_LIBS="-lpthread"
|
||||
enable_memtrace="no"
|
||||
enable_cpuidtrace="no"
|
||||
|
@ -288,10 +288,6 @@ AC_DEFUN([ACVT_CONF_SUMMARY],
|
||||
[answer="yes"], [answer="no"])
|
||||
echo " Build Resource usage trace support: $answer"
|
||||
|
||||
AS_IF([test x"$have_memhooks" = "xyes"],
|
||||
[answer="yes"], [answer="no"])
|
||||
echo " Build GLIBC's memory alloc. trace support: $answer"
|
||||
|
||||
AS_IF([test x"$have_getcpu" = "xyes"],
|
||||
[answer="yes"], [answer="no"])
|
||||
echo " Build GLIBC's CPU ID trace support: $answer"
|
||||
@ -299,18 +295,22 @@ AC_DEFUN([ACVT_CONF_SUMMARY],
|
||||
AS_IF([test x"$have_libwrap" = "xyes"],
|
||||
[
|
||||
answer=
|
||||
AS_IF([test x"$have_libcwrap" = "xyes"],
|
||||
AS_IF([test x"$have_execwrap" = "xyes"],
|
||||
[AS_IF([test x"$answer" != x],
|
||||
[answer="$answer, LIBC"],
|
||||
[answer="LIBC"])])
|
||||
[answer="$answer, LIBC-EXEC"],
|
||||
[answer="LIBC-EXEC"])])
|
||||
AS_IF([test x"$have_iowrap" = "xyes"],
|
||||
[AS_IF([test x"$answer" != x],
|
||||
[answer="$answer, LIBC-I/O"],
|
||||
[answer="LIBC-I/O"])])
|
||||
AS_IF([test x"$have_mallocwrap" = "xyes"],
|
||||
[AS_IF([test x"$answer" != x],
|
||||
[answer="$answer, LIBC-MALLOC"],
|
||||
[answer="LIBC-MALLOC"])])
|
||||
AS_IF([test x"$have_cudartwrap" = "xyes"],
|
||||
[AS_IF([test x"$answer" != x],
|
||||
[answer="$answer, CUDA"],
|
||||
[answer="CUDA"])])
|
||||
[answer="$answer, CUDA-RT"],
|
||||
[answer="CUDA-RT"])])
|
||||
answer="yes ($answer)"
|
||||
], [answer="no"])
|
||||
echo " Build Library trace support: $answer"
|
||||
|
@ -1,21 +1,27 @@
|
||||
AC_DEFUN([ACVT_CUDAWRAP],
|
||||
AC_DEFUN([ACVT_CUDARTWRAP],
|
||||
[
|
||||
check_cudart="yes"
|
||||
force_cudart="no"
|
||||
cudartwrap_error="no"
|
||||
check_cudartwrap="yes"
|
||||
have_cudartwrap="no"
|
||||
|
||||
cudartshlib_pathname=
|
||||
|
||||
AC_ARG_ENABLE(cudawrap,
|
||||
AC_HELP_STRING([--enable-cudawrap],
|
||||
[enable support for tracing CUDA via library wrapping, default: enable if found by configure]),
|
||||
[AS_IF([test x"$enableval" = "xyes"], [force_cudart="yes"], [check_cudart="no"])])
|
||||
AC_REQUIRE([ACVT_CUPTI])
|
||||
|
||||
AS_IF([test "$check_cudart" = "yes"],
|
||||
AC_ARG_ENABLE(cudartwrap,
|
||||
AC_HELP_STRING([--enable-cudartwrap],
|
||||
[enable support for tracing the CUDA runtime API via library wrapping, default: enable if no CUPTI present]),
|
||||
[AS_IF([test x"$enableval" = "xyes"], [force_cudartwrap="yes"], [check_cudartwrap="no"])],
|
||||
[AS_IF([test x"$force_cudartwrap" = "xno" -a x"$have_cupti" = "xyes"], [check_cudartwrap="no"])])
|
||||
|
||||
AS_IF([test "$check_cudartwrap" = "yes"],
|
||||
[
|
||||
AC_REQUIRE([ACVT_CUDA])
|
||||
|
||||
AS_IF([test x"$cudart_error" = "xno"],
|
||||
AS_IF([test x"$have_cuda" != "xyes" -o x"$have_cudart" != "xyes"],
|
||||
[cudartwrap_error="yes"])
|
||||
|
||||
AS_IF([test x"$cudartwrap_error" = "xno"],
|
||||
[
|
||||
AC_ARG_WITH(cudart-shlib,
|
||||
AC_HELP_STRING([--with-cudart-shlib=CUDARTSHLIB], [give the pathname for the shared CUDA runtime library, default: automatically by configure]),
|
||||
@ -26,7 +32,7 @@ AC_DEFUN([ACVT_CUDAWRAP],
|
||||
])
|
||||
])
|
||||
|
||||
AS_IF([test x"$cudart_error" = "xno"],
|
||||
AS_IF([test x"$cudartwrap_error" = "xno"],
|
||||
[
|
||||
AC_MSG_CHECKING([for pathname of shared CUDA runtime library])
|
||||
|
||||
@ -48,7 +54,7 @@ AC_DEFUN([ACVT_CUDAWRAP],
|
||||
[
|
||||
AC_MSG_RESULT([unknown])
|
||||
AC_MSG_NOTICE([error: could not determine pathname of shared CUDA runtime library])
|
||||
cudart_error="yes"
|
||||
cudartwrap_error="yes"
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT([$cudartshlib_pathname])
|
||||
@ -57,7 +63,7 @@ AC_DEFUN([ACVT_CUDAWRAP],
|
||||
])
|
||||
])
|
||||
|
||||
AS_IF([test x"$cudart_error" = "xno"],
|
||||
AS_IF([test x"$cudartwrap_error" = "xno"],
|
||||
[
|
||||
AS_IF([test x"$cudartshlib_pathname" != x],
|
||||
[
|
@ -40,13 +40,16 @@ AC_DEFUN([ACVT_DL],
|
||||
])
|
||||
AS_IF([test "$PLATFORM" = "bgp" -o "$PLATFORM" = "bgq"],
|
||||
[
|
||||
dnl RTLD_NEXT available but not working on BG/P (and BG/Q?) platforms
|
||||
ac_cv_have_decl_RTLD_NEXT="no"
|
||||
AS_IF([test x"$enable_shared" = "xno"],
|
||||
[
|
||||
ac_cv_have_decl_RTLD_DEFAULT="no"
|
||||
ac_cv_have_decl_RTLD_NEXT="no"
|
||||
])
|
||||
])
|
||||
AS_IF([test "$PLATFORM" = "crayxt" -o "$PLATFORM" = "crayxe"],
|
||||
[
|
||||
dnl RTLD_DEFAULT available but not working on CrayX? platforms
|
||||
ac_cv_have_decl_RTLD_DEFAULT="no"
|
||||
ac_cv_have_decl_RTLD_NEXT="no"
|
||||
])
|
||||
|
||||
AS_IF([test x"$dl_error" = "xno"],
|
||||
|
33
ompi/contrib/vt/vt/config/m4/acinclude.execwrap.m4
Обычный файл
33
ompi/contrib/vt/vt/config/m4/acinclude.execwrap.m4
Обычный файл
@ -0,0 +1,33 @@
|
||||
AC_DEFUN([ACVT_EXECWRAP],
|
||||
[
|
||||
execwrap_error="no"
|
||||
check_execwrap="yes"
|
||||
have_execwrap="no"
|
||||
|
||||
AC_ARG_ENABLE(exectrace,
|
||||
AC_HELP_STRING([--enable-exectrace],
|
||||
[enable support for tracing LIBC functions for creating and controling child processes (e.g. execl,fork,system,wait) via library wrapping, default: enable]),
|
||||
[AS_IF([test x"$enableval" = "xyes"], [force_execwrap="yes"], [check_execwrap="no"])])
|
||||
|
||||
AS_IF([test "$check_execwrap" = "yes"],
|
||||
[
|
||||
AS_IF([test x"$shlibc_pathname" = x],
|
||||
[
|
||||
AC_MSG_NOTICE([error: pathname of shared LIBC required for LIBC-EXEC tracing; please specify it by --with-shlibc])
|
||||
execwrap_error="yes"
|
||||
])
|
||||
|
||||
AS_IF([test x"$execwrap_error" = "xno"],
|
||||
[
|
||||
AC_CHECK_TYPES([__WAIT_STATUS], [], [], [#include <sys/wait.h>])
|
||||
|
||||
sav_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"
|
||||
AC_CHECK_FUNCS([execvpe fexecve waitid wait3 wait4])
|
||||
CPPFLAGS=$sav_CPPFLAGS
|
||||
|
||||
have_execwrap="yes"
|
||||
])
|
||||
])
|
||||
])
|
||||
|
@ -1,49 +1,59 @@
|
||||
AC_DEFUN([ACVT_IOWRAP],
|
||||
[
|
||||
iowrap_error="no"
|
||||
check_iowrap="yes"
|
||||
have_iowrap="no"
|
||||
|
||||
AS_IF([test x"$shlibc_pathname" = x],
|
||||
AC_ARG_ENABLE(iotrace,
|
||||
AC_HELP_STRING([--enable-iotrace],
|
||||
[enable support for tracing LIBC I/O functions (e.g. fopen,fclose,fread,fwrite) via library wrapping, default: enable]),
|
||||
[AS_IF([test x"$enableval" = "xyes"], [force_iowrap="yes"], [check_iowrap="no"])])
|
||||
|
||||
|
||||
AS_IF([test "$check_iowrap" = "yes"],
|
||||
[
|
||||
AC_MSG_NOTICE([error: pathname of shared LIBC required for LIBC-I/O tracing; please specify it by --with-shlibc])
|
||||
iowrap_error="yes"
|
||||
])
|
||||
|
||||
AS_IF([test x"$iowrap_error" = "xno"],
|
||||
[
|
||||
sav_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
|
||||
|
||||
AC_CHECK_FUNCS([ \
|
||||
creat64 \
|
||||
fopen64 \
|
||||
fseeko \
|
||||
fseeko64 \
|
||||
lseek64 \
|
||||
fsetpos64 \
|
||||
open64 \
|
||||
pread64 \
|
||||
pwrite64 \
|
||||
flockfile \
|
||||
ftrylockfile \
|
||||
funlockfile \
|
||||
sync \
|
||||
fflush \
|
||||
fsync \
|
||||
fdatasync \
|
||||
lockf])
|
||||
|
||||
AC_CHECK_FUNCS([__fprintf_chk],
|
||||
AS_IF([test x"$shlibc_pathname" = x],
|
||||
[
|
||||
dnl Check whether <stdio.h> declares __vfprintf_chk. This should be the case if
|
||||
dnl _FORTIFY_SOURCE is defined (default when using the GNU compiler).
|
||||
dnl Otherwise, we have to declare this function to avoid compiler warnings.
|
||||
AC_CHECK_DECLS([__vfprintf_chk], [], [], [#include <stdio.h>])
|
||||
AC_MSG_NOTICE([error: pathname of shared LIBC required for LIBC-I/O tracing; please specify it by --with-shlibc])
|
||||
iowrap_error="yes"
|
||||
])
|
||||
|
||||
CPPFLAGS=$sav_CPPFLAGS
|
||||
AS_IF([test x"$iowrap_error" = "xno"],
|
||||
[
|
||||
sav_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
|
||||
|
||||
have_iowrap="yes"
|
||||
AC_CHECK_FUNCS([ \
|
||||
creat64 \
|
||||
fopen64 \
|
||||
fseeko \
|
||||
fseeko64 \
|
||||
lseek64 \
|
||||
fsetpos64 \
|
||||
open64 \
|
||||
pread64 \
|
||||
pwrite64 \
|
||||
flockfile \
|
||||
ftrylockfile \
|
||||
funlockfile \
|
||||
sync \
|
||||
fflush \
|
||||
fsync \
|
||||
fdatasync \
|
||||
lockf])
|
||||
|
||||
AC_CHECK_FUNCS([__fprintf_chk],
|
||||
[
|
||||
dnl Check whether <stdio.h> declares __vfprintf_chk. This should be the case if
|
||||
dnl _FORTIFY_SOURCE is defined (default when using the GNU compiler).
|
||||
dnl Otherwise, we have to declare this function to avoid compiler warnings.
|
||||
AC_CHECK_DECLS([__vfprintf_chk], [], [], [#include <stdio.h>])
|
||||
])
|
||||
|
||||
CPPFLAGS=$sav_CPPFLAGS
|
||||
|
||||
have_iowrap="yes"
|
||||
])
|
||||
])
|
||||
])
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
AC_DEFUN([ACVT_LIBCWRAP],
|
||||
[
|
||||
libcwrap_error="no"
|
||||
have_libcwrap="no"
|
||||
have_fork="no"
|
||||
|
||||
AS_IF([test x"$shlibc_pathname" = x],
|
||||
[
|
||||
AC_MSG_NOTICE([error: pathname of shared LIBC required for LIBC tracing; please specify it by --with-shlibc])
|
||||
libcwrap_error="yes"
|
||||
])
|
||||
|
||||
AS_IF([test x"$libcwrap_error" = "xno"],
|
||||
[
|
||||
AC_CHECK_FUNCS([fork], [have_fork="yes"])
|
||||
|
||||
AC_CHECK_FUNCS([ \
|
||||
execl \
|
||||
execle \
|
||||
execlp \
|
||||
execv \
|
||||
execve \
|
||||
execvp \
|
||||
system \
|
||||
wait \
|
||||
waitpid])
|
||||
|
||||
have_libcwrap="yes"
|
||||
])
|
||||
])
|
||||
|
@ -1,14 +1,15 @@
|
||||
AC_DEFUN([ACVT_LIBWRAP],
|
||||
[
|
||||
libwrap_error="no"
|
||||
check_libwrap="gen libc io cuda"
|
||||
check_libwrap="gen exec io malloc cudart"
|
||||
force_libwrap="no"
|
||||
have_libwrap="no"
|
||||
|
||||
force_libwrapgen="no"
|
||||
build_libwrapgen="no"
|
||||
force_libcwrap="no"
|
||||
force_execwrap="no"
|
||||
force_iowrap="no"
|
||||
force_mallocwrap="no"
|
||||
force_cudartwrap="no"
|
||||
|
||||
shlibc_pathname=
|
||||
@ -17,7 +18,7 @@ AC_DEFUN([ACVT_LIBWRAP],
|
||||
|
||||
AC_ARG_ENABLE(libtrace,
|
||||
AC_HELP_STRING([--enable-libtrace=LIST],
|
||||
[enable library tracing support (gen,libc,io,cuda), default: automatically by configure]),
|
||||
[enable library tracing support (gen,exec,io,malloc,cudart), default: automatically by configure]),
|
||||
[
|
||||
AS_IF([test x"$enableval" = "xno"], [check_libwrap="no"])
|
||||
AS_IF([test x"$enableval" = "xyes"], [force_libwrap="yes"])
|
||||
@ -30,17 +31,24 @@ AC_DEFUN([ACVT_LIBWRAP],
|
||||
gen)
|
||||
force_libwrapgen="yes"
|
||||
;;
|
||||
libc)
|
||||
force_libcwrap="yes"
|
||||
libc | exec)
|
||||
check_execwrap="yes"
|
||||
force_execwrap="yes"
|
||||
;;
|
||||
io)
|
||||
check_iowrap="yes"
|
||||
force_iowrap="yes"
|
||||
;;
|
||||
cuda)
|
||||
malloc)
|
||||
check_mallocwrap="yes"
|
||||
force_mallocwrap="yes"
|
||||
;;
|
||||
cuda | cudart)
|
||||
check_cudartwrap="yes"
|
||||
force_cudartwrap="yes"
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([value of '--enable-libtrace' not properly set])
|
||||
AC_MSG_ERROR([value of '--enable-libwrap' not properly set])
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@ -118,16 +126,23 @@ AC_DEFUN([ACVT_LIBWRAP],
|
||||
[have_libwrap="yes"; build_libwrapgen="yes"],
|
||||
[
|
||||
AS_IF([test x"$force_libwrapgen" = "xyes"],
|
||||
[libwrap_error="yes"; break])
|
||||
[
|
||||
libwrap_error="yes"
|
||||
break
|
||||
])
|
||||
])
|
||||
;;
|
||||
libc)
|
||||
ACVT_CONF_SUBTITLE([LIBC])
|
||||
ACVT_LIBCWRAP
|
||||
AS_IF([test x"$have_libcwrap" = "xyes"], [have_libwrap="yes"],
|
||||
libc | exec)
|
||||
ACVT_CONF_SUBTITLE([LIBC-EXEC])
|
||||
ACVT_EXECWRAP
|
||||
AS_IF([test x"$have_execwrap" = "xyes"], [have_execwrap="yes"],
|
||||
[
|
||||
AS_IF([test x"$force_libcwrap" = "xyes"],
|
||||
[libwrap_error="yes"; break])
|
||||
AS_IF([test x"$force_execwrap" = "xyes"],
|
||||
[
|
||||
force_libwrap="yes"
|
||||
libwrap_error="yes"
|
||||
break
|
||||
])
|
||||
])
|
||||
;;
|
||||
io)
|
||||
@ -136,16 +151,37 @@ AC_DEFUN([ACVT_LIBWRAP],
|
||||
AS_IF([test x"$have_iowrap" = "xyes"], [have_libwrap="yes"],
|
||||
[
|
||||
AS_IF([test x"$force_iowrap" = "xyes"],
|
||||
[libwrap_error="yes"; break])
|
||||
[
|
||||
force_libwrap="yes"
|
||||
libwrap_error="yes"
|
||||
break
|
||||
])
|
||||
])
|
||||
;;
|
||||
cuda)
|
||||
ACVT_CONF_SUBTITLE([CUDAWRAP])
|
||||
ACVT_CUDAWRAP
|
||||
malloc)
|
||||
ACVT_CONF_SUBTITLE([LIBC-MALLOC])
|
||||
ACVT_MALLOCWRAP
|
||||
AS_IF([test x"$have_mallocwrap" = "xyes"], [have_libwrap="yes"],
|
||||
[
|
||||
AS_IF([test x"$force_mallocwrap" = "xyes"],
|
||||
[
|
||||
force_libwrap="yes"
|
||||
libwrap_error="yes"
|
||||
break
|
||||
])
|
||||
])
|
||||
;;
|
||||
cuda | cudart)
|
||||
ACVT_CONF_SUBTITLE([CUDA-RT])
|
||||
ACVT_CUDARTWRAP
|
||||
AS_IF([test x"$have_cudartwrap" = "xyes"], [have_libwrap="yes"],
|
||||
[
|
||||
AS_IF([test x"$force_cudartwrap" = "xyes"],
|
||||
[libwrap_error="yes"; break])
|
||||
[
|
||||
force_libwrap="yes"
|
||||
libwrap_error="yes"
|
||||
break
|
||||
])
|
||||
])
|
||||
;;
|
||||
esac
|
||||
|
35
ompi/contrib/vt/vt/config/m4/acinclude.mallocwrap.m4
Обычный файл
35
ompi/contrib/vt/vt/config/m4/acinclude.mallocwrap.m4
Обычный файл
@ -0,0 +1,35 @@
|
||||
AC_DEFUN([ACVT_MALLOCWRAP],
|
||||
[
|
||||
mallocwrap_error="no"
|
||||
check_mallocwrap="yes"
|
||||
have_mallocwrap="no"
|
||||
|
||||
AC_ARG_ENABLE(memtrace,
|
||||
AC_HELP_STRING([--enable-memtrace],
|
||||
[enable support for tracing LIBC functions for memory de/allocation (e.g. malloc,calloc,realloc,free) via library wrapping, default: enable]),
|
||||
[AS_IF([test x"$enableval" = "xyes"], [force_mallocwrap="yes"], [check_mallocwrap="no"])])
|
||||
|
||||
AS_IF([test "$check_mallocwrap" = "yes"],
|
||||
[
|
||||
sav_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS $DLINCDIR -D_GNU_SOURCE"
|
||||
AC_CHECK_DECLS([RTLD_NEXT], [], [mallocwrap_error="yes"], [#include <dlfcn.h>])
|
||||
CPPFLAGS=$sav_CPPFLAGS
|
||||
|
||||
AS_IF([test x"$mallocwrap_error" = "xno"],
|
||||
[
|
||||
AC_CHECK_FUNC([malloc_usable_size], [], [mallocwrap_error="yes"])
|
||||
])
|
||||
|
||||
AS_IF([test x"$mallocwrap_error" = "xno"],
|
||||
[
|
||||
sav_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS $DLINCDIR -D_BSD_SOURCE"
|
||||
AC_CHECK_FUNCS([memalign posix_memalign valloc])
|
||||
CPPFLAGS=$sav_CPPFLAGS
|
||||
|
||||
have_mallocwrap="yes"
|
||||
])
|
||||
])
|
||||
])
|
||||
|
@ -1,35 +0,0 @@
|
||||
AC_DEFUN([ACVT_MEMHOOKS],
|
||||
[
|
||||
memhooks_error="no"
|
||||
check_memhooks="yes"
|
||||
force_memhooks="no"
|
||||
have_memhooks="no"
|
||||
|
||||
AC_ARG_ENABLE(memtrace,
|
||||
AC_HELP_STRING([--enable-memtrace], [enable memory tracing support, default: enable if found by configure]),
|
||||
[AS_IF([test x"$enableval" = "xyes"], [force_memhooks="yes"], [check_memhooks="no"])])
|
||||
|
||||
AS_IF([test x"$check_memhooks" = "xyes"],
|
||||
[
|
||||
AC_CHECK_HEADER([malloc.h], [],
|
||||
[
|
||||
AC_MSG_NOTICE([error: no malloc.h found])
|
||||
memhooks_error="yes"
|
||||
])
|
||||
|
||||
AS_IF([test x"$memhooks_error" = "xno"],
|
||||
[
|
||||
memhooks_error="yes"
|
||||
AC_CHECK_FUNC([__malloc_hook],
|
||||
[AC_CHECK_FUNC([__realloc_hook],
|
||||
[AC_CHECK_FUNC([__free_hook], [memhooks_error="no"],
|
||||
[])])])
|
||||
])
|
||||
|
||||
AS_IF([test x"$memhooks_error" = "xno"],
|
||||
[
|
||||
have_memhooks="yes"
|
||||
])
|
||||
])
|
||||
])
|
||||
|
@ -82,7 +82,7 @@ See \`config.log' for more details.])
|
||||
[
|
||||
sav_CPPFLAGS=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS $PAPIINCDIR"
|
||||
AC_CHECK_DECLS([long_long], [], [], [#include <papi.h>])
|
||||
AC_CHECK_TYPES([long_long], [], [], [#include <papi.h>])
|
||||
CPPFLAGS=$sav_CPPFLAGS
|
||||
])
|
||||
|
||||
|
@ -49,9 +49,9 @@ AC_DEFUN([ACVT_SETUP],
|
||||
AS_IF([test x"$have_dyninst" = "xyes" -a x"$build_dynattlib" = "xyes"], [VT_SETUP_DYNINST=1])
|
||||
AS_IF([test x"$build_etimesync" = "xyes"], [VT_SETUP_ETIMESYNC=1])
|
||||
AS_IF([test x"$have_iowrap" = "xyes"], [VT_SETUP_IOTRACE=1])
|
||||
AS_IF([test x"$have_execwrap" = "xyes"], [VT_SETUP_EXECTRACE=1])
|
||||
AS_IF([test x"$have_mallocwrap" = "xyes"], [VT_SETUP_MEMTRACE=1])
|
||||
AS_IF([test x"$have_java" = "xyes"], [VT_SETUP_JAVA=1])
|
||||
AS_IF([test x"$have_libcwrap" = "xyes"], [VT_SETUP_LIBCTRACE=1])
|
||||
AS_IF([test x"$have_memhooks" = "xyes"], [VT_SETUP_MEMTRACE=1])
|
||||
AS_IF([test x"$have_papi" = "xyes"], [VT_SETUP_METRICS=1])
|
||||
AS_IF([test x"$have_mpi" = "xyes"], [VT_SETUP_MPI=1])
|
||||
AS_IF([test x"$have_unimci" = "xyes"], [VT_SETUP_MPICHECK=1])
|
||||
|
@ -102,6 +102,7 @@ AC_PROG_CXXCPP
|
||||
AM_PROG_AS
|
||||
|
||||
AC_C_BIGENDIAN
|
||||
AC_C_INLINE
|
||||
|
||||
# Do we want to support Fortran
|
||||
check_fortran="yes"
|
||||
@ -373,14 +374,6 @@ AS_IF([test x"$enable_config_titles" = "xyes" -a x"$check_plugin_cntr" = "xno"],
|
||||
AS_IF([test x"$force_plugin_cntr" = "xyes" -a x"plugin_cntr_error" = "xyes"], [exit 1])
|
||||
AM_CONDITIONAL(AMHAVEPLUGINCNTR, test x"$have_plugin_cntr" = "xyes")
|
||||
|
||||
# Check for memory tracing support
|
||||
ACVT_CONF_TITLE([GLIBC's memory allocation tracing])
|
||||
ACVT_MEMHOOKS
|
||||
AS_IF([test x"$enable_config_titles" = "xyes" -a x"$check_memhooks" = "xno"],
|
||||
[AC_MSG_NOTICE([disabled via command line switch])])
|
||||
AS_IF([test x"$force_memhooks" = "xyes" -a x"$memhooks_error" = "xyes"], [exit 1])
|
||||
AM_CONDITIONAL(AMHAVEMEMHOOKS, test x"$have_memhooks" = "xyes")
|
||||
|
||||
# Check for CPU ID tracing support
|
||||
ACVT_CONF_TITLE([GLIBC's CPU ID tracing])
|
||||
ACVT_GETCPU
|
||||
@ -427,9 +420,9 @@ AS_IF([test x"$enable_config_titles" = "xyes" -a x"$check_libwrap" = "xno"],
|
||||
AM_CONDITIONAL(AMBUILDLIBWRAP, test x"$have_libwrap" = "xyes")
|
||||
AM_CONDITIONAL(AMBUILDLIBWRAPGEN, test x"$build_libwrapgen" = "xyes")
|
||||
AM_CONDITIONAL(AMHAVEDL, test x"$have_dl" = "xyes")
|
||||
AM_CONDITIONAL(AMBUILDLIBCWRAP, test x"$have_libcwrap" = "xyes")
|
||||
AM_CONDITIONAL(AMHAVEFORK, test x"$have_libcwrap" = "xyes" -a x"$have_fork" = "xyes")
|
||||
AM_CONDITIONAL(AMBUILDEXECWRAP, test x"$have_execwrap" = "xyes")
|
||||
AM_CONDITIONAL(AMBUILDIOWRAP, test x"$have_iowrap" = "xyes")
|
||||
AM_CONDITIONAL(AMBUILDMALLOCWRAP, test x"$have_mallocwrap" = "xyes")
|
||||
AM_CONDITIONAL(AMBUILDCUDARTWRAP, test x"$have_cudartwrap" = "xyes")
|
||||
|
||||
cond_cuda=0
|
||||
|
@ -67,7 +67,7 @@ BODY { font-family: sans-serif; }
|
||||
<P>
|
||||
|
||||
<P>
|
||||
<B><BIG CLASS="XHUGE">VampirTrace 5.14.1 User Manual</BIG></B>
|
||||
<B><BIG CLASS="XHUGE">VampirTrace 5.15b User Manual</BIG></B>
|
||||
<BR>
|
||||
<BR>
|
||||
<BR>
|
||||
@ -184,7 +184,7 @@ Contents</A>
|
||||
<LI><A NAME="tex2html163"
|
||||
HREF="#SECTION00580000000000000000">I/O Calls</A>
|
||||
<LI><A NAME="tex2html164"
|
||||
HREF="#SECTION00590000000000000000">fork/system/exec Calls</A>
|
||||
HREF="#SECTION00590000000000000000">Child Process Execution Calls</A>
|
||||
<LI><A NAME="tex2html165"
|
||||
HREF="#SECTION005100000000000000000">MPI Correctness Checking Using UniMCI</A>
|
||||
<LI><A NAME="tex2html166"
|
||||
@ -355,20 +355,20 @@ OpenMP events, and performance counters.
|
||||
<P>
|
||||
After a successful tracing run, VampirTrace writes all collected data to a
|
||||
trace file in the Open Trace Format (OTF)<A NAME="tex2html1"
|
||||
HREF="#foot1569"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1601"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
As a result, the information is available for post-mortem analysis and
|
||||
visualization by various tools.
|
||||
Most notably, VampirTrace provides the input data for the Vampir analysis
|
||||
and visualization tool<A NAME="tex2html2"
|
||||
HREF="#foot1570"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1602"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
|
||||
<P>
|
||||
VampirTrace is included in OpenMPI 1.3 and later versions.
|
||||
If not disabled explicitly, VampirTrace is built automatically when installing
|
||||
OpenMPI<A NAME="tex2html3"
|
||||
HREF="#foot1571"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1603"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
|
||||
<P>
|
||||
@ -507,12 +507,22 @@ Note that not all features are supported on all platforms.
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<SPAN CLASS="textbf">Memory Tracing</SPAN> ⇒ Section <A HREF="#sec:mem_alloc_counter">4.3</A> <BR>
|
||||
<SPAN CLASS="textbf">CPU ID Tracing</SPAN> ⇒ Section <A HREF="#sec:cpu_id_counter">4.4</A> <BR>
|
||||
|
||||
<UL>
|
||||
<LI>Trace GLIBC memory allocation and free functions
|
||||
<LI>Trace core ID of a CPU on which the calling thread is running
|
||||
</LI>
|
||||
<LI>Record size of currently allocated memory as counter
|
||||
<LI>Record core ID as counter
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<SPAN CLASS="textbf">Child Process Execution Tracing</SPAN> ⇒ Section <A HREF="#sec:exec_calls">4.9</A> <BR>
|
||||
|
||||
<UL>
|
||||
<LI>Trace LIBC function calls for creating and controling child processes
|
||||
</LI>
|
||||
<LI>Add forked processes to the trace
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
@ -527,22 +537,12 @@ Note that not all features are supported on all platforms.
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<SPAN CLASS="textbf">CPU ID Tracing</SPAN> ⇒ Section <A HREF="#sec:cpu_id_counter">4.4</A> <BR>
|
||||
<SPAN CLASS="textbf">Memory Allocation Tracing</SPAN> ⇒ Section <A HREF="#sec:mem_alloc_counter">4.3</A> <BR>
|
||||
|
||||
<UL>
|
||||
<LI>Trace core ID of a CPU on which the calling thread is running
|
||||
<LI>Trace LIBC memory allocation and free functions
|
||||
</LI>
|
||||
<LI>Record core ID as counter
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
<SPAN CLASS="textbf">Fork/System/Exec Tracing</SPAN> ⇒ Section <A HREF="#sec:execfork">4.9</A> <BR>
|
||||
|
||||
<UL>
|
||||
<LI>Trace applications calling LIBC's fork, system, or one of the exec functions
|
||||
</LI>
|
||||
<LI>Add forked processes to the trace
|
||||
<LI>Record size of currently allocated memory as counter
|
||||
</LI>
|
||||
</UL>
|
||||
|
||||
@ -1185,7 +1185,7 @@ in a single file, that
|
||||
The names in between may contain wildcards as ``?'', ``*', and ``#'', each entry gets a new line.
|
||||
The lists end with <TT>END[_FILE]_<INCLUDE|EXCLUDE>_LIST</TT>. For further information on selective
|
||||
profiling have a look at the TAU documentation<A NAME="tex2html4"
|
||||
HREF="#foot1595"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1627"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
To announce the file through the compiler wrapper use the option <TT>-vt:tau</TT>:
|
||||
<PRE>
|
||||
@ -1202,7 +1202,7 @@ Binary Instrumentation Using Dyninst
|
||||
The option <TT>-vt:inst dyninst</TT> is used with the compiler wrapper to
|
||||
instrument the application during runtime (binary instrumentation), by using
|
||||
Dyninst<A NAME="tex2html5"
|
||||
HREF="#foot1596"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1628"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
Recompiling is not necessary for this kind of instrumentation,
|
||||
but relinking:
|
||||
@ -1353,7 +1353,7 @@ Tracing Calls to 3rd-Party Libraries
|
||||
VampirTrace is also capable to trace calls to third party libraries, which come with
|
||||
at least one C header file even without the library's source code. If VampirTrace was
|
||||
built with support for library tracing (the CTool library<A NAME="tex2html6"
|
||||
HREF="#foot1597"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1629"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A> is required), the tool <TT>vtlibwrapgen</TT> can be used to
|
||||
generate a wrapper library to intercept each call to the actual library functions.
|
||||
This wrapper library can be linked to the application or used in combination with the
|
||||
@ -1640,10 +1640,10 @@ of a VampirTrace instrumented executable:
|
||||
⇒ Section <A HREF="#sec:io_calls">4.8</A></TD>
|
||||
<TD ALIGN="LEFT">no</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><A NAME="VT_SETUP_VT_LIBCTRACE"></A><TT>VT_LIBCTRACE</TT></TD>
|
||||
<TD ALIGN="LEFT">Enable tracing of fork/system/exec calls?
|
||||
<TR><TD ALIGN="LEFT"><A NAME="VT_SETUP_VT_EXECTRACE"></A><TT>VT_EXECTRACE</TT></TD>
|
||||
<TD ALIGN="LEFT">Enable tracing of function calls for creating and controling child processes?
|
||||
<BR>
|
||||
⇒ Section <A HREF="#sec:execfork">4.9</A> calls</TD>
|
||||
⇒ Section <A HREF="#sec:exec_calls">4.9</A></TD>
|
||||
<TD ALIGN="LEFT">yes</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><A NAME="VT_SETUP_VT_MEMTRACE"></A><TT>VT_MEMTRACE</TT></TD>
|
||||
@ -2029,7 +2029,7 @@ for the enhanced timer synchronization:
|
||||
|
||||
<UL>
|
||||
<LI>CLAPACK <A NAME="tex2html7"
|
||||
HREF="#foot1607"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1639"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>
|
||||
</LI>
|
||||
<LI>AMD ACML
|
||||
@ -2238,26 +2238,36 @@ Memory Allocation Counter
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
The GNU LIBC implementation provides a special hook mechanism that allows
|
||||
intercepting all calls to memory allocation and free functions
|
||||
(e.g. <TT>malloc</TT>, <TT>realloc</TT>, <TT>free</TT>).
|
||||
This is independent from compilation or source code access, but relies on the
|
||||
underlying system library.
|
||||
Calls to functions which reside in external libraries can be intercepted by
|
||||
implementing identical functions and linking them before the external library.
|
||||
Such ``wrapper functions'' can record the parameters and return values of the
|
||||
library functions.
|
||||
|
||||
<P>
|
||||
If VampirTrace has been built with memory-tracing support , VampirTrace is capable of recording memory allocation
|
||||
information as part of the event records. To request the measurement of
|
||||
the application's allocated memory, the user must set the environment variable
|
||||
<TT>VT_MEMTRACE</TT> to <TT>yes</TT>.
|
||||
If VampirTrace has been built with memory allocation tracing support , it uses this technique for recording calls to
|
||||
memory (de)allocation functions of the standard C library, which are executed by the application.
|
||||
The following functions are intercepted by VampirTrace:
|
||||
|
||||
<P>
|
||||
<TABLE CELLPADDING=3>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>malloc</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>memalign</TT></TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>calloc</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>posix_memalign</TT></TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>realloc</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>valloc</TT></TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>free</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<H4><A NAME="SECTION00530010000000000000">
|
||||
Note:</A>
|
||||
</H4>
|
||||
This approach to get memory allocation information requires changing internal
|
||||
function pointers in a non-thread-safe way, so VampirTrace currently does not support
|
||||
memory tracing for thread-able programs, e.g., programs parallelized with OpenMP or Pthreads!
|
||||
<P>
|
||||
The gathered information will be saved as counter which indicates the current memory allocated
|
||||
in bytes. To request the measurement of the application's allocated memory, the user must set the
|
||||
environment variable <TT>VT_MEMTRACE</TT> to <TT>yes</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
@ -2335,6 +2345,9 @@ To enable a particular composition of CUDA measurement features the variable
|
||||
<TR><TD ALIGN="LEFT"><TT>kernel</TT></TD>
|
||||
<TD ALIGN="LEFT">CUDA kernels</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><TT>concurrent</TT></TD>
|
||||
<TD ALIGN="LEFT">force recording of concurrent kernels with CUPTI</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><TT>idle</TT></TD>
|
||||
<TD ALIGN="LEFT">GPU compute idle time</TD>
|
||||
</TR>
|
||||
@ -2424,7 +2437,7 @@ Example: <TT>VT_CUPTI_METRICS=local_store:local_load</TT>
|
||||
<P>
|
||||
</DD>
|
||||
<DT></DT>
|
||||
<DD><TT>VT_CUPTI_SAMPLING=[yes|<SPAN CLASS="textbf">no</SPAN>]</TT>
|
||||
<DD><TT>VT_CUPTI_EVENTS_SAMPLING=[yes|<SPAN CLASS="textbf">no</SPAN>]</TT>
|
||||
<SMALL CLASS="SCRIPTSIZE">(CUDA runtime API wrapper only) </SMALL>
|
||||
<BR>
|
||||
Poll for CUPTI counter values during kernel execution, if set to <TT>yes</TT>.
|
||||
@ -2519,23 +2532,16 @@ Several new region groups have been introduced:
|
||||
<H3><A NAME="SECTION00550100000000000000">
|
||||
Tracing CUDA Runtime API via CUPTI</A>
|
||||
</H3>
|
||||
To enable CUDA runtime API tracing via CUPTI, the option <TT>cupti</TT> has to be
|
||||
added to <TT>VT_GPUTRACE</TT>. By default, the library wrapper will be used.
|
||||
If both tracing methods are configured during the VampirTrace build process,
|
||||
the CUDA runtime library should be preloaded to reduce tracing overhead
|
||||
If the VampirTrace CUDA runtime API wrapper and CUPTI are configured during
|
||||
the VampirTrace build process, the option <TT>cupti</TT> has to be added to
|
||||
<TT>VT_GPUTRACE</TT> to enable CUDA runtime API tracing via CUPTI. In that
|
||||
case the CUDA runtime library should be preloaded to reduce tracing overhead
|
||||
(the dynamic linker can use <TT>LD_PRELOAD=libcudart.so</TT>). Otherwise
|
||||
the library wrapper intercepts every CUDA runtime API call and makes a short
|
||||
but unnecessary check, whether it is enabled.
|
||||
but unnecessary check, whether it is enabled. The CUPTI tracing method does
|
||||
not support recording of peer-to-peer memory copies.
|
||||
<P></P>
|
||||
|
||||
<P>
|
||||
CUPTI prior to version 1.0 (CUDA 4.0) has no native support for tracing of
|
||||
GPU activities, which therefore will be synchronized directly after their
|
||||
asynchronous call to retrieve their runtime.
|
||||
Filtered kernels will not be recorded and their execution time not marked as
|
||||
idle, if GPU idle time tracing is enabled.
|
||||
The CUPTI tracing method does not support peer-to-peer memory copies.
|
||||
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION00550200000000000000">
|
||||
@ -2549,12 +2555,11 @@ CUDA Runtime API Wrapper Particularities</A>
|
||||
<P></P>
|
||||
|
||||
<P>
|
||||
Until CUDA Toolkit 4.1 and Developer Drivers for Linux 285.05.32
|
||||
the usage of CUDA events between asynchronous tasks serializes their on-device
|
||||
execution. This seems to be a bug, which has already been reported to NVIDIA.
|
||||
Until CUDA Toolkit 4.2 the usage of CUDA events between
|
||||
asynchronous tasks serializes their on-device execution.
|
||||
As VampirTrace uses CUDA events for time measurement and asynchronous tasks
|
||||
may overlap (depends on the CUDA device capability), there might be a sensible
|
||||
impact on the program flow.
|
||||
impact on the program flow. CUDA 5 removes this restriction.
|
||||
|
||||
<P>
|
||||
|
||||
@ -2596,7 +2601,7 @@ CUDA Performance Counters via CUPTI Events
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION00550500000000000000">
|
||||
Compile and Link CUDA applications</A>
|
||||
Compile and Link CUDA Applications</A>
|
||||
</H3>
|
||||
Use the VampirTrace compiler wrapper <TT>vtnvcc</TT> instead of <TT>nvcc</TT>
|
||||
to compile the CUDA application, which does automatic source code instrumentation.
|
||||
@ -2672,20 +2677,22 @@ Tracing the NVIDIA CUDA SDK 3.x and 4.x</A>
|
||||
and hybrid programs, if necessary (e.g. the CUDA SDK example
|
||||
<TT>simpleMultiGPU</TT> is a multi-threaded program, which needs to be linked
|
||||
with a multi-threaded VampirTrace library).
|
||||
|
||||
<P><P>
|
||||
<BR>
|
||||
|
||||
<BR>
|
||||
<P>
|
||||
|
||||
<H3><A NAME="SECTION00550700000000000000">
|
||||
Multi-threaded CUDA applications</A>
|
||||
Recording Concurrent Kernels (CUDA 5)</A>
|
||||
</H3>
|
||||
If threads are used to invoke asynchronous CUDA tasks, make sure to call a
|
||||
synchronizing CUDA function to get the tasks flushed before the thread exits.
|
||||
Otherwise tasks may not be flushed and will be missing in the trace file.
|
||||
<P>
|
||||
Since CUDA 5 it is possible to record concurrently executed kernels on the GPU.
|
||||
The VampirTrace CUDA runtime API wrapper uses CUDA events for GPU activity
|
||||
time measurement and is therefore by default enabled for recording concurrent
|
||||
kernels. The NVIDIA CUPTI library provides two possibilities for measuring
|
||||
kernels. If a CUDA application creates the second CUDA stream, the activity
|
||||
buffer will be flushed, the light-weight kernel recording disabled and
|
||||
concurrent kernel recording enabled. To force concurrent kernel support at
|
||||
VampirTrace CUDA initialization add the GPU tracing option <TT>concurrent</TT>.
|
||||
|
||||
<P><P>
|
||||
<BR>
|
||||
|
||||
<BR>
|
||||
@ -2780,16 +2787,10 @@ I/O Calls
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
Calls to functions which reside in external libraries can be intercepted by
|
||||
implementing identical functions and linking them before the external library.
|
||||
Such ``wrapper functions'' can record the parameters and return values of the
|
||||
library functions.
|
||||
|
||||
<P>
|
||||
If VampirTrace has been built with I/O tracing support, it uses this technique
|
||||
for recording calls to I/O functions of the standard C library, which are
|
||||
executed by the application. The following functions
|
||||
are intercepted by VampirTrace:
|
||||
If VampirTrace has been built with I/O tracing support , it uses the same technique as used to intercept
|
||||
memory (de)allocation functions (⇒ Section <A HREF="#sec:mem_alloc_counter">4.3</A>) for recording calls
|
||||
to I/O functions of the standard C library, which are executed by the application. The following
|
||||
functions are intercepted by VampirTrace:
|
||||
|
||||
<P>
|
||||
<TABLE CELLPADDING=3>
|
||||
@ -2856,52 +2857,62 @@ If VampirTrace has been built with I/O tracing support, it uses this technique
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
The gathered information will be saved
|
||||
as I/O event records in the trace file. This feature has to be activated for
|
||||
each tracing run by setting the environment variable <TT>VT_IOTRACE</TT> to
|
||||
The gathered information will be saved as I/O event records in the trace file. This feature has
|
||||
to be activated for each tracing run by setting the environment variable <TT>VT_IOTRACE</TT> to
|
||||
<TT>yes</TT>.
|
||||
|
||||
<P>
|
||||
This works for both dynamically and statically linked executables.
|
||||
Note that when linking statically, a warning like the following may be issued: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking.
|
||||
This is ok as long as the mentioned libraries are available for running the application.
|
||||
|
||||
<P>
|
||||
If you'd like to experiment with some other I/O library, set the environment variable <TT>VT_IOLIB_PATHNAME</TT> to the alternative one.
|
||||
Beware that this library must provide all I/O functions mentioned above otherwise VampirTrace will abort.
|
||||
Setting the environment variable <TT>VT_IOTRACE_EXTENDED</TT> to <TT>yes</TT> enables the collection of additional function arguments
|
||||
for some of the I/O function mentioned above.
|
||||
For example, this option stores offsets for <TT>pwrite</TT> and <TT>pread</TT> additionally to the I/O event record.
|
||||
Enabling <TT>VT_IOTRACE_EXTENDED</TT> automatically enables <TT>VT_IOTRACE</TT>.
|
||||
If you'd like to experiment with some other I/O library, set the environment variable <TT>VT_IOLIB_PATHNAME</TT>
|
||||
to the alternative one. Beware that this library must provide all I/O functions mentioned above
|
||||
otherwise VampirTrace will abort. Setting the environment variable <TT>VT_IOTRACE_EXTENDED</TT> to <TT>yes</TT>
|
||||
enables the collection of additional function arguments for some of the I/O function mentioned above.
|
||||
For example, this option stores offsets for <TT>pwrite</TT> and <TT>pread</TT> additionally to the
|
||||
I/O event record. Enabling <TT>VT_IOTRACE_EXTENDED</TT> automatically enables <TT>VT_IOTRACE</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
<H1><A NAME="SECTION00590000000000000000"></A>
|
||||
<A NAME="sec:execfork"></A>
|
||||
<A NAME="sec:exec_calls"></A>
|
||||
<BR>
|
||||
fork/system/exec Calls
|
||||
Child Process Execution Calls
|
||||
</H1>
|
||||
|
||||
<P>
|
||||
If VampirTrace has been built with LIBC trace support ,
|
||||
it is capable of tracing programs which call functions from the LIBC <TT>exec</TT> family
|
||||
(<TT>execl</TT>, <TT>execlp</TT>, <TT>execle</TT>, <TT>execv</TT>, <TT>execvp</TT>, <TT>execve</TT>),
|
||||
<TT>system</TT>, and <TT>fork</TT>.
|
||||
VampirTrace records the call of the LIBC function to the trace.
|
||||
This feature works for sequential (i.e. no MPI or threaded parallelization) programs only.
|
||||
It works for both dynamically and statically linked executables.
|
||||
Note that when linking statically, a warning like the following may be issued: Using 'dlopen' in statically linked applications requires at
|
||||
runtime the shared libraries from the glibc version used for linking.
|
||||
This is ok as long as the mentioned libraries are available for running the application.
|
||||
In addition to the memory allocation tracing (⇒ Section <A HREF="#sec:mem_alloc_counter">4.3</A>) and I/O tracing
|
||||
(⇒ Section <A HREF="#sec:io_calls">4.8</A>), VampirTrace uses the library wrapping technique also to intercept
|
||||
functions of the standard C library for creating and controling child processes. These functions are:
|
||||
|
||||
<P>
|
||||
When VampirTrace detects a call of an <TT>exec</TT> function,
|
||||
the current trace file is closed before executing the new program.
|
||||
If the executed program is also instrumented with VampirTrace, it will create a different trace file.
|
||||
Note that VampirTrace aborts if the exec function returns unsuccessfully.
|
||||
<TABLE CELLPADDING=3>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execl</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execvp</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>fork</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>waitid</TT></TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execlp</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execve</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>system</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>wait3</TT></TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execle</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execvpe</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>wait</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>wait4</TT></TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>execv</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>fexecve</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110><TT>waitpid</TT></TD>
|
||||
<TD ALIGN="LEFT" VALIGN="TOP" WIDTH=110> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<P>
|
||||
Calling <TT>fork</TT> in an instrumented program creates an additional process in the same trace file.
|
||||
When VampirTrace detects a call of an <TT>exec</TT> function, the current trace file is closed before
|
||||
executing the new program. If the executed program is also instrumented with VampirTrace, it will create
|
||||
a different trace file. Note that VampirTrace aborts if the <TT>exec</TT> function returns unsuccessfully.
|
||||
Calling <TT>fork</TT> in an instrumented program creates an additional process in the same trace file.
|
||||
Using this feature requires building VampirTrace with support for tracing LIBC functions for creating and , and setting
|
||||
the environment variable <TT>VT_EXECTRACE</TT> to <TT>yes</TT>.
|
||||
|
||||
<P>
|
||||
|
||||
@ -3506,14 +3517,14 @@ VampirTrace allows assigning functions/regions to a group.
|
||||
<TR><TD ALIGN="LEFT"><TT>Pthreads</TT></TD>
|
||||
<TD ALIGN="LEFT">Pthread API function calls</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><TT>MEM</TT></TD>
|
||||
<TD ALIGN="LEFT">Memory allocation functions (⇒ Section <A HREF="#sec:mem_alloc_counter">4.3</A>)</TD>
|
||||
<TR><TD ALIGN="LEFT"><TT>LIBC-EXEC</TT></TD>
|
||||
<TD ALIGN="LEFT">LIBC function calls for creating and controling child processes (⇒ Section <A HREF="#sec:exec_calls">4.9</A>)</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><TT>I/O</TT></TD>
|
||||
<TD ALIGN="LEFT">I/O functions (⇒ Section <A HREF="#sec:io_calls">4.8</A>)</TD>
|
||||
<TR><TD ALIGN="LEFT"><TT>LIBC-I/O</TT></TD>
|
||||
<TD ALIGN="LEFT">LIBC functions (⇒ Section <A HREF="#sec:io_calls">4.8</A>)</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><TT>LIBC</TT></TD>
|
||||
<TD ALIGN="LEFT">LIBC fork/system/exec functions (⇒ Section <A HREF="#sec:execfork">4.9</A>)</TD>
|
||||
<TR><TD ALIGN="LEFT"><TT>LIBC-MALLOC</TT></TD>
|
||||
<TD ALIGN="LEFT">LIBC memory (de)allocation functions (⇒ Section <A HREF="#sec:mem_alloc_counter">4.3</A>)</TD>
|
||||
</TR>
|
||||
<TR><TD ALIGN="LEFT"><TT>Application</TT></TD>
|
||||
<TD ALIGN="LEFT">remaining instrumented functions and source code regions</TD>
|
||||
@ -3678,7 +3689,7 @@ default: automatically by configure.
|
||||
enable support for Dyninst instrumentation,
|
||||
default: enable if found by configure.
|
||||
<SPAN CLASS="textbf">Note:</SPAN> Requires Dyninst<A NAME="tex2html8"
|
||||
HREF="#foot1629"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1667"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A> version 6.1 or higher!
|
||||
|
||||
<P>
|
||||
@ -3700,19 +3711,11 @@ enable support for automatic source code
|
||||
instrumentation by using TAU, default: enable if
|
||||
found by configure.
|
||||
<SPAN CLASS="textbf">Note:</SPAN> Requires PDToolkit<A NAME="tex2html9"
|
||||
HREF="#foot1630"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1668"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A> or TAU<A NAME="tex2html10"
|
||||
HREF="#foot1631"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1669"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>!
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-memtrace</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable memory tracing support, default: enable if
|
||||
found by configure
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-cpuidtrace</TT></STRONG></DT>
|
||||
@ -3726,8 +3729,46 @@ enable CPU ID tracing support, default: enable if
|
||||
<DT><STRONG><TT>-enable-libtrace=LIST</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable library tracing support (gen,libc,io),
|
||||
default: automatically by configure
|
||||
enable library tracing support
|
||||
(gen,exec,io,malloc,cudart), default: automatically
|
||||
by configure
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-exectrace</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable support for tracing LIBC functions for
|
||||
creating and controling child processes (e.g.
|
||||
execl,fork,system,wait) via library wrapping,
|
||||
default: enable
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-iotrace</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable support for tracing LIBC I/O functions (e.g.
|
||||
fopen,fclose,fread,fwrite) via library wrapping,
|
||||
default: enable
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-memtrace</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable support for tracing LIBC functions for memory
|
||||
de/allocation (e.g. malloc,realloc,free) via library
|
||||
wrapping, default: enable
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-cudartwrap</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable support for tracing the CUDA runtime API via
|
||||
library wrapping, default: enable if no CUPTI
|
||||
present
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
@ -3853,14 +3894,6 @@ enable Java support, default: enable if JVMTI
|
||||
enable support for tracing CUDA via CUPTI,
|
||||
default: enable if found by configure
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
<DT><STRONG><TT>-enable-cudawrap</TT></STRONG></DT>
|
||||
<DD>
|
||||
<BR>
|
||||
enable support for tracing CUDA via library
|
||||
wrapping, default: enable if found by configure
|
||||
|
||||
<P>
|
||||
</DD>
|
||||
</DL>
|
||||
@ -4278,7 +4311,7 @@ give the path for JVMTI-include files, default:
|
||||
|
||||
<P>
|
||||
To enable support for generating wrapper for 3th-Party libraries the C code parser CTool<A NAME="tex2html11"
|
||||
HREF="#foot1632"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot1670"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A> is needed:
|
||||
|
||||
<P>
|
||||
@ -5440,7 +5473,7 @@ Since IOFSL servers can handle multiple clients, an N:M mapping of clients to se
|
||||
|
||||
<P>
|
||||
When using the IOFSL integration, all write requests in OTF are issued using the zoidfs API<A NAME="tex2html12"
|
||||
HREF="#foot3235"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot3277"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>. Those writes are handled by the IOFSL forwarding servers and aggregated into a single file using the atomic append feature. The offset in the multifile is returned to OTF and stored in a second file, the so called index file, in order to maintain the mapping between written blocks and streams. For any block of a stream written into the multifile, the index file contains the ID of the stream, the start of the block, and its length. This allows for an efficient reading of blocks since only the index file has to be scanned for entries for a given stream ID. Additionally, a large number of logical files (streams) can be stored using only two physical files.
|
||||
|
||||
<P>
|
||||
@ -5452,7 +5485,7 @@ Installation</A>
|
||||
<P>
|
||||
In order to use this setup, IOFSL and VampirTrace have to be compiled in order.
|
||||
In the following sections, the directory <TT><install_dir></TT> should be replaced with a - possibly user-local - directory used for installation, e.g. <TT>$HOME/local</TT><A NAME="tex2html13"
|
||||
HREF="#foot3239"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot3281"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
The installation procedure for IOFSL is described at https://trac.mcs.anl.gov/projects/iofsl/wiki/Building.
|
||||
Currently the <TT>iofsl_vampir</TT> git branch is required.
|
||||
@ -5631,7 +5664,7 @@ They will be launched on dedicated compute nodes that are part of the batch Job
|
||||
PBS Options</A>
|
||||
</H4>
|
||||
It is important to reserve a sufficient number of processor cores. The number of cores requested must be large enough to contain the number of application cores plus the number of cores required for the IOFSL server instances. Each IOFSL server will run on a dedicated node<A NAME="tex2html14"
|
||||
HREF="#foot3283"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot3325"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.Thus N_allocated ≥((N_IOFSL * 16) + N_Application) must hold.
|
||||
<P>
|
||||
Example using 64 server instances:
|
||||
@ -5728,10 +5761,10 @@ Configuring the Server</A>
|
||||
The server is configured using a configuration file.
|
||||
At server start-up, this file is provided using the <TT>-config</TT> argument.
|
||||
The cray XK6 configuration file is provided in the package<A NAME="tex2html15"
|
||||
HREF="#foot3423"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot3465"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
For more information about the options available please refer to the IOFSL documentation<A NAME="tex2html16"
|
||||
HREF="#foot3424"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
HREF="#foot3466"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A>.
|
||||
The most important option is the <TT>serverlist</TT> entry in the <TT>bmi</TT> section which takes a list of server addresses, e.g. :
|
||||
<PRE>
|
||||
@ -6137,99 +6170,99 @@ If you provide us with your additions afterwards we will consider merging them
|
||||
into the official VampirTrace package.
|
||||
<BR><HR><H4>Footnotes</H4>
|
||||
<DL>
|
||||
<DT><A NAME="foot1569">... (OTF)</A><A
|
||||
<DT><A NAME="foot1601">... (OTF)</A><A
|
||||
HREF="#tex2html1"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.tu-dresden.de/zih/otf
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1570">... tool </A><A
|
||||
<DT><A NAME="foot1602">... tool </A><A
|
||||
HREF="#tex2html2"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.vampir.eu
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1571">...
|
||||
<DT><A NAME="foot1603">...
|
||||
Open MPI </A><A
|
||||
HREF="#tex2html3"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.open-mpi.org/faq/?category=vampirtrace
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1595">... documentation </A><A
|
||||
<DT><A NAME="foot1627">... documentation </A><A
|
||||
HREF="#tex2html4"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.cs.uoregon.edu/Research/tau/docs/newguide/bk05ch02.html#d0e3770
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1596">...
|
||||
<DT><A NAME="foot1628">...
|
||||
Dyninst </A><A
|
||||
HREF="#tex2html5"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.dyninst.org
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1597">... library </A><A
|
||||
<DT><A NAME="foot1629">... library </A><A
|
||||
HREF="#tex2html6"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://sourceforge.net/projects/ctool
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1607">... CLAPACK</A><A
|
||||
<DT><A NAME="foot1639">... CLAPACK</A><A
|
||||
HREF="#tex2html7"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>www.netlib.org/clapack
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1629">... Dyninst </A><A
|
||||
<DT><A NAME="foot1667">... Dyninst </A><A
|
||||
HREF="#tex2html8"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.dyninst.org
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1630">... PDToolkit </A><A
|
||||
<DT><A NAME="foot1668">... PDToolkit </A><A
|
||||
HREF="#tex2html9"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://www.cs.uoregon.edu/research/pdt/home.php
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1631">... TAU </A><A
|
||||
<DT><A NAME="foot1669">... TAU </A><A
|
||||
HREF="#tex2html10"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://tau.uoregon.edu
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot1632">... CTool </A><A
|
||||
<DT><A NAME="foot1670">... CTool </A><A
|
||||
HREF="#tex2html11"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>http://sourceforge.net/projects/ctool
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot3235">... API</A><A
|
||||
<DT><A NAME="foot3277">... API</A><A
|
||||
HREF="#tex2html12"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>The OTF master control file is written using POSIX I/O in any case.
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot3239">...$HOME/local</A><A
|
||||
<DT><A NAME="foot3281">...$HOME/local</A><A
|
||||
HREF="#tex2html13"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>The software packages can be installed in different directories.
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot3283">... node</A><A
|
||||
<DT><A NAME="foot3325">... node</A><A
|
||||
HREF="#tex2html14"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>The server makes use of all the nodes resources by multithreading and allocating large I/O buffers
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot3423">... package</A><A
|
||||
<DT><A NAME="foot3465">... package</A><A
|
||||
HREF="#tex2html15"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD><TT>tools/vtiofsl/platform/crayxk6-iofwd.cf</TT>
|
||||
|
||||
</DD>
|
||||
<DT><A NAME="foot3424">... documentation</A><A
|
||||
<DT><A NAME="foot3466">... documentation</A><A
|
||||
HREF="#tex2html16"><SUP><IMG ALIGN="BOTTOM" BORDER="1" ALT="[*]"
|
||||
SRC="/usr/share/latex2html/icons/footnote.png"></SUP></A></DT>
|
||||
<DD>https://trac.mcs.anl.gov/projects/iofsl/wiki/ConfigurationFile
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@ -3,6 +3,7 @@
|
||||
- replaced temporary workaround for handling bogus zlib
|
||||
sync. points by a more elaborated solution
|
||||
- otfprofile:
|
||||
- fixed build error when using the IBM XL C++ compiler
|
||||
- removed unnecessary '-k' option from otfshrink command
|
||||
|
||||
1.12.1openmpi
|
||||
|
@ -234,8 +234,8 @@ static bool write_markerDispersion_callpath( AllData& alldata, OTF_WStream* writ
|
||||
int i= 0;
|
||||
uint64_t timerResolution= alldata.timerResolution;
|
||||
|
||||
map< TripleCallpath, FunctionDispersionData, gtTripleCallpathSortByDispersion >::const_iterator it= alldata.functionDispersionCallpathMap.begin();
|
||||
map< TripleCallpath, FunctionDispersionData, gtTripleCallpathSortByDispersion >::const_iterator itend= alldata.functionDispersionCallpathMap.end();
|
||||
map< TripleCallpath, FunctionDispersionData, gtTripleCallpathSortByCallpath >::const_iterator it= alldata.functionDispersionCallpathMap.begin();
|
||||
map< TripleCallpath, FunctionDispersionData, gtTripleCallpathSortByCallpath >::const_iterator itend= alldata.functionDispersionCallpathMap.end();
|
||||
|
||||
|
||||
|
||||
|
@ -192,7 +192,7 @@ bool ProcessDispersion( AllData& alldata ) {
|
||||
uint64_t funcid = it->first.a;
|
||||
string callpath = it->second.callpath;
|
||||
|
||||
map<PairCallpath, FunctionData>::const_iterator
|
||||
map<PairCallpath, FunctionData, ltPairCallpath>::const_iterator
|
||||
iter_funcCallpathMapGlobal;
|
||||
iter_funcCallpathMapGlobal
|
||||
= alldata.functionCallpathMapGlobal.find(PairCallpath(
|
||||
|
@ -20,12 +20,24 @@
|
||||
#define VT_LIBWRAP_MAX_SHLIBS 10
|
||||
|
||||
/* default library wrapper attributes */
|
||||
#define VT_LIBWRAP_ATTR_DEFAULT \
|
||||
{ 0, { NULL }, NULL, 0, NULL }
|
||||
#define VT_LIBWRAP_ATTR_DEFAULT { \
|
||||
0, /* shlibs_num */ \
|
||||
{ NULL }, /* shlibs */ \
|
||||
NULL, /* func_group */ \
|
||||
0, /* libc */ \
|
||||
0, /* wait_for_init */ \
|
||||
NULL /* init_func */ \
|
||||
}
|
||||
|
||||
/* library wrapper attributes with a pointer to an initializer function */
|
||||
#define VT_LIBWRAP_ATTR_INITIALIZER(_init_func) \
|
||||
{ 0, { NULL }, NULL, 0, _init_func }
|
||||
#define VT_LIBWRAP_ATTR_INITIALIZER(_init_func) { \
|
||||
0, /* shlibs_num */ \
|
||||
{ NULL }, /* shlibs */ \
|
||||
NULL, /* func_group */ \
|
||||
0, /* libc */ \
|
||||
0, /* wait_for_init */ \
|
||||
_init_func /* init_func */ \
|
||||
}
|
||||
|
||||
/* miscellaneous constants */
|
||||
#define VT_LIBWRAP_NULL NULL
|
||||
@ -47,20 +59,29 @@
|
||||
_line = source code location (line) */
|
||||
#define VT_LIBWRAP_FUNC_INIT(_lw, _lwattr, _func, _rettype, _argtypes, \
|
||||
_file, _line) \
|
||||
static _rettype (*VT_LIBWRAP_FUNC_PTR)_argtypes = VT_LIBWRAP_NULL; \
|
||||
static int VT_LIBWRAP_FUNC_ID = VT_LIBWRAP_NOID; \
|
||||
_VT_LIBWRAP_FUNC_INIT_DECL_VARS(_func, _rettype, _argtypes); \
|
||||
if( _lw == VT_LIBWRAP_NULL ) { \
|
||||
VTLibwrap_create(&_lw, &_lwattr); \
|
||||
} \
|
||||
if( VT_LIBWRAP_FUNC_PTR == VT_LIBWRAP_NULL || \
|
||||
VT_LIBWRAP_FUNC_ID == VT_LIBWRAP_NOID ) { \
|
||||
VTLibwrap_func_init(_lw, _func, _file, _line, \
|
||||
VTLibwrap_func_init(_lw, VT_LIBWRAP_FUNC_NAME, _file, _line, \
|
||||
(void**)(&VT_LIBWRAP_FUNC_PTR), &VT_LIBWRAP_FUNC_ID); \
|
||||
}
|
||||
|
||||
/* internal macro used within VT_LIBWRAP_FUNC_INIT to declare variables for
|
||||
storing the function name, the actual function pointer, and the unique
|
||||
function identifier */
|
||||
#define _VT_LIBWRAP_FUNC_INIT_DECL_VARS(_func, _rettype, _argtypes) \
|
||||
static const char* VT_LIBWRAP_FUNC_NAME = _func; \
|
||||
static _rettype (*VT_LIBWRAP_FUNC_PTR)_argtypes = VT_LIBWRAP_NULL; \
|
||||
static int VT_LIBWRAP_FUNC_ID = VT_LIBWRAP_NOID
|
||||
|
||||
/* The following macros are only available inside a wrapper function after
|
||||
calling VT_LIBWRAP_FUNC_INIT. */
|
||||
|
||||
/* variable name of function name */
|
||||
#define VT_LIBWRAP_FUNC_NAME _vtlw_funcname
|
||||
/* variable name of pointer to the real function */
|
||||
#define VT_LIBWRAP_FUNC_PTR _vtlw_funcptr
|
||||
/* variable name of function identifier */
|
||||
@ -110,8 +131,11 @@ struct VTLibwrapAttr_struct
|
||||
assigned to the default group 'Application'. */
|
||||
char* func_group;
|
||||
|
||||
/* Wait for initialization of VampirTrace before generating events by the
|
||||
wrapper functions (1=yes / 0=no) */
|
||||
/* Flag: Do additional search actual library functions in the LIBC. */
|
||||
char libc;
|
||||
|
||||
/* Flag: Wait for initialization of VampirTrace before generating events by
|
||||
the wrapper functions. */
|
||||
char wait_for_init;
|
||||
|
||||
/* Pointer to a function which may be used to initialize the library wrapper
|
||||
@ -144,7 +168,7 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr);
|
||||
/* delete a library wrapper object
|
||||
arguments:
|
||||
lw = library wrapper object */
|
||||
void VTLibwrap_delete(VTLibwrap** lw);
|
||||
void VTLibwrap_delete(VTLibwrap* lw);
|
||||
|
||||
/* delete all library wrapper objects */
|
||||
void VTLibwrap_delete_all(void);
|
||||
|
@ -1,5 +1,7 @@
|
||||
lib_LTLIBRARIES = libvt-dynatt.la
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/vtlib
|
||||
|
||||
libvt_dynatt_la_CFLAGS = -shared
|
||||
libvt_dynatt_la_LDFLAGS = -shared -avoid-version
|
||||
libvt_dynatt_la_SOURCES = \
|
||||
|
@ -17,10 +17,12 @@
|
||||
# define INITROU _init
|
||||
#endif
|
||||
|
||||
extern void VT_Dyn_attach(void);
|
||||
#include "vt_dyninst.h"
|
||||
|
||||
void INITROU(void);
|
||||
|
||||
void INITROU()
|
||||
{
|
||||
VT_Dyn_attach();
|
||||
vt_dyn_attach();
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
#include "vt_dyn.h"
|
||||
|
||||
#include "BPatch_flowGraph.h"
|
||||
#include "BPatch_module.h"
|
||||
#include "BPatch_point.h"
|
||||
#include "BPatch_process.h"
|
||||
#include "BPatch_snippet.h"
|
||||
#include "BPatch_statement.h"
|
||||
@ -596,8 +598,8 @@ MutatorC::initialize()
|
||||
// search instrumentation functions to insert at entry/exit points
|
||||
//
|
||||
|
||||
if( !findFunction( "VT_Dyn_start", m_vtStartFunc ) ||
|
||||
!findFunction( "VT_Dyn_end", m_vtEndFunc ) )
|
||||
if( !findFunction( "vt_dyn_start", m_vtStartFunc ) ||
|
||||
!findFunction( "vt_dyn_end", m_vtEndFunc ) )
|
||||
{
|
||||
std::cerr << ExeName << ": [" << ExePid << "]: "
|
||||
<< "Error: Could not find instrumentation functions. "
|
||||
@ -640,9 +642,9 @@ MutatorC::finalize( bool & error )
|
||||
// send mutatee process a signal to continue execution
|
||||
//
|
||||
if( Params.mutatee_pid != -1 )
|
||||
kill( Params.mutatee_pid, SIGUSR1 );
|
||||
kill( Params.mutatee_pid, VT_DYNINST_CONT_SIGNUM );
|
||||
|
||||
if( Params.mode == MODE_CREATE || !Params.detach )
|
||||
if( !Params.detach )
|
||||
{
|
||||
// continue execution of mutatee
|
||||
app_process->continueExecution();
|
||||
@ -658,7 +660,7 @@ MutatorC::finalize( bool & error )
|
||||
vPrint( 1, "End of process\n" );
|
||||
vPrint( 1, "Done\n" );
|
||||
}
|
||||
else // Params.mode == MODE_ATTACH && Params.detach
|
||||
else
|
||||
{
|
||||
// continue execution of mutatee and detach from its process
|
||||
app_process->detach( true );
|
||||
|
@ -966,16 +966,19 @@ GeneratorC::writeHead()
|
||||
<< " * functions. If 0 is specified, the addresses of the functions will be" << std::endl
|
||||
<< " * searched in the shared libraries linked to the application, in order," << std::endl
|
||||
<< " * starting after the VampirTrace library." << std::endl
|
||||
<< " * char* shlibs[VT_LIBWRAP_MAX_SEARCH_LIBS]:" << std::endl
|
||||
<< " * char* shlibs[VT_LIBWRAP_MAX_SHLIBS]:" << std::endl
|
||||
<< " * Array of pathnames to the shared libraries which will be searched for the" << std::endl
|
||||
<< " * actual library functions." << std::endl
|
||||
<< " * char* func_group:" << std::endl
|
||||
<< " * Separate function group which will be assigned to all of the wrapped" << std::endl
|
||||
<< " * functions. If no group specified (NULL), each wrapped function will be" << std::endl
|
||||
<< " * assigned to the default group 'Application'." << std::endl
|
||||
<< " * char libc:" << std::endl
|
||||
<< " * Do additional search actual library functions in the LIBC." << std::endl
|
||||
<< " * (1=yes / 0=no)" << std::endl
|
||||
<< " * char wait_for_init:" << std::endl
|
||||
<< " * Wait for initialization of VampirTrace before generating events by these" << std::endl
|
||||
<< " * wrapper functions (1=yes / 0=no)" << std::endl
|
||||
<< " * wrapper functions. (1=yes / 0=no)" << std::endl
|
||||
<< " * VTLibwrapAttrInitFunc init_func:" << std::endl
|
||||
<< " * Pointer to a function which may be used to initialize the library wrapper" << std::endl
|
||||
<< " * attributes above. It is called at the first wrapper event, if it is not set" << std::endl
|
||||
@ -990,6 +993,7 @@ GeneratorC::writeHead()
|
||||
<< " * shlibs_num = 0" << std::endl
|
||||
<< " * shlibs = { NULL, ... } - no shared libraries" << std::endl
|
||||
<< " * func_group = NULL - no separate function group" << std::endl
|
||||
<< " * libc = 0 - do not search actual library functions in LIBC" << std::endl
|
||||
<< " * wait_for_init = 0 - do not wait for initialization of VampirTrace" << std::endl
|
||||
<< " *" << std::endl
|
||||
<< " * uncomment the following line to use the default attributes:" << std::endl
|
||||
@ -1009,6 +1013,7 @@ GeneratorC::writeHead()
|
||||
<< " attr->shlibs[1] = <shlib2>;" << std::endl
|
||||
<< " ..." << std::endl
|
||||
<< " attr->func_group = <groupname>;" << std::endl
|
||||
<< " attr->libc = <0|1>;" << std::endl
|
||||
<< " attr->wait_for_init = <0|1>;" << std::endl
|
||||
<< "}" << std::endl
|
||||
<< "static VTLibwrapAttr lw_attr = VT_LIBWRAP_ATTR_INITIALIZER(libwrap_attr_init);" << std::endl
|
||||
@ -1043,7 +1048,8 @@ GeneratorC::writeHead()
|
||||
out << " NULL,";
|
||||
out << " /* func_group */" << std::endl;
|
||||
|
||||
out << " 0 /* wait_for_init */" << std::endl
|
||||
out << " 0, /* libc */" << std::endl
|
||||
<< " 0 /* wait_for_init */" << std::endl
|
||||
<< "};" << std::endl
|
||||
<< std::endl
|
||||
<< std::endl
|
||||
|
@ -360,13 +360,7 @@ if test $mpi -eq 1 -a $fortran -eq 1 -a x"$FMPILIB" != x; then
|
||||
fi
|
||||
|
||||
if test $dyninst -eq 1; then
|
||||
if test x"$DYNINSTAPI_RT_LIB" = x; then
|
||||
error_msg "Error: Environment variable DYNINSTAPI_RT_LIB is not "\
|
||||
"defined. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ld_preload="$DYNINSTAPI_RT_LIB:$libdir/$DYNATTLIB:$ld_preload"
|
||||
ld_preload="$libdir/$DYNATTLIB:$ld_preload"
|
||||
fi
|
||||
|
||||
if test x"$extra_libs" != x; then
|
||||
|
@ -350,18 +350,18 @@
|
||||
<available>@VT_SETUP_IOTRACE@</available>
|
||||
<anchor>VT_SETUP_VT_IOLIB_PATHNAME</anchor>
|
||||
</env>
|
||||
<env isdeprecated="0" priority="290" descname="Enable libc tracing" isadvanced="1" group="libtrace"
|
||||
envname="VT_LIBCTRACE">
|
||||
<desc>Enable / disable event recording of fork/system/exec calls.</desc>
|
||||
<env isdeprecated="0" priority="290" descname="Enable exec(3) function tracing" isadvanced="1" group="libtrace"
|
||||
envname="VT_EXECTRACE">
|
||||
<desc>Enable / disable the recording of functions for creating and controling child processes (e.g. execl).</desc>
|
||||
<valuedesc>
|
||||
<value type="bool">
|
||||
<default>1</default>
|
||||
</value>
|
||||
</valuedesc>
|
||||
<since major="5" minor="0" patch="0" /><available>@VT_SETUP_LIBCTRACE@</available>
|
||||
<anchor>VT_SETUP_VT_LIBCTRACE</anchor>
|
||||
<since major="5" minor="0" patch="0" /><available>@VT_SETUP_EXECTRACE@</available>
|
||||
<anchor>VT_SETUP_VT_EXECTRACE</anchor>
|
||||
</env>
|
||||
<env isdeprecated="0" priority="100" descname="Enable memory usage counter" isadvanced="0" group="libtrace"
|
||||
<env isdeprecated="0" priority="100" descname="Enable memory allocation tracing" isadvanced="0" group="libtrace"
|
||||
envname="VT_MEMTRACE">
|
||||
<desc>Enable / disable recording of memory allocation counter.</desc>
|
||||
<valuedesc>
|
||||
|
@ -32,9 +32,7 @@
|
||||
#ifndef _HASH_H
|
||||
#define _HASH_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h" /* defines WORDS_BIGENDIAN etc */
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
#include "config.h" /* defines WORDS_BIGENDIAN (and 'inline') etc */
|
||||
|
||||
#include "vt_inttypes.h" /* defines uint32_t etc */
|
||||
|
||||
|
@ -152,18 +152,12 @@ LIBWRAPSOURCES =
|
||||
LIBWRAPCFLAGS =
|
||||
endif
|
||||
|
||||
if AMBUILDLIBCWRAP
|
||||
LIBCWRAPSOURCES = vt_libcwrap.c
|
||||
LIBCWRAPCFLAGS = -DVT_LIBCWRAP
|
||||
if AMBUILDEXECWRAP
|
||||
EXECWRAPSOURCES = vt_execwrap.c
|
||||
EXECWRAPCFLAGS = -DVT_EXECWRAP
|
||||
else
|
||||
LIBCWRAPSOURCES =
|
||||
LIBCWRAPCFLAGS =
|
||||
endif
|
||||
|
||||
if AMHAVEFORK
|
||||
FORKSOURCES = vt_fork.c
|
||||
else
|
||||
FORKSOURCES =
|
||||
EXECWRAPSOURCES =
|
||||
EXECWRAPCFLAGS =
|
||||
endif
|
||||
|
||||
if AMBUILDIOWRAP
|
||||
@ -174,6 +168,14 @@ IOWRAPSOURCES =
|
||||
IOWRAPCFLAGS =
|
||||
endif
|
||||
|
||||
if AMBUILDMALLOCWRAP
|
||||
MALLOCWRAPSOURCES = vt_mallocwrap.c
|
||||
MALLOCWRAPCFLAGS = -DVT_MALLOCWRAP
|
||||
else
|
||||
MALLOCWRAPSOURCES =
|
||||
MALLOCWRAPCFLAGS =
|
||||
endif
|
||||
|
||||
if AMHAVEGPU
|
||||
GPUSOURCES = vt_gpu.c
|
||||
GPUHEADERS = vt_gpu.h
|
||||
@ -202,8 +204,8 @@ endif
|
||||
endif
|
||||
|
||||
if AMBUILDCUPTI
|
||||
GPUSOURCES += vt_cupti.c
|
||||
GPUHEADERS += vt_cupti.h
|
||||
GPUSOURCES += vt_cupti_common.c
|
||||
GPUHEADERS += vt_cupti_common.h vt_cupti.h
|
||||
GPULIBRARY += $(CUPTILIBDIR) $(CUPTILIB)
|
||||
GPUCFLAGS += -DVT_CUPTI $(CUPTIINCDIR)
|
||||
if AMHAVECUPTIEVENTS
|
||||
@ -230,14 +232,6 @@ GPUCFLAGS =
|
||||
GPULIBRARY =
|
||||
endif
|
||||
|
||||
if AMHAVEMEMHOOKS
|
||||
MEMHOOKSOURCES = vt_memhook.c
|
||||
MEMHOOKCFLAGS = -DVT_MEMHOOK
|
||||
else
|
||||
MEMHOOKSOURCES =
|
||||
MEMHOOKCFLAGS =
|
||||
endif
|
||||
|
||||
if AMHAVEGETCPU
|
||||
GETCPUSOURCES = vt_getcpu.c
|
||||
GETCPUCFLAGS = -DVT_GETCPU
|
||||
@ -320,8 +314,10 @@ endif
|
||||
|
||||
if AMHAVEDYNINST
|
||||
DYNINSTSOURCES = vt_dyninst.c
|
||||
DYNINSTCFLAGS = -DVT_DYNINST
|
||||
else
|
||||
DYNINSTSOURCES =
|
||||
DYNINSTCFLAGS =
|
||||
endif
|
||||
|
||||
if AMHAVEDL
|
||||
@ -343,9 +339,11 @@ VT_COMMON_SOURCES = \
|
||||
$(GPUHEADERS) \
|
||||
vt_defs.h \
|
||||
vt_demangle.h \
|
||||
vt_dyninst.h \
|
||||
vt_env.h \
|
||||
vt_error.h \
|
||||
vt_esync.h \
|
||||
vt_execwrap.h \
|
||||
vt_fbindings.h \
|
||||
vt_fork.h \
|
||||
vt_getcpu.h \
|
||||
@ -353,8 +351,7 @@ VT_COMMON_SOURCES = \
|
||||
vt_iowrap.h \
|
||||
vt_iowrap_helper.h \
|
||||
vt_java.h \
|
||||
vt_libcwrap.h \
|
||||
vt_memhook.h \
|
||||
vt_mallocwrap.h \
|
||||
vt_metric.h \
|
||||
vt_mpicom.h \
|
||||
vt_mpifile.h \
|
||||
@ -375,10 +372,10 @@ VT_COMMON_SOURCES = \
|
||||
$(DYNINSTSOURCES) \
|
||||
$(GETCPUSOURCES) \
|
||||
$(GPUSOURCES) \
|
||||
$(EXECWRAPSOURCES) \
|
||||
$(IOWRAPSOURCES) \
|
||||
$(LIBWRAPSOURCES) \
|
||||
$(LIBCWRAPSOURCES) \
|
||||
$(MEMHOOKSOURCES) \
|
||||
$(MALLOCWRAPSOURCES) \
|
||||
$(METRSOURCES) \
|
||||
$(PLUGINCNTRSOURCES) \
|
||||
$(RUSAGESOURCES) \
|
||||
@ -398,7 +395,7 @@ VT_COMMON_SOURCES = \
|
||||
vt_user_region.c
|
||||
|
||||
VT_SEQ_SOURCES = \
|
||||
$(FORKSOURCES)
|
||||
vt_fork.c
|
||||
|
||||
VT_MPI_SOURCES = \
|
||||
vt_mpicom.c \
|
||||
@ -438,7 +435,7 @@ VT_FMPI_SOURCES = \
|
||||
$(FMPI2CONSTSOURCES)
|
||||
|
||||
CC = $(MPICC)
|
||||
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/rfg $(OTFCFLAGS) $(DLCFLAGS) $(COMPINSTCFLAGS) $(LIBWRAPCFLAGS) $(GPUCFLAGS) $(LIBCWRAPCFLAGS) $(IOWRAPCFLAGS) $(MEMHOOKCFLAGS) $(GETCPUCFLAGS) $(RUSAGECFLAGS) $(METRCFLAGS) $(PLUGINCNTRCFLAGS)
|
||||
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include -I$(top_srcdir)/rfg $(OTFCFLAGS) $(DLCFLAGS) $(COMPINSTCFLAGS) $(DYNINSTCFLAGS) $(LIBWRAPCFLAGS) $(GPUCFLAGS) $(EXECWRAPCFLAGS) $(IOWRAPCFLAGS) $(MALLOCWRAPCFLAGS) $(GETCPUCFLAGS) $(RUSAGECFLAGS) $(METRCFLAGS) $(PLUGINCNTRCFLAGS)
|
||||
|
||||
libvt_la_LIBADD = $(top_builddir)/util/libvt_util.la $(top_builddir)/rfg/libvt_rfg.la $(OTFLIBRARY) $(METRLIBRARY) $(GPULIBRARY) $(DLLIBRARY) $(MATHLIBRARY)
|
||||
libvt_la_DEPENDENCIES = $(top_builddir)/util/libvt_util.la $(top_builddir)/rfg/libvt_rfg.la $(OTFDEPENDENCIES)
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <string.h>
|
||||
#include "vt_comp.h"
|
||||
#include "vt_defs.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -23,6 +23,14 @@
|
||||
extern void* vftr_getname(void);
|
||||
extern int vftr_getname_len(void);
|
||||
|
||||
/*
|
||||
* Macro for getting id of calling thread
|
||||
*/
|
||||
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------
|
||||
* Simple hash table to map function names to region identifier
|
||||
@ -75,13 +83,13 @@ static uint32_t hash_get(long h) {
|
||||
* Register new region
|
||||
*/
|
||||
|
||||
static uint32_t register_region(char *func, int len) {
|
||||
static uint32_t register_region(uint32_t tid, char *func, int len) {
|
||||
uint32_t rid;
|
||||
static char fname[1024];
|
||||
|
||||
strncpy(fname, func, len);
|
||||
fname[len] = '\0';
|
||||
rid = vt_def_region(VT_CURRENT_THREAD, fname, VT_NO_ID, VT_NO_LNO, VT_NO_LNO,
|
||||
rid = vt_def_region(tid, fname, VT_NO_ID, VT_NO_LNO, VT_NO_LNO,
|
||||
NULL, VT_FUNCTION);
|
||||
hash_put((long) func, rid);
|
||||
return rid;
|
||||
@ -118,16 +126,15 @@ void ftrace_finalize()
|
||||
void _ftrace_enter2_() {
|
||||
char *func = (char *)vftr_getname();
|
||||
int len = vftr_getname_len();
|
||||
uint32_t tid;
|
||||
uint32_t rid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if not yet initialized, initialize VampirTrace -- */
|
||||
if ( necsx_init ) {
|
||||
VT_MEMHOOKS_OFF();
|
||||
necsx_init = 0;
|
||||
vt_open();
|
||||
vt_comp_finalize = &ftrace_finalize;
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
@ -136,7 +143,10 @@ void _ftrace_enter2_() {
|
||||
/* -- ignore NEC OMP runtime functions -- */
|
||||
if ( strchr(func, '$') != NULL ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -146,17 +156,17 @@ void _ftrace_enter2_() {
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if ( (rid = hash_get((long) func)) == VT_NO_ID )
|
||||
rid = register_region(func, len);
|
||||
rid = register_region(tid, func, len);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
rid = register_region(func, len);
|
||||
rid = register_region(tid, func, len);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, rid);
|
||||
vt_enter(tid, &time, rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -166,27 +176,31 @@ void _ftrace_enter2_() {
|
||||
|
||||
void _ftrace_exit2_() {
|
||||
char *func;
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
func = (char *)vftr_getname();
|
||||
|
||||
/* -- ignore NEC OMP runtime functions -- */
|
||||
if ( strchr(func, '$') != NULL )
|
||||
{
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
return;
|
||||
}
|
||||
|
||||
/* -- write exit record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "vt_error.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_iowrap.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
#include "vt_thrd.h"
|
||||
@ -45,6 +45,10 @@
|
||||
# define GET_IA64_FUNC_ADDR(addr) (long)(addr)
|
||||
#endif /* __ia64__ */
|
||||
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
#ifdef VT_COMPINST_CRAYCCE
|
||||
# define __cyg_profile_func_enter __pat_tp_func_entry
|
||||
# define __cyg_profile_func_exit __pat_tp_func_return
|
||||
@ -125,6 +129,7 @@ static void get_symtab(void)
|
||||
|
||||
uint8_t parse_error = 0;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
VT_SUSPEND_IO_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* open nm-file, if given */
|
||||
@ -387,25 +392,26 @@ static void get_symtab(void)
|
||||
free(line);
|
||||
|
||||
VT_RESUME_IO_TRACING(VT_CURRENT_THREAD);
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/*
|
||||
* Register new region
|
||||
*/
|
||||
|
||||
static void register_region(HashNode* hn) {
|
||||
static void register_region(uint32_t tid, HashNode* hn) {
|
||||
uint32_t fid = VT_NO_ID;
|
||||
uint32_t lno = VT_NO_LNO;
|
||||
|
||||
/* -- register file if available -- */
|
||||
if (hn->fname != NULL)
|
||||
{
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, hn->fname);
|
||||
fid = vt_def_scl_file(tid, hn->fname);
|
||||
lno = hn->lno;
|
||||
}
|
||||
|
||||
/* -- register region and store region identifier -- */
|
||||
hn->vtid = vt_def_region(VT_CURRENT_THREAD, hn->name, fid, lno, VT_NO_LNO,
|
||||
hn->vtid = vt_def_region(tid, hn->name, fid, lno, VT_NO_LNO,
|
||||
NULL, VT_FUNCTION);
|
||||
}
|
||||
|
||||
@ -472,6 +478,7 @@ void gnu_finalize()
|
||||
|
||||
void __cyg_profile_func_enter(void* func, void* callsite) {
|
||||
long addr;
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
HashNode* hn;
|
||||
|
||||
@ -479,18 +486,19 @@ void __cyg_profile_func_enter(void* func, void* callsite) {
|
||||
|
||||
/* -- if not yet initialized, initialize VampirTrace -- */
|
||||
if ( gnu_init ) {
|
||||
VT_MEMHOOKS_OFF();
|
||||
gnu_init = 0;
|
||||
vt_open();
|
||||
vt_comp_finalize = gnu_finalize;
|
||||
get_symtab();
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -501,18 +509,18 @@ void __cyg_profile_func_enter(void* func, void* callsite) {
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if( hn->vtid == VT_NO_ID )
|
||||
register_region(hn);
|
||||
register_region(tid, hn);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
register_region(hn);
|
||||
register_region(tid, hn);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, hn->vtid);
|
||||
vt_enter(tid, &time, hn->vtid);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -522,6 +530,7 @@ void __cyg_profile_func_enter(void* func, void* callsite) {
|
||||
|
||||
void __cyg_profile_func_exit(void* func, void* callsite) {
|
||||
long addr;
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
addr = GET_IA64_FUNC_ADDR(func);
|
||||
@ -529,14 +538,17 @@ void __cyg_profile_func_exit(void* func, void* callsite) {
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* -- write exit record -- */
|
||||
if ( hash_get(addr) ) {
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
@ -17,11 +17,19 @@
|
||||
#include "vt_comp.h"
|
||||
#include "vt_defs.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
/*
|
||||
* Macro for getting id of calling thread
|
||||
*/
|
||||
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
/*
|
||||
* Subtypes for loops.
|
||||
* A loop can be a 'DO-LOOP' in Fortran or 'while-do'/'do-while' in C/C++.
|
||||
@ -83,7 +91,8 @@ static struct data_list_struct* data_list = NULL;
|
||||
* Registers a new region.
|
||||
*/
|
||||
|
||||
static void register_region(struct profile_gen_struct* d, uint8_t rtype)
|
||||
static void register_region(uint32_t tid, struct profile_gen_struct* d,
|
||||
uint8_t rtype)
|
||||
{
|
||||
struct data_list_struct* data;
|
||||
char* rname = d->pu_name;
|
||||
@ -94,7 +103,7 @@ static void register_region(struct profile_gen_struct* d, uint8_t rtype)
|
||||
/* -- register file, if available -- */
|
||||
if ( d->file_name != NULL )
|
||||
{
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, d->file_name);
|
||||
fid = vt_def_scl_file(tid, d->file_name);
|
||||
begln = d->linenum;
|
||||
endln = d->endline;
|
||||
}
|
||||
@ -140,7 +149,7 @@ static void register_region(struct profile_gen_struct* d, uint8_t rtype)
|
||||
d->data = (uint32_t*)malloc(sizeof(uint32_t));
|
||||
if ( d->data == NULL ) vt_error();
|
||||
*((uint32_t*)(d->data)) =
|
||||
vt_def_region(VT_CURRENT_THREAD, rname, fid, begln, endln, NULL, rtype);
|
||||
vt_def_region(tid, rname, fid, begln, endln, NULL, rtype);
|
||||
|
||||
/* -- free generated region name -- */
|
||||
if ( rtype == VT_LOOP )
|
||||
@ -195,11 +204,9 @@ VT_DECLDEF(void __profile_init(struct profile_init_struct* d))
|
||||
|
||||
if ( openuh_init )
|
||||
{
|
||||
VT_MEMHOOKS_OFF();
|
||||
openuh_init = 0;
|
||||
vt_open();
|
||||
vt_comp_finalize = &__profile_finish;
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,12 +216,16 @@ VT_DECLDEF(void __profile_init(struct profile_init_struct* d))
|
||||
|
||||
VT_DECLDEF(void __profile_invoke(struct profile_gen_struct* d))
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -225,17 +236,17 @@ VT_DECLDEF(void __profile_invoke(struct profile_gen_struct* d))
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if ( d->data == NULL )
|
||||
register_region(d, VT_FUNCTION);
|
||||
register_region(tid, d, VT_FUNCTION);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
register_region(d, VT_FUNCTION);
|
||||
register_region(tid, d, VT_FUNCTION);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, *((uint32_t*)(d->data)));
|
||||
vt_enter(tid, &time, *((uint32_t*)(d->data)));
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -245,21 +256,25 @@ VT_DECLDEF(void __profile_invoke(struct profile_gen_struct* d))
|
||||
|
||||
VT_DECLDEF(void __profile_invoke_exit(struct profile_gen_struct* d))
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* -- write exit record -- */
|
||||
if ( d->data != NULL ) {
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -279,12 +294,16 @@ VT_DECLDEF(void __profile_branch(struct profile_gen_struct* d))
|
||||
|
||||
VT_DECLDEF(void __profile_loop(struct profile_gen_struct* d))
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -295,17 +314,17 @@ VT_DECLDEF(void __profile_loop(struct profile_gen_struct* d))
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if ( d->data == NULL )
|
||||
register_region(d, VT_LOOP);
|
||||
register_region(tid, d, VT_LOOP);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
register_region(d, VT_LOOP);
|
||||
register_region(tid, d, VT_LOOP);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, *((uint32_t*)(d->data)));
|
||||
vt_enter(tid, &time, *((uint32_t*)(d->data)));
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -324,21 +343,25 @@ VT_DECLDEF(void __profile_loop_iter(struct profile_gen_struct* d))
|
||||
|
||||
VT_DECLDEF(void __profile_loop_exit(struct profile_gen_struct* d))
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* -- write exit record -- */
|
||||
if ( d->data != NULL ) {
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "vt_comp.h"
|
||||
#include "vt_defs.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -21,6 +21,16 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------
|
||||
* macro for getting id of calling thread
|
||||
*-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
struct s1 {
|
||||
long l1;
|
||||
long l2;
|
||||
@ -74,21 +84,23 @@ void __rouexit() {
|
||||
|
||||
#pragma save_all_regs
|
||||
void ___rouent2(struct s1 *p) {
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if not yet initialized, initialize VampirTrace -- */
|
||||
if (rou_init)
|
||||
{
|
||||
VT_MEMHOOKS_OFF();
|
||||
rou_init = 0;
|
||||
vt_open();
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -107,24 +119,24 @@ void ___rouent2(struct s1 *p) {
|
||||
VTTHRD_LOCK_IDS();
|
||||
if (!p->isseen)
|
||||
{
|
||||
p->fid = vt_def_scl_file(VT_CURRENT_THREAD, p->file);
|
||||
p->rid = vt_def_region(VT_CURRENT_THREAD, rname, p->fid, p->lineno,
|
||||
p->fid = vt_def_scl_file(tid, p->file);
|
||||
p->rid = vt_def_region(tid, rname, p->fid, p->lineno,
|
||||
VT_NO_LNO, NULL, VT_FUNCTION);
|
||||
p->isseen = 1;
|
||||
}
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
p->fid = vt_def_scl_file(VT_CURRENT_THREAD, p->file);
|
||||
p->rid = vt_def_region(VT_CURRENT_THREAD, rname, p->fid, p->lineno,
|
||||
p->fid = vt_def_scl_file(tid, p->file);
|
||||
p->rid = vt_def_region(tid, rname, p->fid, p->lineno,
|
||||
VT_NO_LNO, NULL, VT_FUNCTION);
|
||||
p->isseen = 1;
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* write enter trace record */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, p->rid);
|
||||
vt_enter(tid, &time, p->rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -135,17 +147,21 @@ void ___rouent2(struct s1 *p) {
|
||||
|
||||
#pragma save_all_regs
|
||||
void ___rouret2(void) {
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
#pragma save_used_gp_regs
|
||||
|
@ -14,11 +14,19 @@
|
||||
#include <string.h>
|
||||
#include "vt_comp.h"
|
||||
#include "vt_defs.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
/*
|
||||
* Macro for getting id of calling thread
|
||||
*/
|
||||
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------
|
||||
* Simple hash table to map function names to region identifier
|
||||
@ -72,11 +80,11 @@ static uint32_t hash_get(long h) {
|
||||
* `str' is passed in from SUN compiler
|
||||
*/
|
||||
|
||||
static uint32_t register_region(char *str) {
|
||||
static uint32_t register_region(uint32_t tid, char *str) {
|
||||
uint32_t rid;
|
||||
|
||||
/* -- register region and store region identifier -- */
|
||||
rid = vt_def_region(VT_CURRENT_THREAD, str, VT_NO_ID, VT_NO_LNO, VT_NO_LNO,
|
||||
rid = vt_def_region(tid, str, VT_NO_ID, VT_NO_LNO, VT_NO_LNO,
|
||||
NULL, VT_FUNCTION);
|
||||
hash_put((long) str, rid);
|
||||
return rid;
|
||||
@ -110,15 +118,14 @@ void phat_finalize()
|
||||
*/
|
||||
|
||||
void phat_enter(char *str, int *id) {
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if not yet initialized, initialize VampirTrace -- */
|
||||
if ( phat_init ) {
|
||||
VT_MEMHOOKS_OFF();
|
||||
phat_init = 0;
|
||||
vt_open();
|
||||
vt_comp_finalize = &phat_finalize;
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
@ -127,7 +134,10 @@ void phat_enter(char *str, int *id) {
|
||||
/* -- ignore SUN OMP runtime functions -- */
|
||||
if ( strchr(str, '$') != NULL ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -137,17 +147,17 @@ void phat_enter(char *str, int *id) {
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if ( (*id = hash_get((long) str)) == VT_NO_ID )
|
||||
*id = register_region(str);
|
||||
*id = register_region(tid, str);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
*id = register_region(str);
|
||||
*id = register_region(tid, str);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, *id);
|
||||
vt_enter(tid, &time, *id);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
|
||||
@ -157,6 +167,7 @@ void phat_enter(char *str, int *id) {
|
||||
*/
|
||||
|
||||
void phat_exit(char *str, int *id) {
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
@ -164,11 +175,14 @@ void phat_exit(char *str, int *id) {
|
||||
|
||||
if ( *id == -1 ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* -- write exit record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
@ -16,11 +16,19 @@
|
||||
#include "vt_comp.h"
|
||||
#include "vt_defs.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
/*
|
||||
* Macro for getting id of calling thread
|
||||
*/
|
||||
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
/*
|
||||
*-----------------------------------------------------------------------------
|
||||
* Simple hash table to map function data to region identifier
|
||||
@ -81,15 +89,15 @@ static HashNode *hash_get(long h) {
|
||||
* Register new region
|
||||
*/
|
||||
|
||||
static HashNode *register_region(char *func, char *file, int lno) {
|
||||
static HashNode *register_region(uint32_t tid, char *func, char *file,
|
||||
int lno) {
|
||||
uint32_t rid;
|
||||
uint32_t fid;
|
||||
HashNode* nhn;
|
||||
|
||||
/* -- register file and region and store region identifier -- */
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, file);
|
||||
rid = vt_def_region(VT_CURRENT_THREAD, func, fid, lno, VT_NO_LNO, NULL,
|
||||
VT_FUNCTION);
|
||||
fid = vt_def_scl_file(tid, file);
|
||||
rid = vt_def_region(tid, func, fid, lno, VT_NO_LNO, NULL, VT_FUNCTION);
|
||||
nhn = hash_put((long) func, rid);
|
||||
nhn->func = func;
|
||||
nhn->file = file;
|
||||
@ -139,6 +147,7 @@ void __func_trace_enter(char* name, char* fname, int lno)
|
||||
#endif /* __IBMC__ */
|
||||
{
|
||||
HashNode *hn;
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- ignore IBM OMP runtime functions -- */
|
||||
@ -154,17 +163,18 @@ void __func_trace_enter(char* name, char* fname, int lno)
|
||||
|
||||
/* -- if not yet initialized, initialize VampirTrace -- */
|
||||
if ( xl_init ) {
|
||||
VT_MEMHOOKS_OFF();
|
||||
xl_init = 0;
|
||||
vt_open();
|
||||
vt_comp_finalize = &xl_finalize;
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -179,14 +189,14 @@ void __func_trace_enter(char* name, char* fname, int lno)
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if ( (hn = hash_get((long) name)) == 0 ) {
|
||||
hn = register_region(name, fname, lno);
|
||||
hn = register_region(tid, name, fname, lno);
|
||||
# if __IBMC__ > 1100
|
||||
*ihn = hn;
|
||||
# endif /* __IBMC__ */
|
||||
}
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
hn = register_region(name, fname, lno);
|
||||
hn = register_region(tid, name, fname, lno);
|
||||
# if __IBMC__ > 1100
|
||||
*ihn = hn;
|
||||
# endif /* __IBMC__ */
|
||||
@ -201,9 +211,9 @@ void __func_trace_enter(char* name, char* fname, int lno)
|
||||
#endif /* __IBMC__ */
|
||||
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, hn->vtid);
|
||||
vt_enter(tid, &time, hn->vtid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -221,6 +231,7 @@ void __func_trace_exit(char* name, char* fname, int lno)
|
||||
#endif
|
||||
{
|
||||
HashNode *hn;
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
/* -- if VampirTrace already finalized, return -- */
|
||||
@ -242,12 +253,15 @@ void __func_trace_exit(char* name, char* fname, int lno)
|
||||
vt_libassert(hn != NULL);
|
||||
# endif /* __IBMC__ */
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
/* -- get calling thread id -- */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* -- write exit record -- */
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
vt_exit(tid, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "vt_libwrap.h" /* wrapping of CUDA Runtime API functions */
|
||||
#include "vt_cudartwrap.h" /* CUDA wrapper functions for external use */
|
||||
#include "vt_gpu.h" /* common for GPU */
|
||||
#include "vt_memhook.h" /* Switch memory tracing on/off */
|
||||
#include "vt_mallocwrap.h" /* Switch memory tracing on/off */
|
||||
|
||||
#if (defined(VT_CUPTI_EVENTS))
|
||||
#include "vt_cupti_events.h" /* Support for CUPTI events */
|
||||
@ -768,6 +768,9 @@ void vt_cudartwrap_init(void)
|
||||
vt_cudart_bufSize = sizeof(VTCUDAKernel) + sizeof(VTCUDAknconf);
|
||||
vt_cntl_msg(2, "[CUDART] Current CUDA buffer size: %d bytes",
|
||||
vt_cudart_bufSize);
|
||||
|
||||
/* initialize the VampirTrace CUPTI events interface */
|
||||
vt_cupti_events_init();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -861,10 +864,10 @@ static void VTCUDAresetDevice(uint32_t ptid, VTCUDADevice *vtDev,
|
||||
if(trace_cupti_events && cleanEvents){
|
||||
uint64_t time = vt_pform_wtime();
|
||||
VTCUDAStrm *curStrm = vtDev->strmList;
|
||||
vt_cuptievt_ctx_t* vtcuptiCtx = vt_cuptievt_getCurrentContext(ptid);
|
||||
vt_cupti_ctx_t* vtcuptiCtx = vt_cuptievt_getOrCreateCurrentCtx(ptid);
|
||||
|
||||
while(curStrm != NULL){
|
||||
vt_cuptievt_resetCounter(vtcuptiCtx, curStrm->tid, &time);
|
||||
vt_cuptievt_resetCounter(vtcuptiCtx->events, curStrm->tid, &time);
|
||||
curStrm = curStrm->next;
|
||||
}
|
||||
|
||||
@ -979,11 +982,13 @@ void vt_cudartwrap_finalize(void)
|
||||
uint32_t ptid;
|
||||
|
||||
vt_cntl_msg(2, "[CUDART] Finalizing wrapper.");
|
||||
|
||||
vt_gpu_finalize();
|
||||
|
||||
|
||||
VT_CHECK_THREAD;
|
||||
ptid = VT_MY_THREAD;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
|
||||
vt_gpu_finalize();
|
||||
|
||||
/* cleanup CUDA device list */
|
||||
while(cudaDevices != NULL){
|
||||
@ -1018,9 +1023,19 @@ void vt_cudartwrap_finalize(void)
|
||||
cudaDevices = NULL;
|
||||
}
|
||||
|
||||
/* free the global kernel element list */
|
||||
while(NULL != kernelListHead){
|
||||
VTCUDAkernelSymbol *knSym = kernelListHead;
|
||||
|
||||
kernelListHead = kernelListHead->next;
|
||||
free(knSym);
|
||||
knSym = NULL;
|
||||
}
|
||||
|
||||
/* free filter for CUDA kernel filtering */
|
||||
RFG_Filter_free(vt_cudart_filter);
|
||||
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
}
|
||||
finalized = 1;
|
||||
CUDARTWRAP_UNLOCK();
|
||||
@ -1147,17 +1162,21 @@ static void VTCUDAflush(VTCUDADevice *vtDev, uint32_t ptid)
|
||||
VTCUDAStrm *strm = bufEntry->strm;
|
||||
float diff_ms;
|
||||
|
||||
/* time between synchronize start event and kernel start event */
|
||||
VT_CUDART_CALL(cudaEventElapsedTime_ptr(&diff_ms, strm->lastEvt, bufEntry->evt->strt),
|
||||
"cudaEventElapsedTime(diff, tmpStrtEvt, knStrtEvt) failed!");
|
||||
/* time between last stream event and activity start event */
|
||||
VT_CUDART_CALL(cudaEventElapsedTime_ptr(&diff_ms, strm->lastEvt,
|
||||
bufEntry->evt->strt),
|
||||
"cudaEventElapsedTime(diff, lastEvt, strtEvt) failed!");
|
||||
|
||||
/* convert CUDA kernel start event to VampirTrace timestamp */
|
||||
strttime = strm->lastVTTime + (uint64_t)((double)diff_ms * factorX);
|
||||
|
||||
/* check if kernel start time is before last synchronous CUDA call */
|
||||
/* check if activity start time is before last synchronous CUDA call */
|
||||
if(strttime < sync->lastTime){
|
||||
vt_warning("[CUDART] Set activity start time to last time in stream -"
|
||||
" truncate %.4lf%% (CUDA device %d, Thread ID: %d)",
|
||||
(double)(sync->lastTime-strttime)/((double)diff_ms*factorX),
|
||||
vtDev->device, strm->tid);
|
||||
strttime = sync->lastTime;
|
||||
vt_warning("[CUDART] event before last synchronous CUDA call measured!");
|
||||
}
|
||||
|
||||
/* time between kernel start event and kernel stop event */
|
||||
@ -1167,12 +1186,21 @@ static void VTCUDAflush(VTCUDADevice *vtDev, uint32_t ptid)
|
||||
/* convert CUDA kernel stop event to VampirTrace timestamp */
|
||||
stoptime = strttime + (uint64_t)((double)diff_ms * factorX);
|
||||
|
||||
/* check if activity stop time is after sync point stop time */
|
||||
if(stoptime > syncStopTime){
|
||||
stoptime = syncStopTime;
|
||||
if(strttime > syncStopTime){
|
||||
strttime = syncStopTime;
|
||||
vt_warning("[CUDART] Activity stop time > sync-point time! "
|
||||
"(CUDA device %d, Thread ID: %d)", vtDev->device, strm->tid);
|
||||
|
||||
/* if activity start time is before sync time activity can be truncated */
|
||||
if(strttime < syncStopTime){
|
||||
vt_warning("[CUDART] Set activity start time to last time in stream!"
|
||||
"truncate %.4lf%%",
|
||||
(double)(stoptime-syncStopTime)/((double)diff_ms*factorX));
|
||||
stoptime = syncStopTime;
|
||||
}else{
|
||||
vt_warning("[CUDART] Skipping activity ...");
|
||||
continue;
|
||||
}
|
||||
vt_warning("[CUDART] time measurement of kernel or memcpyAsync failed!");
|
||||
}
|
||||
|
||||
/* set new synchronized CUDA start event and VampirTrace start timestamp,
|
||||
@ -1347,7 +1375,11 @@ static VTCUDAStrm* VTCUDAcreateStream(VTCUDADevice* vtDev, cudaStream_t cuStrm)
|
||||
*/
|
||||
static VTCUDADevice* VTCUDAcreateDevice(uint32_t ptid, int device)
|
||||
{
|
||||
VTCUDADevice *vtDev = (VTCUDADevice*)malloc(sizeof(VTCUDADevice));
|
||||
VTCUDADevice *vtDev = NULL;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
|
||||
vtDev = (VTCUDADevice*)malloc(sizeof(VTCUDADevice));
|
||||
if(vtDev == NULL) vt_error_msg("Could not allocate memory for VTCUDADevice!");
|
||||
vtDev->device = device;
|
||||
vtDev->ptid = ptid;
|
||||
@ -1438,6 +1470,8 @@ static VTCUDADevice* VTCUDAcreateDevice(uint32_t ptid, int device)
|
||||
vtDev->conf_stack = vtDev->buf_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
|
||||
return vtDev;
|
||||
}
|
||||
@ -1502,6 +1536,9 @@ static VTCUDADevice* VTCUDAinitDevice(uint32_t ptid, int cudaDev,
|
||||
VTCUDADevice *vtDev = NULL;
|
||||
|
||||
/*vt_cntl_msg(1, "Init CUDA device %d", cudaDev);*/
|
||||
|
||||
/* suspend malloc tracing, due to CUDA device and stream creation */
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
|
||||
/* cuda device not found, create new cuda device node */
|
||||
time = vt_pform_wtime();
|
||||
@ -1520,6 +1557,8 @@ static VTCUDADevice* VTCUDAinitDevice(uint32_t ptid, int cudaDev,
|
||||
/* set the current stream (stream 0) */
|
||||
vtDev->strmList = VTCUDAcreateStream(vtDev, cuStrm);
|
||||
}
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
|
||||
/* add thread and CUDA device to list */
|
||||
CUDARTWRAP_LOCK();
|
||||
@ -1595,9 +1634,11 @@ static VTCUDADevice* VTCUDAcheckThread(cudaStream_t cuStrm, uint32_t ptid,
|
||||
reusableStrm->stream = cuStrm;
|
||||
*vtStrm = reusableStrm;
|
||||
}else{
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
/* append newly created stream (stream 0 is probably used most, will
|
||||
therefore always be the first element in the list */
|
||||
ptrLastStrm->next = VTCUDAcreateStream(vtDev, cuStrm);
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
*vtStrm = ptrLastStrm->next;
|
||||
}
|
||||
|
||||
@ -1888,10 +1929,15 @@ static void vtcudaMalloc(void *devPtr, size_t size)
|
||||
uint64_t vtTime;
|
||||
VTCUDADevice *vtDev = NULL;
|
||||
VTCUDAStrm *vtStrm = NULL;
|
||||
VTCUDAmalloc *vtMalloc = (VTCUDAmalloc*)malloc(sizeof(VTCUDAmalloc));
|
||||
VTCUDAmalloc *vtMalloc = NULL;
|
||||
|
||||
VT_CHECK_THREAD;
|
||||
ptid = VT_MY_THREAD;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
vtMalloc = (VTCUDAmalloc*)malloc(sizeof(VTCUDAmalloc));
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
|
||||
vtDev = VTCUDAcheckThread(NULL, ptid, &vtStrm);
|
||||
|
||||
vtMalloc->memPtr = devPtr;
|
||||
@ -1953,7 +1999,9 @@ static void vtcudaFree(void *devPtr)
|
||||
|
||||
/* free VT memory of cuda malloc */
|
||||
curMalloc->next = NULL;
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
free(curMalloc);
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
curMalloc = NULL;
|
||||
|
||||
/* set mallocList to NULL, if last element freed */
|
||||
@ -1979,9 +2027,13 @@ static void vtcudaFree(void *devPtr)
|
||||
*/
|
||||
static void insertKernelSymbol(const char* hostFun, const char* devFunc)
|
||||
{
|
||||
VTCUDAkernelSymbol* e = (VTCUDAkernelSymbol*) malloc(sizeof(VTCUDAkernelSymbol));
|
||||
VTCUDAkernelSymbol* e = NULL;
|
||||
char *kname = NULL;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
e = (VTCUDAkernelSymbol*) malloc(sizeof(VTCUDAkernelSymbol));
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* store the host function (used to identify kernel in cudaLaunch) */
|
||||
e->pointer = hostFun;
|
||||
|
||||
@ -2571,7 +2623,11 @@ cudaError_t cudaConfigureCall(dim3 gridDim, dim3 blockDim, size_t sharedMem, cu
|
||||
size_t new_size = sizeof(VTCUDAKernel) + 16*sizeof(VTCUDAknconf);
|
||||
size_t conf_stack_size =
|
||||
vtDev->buf_size - (vtDev->conf_stack + sizeof(VTCUDAknconf));
|
||||
buffer_t new_buf = (buffer_t)realloc(vtDev->asyncbuf, new_size);
|
||||
buffer_t new_buf = NULL;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
new_buf = (buffer_t)realloc(vtDev->asyncbuf, new_size);
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
|
||||
/* copy stacked kernel configurations */
|
||||
memcpy(new_buf + new_size - conf_stack_size,
|
||||
@ -2625,7 +2681,7 @@ cudaError_t cudaLaunch(VT_CUDARTWRAP_COMPAT_PTR entry)
|
||||
uint64_t time;
|
||||
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
vt_cuptievt_ctx_t* vtcuptiCtx = NULL;
|
||||
vt_cupti_ctx_t* vtcuptiCtx = NULL;
|
||||
#endif
|
||||
|
||||
CUDARTWRAP_FUNC_INIT(vt_cudart_lw, vt_cudart_lw_attr, "cudaLaunch",
|
||||
@ -2707,8 +2763,8 @@ cudaError_t cudaLaunch(VT_CUDARTWRAP_COMPAT_PTR entry)
|
||||
vt_count(tid, &time, cid_threadsPerKernel,
|
||||
kernel->threadsPerBlock * kernel->blocksPerGrid);
|
||||
|
||||
vtcuptiCtx = vt_cuptievt_getCurrentContext(ptid);
|
||||
vt_cuptievt_resetCounter(vtcuptiCtx, tid, &time);
|
||||
vtcuptiCtx = vt_cuptievt_getOrCreateCurrentCtx(ptid);
|
||||
vt_cuptievt_resetCounter(vtcuptiCtx->events, tid, &time);
|
||||
}else
|
||||
#endif
|
||||
{
|
||||
@ -2750,7 +2806,7 @@ cudaError_t cudaLaunch(VT_CUDARTWRAP_COMPAT_PTR entry)
|
||||
/* sampling of CUPTI counter values */
|
||||
do{
|
||||
time = vt_pform_wtime();
|
||||
vt_cuptievt_writeCounter(vtcuptiCtx, tid, &time);
|
||||
vt_cuptievt_writeCounter(vtcuptiCtx->events, tid, &time);
|
||||
/*ret = cudaEventQuery_ptr(kernel->evt->stop);*/
|
||||
ret = cudaStreamQuery_ptr(kernel->strm->stream);
|
||||
}while(ret != cudaSuccess);
|
||||
@ -2760,7 +2816,7 @@ cudaError_t cudaLaunch(VT_CUDARTWRAP_COMPAT_PTR entry)
|
||||
}
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_cuptievt_writeCounter(vtcuptiCtx, tid, &time);
|
||||
vt_cuptievt_writeCounter(vtcuptiCtx->events, tid, &time);
|
||||
vt_exit(ptid, &time);
|
||||
|
||||
/* write VT kernel stop events */
|
||||
@ -2844,9 +2900,12 @@ cudaError_t cudaThreadExit()
|
||||
|
||||
vt_cntl_msg(2, "cudaThreadExit called (thread; %d)", ptid);
|
||||
/* cleanup the CUDA device associated to this thread */
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
CUDARTWRAP_LOCK();
|
||||
VTCUDAcleanupDevice(ptid, vtDev, 1);
|
||||
CUDARTWRAP_UNLOCK();
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
|
||||
VT_LIBWRAP_FUNC_START(vt_cudart_lw); /* no extra if(trace_enabled) */
|
||||
}
|
||||
|
||||
@ -3011,10 +3070,14 @@ cudaError_t cudaDeviceReset()
|
||||
vtDev = VTCUDAgetDevice(ptid);
|
||||
|
||||
vt_cntl_msg(2, "cudaDeviceReset called (thread; %d)", ptid);
|
||||
|
||||
/* cleanup the CUDA device associated to this thread */
|
||||
VT_SUSPEND_MALLOC_TRACING(ptid);
|
||||
CUDARTWRAP_LOCK();
|
||||
VTCUDAresetDevice(ptid, vtDev, 1);
|
||||
CUDARTWRAP_UNLOCK();
|
||||
VT_RESUME_MALLOC_TRACING(ptid);
|
||||
|
||||
VT_LIBWRAP_FUNC_START(vt_cudart_lw); /* no extra if(trace_enabled) */
|
||||
}
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#include "vt_cupti.h" /* Support for CUPTI */
|
||||
#include "vt_gpu.h" /* common for GPU */
|
||||
|
||||
/*
|
||||
* Handles errors returned from CUPTI function calls.
|
||||
*
|
||||
* @param ecode the CUDA driver API error code
|
||||
* @param msg a message to get more detailed information about the error
|
||||
* @param the corresponding file
|
||||
* @param the line the error occurred
|
||||
*/
|
||||
void vt_cupti_handleError(CUptiResult err, const char* msg,
|
||||
const char *file, const int line)
|
||||
{
|
||||
const char *errstr;
|
||||
|
||||
if(msg != NULL) vt_cntl_msg(1, msg);
|
||||
|
||||
cuptiGetResultString(err, &errstr);
|
||||
|
||||
if(vt_gpu_error){
|
||||
vt_error_msg("[CUPTI] %s:%d:'%s'", file, line, errstr);
|
||||
}else{
|
||||
vt_warning("[CUPTI] %s:%d:'%s'", file, line, errstr);
|
||||
}
|
||||
}
|
@ -26,29 +26,5 @@
|
||||
#endif /* __GNUC__ */
|
||||
#include "cupti.h"
|
||||
|
||||
#define VT_CUPTI_CALL(_err, _msg) \
|
||||
if(_err != CUPTI_SUCCESS){ \
|
||||
vt_cupti_handleError(_err, _msg,__FILE__, __LINE__); \
|
||||
}
|
||||
|
||||
/* CUPTI global CUDA kernel counter group ID */
|
||||
EXTERN uint32_t vt_cupti_cgid_cuda_kernel;
|
||||
|
||||
/* global counter IDs for CUPTI callback and activity API */
|
||||
EXTERN uint32_t vt_cupti_cid_blocksPerGrid;
|
||||
EXTERN uint32_t vt_cupti_cid_threadsPerBlock;
|
||||
EXTERN uint32_t vt_cupti_cid_threadsPerKernel;
|
||||
|
||||
/*
|
||||
* Handles errors returned from CUPTI function calls.
|
||||
*
|
||||
* @param ecode the CUDA driver API error code
|
||||
* @param msg a message to get more detailed information about the error
|
||||
* @param the corresponding file
|
||||
* @param the line the error occurred
|
||||
*/
|
||||
EXTERN void vt_cupti_handleError(CUptiResult err, const char* msg,
|
||||
const char *file, const int line);
|
||||
|
||||
#endif /* VT_CUPTI_H */
|
||||
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@ -19,6 +19,8 @@
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "vt_cupti_common.h" /* CUPTI common structures, functions, etc. */
|
||||
|
||||
/*
|
||||
* Initialize the VampirTrace CUPTI Activity implementation.
|
||||
*/
|
||||
@ -30,14 +32,15 @@ EXTERN void vt_cupti_activity_init(void);
|
||||
EXTERN void vt_cupti_activity_finalize(void);
|
||||
|
||||
/*
|
||||
* Create and add a new context to list of contexts.
|
||||
* Setup a the VampirTrace CUPTI activity context. Trigger initialization and
|
||||
* enqueuing of the CUPTI activity buffer for the given context.
|
||||
*
|
||||
* @param cuCtx the CUDA context, specifying the queue
|
||||
* @param vtCtx the VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN void vt_cuptiact_addContext(CUcontext cuCtx, CUdevice cuDev);
|
||||
EXTERN void vt_cuptiact_setupActivityContext(vt_cupti_ctx_t *vtCtx);
|
||||
|
||||
/*
|
||||
* Handle activities buffered by CUPTI.
|
||||
* Handle activities buffered by CUPTI. Lock a call to this routine!!!
|
||||
*
|
||||
* NVIDIA:
|
||||
* "Global Queue: The global queue collects all activity records that
|
||||
@ -55,9 +58,10 @@ EXTERN void vt_cuptiact_addContext(CUcontext cuCtx, CUdevice cuDev);
|
||||
* activity records associated with the stream. A buffer is enqueued
|
||||
* in a stream queue by specifying a context and a non-zero stream ID."
|
||||
*
|
||||
* @param cuCtx CUDA context, NULL to handle globally buffered activities
|
||||
* @param vtCtx VampirTrace CUPTI context, NULL to handle globally buffered
|
||||
* activities
|
||||
*/
|
||||
EXTERN void vt_cuptiact_flushCtxActivities(CUcontext cuCtx);
|
||||
EXTERN void vt_cuptiact_flushCtxActivities(vt_cupti_ctx_t *cuCtx);
|
||||
|
||||
/*
|
||||
* Mark a CUDA stream as destroyed, so that it can be reused afterwards.
|
||||
@ -84,6 +88,15 @@ EXTERN void vt_cuptiact_writeFree(uint32_t ctxID, CUcontext cuCtx,
|
||||
EXTERN void vt_cuptiact_addCorrelation(uint32_t ctxID, uint32_t correlationID,
|
||||
uint32_t ptid);
|
||||
|
||||
#if (defined(CUPTI_API_VERSION) && (CUPTI_API_VERSION >= 3))
|
||||
/*
|
||||
* Enable tracing of concurrent kernels. Disable normal kernel tracing, if
|
||||
* necessary.
|
||||
*
|
||||
* @param vtCtx pointer to the VampirTrace CUPTI context.
|
||||
*/
|
||||
EXTERN void vt_cuptiact_enableConcurrentKernel(vt_cupti_ctx_t *vtCtx);
|
||||
#endif
|
||||
|
||||
#endif /* VT_CUPTI_ACTIVITY_H */
|
||||
|
||||
|
@ -12,15 +12,16 @@
|
||||
|
||||
#include "config.h" /* snprintf */
|
||||
|
||||
#include "vt_defs.h" /* global definitions */
|
||||
#include "vt_env.h" /* get environment variables */
|
||||
#include "vt_pform.h" /* VampirTrace time measurement */
|
||||
#include "vt_defs.h" /* VampirTrace constants */
|
||||
#include "vt_error.h" /* VampirTrace warning and error messages */
|
||||
#include "vt_mallocwrap.h" /* wrapping of malloc and free */
|
||||
#include "vt_gpu.h" /* common for GPU */
|
||||
#include "util/hash.h"
|
||||
|
||||
#include "vt_cupti.h" /* Support for CUPTI */
|
||||
#include "vt_cupti.h" /* CUPTI header */
|
||||
#include "vt_cupti_common.h" /* CUPTI common structures, functions, etc. */
|
||||
|
||||
#include "vt_cupti_callback.h"
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
@ -34,17 +35,6 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* mutex for locking global CUPTI callback lists */
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
static VTThrdMutex* VTThrdMutexCuptiCB = NULL;
|
||||
# define CUPTI_CB_LOCK() VTThrd_lock(&VTThrdMutexCuptiCB)
|
||||
# define CUPTI_CB_UNLOCK() VTThrd_unlock(&VTThrdMutexCuptiCB)
|
||||
#else /* VT_MT || VT_HYB */
|
||||
# define CUPTI_CB_LOCK()
|
||||
# define CUPTI_CB_UNLOCK()
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
|
||||
#define DISABLE_CUDART_CALLBACK(_cbid) \
|
||||
{ \
|
||||
CUptiResult cuptiErr = cuptiEnableCallback( \
|
||||
@ -80,58 +70,6 @@ static VTThrdMutex* VTThrdMutexCuptiCB = NULL;
|
||||
#define SUSPEND_CALLBACKS(_vtCtx) _vtCtx->callbacks_enabled = 0;
|
||||
#define RESUME_CALLBACKS(_vtCtx) _vtCtx->callbacks_enabled = 1;
|
||||
|
||||
/*
|
||||
* structure of a VampirTrace CUPTI CUDA stream
|
||||
*/
|
||||
typedef struct vt_cupticb_strm_st
|
||||
{
|
||||
CUstream stream; /**< the CUDA stream */
|
||||
uint32_t tid; /**< VT thread id for this stream (unique) */
|
||||
struct vt_cupticb_strm_st *next;
|
||||
}vt_cupticb_strm_t;
|
||||
|
||||
/*
|
||||
* structure of a VampirTrace CUPTI CUDA runtime kernel
|
||||
*/
|
||||
typedef struct vt_cupticb_kernel_st
|
||||
{
|
||||
cudaStream_t stream; /**< the CUDA stream */
|
||||
uint32_t blocksPerGrid; /**< number of blocks per grid */
|
||||
uint32_t threadsPerBlock; /**< number of threads per block */
|
||||
struct vt_cupticb_kernel_st *prev;
|
||||
}vt_cupticb_kernel_t;
|
||||
|
||||
/*
|
||||
* structure of a VampirTrace CUDA malloc (initiated with cudaMalloc*()
|
||||
*/
|
||||
typedef struct vt_cupticb_gpumem_st
|
||||
{
|
||||
void *memPtr; /**< pointer value to allocated memory */
|
||||
size_t size; /**< number of bytes allocated */
|
||||
uint32_t tid; /**< thread id used with this malloc */
|
||||
struct vt_cupticb_gpumem_st *next;
|
||||
}vt_cupticb_gpumem_t;
|
||||
|
||||
/*
|
||||
* VampirTrace CUDA context element
|
||||
* - used in single linked list
|
||||
*/
|
||||
typedef struct vt_cupticb_ctx_st
|
||||
{
|
||||
uint64_t ctxUID; /**< unique CUDA context ID (available in callback) */
|
||||
/*CUcontext cuCtx; *< the CUDA context */
|
||||
CUdevice dev; /**< the CUDA device */
|
||||
vt_cupticb_gpumem_t *gpuMemList; /**< list of allocated GPU memory fields */
|
||||
size_t gpuMemAllocated; /**< memory allocated on CUDA device */
|
||||
vt_cupticb_strm_t *strmList; /**< CUDA stream list */
|
||||
uint32_t strmNum; /**< Number of streams created for this device */
|
||||
vt_cupticb_kernel_t *kernelData; /**< pointer to top of CUDA runtime kernel
|
||||
configuration stack */
|
||||
uint8_t stack_size; /**< number of params on the stack */
|
||||
uint8_t callbacks_enabled; /**< execute callback function? */
|
||||
struct vt_cupticb_ctx_st *next;
|
||||
}vt_cupticb_ctx_t;
|
||||
|
||||
/* global subscriber handles */
|
||||
static CUpti_SubscriberHandle vt_cupticb_subscriber;
|
||||
|
||||
@ -149,14 +87,6 @@ static uint8_t vt_cupticb_trace_events = 1;
|
||||
static uint8_t vt_cupticb_event_sampling = 0;
|
||||
#endif
|
||||
|
||||
/* CUPTI global CUDA kernel counter group ID */
|
||||
uint32_t vt_cupti_cgid_cuda_kernel = VT_NO_ID;
|
||||
|
||||
/* global kernel counter IDs */
|
||||
uint32_t vt_cupti_cid_blocksPerGrid = VT_NO_ID;
|
||||
uint32_t vt_cupti_cid_threadsPerBlock = VT_NO_ID;
|
||||
uint32_t vt_cupti_cid_threadsPerKernel = VT_NO_ID;
|
||||
|
||||
/* initialization and finalization flags */
|
||||
static uint8_t vt_cupticb_initialized = 0;
|
||||
static uint8_t vt_cupticb_finalized = 0;
|
||||
@ -166,9 +96,6 @@ static uint32_t vt_cupticb_rid_sync = VT_NO_ID;
|
||||
|
||||
#if !defined(VT_CUPTI_ACTIVITY)
|
||||
|
||||
/* list of VampirTrace CUDA contexts */
|
||||
static vt_cupticb_ctx_t* vt_cupticb_ctxList = NULL;
|
||||
|
||||
/*
|
||||
* Synchronization Level:
|
||||
* 0 no extra synchronization
|
||||
@ -217,8 +144,8 @@ static void vt_cupticb_handle_cudart_memcpy(const CUpti_CallbackData *,
|
||||
static void vt_cupticb_handle_cudart_mcpyAsync(const CUpti_CallbackData *cbInfo,
|
||||
enum cudaMemcpyKind kind, uint64_t bytes, cudaStream_t cuStrm);
|
||||
|
||||
static void vt_cupticb_handle_malloc(uint64_t, void *, size_t);
|
||||
static void vt_cupticb_handle_free(uint64_t ctxUID, void *devPtr);
|
||||
static void vt_cupticb_handle_malloc(uint64_t, CUcontext, void *, size_t);
|
||||
static void vt_cupticb_handle_free(uint64_t ctxUID, CUcontext, void *devPtr);
|
||||
/******************************************************************************/
|
||||
#endif /* VT_CUPTI_ACTIVITY */
|
||||
|
||||
@ -317,6 +244,41 @@ static void vt_cupti_set_callback(CUpti_CallbackFunc callback,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
# if (defined(CUPTI_API_VERSION) && (CUPTI_API_VERSION >= 3))
|
||||
/*
|
||||
* Creates a VampirTrace CUPTI callbacks context.
|
||||
*
|
||||
* @param cuDev the CUDA device
|
||||
*
|
||||
* @return the VampirTrace CUPTI callbacks context
|
||||
*/
|
||||
static vt_cupti_callbacks_t* vt_cupticb_createCbCtx(CUdevice cuDev)
|
||||
{
|
||||
vt_cupti_callbacks_t *vtCbCtx = NULL;
|
||||
int concurrentKernels = 0;
|
||||
|
||||
/* create new context, as it is not listed */
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
vtCbCtx = (vt_cupti_callbacks_t *)malloc(sizeof(vt_cupti_callbacks_t));
|
||||
if(vtCbCtx == NULL)
|
||||
vt_error_msg("[CUPTI Callbacks] Could not allocate memory for callbacks context!");
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vtCbCtx->streamsCreated = 0;
|
||||
|
||||
/* check for concurrent kernel support */
|
||||
CHECK_CU_ERROR(cuDeviceGetAttribute(&concurrentKernels,
|
||||
CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS, cuDev),
|
||||
"cuDeviceGetAttribute");
|
||||
|
||||
vtCbCtx->concurrentKernels = concurrentKernels;
|
||||
|
||||
return vtCbCtx;
|
||||
}
|
||||
# endif
|
||||
|
||||
#if !defined(VT_CUPTI_ACTIVITY)
|
||||
/*
|
||||
* Creates a VampirTrace CUPTI stream object and returns it.
|
||||
@ -328,23 +290,26 @@ static void vt_cupti_set_callback(CUpti_CallbackFunc callback,
|
||||
*/
|
||||
static vt_cupticb_strm_t* vt_cupticb_createStream(uint32_t ptid,
|
||||
CUstream cuStrm,
|
||||
vt_cupticb_ctx_t *vtCtx)
|
||||
vt_cupti_ctx_t *vtCtx)
|
||||
{
|
||||
vt_cupti_callbacks_t *vtcuptiCallbacks = vtCtx->callbacks;
|
||||
uint32_t gpu_tid = 0;
|
||||
char thread_name[16];
|
||||
vt_cupticb_strm_t *vtStrm;
|
||||
uint32_t strmNum = 0;
|
||||
|
||||
if(vtCtx == NULL){
|
||||
vt_warning("[CUPTI CALLBACKS] Create stream without VampirTrace context");
|
||||
vt_warning("[CUPTI Callbacks] Create stream without VampirTrace context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strmNum = vtCtx->strmNum;
|
||||
strmNum = vtcuptiCallbacks->strmNum;
|
||||
|
||||
/* allocate memory for stream */
|
||||
vtStrm = (vt_cupticb_strm_t *)malloc(sizeof(vt_cupticb_strm_t));
|
||||
if(vtStrm == NULL) vt_error_msg("malloc(sizeof(vt_cupti_strm_t)) failed!");
|
||||
if(vtStrm == NULL)
|
||||
vt_error_msg("[CUPTI Callbacks] malloc(sizeof(vt_cupti_strm_t)) failed!");
|
||||
|
||||
vtStrm->next = NULL;
|
||||
vtStrm->stream = cuStrm;
|
||||
|
||||
@ -352,11 +317,11 @@ static vt_cupticb_strm_t* vt_cupticb_createStream(uint32_t ptid,
|
||||
if(cuStrm == NULL){
|
||||
strmNum = 1;
|
||||
}else{
|
||||
vtCtx->strmNum++;
|
||||
vtcuptiCallbacks->strmNum++;
|
||||
}
|
||||
|
||||
/* create VT-User-Thread with name and parent id and get its id */
|
||||
if(-1 == snprintf(thread_name, 15, "CUDA[%d:%d]", (uint32_t)vtCtx->dev, strmNum))
|
||||
if(-1 == snprintf(thread_name, 15, "CUDA[%d:%d]", (uint32_t)vtCtx->devID, strmNum))
|
||||
vt_cntl_msg(1, "Could not create thread name for CUDA thread!");
|
||||
|
||||
vt_gpu_registerThread(thread_name, ptid, &gpu_tid);
|
||||
@ -372,7 +337,7 @@ static vt_cupticb_strm_t* vt_cupticb_createStream(uint32_t ptid,
|
||||
vt_count(gpu_tid, &vt_gpu_init_time, vt_cupti_cid_threadsPerKernel, 0);
|
||||
}
|
||||
|
||||
if(vtCtx->strmList == NULL){
|
||||
if(vtcuptiCallbacks->strmList == NULL){
|
||||
/* write enter event for GPU_IDLE on first stream */
|
||||
if(vt_gpu_trace_idle)
|
||||
vt_enter(gpu_tid, &vt_gpu_init_time, vt_gpu_rid_idle);
|
||||
@ -385,32 +350,6 @@ static vt_cupticb_strm_t* vt_cupticb_createStream(uint32_t ptid,
|
||||
return vtStrm;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieve the VampirTrace CUPTI context by its ID or NULL if not available.
|
||||
*
|
||||
* @param cuCtxID ID of the CUDA context
|
||||
*
|
||||
* @return the VampirTrace CUPTI context object
|
||||
*/
|
||||
static vt_cupticb_ctx_t* vt_cupticb_getCtx(uint64_t cuCtxUID)
|
||||
{
|
||||
vt_cupticb_ctx_t *vtCtx = NULL;
|
||||
|
||||
/*** search CUDA context in list ***/
|
||||
CUPTI_CB_LOCK();
|
||||
vtCtx = vt_cupticb_ctxList;
|
||||
while(vtCtx != NULL){
|
||||
if(vtCtx->ctxUID == cuCtxUID){
|
||||
CUPTI_CB_UNLOCK();
|
||||
return vtCtx;
|
||||
}
|
||||
vtCtx = vtCtx->next;
|
||||
}
|
||||
CUPTI_CB_UNLOCK();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates new VampirTrace CUPTI callback context.
|
||||
*
|
||||
@ -418,71 +357,50 @@ static vt_cupticb_ctx_t* vt_cupticb_getCtx(uint64_t cuCtxUID)
|
||||
*
|
||||
* @return the VampirTrace CUPTI context object
|
||||
*/
|
||||
static vt_cupticb_ctx_t* vt_cupticb_createCtx(uint64_t cuCtxUID, CUstream cuStrm)
|
||||
static vt_cupti_callbacks_t* vt_cupticb_createCbCtx(vt_cupti_ctx_t *vtCtx,
|
||||
CUstream cuStrm)
|
||||
{
|
||||
vt_cupticb_ctx_t *vtCtx = (vt_cupticb_ctx_t*)malloc(sizeof(vt_cupticb_ctx_t));
|
||||
if(vtCtx == NULL)
|
||||
vt_error_msg("Could not allocate memory for vt_cupticb_ctx_t!");
|
||||
|
||||
vtCtx->ctxUID = cuCtxUID;
|
||||
vt_cupti_callbacks_t *vtCbCtx =
|
||||
(vt_cupti_callbacks_t*)malloc(sizeof(vt_cupti_callbacks_t));
|
||||
if(vtCbCtx == NULL)
|
||||
vt_error_msg("[CUPTI Callbacks] Could not allocate memory for vt_cupti_callbacks_t!");
|
||||
|
||||
/* enable handling of callbacks */
|
||||
vtCtx->callbacks_enabled = 1;
|
||||
|
||||
CHECK_CU_ERROR(cuCtxGetDevice(&vtCtx->dev), NULL);
|
||||
vtCbCtx->callbacks_enabled = 1;
|
||||
|
||||
/* initialize GPU memory allocation parameter */
|
||||
vtCtx->gpuMemList = NULL;
|
||||
vtCtx->gpuMemAllocated = 0;
|
||||
vtCbCtx->gpuMemList = NULL;
|
||||
vtCbCtx->gpuMemAllocated = 0;
|
||||
|
||||
|
||||
/* create first empty CUDA stream */
|
||||
VT_CHECK_THREAD;
|
||||
vtCtx->strmNum = 2;
|
||||
vtCtx->strmList = NULL;
|
||||
vtCtx->strmList = vt_cupticb_createStream(VT_MY_THREAD, cuStrm, vtCtx);
|
||||
vtCbCtx->strmNum = 2;
|
||||
vtCbCtx->strmList = NULL;
|
||||
vtCbCtx->strmList = vt_cupticb_createStream(vtCtx->ptid, cuStrm, vtCtx);
|
||||
|
||||
/* initialize CUDA kernel configure stack */
|
||||
{
|
||||
vt_cupticb_kernel_t *vtKn = NULL;
|
||||
vt_cupti_kernel_t *vtKn = NULL;
|
||||
|
||||
vtKn = (vt_cupticb_kernel_t*)malloc(sizeof(vt_cupticb_kernel_t));
|
||||
vtKn = (vt_cupti_kernel_t*)malloc(sizeof(vt_cupti_kernel_t));
|
||||
if(vtKn == NULL)
|
||||
vt_error_msg("Could not allocate memory for vt_cupti_kernel_t!");
|
||||
|
||||
vtKn->prev = NULL;
|
||||
vtCtx->kernelData = vtKn;
|
||||
vtCtx->stack_size = 0;
|
||||
vtCbCtx->kernelData = vtKn;
|
||||
vtCbCtx->stack_size = 0;
|
||||
}
|
||||
|
||||
return vtCtx;
|
||||
return vtCbCtx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup a VampirTrace CUPTI callback context by its ID and if not available,
|
||||
* create a new one.
|
||||
*
|
||||
* @param cuCtxID ID of the CUDA context
|
||||
*
|
||||
* @return the VampirTrace CUPTI context object
|
||||
*/
|
||||
static vt_cupticb_ctx_t* vt_cupticb_checkCtx(uint64_t cuCtxUID, CUstream cuStrm)
|
||||
static vt_cupti_ctx_t* vt_cupticb_checkCtx(CUcontext cuCtx, cudaStream_t cuStrm)
|
||||
{
|
||||
vt_cupticb_ctx_t *vtCtx = NULL;
|
||||
vt_cupti_ctx_t* vtCtx = vt_cupti_getCreateCtx(cuCtx);
|
||||
|
||||
/* search for existing CUPTI context */
|
||||
vtCtx = vt_cupticb_getCtx(cuCtxUID);
|
||||
|
||||
if(vtCtx == NULL){
|
||||
/* create new CUPTI callback context */
|
||||
vtCtx = vt_cupticb_createCtx(cuCtxUID, cuStrm);
|
||||
|
||||
/* prepend CUDA context to global list */
|
||||
CUPTI_CB_LOCK();
|
||||
vtCtx->next = vt_cupticb_ctxList;
|
||||
vt_cupticb_ctxList = vtCtx;
|
||||
CUPTI_CB_UNLOCK();
|
||||
}
|
||||
if(vtCtx->callbacks == NULL)
|
||||
vtCtx->callbacks = vt_cupticb_createCbCtx(vtCtx, cuStrm);
|
||||
|
||||
return vtCtx;
|
||||
}
|
||||
@ -498,7 +416,7 @@ static vt_cupticb_ctx_t* vt_cupticb_checkCtx(uint64_t cuCtxUID, CUstream cuStrm)
|
||||
* @return a VampirTrace stream object
|
||||
*/
|
||||
static vt_cupticb_strm_t* vt_cupticb_checkStream(uint32_t ptid,
|
||||
vt_cupticb_ctx_t *vtCtx,
|
||||
vt_cupti_ctx_t *vtCtx,
|
||||
CUstream cuStrm)
|
||||
{
|
||||
vt_cupticb_strm_t *currStrm = NULL;
|
||||
@ -509,7 +427,7 @@ static vt_cupticb_strm_t* vt_cupticb_checkStream(uint32_t ptid,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
currStrm = vtCtx->strmList;
|
||||
currStrm = vtCtx->callbacks->strmList;
|
||||
|
||||
/* this should never happen */
|
||||
if(currStrm == NULL) return NULL;
|
||||
@ -613,7 +531,8 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
vt_cuptiact_writeMalloc((uint32_t)cbInfo->contextUid, cbInfo->context,
|
||||
*(params->devPtr), params->size);
|
||||
#else
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, *(params->devPtr),
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, cbInfo->context,
|
||||
*(params->devPtr),
|
||||
params->size);
|
||||
#endif
|
||||
}
|
||||
@ -630,8 +549,9 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
*(params->devPtr),
|
||||
params->height * (*(params->pitch)));
|
||||
#else
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, *(params->devPtr),
|
||||
params->height * (*(params->pitch)));
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, cbInfo->context,
|
||||
*(params->devPtr),
|
||||
params->height * (*(params->pitch)));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -647,8 +567,9 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
*(params->array),
|
||||
params->height * params->width);
|
||||
#else
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, *(params->array),
|
||||
params->height * params->width);
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, cbInfo->context,
|
||||
*(params->array),
|
||||
params->height * params->width);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -664,7 +585,8 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
params->pitchedDevPtr->ptr,
|
||||
params->pitchedDevPtr->pitch * params->extent.height * params->extent.depth);
|
||||
#else
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, params->pitchedDevPtr->ptr,
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, cbInfo->context,
|
||||
params->pitchedDevPtr->ptr,
|
||||
params->pitchedDevPtr->pitch * params->extent.height * params->extent.depth);
|
||||
#endif
|
||||
}
|
||||
@ -681,7 +603,8 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
*(params->array),
|
||||
params->extent.width * params->extent.height * params->extent.depth);
|
||||
#else
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, *(params->array),
|
||||
vt_cupticb_handle_malloc(cbInfo->contextUid, cbInfo->context,
|
||||
*(params->array),
|
||||
params->extent.width * params->extent.height * params->extent.depth);
|
||||
#endif
|
||||
}
|
||||
@ -695,7 +618,7 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
vt_cuptiact_writeFree((uint32_t)cbInfo->contextUid, cbInfo->context,
|
||||
((cudaFree_v3020_params *)cbInfo->functionParams)->devPtr);
|
||||
#else
|
||||
vt_cupticb_handle_free(cbInfo->contextUid,
|
||||
vt_cupticb_handle_free(cbInfo->contextUid, cbInfo->context,
|
||||
((cudaFree_v3020_params *)cbInfo->functionParams)->devPtr);
|
||||
#endif
|
||||
}
|
||||
@ -709,7 +632,7 @@ void CUPTIAPI vt_cupticb_cudart(void *userdata,
|
||||
vt_cuptiact_writeFree((uint32_t)cbInfo->contextUid, cbInfo->context,
|
||||
((cudaFreeArray_v3020_params *)cbInfo->functionParams)->array);
|
||||
#else
|
||||
vt_cupticb_handle_free(cbInfo->contextUid,
|
||||
vt_cupticb_handle_free(cbInfo->contextUid, cbInfo->context,
|
||||
((cudaFreeArray_v3020_params *)cbInfo->functionParams)->array);
|
||||
#endif
|
||||
}
|
||||
@ -1063,18 +986,16 @@ void CUPTIAPI vt_cupticb_driverAPI(CUpti_CallbackId cbid,
|
||||
void vt_cupticb_sync(CUpti_CallbackId cbid,
|
||||
const CUpti_SynchronizeData *syncData)
|
||||
{
|
||||
if(CUPTI_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED == cbid){
|
||||
if(CUPTI_CBID_SYNCHRONIZE_CONTEXT_SYNCHRONIZED == cbid){
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Synchronize called");
|
||||
|
||||
vt_cuptiact_flushCtxActivities(syncData->context);
|
||||
VT_CUPTI_LOCK();
|
||||
vt_cuptiact_flushCtxActivities(vt_cupti_getCtxNoLock(syncData->context));
|
||||
VT_CUPTI_UNLOCK();
|
||||
}
|
||||
|
||||
/*if(CUPTI_CBID_SYNCHRONIZE_STREAM_SYNCHRONIZED == cbid){
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Synchronize called");
|
||||
|
||||
vt_cuptiact_handleCtxActivities(syncData->context);
|
||||
syncData->stream;
|
||||
cuptiGetStreamId(syncData->context, syncData->stream, &streamId);
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Stream synchronize called");
|
||||
}*/
|
||||
}
|
||||
|
||||
@ -1090,32 +1011,58 @@ void vt_cupticb_resource(CUpti_CallbackId cbid,
|
||||
switch(cbid){
|
||||
/********************** CUDA memory allocation ******************************/
|
||||
case CUPTI_CBID_RESOURCE_CONTEXT_CREATED: {
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Creating context %d", resData->context);
|
||||
vt_cupti_ctx_t *vtCtx = NULL;
|
||||
CUcontext cuCtx = resData->context;
|
||||
|
||||
/*vt_cntl_msg(2, "[CUPTI Callbacks] Creating context %d", cuCtx);*/
|
||||
|
||||
|
||||
vtCtx = vt_cupti_getCreateCtx(cuCtx);
|
||||
|
||||
/*
|
||||
* Create the VampirTrace CUPTI callbacks context for CUPTI >3
|
||||
* (needed for concurrent kernel tracing)
|
||||
*/
|
||||
#if (defined(CUPTI_API_VERSION) && (CUPTI_API_VERSION >= 3))
|
||||
if(vtCtx->callbacks == NULL)
|
||||
vtCtx->callbacks = vt_cupticb_createCbCtx(vtCtx->cuDev);
|
||||
#endif
|
||||
|
||||
/* CUdevice is always '0' (try simpleP2P example)
|
||||
{
|
||||
CUdevice cuDev;
|
||||
if(CUDA_SUCCESS != cuCtxGetDevice(&cuDev)){
|
||||
vt_warning("could not get CUdevice from context");
|
||||
}
|
||||
vt_cntl_msg(1, "CUcontext %d, CUdevice %d", cuCtx, cuDev);
|
||||
}*/
|
||||
|
||||
/* add the context without tracing CUDA driver API calls, if enabled */
|
||||
if(vt_cupticb_trace_driverAPI){
|
||||
cuptiEnableDomain(0, vt_cupticb_subscriber, CUPTI_CB_DOMAIN_DRIVER_API);
|
||||
vt_cuptiact_addContext(resData->context, (CUdevice)-1);
|
||||
vt_cuptiact_setupActivityContext(vtCtx);
|
||||
cuptiEnableDomain(1, vt_cupticb_subscriber, CUPTI_CB_DOMAIN_DRIVER_API);
|
||||
}else{
|
||||
vt_cuptiact_addContext(resData->context, (CUdevice)-1);
|
||||
vt_cuptiact_setupActivityContext(vtCtx);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CUPTI_CBID_RESOURCE_CONTEXT_DESTROY_STARTING: {
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Destroying context");
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Destroying context ...");
|
||||
|
||||
/* Only flush the activities of the context. The user code has to ensure,
|
||||
that the context is synchronized */
|
||||
vt_cuptiact_flushCtxActivities(resData->context);
|
||||
VT_CUPTI_LOCK();
|
||||
vt_cuptiact_flushCtxActivities(vt_cupti_getCtxNoLock(resData->context));
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CUPTI_CBID_RESOURCE_STREAM_CREATED: {
|
||||
if(vt_gpu_stream_reuse){
|
||||
/*if(vt_gpu_stream_reuse){
|
||||
uint32_t strmID;
|
||||
|
||||
VT_CUPTI_CALL(cuptiGetStreamId(resData->context,
|
||||
@ -1125,12 +1072,32 @@ void vt_cupticb_resource(CUpti_CallbackId cbid,
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Creating stream %d (context %d)",
|
||||
strmID, resData->context);
|
||||
}
|
||||
}*/
|
||||
|
||||
#if (defined(CUPTI_API_VERSION) && (CUPTI_API_VERSION >= 3))
|
||||
if(vt_gpu_trace_kernels > 0){
|
||||
vt_cupti_ctx_t *vtCtx = vt_cupti_getCreateCtx(resData->context);
|
||||
|
||||
/* if the device is capable of concurrent kernels */
|
||||
if(vtCtx->callbacks->concurrentKernels){
|
||||
|
||||
vtCtx->callbacks->streamsCreated++;
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Creating stream %d (context %d)",
|
||||
vtCtx->callbacks->streamsCreated, resData->context);
|
||||
|
||||
if(vtCtx->callbacks->streamsCreated < 1)
|
||||
vtCtx->callbacks->streamsCreated++;
|
||||
else
|
||||
vt_cuptiact_enableConcurrentKernel(vtCtx);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CUPTI_CBID_RESOURCE_STREAM_DESTROY_STARTING: {
|
||||
case CUPTI_CBID_RESOURCE_STREAM_DESTROY_STARTING: {
|
||||
if(vt_gpu_stream_reuse){
|
||||
uint32_t ptid, strmID;
|
||||
uint64_t time;
|
||||
@ -1141,6 +1108,7 @@ void vt_cupticb_resource(CUpti_CallbackId cbid,
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(ptid, &time, vt_cupticb_rid_sync);
|
||||
|
||||
/*#if (defined(CUDA_VERSION) && (CUDA_VERSION < 5000))*/
|
||||
/* implicitly flush context activities via cuCtxSynchronize() */
|
||||
if(vt_cupticb_trace_driverAPI){
|
||||
cuptiEnableDomain(0, vt_cupticb_subscriber, CUPTI_CB_DOMAIN_DRIVER_API);
|
||||
@ -1149,6 +1117,13 @@ void vt_cupticb_resource(CUpti_CallbackId cbid,
|
||||
}else{
|
||||
CHECK_CU_ERROR(cuCtxSynchronize(), NULL);
|
||||
}
|
||||
/*#else*/
|
||||
/* TODO: NVIDIA bug??? *
|
||||
* cuCtxSynchronize() runs into a lock here, therefore just flush *
|
||||
VT_CUPTI_LOCK();
|
||||
vt_cuptiact_flushCtxActivities(vt_cupti_getCtx(resData->context));
|
||||
VT_CUPTI_UNLOCK();*
|
||||
*#endif*/
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(ptid, &time);
|
||||
@ -1183,11 +1158,12 @@ void vt_cupticb_resource(CUpti_CallbackId cbid,
|
||||
* @param devPtr pointer to the allocated memory (needed for vtcudaFree())
|
||||
* @param size the number of bytes allocated
|
||||
*/
|
||||
static void vt_cupticb_handle_malloc(uint64_t ctxUID, void *devPtr, size_t size)
|
||||
static void vt_cupticb_handle_malloc(uint64_t ctxID, CUcontext cuCtx,
|
||||
void *devPtr, size_t size)
|
||||
{
|
||||
uint64_t vtTime;
|
||||
vt_cupticb_ctx_t *vtCtx = vt_cupticb_checkCtx(ctxUID, NULL);
|
||||
vt_cupticb_gpumem_t *vtMalloc = (vt_cupticb_gpumem_t*)malloc(sizeof(vt_cupticb_gpumem_t));
|
||||
vt_cupti_callbacks_t *vtCtx = vt_cupticb_checkCtx(cuCtx, NULL);
|
||||
vt_cupti_gpumem_t *vtMalloc = (vt_cupti_gpumem_t*)malloc(sizeof(vt_cupti_gpumem_t));
|
||||
|
||||
vtMalloc->memPtr = devPtr;
|
||||
vtMalloc->size = size;
|
||||
@ -1217,12 +1193,13 @@ static void vt_cupticb_handle_malloc(uint64_t ctxUID, void *devPtr, size_t size)
|
||||
* @param ctxUID CUDA context identifier (@see CUPTI callback info)
|
||||
* @param devPtr pointer to the allocated memory
|
||||
*/
|
||||
static void vt_cupticb_handle_free(uint64_t ctxUID, void *devPtr)
|
||||
static void vt_cupticb_handle_free(uint64_t ctxUID, CUcontext cuCtx,
|
||||
void *devPtr)
|
||||
{
|
||||
uint64_t vtTime;
|
||||
vt_cupticb_ctx_t *vtCtx = vt_cupticb_checkCtx(ctxUID, NULL);
|
||||
vt_cupticb_gpumem_t *curMalloc = NULL;
|
||||
vt_cupticb_gpumem_t *lastMalloc = NULL;
|
||||
vt_cupti_callbacks_t *vtCtx = vt_cupticb_checkCtx(cuCtx, NULL)->callbacks;
|
||||
vt_cupti_gpumem_t *curMalloc = NULL;
|
||||
vt_cupti_gpumem_t *lastMalloc = NULL;
|
||||
|
||||
if(devPtr == NULL) return;
|
||||
|
||||
@ -1277,30 +1254,30 @@ static void vt_cupticb_handle_cudart_knconf(const CUpti_CallbackData *cbInfo)
|
||||
/* configure call parameter have to be saved for kernel launch on a per
|
||||
* thread basis. */
|
||||
if(cbInfo->callbackSite == CUPTI_API_EXIT){
|
||||
vt_cupticb_kernel_t *vtParams = NULL;
|
||||
vt_cupti_kernel_t *vtParams = NULL;
|
||||
cudaConfigureCall_v3020_params *params =
|
||||
(cudaConfigureCall_v3020_params *) cbInfo->functionParams;
|
||||
vt_cupticb_ctx_t *vtCtx =
|
||||
vt_cupticb_checkCtx(cbInfo->contextUid, params->stream);
|
||||
vt_cupti_callbacks_t *vtCbCtx =
|
||||
vt_cupticb_checkCtx(cbInfo->contextUid, params->stream)->callbacks;
|
||||
|
||||
/* Is another kernel already configured? */
|
||||
if(vtCtx->stack_size > 0){
|
||||
if(vtCbCtx->stack_size > 0){
|
||||
/* memory already allocated */
|
||||
if(vtCtx->kernelData->prev == NULL){
|
||||
vtParams = (vt_cupticb_kernel_t*)malloc(sizeof(vt_cupticb_kernel_t));
|
||||
if(vtCbCtx->kernelData->prev == NULL){
|
||||
vtParams = (vt_cupti_kernel_t*)malloc(sizeof(vt_cupti_kernel_t));
|
||||
if(vtParams == NULL)
|
||||
vt_error_msg("Could not allocate memory for vt_cupti_kernel_t!");
|
||||
|
||||
vtParams->prev = NULL;
|
||||
}else{
|
||||
vtParams = vtCtx->kernelData->prev;
|
||||
vtParams = vtCbCtx->kernelData->prev;
|
||||
}
|
||||
|
||||
/* add to kernel configure call parameter stack */
|
||||
vtParams->prev = vtCtx->kernelData;
|
||||
vtCtx->kernelData = vtParams;
|
||||
vtParams->prev = vtCbCtx->kernelData;
|
||||
vtCbCtx->kernelData = vtParams;
|
||||
}else{
|
||||
vtParams = vtCtx->kernelData;
|
||||
vtParams = vtCbCtx->kernelData;
|
||||
}
|
||||
|
||||
vtParams->blocksPerGrid = params->gridDim.x * params->gridDim.y
|
||||
@ -1310,7 +1287,7 @@ static void vt_cupticb_handle_cudart_knconf(const CUpti_CallbackData *cbInfo)
|
||||
|
||||
vtParams->stream = params->stream;
|
||||
|
||||
(vtCtx->stack_size)++;
|
||||
(vtCbCtx->stack_size)++;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1330,7 +1307,8 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
const char *symName = cbInfo->symbolName;
|
||||
vt_cupticb_strm_t *vtStrm = NULL;
|
||||
vt_gpu_hn_string_t *hn = NULL;
|
||||
vt_cupticb_ctx_t *vtCtx = NULL;
|
||||
vt_cupti_ctx_t *vtCtx = NULL;
|
||||
vt_cupti_callbacks_t *vtCbCtx = NULL;
|
||||
uint32_t ptid;
|
||||
|
||||
VT_CHECK_THREAD;
|
||||
@ -1346,25 +1324,24 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
}else{
|
||||
char *knName = NULL;
|
||||
|
||||
CUPTI_CB_LOCK();
|
||||
VT_CUPTI_LOCK();
|
||||
knName = vt_cuda_demangleKernel(symName);
|
||||
knRID = vt_def_region(VT_MASTER_THREAD, knName, VT_NO_ID,
|
||||
VT_NO_LNO, VT_NO_LNO, "CUDA_KERNEL", VT_FUNCTION);
|
||||
CUPTI_CB_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
hn = vt_gpu_stringHashPut(symName, knRID);
|
||||
/*hn->fname = knName;*/
|
||||
}
|
||||
|
||||
/* get the VampirTrace thread ID the kernel is running on */
|
||||
{
|
||||
vtCtx = vt_cupticb_checkCtx(cbInfo->contextUid, NULL);
|
||||
vtCtx = vt_cupticb_checkCtx(cbInfo->contextUid, NULL);
|
||||
vtCbCtx = vtCtx->callbacks;
|
||||
|
||||
vtStrm = vt_cupticb_checkStream(ptid, vtCtx, vtCtx->kernelData->stream);
|
||||
vtStrm = vt_cupticb_checkStream(ptid, vtCtx, vtCtx->callbacks->kernelData->stream);
|
||||
|
||||
/* save address into 64 Bit correlation value for exit callback */
|
||||
*cbInfo->correlationData = (uint64_t)vtStrm;
|
||||
}
|
||||
/* save address into 64 Bit correlation value for exit callback */
|
||||
*cbInfo->correlationData = (uint64_t)vtStrm;
|
||||
|
||||
/* write the event records */
|
||||
CHECK_CU_ERROR(cuCtxSynchronize(), NULL);
|
||||
@ -1372,37 +1349,37 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
/* write VT kernel start events */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if(vt_gpu_trace_idle) vt_exit(vtCtx->strmList->tid, &time);
|
||||
if(vt_gpu_trace_idle) vt_exit(vtCbCtx->strmList->tid, &time);
|
||||
vt_enter(vtStrm->tid, &time, knRID);
|
||||
|
||||
if(vt_gpu_trace_kernels > 1){
|
||||
vt_count(vtStrm->tid, &time, vt_cupti_cid_blocksPerGrid,
|
||||
vtCtx->kernelData->blocksPerGrid);
|
||||
vtCbCtx->kernelData->blocksPerGrid);
|
||||
vt_count(vtStrm->tid, &time, vt_cupti_cid_threadsPerBlock,
|
||||
vtCtx->kernelData->threadsPerBlock);
|
||||
vtCbCtx->kernelData->threadsPerBlock);
|
||||
vt_count(vtStrm->tid, &time, vt_cupti_cid_threadsPerKernel,
|
||||
vtCtx->kernelData->threadsPerBlock *
|
||||
vtCtx->kernelData->blocksPerGrid);
|
||||
vtCbCtx->kernelData->threadsPerBlock *
|
||||
vtCbCtx->kernelData->blocksPerGrid);
|
||||
}
|
||||
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
if(vt_cupticb_trace_events){
|
||||
vt_cuptievt_ctx_t *vtcuptiCtx = vt_cuptievt_getCurrentContext(ptid);
|
||||
vt_cuptievt_resetCounter(vtcuptiCtx, vtStrm->tid, &time);
|
||||
vtCtx = vt_cuptievt_getOrCreateCurrentCtx(ptid);
|
||||
vt_cuptievt_resetCounter(vtCtx->events, vtStrm->tid, &time);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* take the configure parameters from stack */
|
||||
(vtCtx->stack_size)--;
|
||||
if(vtCtx->stack_size > 0){
|
||||
vtCtx->kernelData = vtCtx->kernelData->prev;
|
||||
(vtCbCtx->stack_size)--;
|
||||
if(vtCbCtx->stack_size > 0){
|
||||
vtCbCtx->kernelData = vtCbCtx->kernelData->prev;
|
||||
}
|
||||
}
|
||||
|
||||
if(cbInfo->callbackSite == CUPTI_API_EXIT){
|
||||
vt_cupticb_strm_t *vtStrm = (vt_cupticb_strm_t *)(*cbInfo->correlationData);
|
||||
uint32_t tid = vtStrm->tid;
|
||||
vt_cupticb_ctx_t *vtCtx = vt_cupticb_checkCtx(cbInfo->contextUid, NULL);
|
||||
vt_cupti_ctx_t *vtCtx = vt_cupticb_checkCtx(cbInfo->contextUid, NULL);
|
||||
uint32_t ptid;
|
||||
|
||||
VT_CHECK_THREAD;
|
||||
@ -1410,8 +1387,6 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
if(vt_cupticb_trace_events){
|
||||
vt_cuptievt_ctx_t *vtcuptiCtx = vt_cuptievt_getCurrentContext(ptid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(ptid, &time, vt_cupticb_rid_sync);
|
||||
|
||||
@ -1420,7 +1395,7 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
/* sampling of CUPTI counter values */
|
||||
do{
|
||||
time = vt_pform_wtime();
|
||||
vt_cuptievt_writeCounter(vtcuptiCtx, tid, &time);
|
||||
vt_cuptievt_writeCounter(vtCtx->events, tid, &time);
|
||||
ret = cuStreamQuery(vtStrm->stream);
|
||||
}while(ret != CUDA_SUCCESS);
|
||||
}else{
|
||||
@ -1428,7 +1403,7 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
}
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_cuptievt_writeCounter(vtcuptiCtx, tid, &time);
|
||||
vt_cuptievt_writeCounter(vtCtx->events, tid, &time);
|
||||
vt_exit(ptid, &time);
|
||||
}else
|
||||
#endif /* VT_CUPTI_EVENTS */
|
||||
@ -1454,7 +1429,7 @@ static void vt_cupticb_handle_cudart_kernel(const CUpti_CallbackData *cbInfo)
|
||||
vt_exit(tid, &time);
|
||||
|
||||
if(vt_gpu_trace_idle){
|
||||
vt_enter(vtCtx->strmList->tid, &time, vt_gpu_rid_idle);
|
||||
vt_enter(vtCtx->callbacks->strmList->tid, &time, vt_gpu_rid_idle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1481,7 +1456,7 @@ static void vt_cupticb_handle_cudart_memcpy(
|
||||
if(cbInfo->callbackSite == CUPTI_API_ENTER){
|
||||
/* get the VampirTrace thread ID the kernel is running on */
|
||||
{
|
||||
vt_cupticb_ctx_t *vtCtx =
|
||||
vt_cupti_ctx_t *vtCtx =
|
||||
vt_cupticb_checkCtx(cbInfo->contextUid, NULL);
|
||||
vt_cupticb_strm_t *vtStrm =
|
||||
vtStrm = vt_cupticb_checkStream(ptid, vtCtx, NULL);
|
||||
@ -1507,10 +1482,10 @@ static void vt_cupticb_handle_cudart_memcpy(
|
||||
*/
|
||||
}
|
||||
|
||||
CUPTI_CB_LOCK();
|
||||
VT_CUPTI_LOCK();
|
||||
if(kind != cudaMemcpyDeviceToDevice) vt_gpu_prop[ptid] |= VTGPU_GPU_COMM;
|
||||
vt_gpu_prop[strmID] |= VTGPU_GPU_COMM;
|
||||
CUPTI_CB_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
/*time = vt_pform_wtime();*/
|
||||
if(kind == cudaMemcpyHostToDevice){
|
||||
@ -1562,7 +1537,7 @@ static void vt_cupticb_handle_cudart_mcpyAsync(const CUpti_CallbackData *cbInfo,
|
||||
if(cbInfo->callbackSite == CUPTI_API_ENTER){
|
||||
/* get the VampirTrace thread ID the kernel is running on */
|
||||
{
|
||||
vt_cupticb_ctx_t *vtCtx = vt_cupticb_checkCtx(cbInfo->contextUid, cuStrm);
|
||||
vt_cupti_ctx_t *vtCtx = vt_cupticb_checkCtx(cbInfo->contextUid, cuStrm);
|
||||
vt_cupticb_strm_t *vtStrm = vt_cupticb_checkStream(ptid, vtCtx, cuStrm);
|
||||
|
||||
strmID = vtStrm->tid;
|
||||
@ -1571,10 +1546,10 @@ static void vt_cupticb_handle_cudart_mcpyAsync(const CUpti_CallbackData *cbInfo,
|
||||
*cbInfo->correlationData = (uint64_t)vtStrm;
|
||||
}
|
||||
|
||||
CUPTI_CB_LOCK();
|
||||
VT_CUPTI_LOCK();
|
||||
if(kind != cudaMemcpyDeviceToDevice) vt_gpu_prop[ptid] |= VTGPU_GPU_COMM;
|
||||
vt_gpu_prop[strmID] |= VTGPU_GPU_COMM;
|
||||
CUPTI_CB_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
time = vt_pform_wtime();
|
||||
if(kind == cudaMemcpyHostToDevice){
|
||||
@ -1610,7 +1585,7 @@ static void vt_cupticb_handle_cudart_mcpyAsync(const CUpti_CallbackData *cbInfo,
|
||||
}
|
||||
}
|
||||
|
||||
static void vt_cupti_callback_finalizeContext(vt_cupticb_ctx_t *vtCtx)
|
||||
static void vt_cupti_callback_finalizeContext(vt_cupti_ctx_t *vtCtx)
|
||||
{
|
||||
uint32_t ptid;
|
||||
|
||||
@ -1620,8 +1595,8 @@ static void vt_cupti_callback_finalizeContext(vt_cupticb_ctx_t *vtCtx)
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
if(vt_cupticb_trace_events && vt_gpu_debug == 0){
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_cupticb_strm_t *curStrm = vtCtx->strmList;
|
||||
vt_cuptievt_ctx_t* vtcuptiCtx = vt_cuptievt_getCurrentContext(ptid);
|
||||
vt_cupticb_strm_t *curStrm = vtCtx->callbacks->strmList;
|
||||
vt_cupti_ctx_t* vtcuptiCtx = vt_cuptievt_getOrCreateCurrentCtx(ptid);
|
||||
|
||||
while(curStrm != NULL){
|
||||
vt_cuptievt_resetCounter(vtcuptiCtx, curStrm->tid, &time);
|
||||
@ -1636,14 +1611,14 @@ static void vt_cupti_callback_finalizeContext(vt_cupticb_ctx_t *vtCtx)
|
||||
/* write idle end time to CUDA stream 0 */
|
||||
if(vt_gpu_trace_idle){
|
||||
uint64_t idle_end = vt_pform_wtime();
|
||||
vt_exit(vtCtx->strmList->tid, &idle_end);
|
||||
vt_exit(vtCtx->callbacks->strmList->tid, &idle_end);
|
||||
}
|
||||
#endif /* !VT_CUPTI_ACTIVITY */
|
||||
|
||||
/* cleanup stream list */
|
||||
if(vtCtx->strmList != NULL){
|
||||
free(vtCtx->strmList);
|
||||
vtCtx->strmList = NULL;
|
||||
if(vtCtx->callbacks->strmList != NULL){
|
||||
free(vtCtx->callbacks->strmList);
|
||||
vtCtx->callbacks->strmList = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* !VT_CUPTI_ACTIVITY */
|
||||
@ -1657,10 +1632,8 @@ static void vt_cupti_callback_finalizeContext(vt_cupticb_ctx_t *vtCtx)
|
||||
void vt_cupti_callback_init()
|
||||
{
|
||||
if(!vt_cupticb_initialized){
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTThrd_createMutex(&VTThrdMutexCuptiCB);
|
||||
#endif
|
||||
CUPTI_CB_LOCK();
|
||||
vt_cupti_init();
|
||||
VT_CUPTI_LOCK();
|
||||
if(!vt_cupticb_initialized){
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Initializing ... ");
|
||||
@ -1774,6 +1747,8 @@ void vt_cupti_callback_init()
|
||||
vt_cupticb_trace_events = 1;
|
||||
vt_cupticb_event_sampling = (uint8_t)vt_env_cupti_sampling();
|
||||
|
||||
vt_cupti_events_init();
|
||||
|
||||
/* TODO: check exit handler problems with CUPTI events */
|
||||
vt_gpu_debug = 1;
|
||||
}else{
|
||||
@ -1791,7 +1766,7 @@ void vt_cupti_callback_init()
|
||||
|
||||
vt_cupticb_initialized = 1;
|
||||
} /* !vt_cupticb_initialized */
|
||||
CUPTI_CB_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
} /* !vt_cupticb_initialized */
|
||||
}
|
||||
|
||||
@ -1801,19 +1776,21 @@ void vt_cupti_callback_init()
|
||||
void vt_cupti_callback_finalize()
|
||||
{
|
||||
if(!vt_cupticb_finalized && vt_cupticb_initialized){
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* finalize CUPTI activities outside the lock, as it uses the same lock */
|
||||
#if defined(VT_CUPTI_ACTIVITY)
|
||||
if(vt_gpu_trace_kernels > 0 || vt_gpu_trace_mcpy ||
|
||||
vt_gpu_trace_memusage > 0){
|
||||
vt_cupti_activity_finalize();
|
||||
}
|
||||
#endif
|
||||
|
||||
CUPTI_CB_LOCK();
|
||||
VT_CUPTI_LOCK();
|
||||
if(!vt_cupticb_finalized && vt_cupticb_initialized){
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI Callbacks] Finalizing ... ");
|
||||
|
||||
#if defined(VT_CUPTI_ACTIVITY)
|
||||
if(vt_gpu_trace_kernels > 0 || vt_gpu_trace_mcpy ||
|
||||
vt_gpu_trace_memusage > 0){
|
||||
vt_cupti_activity_finalize();
|
||||
}
|
||||
#endif
|
||||
|
||||
if(vt_cupticb_trace_runtimeAPI || vt_cupticb_trace_driverAPI ||
|
||||
vt_gpu_trace_kernels > 0 || vt_gpu_trace_mcpy ||
|
||||
vt_gpu_trace_memusage > 0){
|
||||
@ -1822,15 +1799,16 @@ void vt_cupti_callback_finalize()
|
||||
}
|
||||
|
||||
#if !defined(VT_CUPTI_ACTIVITY)
|
||||
/* clean up the VampirTrace CUDA context list */
|
||||
while(vt_cupticb_ctxList != NULL){
|
||||
vt_cupticb_ctx_t *vtCtx = vt_cupticb_ctxList;
|
||||
/* clean up the VampirTrace CUPTI context list */
|
||||
while(vt_cupti_ctxList != NULL){
|
||||
vt_cupti_ctx_t *vtCtx = vt_cupti_ctxList;
|
||||
|
||||
vt_cupticb_ctxList = vt_cupticb_ctxList->next;
|
||||
vt_cupti_ctxList = vt_cupti_ctxList->next;
|
||||
|
||||
vt_cupti_callback_finalizeContext(vtCtx);
|
||||
|
||||
free(vtCtx);
|
||||
vtCtx = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1838,14 +1816,15 @@ void vt_cupti_callback_finalize()
|
||||
|
||||
vt_gpu_finalize();
|
||||
|
||||
if(vt_gpu_trace_kernels > 0)
|
||||
vt_gpu_stringhashClear();
|
||||
|
||||
vt_cupticb_finalized = 1;
|
||||
CUPTI_CB_UNLOCK();
|
||||
|
||||
#if (defined(VT_MT) || defined (VT_HYB))
|
||||
VTTHRD_LOCK_ENV();
|
||||
VTThrd_deleteMutex(&VTThrdMutexCuptiCB);
|
||||
VTTHRD_UNLOCK_ENV();
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
vt_cupti_finalize();
|
||||
}
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
}
|
||||
|
332
ompi/contrib/vt/vt/vtlib/vt_cupti_common.c
Обычный файл
332
ompi/contrib/vt/vt/vtlib/vt_cupti_common.c
Обычный файл
@ -0,0 +1,332 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#include "vt_thrd.h" /* thread creation for GPU kernels */
|
||||
#include "vt_gpu.h" /* common for GPU */
|
||||
#include "vt_mallocwrap.h" /* wrapping of malloc and free */
|
||||
#include "vt_cupti.h" /* Support for CUPTI */
|
||||
#include "vt_cupti_common.h" /* CUPTI common structures, functions, etc. */
|
||||
|
||||
/* mutex for locking the CUPTI environment */
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTThrdMutex* VTThrdMutexCupti = NULL;
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
|
||||
/* set the list of CUPTI contexts to 'empty' */
|
||||
vt_cupti_ctx_t *vt_cupti_ctxList = NULL;
|
||||
|
||||
/* CUPTI global CUDA kernel counter group ID */
|
||||
uint32_t vt_cupti_cgid_cuda_kernel = VT_NO_ID;
|
||||
|
||||
/* global kernel counter IDs */
|
||||
uint32_t vt_cupti_cid_blocksPerGrid = VT_NO_ID;
|
||||
uint32_t vt_cupti_cid_threadsPerBlock = VT_NO_ID;
|
||||
uint32_t vt_cupti_cid_threadsPerKernel = VT_NO_ID;
|
||||
|
||||
static uint8_t vt_cupti_initialized = 0;
|
||||
static uint8_t vt_cupti_finalized = 0;
|
||||
|
||||
void vt_cupti_init()
|
||||
{
|
||||
if(!vt_cupti_initialized){
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTThrd_createMutex(&VTThrdMutexCupti);
|
||||
#endif
|
||||
VT_CUPTI_LOCK();
|
||||
if(!vt_cupti_initialized){
|
||||
vt_cntl_msg(2, "[CUPTI] Initializing ... ");
|
||||
|
||||
/* register the finalize function of VampirTrace CUPTI to be called before
|
||||
* the program exits */
|
||||
atexit(vt_cupti_finalize);
|
||||
|
||||
vt_cupti_initialized = 1;
|
||||
VT_CUPTI_UNLOCK();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalize the CUPTI common interface.
|
||||
* - free the VampirTrace CUPTI context list
|
||||
*/
|
||||
void vt_cupti_finalize()
|
||||
{
|
||||
if(!vt_cupti_finalized && vt_cupti_initialized){
|
||||
VT_CUPTI_LOCK();
|
||||
if(!vt_cupti_finalized && vt_cupti_initialized){
|
||||
vt_cntl_msg(2, "[CUPTI] Finalizing ... ");
|
||||
|
||||
/* free VampirTrace CUPTI context structures */
|
||||
while(vt_cupti_ctxList != NULL){
|
||||
vt_cupti_ctx_t *tmp = vt_cupti_ctxList;
|
||||
|
||||
vt_cupti_ctxList = vt_cupti_ctxList->next;
|
||||
|
||||
vt_cupti_freeCtx(tmp);
|
||||
tmp = NULL;
|
||||
}
|
||||
|
||||
vt_cupti_finalized = 1;
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
#if (defined(VT_MT) || defined (VT_HYB))
|
||||
VTTHRD_LOCK_ENV();
|
||||
VTThrd_deleteMutex(&VTThrdMutexCupti);
|
||||
VTTHRD_UNLOCK_ENV();
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a VampirTrace CUPTI context.
|
||||
*
|
||||
* @param cuCtx CUDA context
|
||||
* @param cuDev CUDA device
|
||||
* @param ctxID ID of the CUDA context
|
||||
* @param devID ID of the CUDA device
|
||||
*
|
||||
* @return pointer to created VampirTrace CUPTI context
|
||||
*/
|
||||
vt_cupti_ctx_t* vt_cupti_createCtx(CUcontext cuCtx, CUdevice cuDev,
|
||||
uint32_t cuCtxID, uint32_t cuDevID)
|
||||
{
|
||||
vt_cupti_ctx_t* vtCtx = NULL;
|
||||
|
||||
/* create new context */
|
||||
vtCtx = (vt_cupti_ctx_t *)malloc(sizeof(vt_cupti_ctx_t));
|
||||
if(vtCtx == NULL)
|
||||
vt_error_msg("[CUPTI] Could not allocate memory for VT CUPTI context!");
|
||||
vtCtx->ctxID = cuCtxID;
|
||||
vtCtx->next = NULL;
|
||||
|
||||
VT_CHECK_THREAD;
|
||||
vtCtx->ptid = VT_MY_THREAD;
|
||||
|
||||
/* get the current CUDA context, if it is not given */
|
||||
if(cuCtx == NULL) CHECK_CU_ERROR(cuCtxGetCurrent(&cuCtx), NULL);
|
||||
vtCtx->cuCtx = cuCtx;
|
||||
|
||||
/* try to get CUDA device (ID), if they are not given */
|
||||
if(cuDevID == VT_CUPTI_NO_DEVICE_ID){
|
||||
if(cuDev == VT_CUPTI_NO_CUDA_DEVICE){
|
||||
/* neither device ID nor CUDA device is given */
|
||||
if(CUDA_SUCCESS == cuCtxGetDevice(&cuDev)){
|
||||
cuDevID = (uint32_t)cuDev;
|
||||
}
|
||||
}else{
|
||||
/* no device ID, but CUDA device is given */
|
||||
cuDevID = (uint32_t)cuDev;
|
||||
}
|
||||
}
|
||||
|
||||
vtCtx->devID = cuDevID;
|
||||
vtCtx->cuDev = cuDev;
|
||||
|
||||
#if defined(VT_CUPTI_ACTIVITY)
|
||||
vtCtx->activity = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(VT_CUPTI_CALLBACKS)
|
||||
vtCtx->callbacks = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
vtCtx->events = NULL;
|
||||
#endif
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI] Created context for CUcontext %d, CUdevice %d",
|
||||
cuCtx, cuDev);
|
||||
|
||||
return vtCtx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepend the given VampirTrace CUPTI context to the global context list.
|
||||
*
|
||||
* @param vtCtx pointer to the VampirTrace CUPTI context to be prepended
|
||||
*/
|
||||
void vt_cupti_prependCtx(vt_cupti_ctx_t *vtCtx)
|
||||
{
|
||||
VT_CUPTI_LOCK();
|
||||
vtCtx->next = vt_cupti_ctxList;
|
||||
vt_cupti_ctxList = vtCtx;
|
||||
VT_CUPTI_UNLOCK();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a VampirTrace CUPTI context by CUDA context
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
vt_cupti_ctx_t* vt_cupti_getCtx(CUcontext cuCtx)
|
||||
{
|
||||
vt_cupti_ctx_t* vtCtx = NULL;
|
||||
|
||||
/* lookup context */
|
||||
VT_CUPTI_LOCK();
|
||||
vtCtx = vt_cupti_ctxList;
|
||||
while(vtCtx != NULL){
|
||||
if(vtCtx->cuCtx == cuCtx){
|
||||
VT_CUPTI_UNLOCK();
|
||||
return vtCtx;
|
||||
}
|
||||
vtCtx = vtCtx->next;
|
||||
}
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a VampirTrace CUPTI context by CUDA context without locking.
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
vt_cupti_ctx_t* vt_cupti_getCtxNoLock(CUcontext cuCtx)
|
||||
{
|
||||
vt_cupti_ctx_t* vtCtx = NULL;
|
||||
|
||||
vtCtx = vt_cupti_ctxList;
|
||||
while(vtCtx != NULL){
|
||||
if(vtCtx->cuCtx == cuCtx){
|
||||
return vtCtx;
|
||||
}
|
||||
vtCtx = vtCtx->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get or if not available create a VampirTrace CUPTI context by CUDA context.
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
vt_cupti_ctx_t* vt_cupti_getCreateCtx(CUcontext cuCtx)
|
||||
{
|
||||
vt_cupti_ctx_t* vtCtx = NULL;
|
||||
|
||||
/* lookup context */
|
||||
VT_CUPTI_LOCK();
|
||||
vtCtx = vt_cupti_ctxList;
|
||||
while(vtCtx != NULL){
|
||||
if(vtCtx->cuCtx == cuCtx){
|
||||
VT_CUPTI_UNLOCK();
|
||||
return vtCtx;
|
||||
}
|
||||
vtCtx = vtCtx->next;
|
||||
}
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
vtCtx = vt_cupti_createCtx(cuCtx, VT_CUPTI_NO_CUDA_DEVICE,
|
||||
VT_CUPTI_NO_CONTEXT_ID, VT_CUPTI_NO_DEVICE_ID);
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_cupti_prependCtx(vtCtx);
|
||||
|
||||
return vtCtx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove a context from the global context list and return it.
|
||||
*
|
||||
* @param cuCtx pointer to the CUDA context
|
||||
* @return the VampirTrace CUPTI context, which has been removed
|
||||
*/
|
||||
vt_cupti_ctx_t* vt_cupti_removeCtx(CUcontext *cuCtx)
|
||||
{
|
||||
vt_cupti_ctx_t *currCtx = NULL;
|
||||
vt_cupti_ctx_t *lastCtx = NULL;
|
||||
|
||||
VT_CUPTI_LOCK();
|
||||
currCtx = vt_cupti_ctxList;
|
||||
lastCtx = vt_cupti_ctxList;
|
||||
while(currCtx != NULL){
|
||||
if(currCtx->cuCtx == *cuCtx){
|
||||
/* if first element in list */
|
||||
if(currCtx == vt_cupti_ctxList){
|
||||
vt_cupti_ctxList = vt_cupti_ctxList->next;
|
||||
}else{
|
||||
lastCtx->next = currCtx->next;
|
||||
}
|
||||
VT_CUPTI_UNLOCK();
|
||||
return currCtx;
|
||||
}
|
||||
lastCtx = currCtx;
|
||||
currCtx = currCtx->next;
|
||||
}
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI] Could not remove context (CUDA Context not found)!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the allocated memory for this VampirTrace CUPTI context.
|
||||
*
|
||||
* @param vtCtx pointer to the VampirTrace CUPTI context
|
||||
*/
|
||||
void vt_cupti_freeCtx(vt_cupti_ctx_t *vtCtx)
|
||||
{
|
||||
if(vtCtx == NULL)
|
||||
return;
|
||||
|
||||
#if defined(VT_CUPTI_ACTIVITY)
|
||||
if(vtCtx->activity != NULL)
|
||||
free(vtCtx->activity);
|
||||
#endif
|
||||
|
||||
#if (defined(VT_CUPTI_CALLBACKS) && !defined(VT_CUPTI_ACTIVITY))
|
||||
if(vtCtx->callbacks != NULL)
|
||||
free(vtCtx->callbacks);
|
||||
#endif
|
||||
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
if(vtCtx->events != NULL)
|
||||
free(vtCtx->events);
|
||||
#endif
|
||||
|
||||
free(vtCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handles errors returned from CUPTI function calls.
|
||||
*
|
||||
* @param ecode the CUDA driver API error code
|
||||
* @param msg a message to get more detailed information about the error
|
||||
* @param the corresponding file
|
||||
* @param the line the error occurred
|
||||
*/
|
||||
void vt_cupti_handleError(CUptiResult err, const char* msg,
|
||||
const char *file, const int line)
|
||||
{
|
||||
const char *errstr;
|
||||
|
||||
if(msg != NULL) vt_cntl_msg(1, msg);
|
||||
|
||||
cuptiGetResultString(err, &errstr);
|
||||
|
||||
if(vt_gpu_error){
|
||||
vt_error_msg("[CUPTI] %s:%d:'%s'", file, line, errstr);
|
||||
}else{
|
||||
vt_warning("[CUPTI] %s:%d:'%s'", file, line, errstr);
|
||||
}
|
||||
}
|
317
ompi/contrib/vt/vt/vtlib/vt_cupti_common.h
Обычный файл
317
ompi/contrib/vt/vt/vtlib/vt_cupti_common.h
Обычный файл
@ -0,0 +1,317 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#ifndef VT_CUPTI_COMMON_H
|
||||
#define VT_CUPTI_COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_cuda_driver_api.h"
|
||||
#include "vt_cupti.h" /* the CUPTI header */
|
||||
|
||||
#define VT_CUPTI_NO_CUDA_DEVICE (CUdevice)VT_NO_ID
|
||||
#define VT_CUPTI_NO_DEVICE_ID VT_NO_ID
|
||||
#define VT_CUPTI_NO_CONTEXT_ID VT_NO_ID
|
||||
|
||||
#define VT_CUPTI_CALL(_err, _msg) \
|
||||
if(_err != CUPTI_SUCCESS){ \
|
||||
vt_cupti_handleError(_err, _msg,__FILE__, __LINE__); \
|
||||
}
|
||||
|
||||
/* mutex for locking the CUPTI environment */
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
EXTERN VTThrdMutex* VTThrdMutexCupti;
|
||||
# define VT_CUPTI_LOCK() VTThrd_lock(&VTThrdMutexCupti)
|
||||
# define VT_CUPTI_UNLOCK() VTThrd_unlock(&VTThrdMutexCupti)
|
||||
#else /* VT_MT || VT_HYB */
|
||||
# define VT_CUPTI_LOCK()
|
||||
# define VT_CUPTI_UNLOCK()
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
/*
|
||||
* VampirTrace CUPTI event (single linked list element)
|
||||
*/
|
||||
typedef struct vtcuptievtctr_st
|
||||
{
|
||||
CUpti_EventID cuptiEvtID; /**< CUPTI event ID */
|
||||
uint32_t vtCID; /**< VampirTrace counter ID */
|
||||
/*CUpti_EventDomainID cuptiDomainID; *< CUPTI domain ID */
|
||||
struct vtcuptievtctr_st *next;
|
||||
}vt_cupti_evtctr_t;
|
||||
|
||||
/*
|
||||
* Structure that stores events to be trace for specific device capability
|
||||
* (single linked list element)
|
||||
*/
|
||||
typedef struct vtcuptievtdev_st
|
||||
{
|
||||
int dev_major; /**< Major CUDA device capability */
|
||||
int dev_minor; /**< Minor CUDA device capability */
|
||||
CUdevice cuDev; /**< CUDA device */
|
||||
vt_cupti_evtctr_t *vtcuptiEvtList; /**< list of events to be traced for this device*/
|
||||
size_t evtNum; /**< Number of tracable CUPTI events */
|
||||
struct vtcuptievtdev_st *next;
|
||||
}vt_cupti_device_t;
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI event group and its counters and properties.
|
||||
*/
|
||||
typedef struct vtcuptievtgrp_st
|
||||
{
|
||||
CUpti_EventGroup evtGrp; /**< CUPTI event group, created for this context */
|
||||
CUpti_EventID *cuptiEvtIDs; /**< CUPTI event IDs to be traced */
|
||||
uint32_t *vtCIDs; /**< VampirTrace counter ids */
|
||||
size_t evtNum; /**< number of CUPTI events in this group */
|
||||
uint8_t enabled; /**< is the threads CUPTI capturing enabled */
|
||||
struct vtcuptievtgrp_st *next;
|
||||
}vt_cupti_evtgrp_t;
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI events specific context data.
|
||||
*/
|
||||
typedef struct vtcuptievents_st
|
||||
{
|
||||
vt_cupti_device_t *vtDevCap; /**< pointer to device capability (events, ...) */
|
||||
vt_cupti_evtgrp_t *vtGrpList; /**< list of VT CUPTI event groups */
|
||||
uint64_t *counterData; /**< preallocated buffer for counter data */
|
||||
CUpti_EventID *cuptiEvtIDs; /**< preallocated buffer for CUPTI event IDs*/
|
||||
}vt_cupti_events_t;
|
||||
#endif
|
||||
|
||||
#if (defined(VT_CUPTI_CALLBACKS) || defined(VT_CUPTI_ACTIVITY))
|
||||
/*
|
||||
* data structure contains information about allocated CUDA memory
|
||||
*/
|
||||
typedef struct vt_cupti_gpumem_st
|
||||
{
|
||||
void *memPtr; /**< pointer value to allocated memory */
|
||||
size_t size; /**< number of bytes allocated */
|
||||
uint32_t tid; /**< thread id used with this malloc */
|
||||
struct vt_cupti_gpumem_st *next;
|
||||
}vt_cupti_gpumem_t;
|
||||
#endif /* VT_CUPTI_CALLBACKS || VT_CUPTI_ACTIVITY */
|
||||
|
||||
#if defined(VT_CUPTI_CALLBACKS)
|
||||
/*
|
||||
* structure of a VampirTrace CUPTI CUDA stream
|
||||
*/
|
||||
typedef struct vt_cupticb_strm_st
|
||||
{
|
||||
CUstream stream; /**< the CUDA stream */
|
||||
uint32_t tid; /**< VT thread id for this stream (unique) */
|
||||
struct vt_cupticb_strm_st *next;
|
||||
}vt_cupticb_strm_t;
|
||||
|
||||
/*
|
||||
* structure of a VampirTrace CUPTI CUDA runtime kernel
|
||||
*/
|
||||
typedef struct vt_cupticb_kernel_st
|
||||
{
|
||||
cudaStream_t stream; /**< the CUDA stream */
|
||||
uint32_t blocksPerGrid; /**< number of blocks per grid */
|
||||
uint32_t threadsPerBlock; /**< number of threads per block */
|
||||
struct vt_cupticb_kernel_st *prev;
|
||||
}vt_cupti_kernel_t;
|
||||
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI callbacks specific context data.
|
||||
*/
|
||||
typedef struct vtcupticallbacks_st
|
||||
{
|
||||
# if defined(VT_CUPTI_ACTIVITY)
|
||||
uint8_t concurrentKernels;
|
||||
uint8_t streamsCreated;
|
||||
# else
|
||||
vt_cupti_gpumem_t *gpuMemList; /**< list of allocated GPU memory fields */
|
||||
size_t gpuMemAllocated; /**< memory allocated on CUDA device */
|
||||
vt_cupticb_strm_t *strmList; /**< CUDA stream list */
|
||||
uint32_t strmNum; /**< Number of streams created for this device */
|
||||
vt_cupti_kernel_t *kernelData; /**< pointer to top of CUDA runtime kernel
|
||||
configuration stack */
|
||||
uint8_t stack_size; /**< number of params on the stack */
|
||||
uint8_t callbacks_enabled; /**< execute callback function? */
|
||||
# endif
|
||||
}vt_cupti_callbacks_t;
|
||||
#endif
|
||||
|
||||
#if defined(VT_CUPTI_ACTIVITY)
|
||||
/*
|
||||
* VampirTrace CUPTI activity synchronization structure
|
||||
*/
|
||||
typedef struct vt_cuptiact_sync_st
|
||||
{
|
||||
uint64_t hostStart; /**< host measurement interval start timestamp */
|
||||
uint64_t hostStop; /**< host measurement interval stop timestamp */
|
||||
uint64_t gpuStart; /**< gpu measurement interval start timestamp */
|
||||
double factor; /**< synchronization factor for time interval */
|
||||
}vt_cupti_sync_t;
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI activity stream
|
||||
*/
|
||||
typedef struct vt_cuptiact_strm_st
|
||||
{
|
||||
uint32_t strmID; /**< the CUDA stream */
|
||||
uint32_t vtThrdID; /**< VT thread id for this stream (unique) */
|
||||
uint64_t vtLastTime; /**< last written VampirTrace timestamp */
|
||||
uint8_t destroyed; /**< Is stream destroyed? Ready for reuse? */
|
||||
struct vt_cuptiact_strm_st *next;
|
||||
}vt_cuptiact_strm_t;
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI activity specific context data.
|
||||
*/
|
||||
typedef struct vtcuptiactivity_st
|
||||
{
|
||||
vt_cuptiact_strm_t *strmList; /**< list of streams */
|
||||
uint32_t defaultStrmID; /**< CUPTI stream ID of default stream */
|
||||
vt_cupti_gpumem_t *gpuMemList; /**< list of allocated GPU memory fields */
|
||||
size_t gpuMemAllocated; /**< memory allocated on CUDA device */
|
||||
vt_cupti_sync_t sync; /**< store synchronization information */
|
||||
uint8_t *buffer; /**< CUPTI activity buffer pointer */
|
||||
uint64_t vtLastGPUTime; /**< last written VampirTrace timestamp */
|
||||
uint8_t gpuIdleOn; /**< has idle region enter been written last */
|
||||
}vt_cupti_activity_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI context.
|
||||
*/
|
||||
typedef struct vtcuptictx_st
|
||||
{
|
||||
CUcontext cuCtx; /**< CUDA context handle */
|
||||
uint32_t ctxID; /**< context ID */
|
||||
uint32_t devID; /**< device ID */
|
||||
CUdevice cuDev; /**< CUDA device handle */
|
||||
uint32_t ptid; /**< VampirTrace process/thread */
|
||||
#if defined(VT_CUPTI_EVENTS)
|
||||
vt_cupti_events_t* events;
|
||||
#endif
|
||||
#if defined(VT_CUPTI_ACTIVITY)
|
||||
vt_cupti_activity_t* activity;
|
||||
#endif
|
||||
#if defined(VT_CUPTI_CALLBACKS)
|
||||
vt_cupti_callbacks_t* callbacks;
|
||||
#endif
|
||||
struct vtcuptictx_st *next;
|
||||
}vt_cupti_ctx_t;
|
||||
|
||||
EXTERN vt_cupti_ctx_t *vt_cupti_ctxList;
|
||||
|
||||
/* CUPTI global CUDA kernel counter group ID */
|
||||
EXTERN uint32_t vt_cupti_cgid_cuda_kernel;
|
||||
|
||||
/* global counter IDs for CUPTI callback and activity API */
|
||||
EXTERN uint32_t vt_cupti_cid_blocksPerGrid;
|
||||
EXTERN uint32_t vt_cupti_cid_threadsPerBlock;
|
||||
EXTERN uint32_t vt_cupti_cid_threadsPerKernel;
|
||||
|
||||
EXTERN void vt_cupti_init(void);
|
||||
|
||||
EXTERN void vt_cupti_finalize(void);
|
||||
|
||||
/*
|
||||
* Handles errors returned from CUPTI function calls.
|
||||
*
|
||||
* @param ecode the CUDA driver API error code
|
||||
* @param msg a message to get more detailed information about the error
|
||||
* @param the corresponding file
|
||||
* @param the line the error occurred
|
||||
*/
|
||||
EXTERN void vt_cupti_handleError(CUptiResult err, const char* msg,
|
||||
const char *file, const int line);
|
||||
|
||||
/*
|
||||
* Create a VampirTrace CUPTI context.
|
||||
*
|
||||
* @param cuCtx CUDA context
|
||||
* @param cuDev CUDA device
|
||||
* @param ctxID ID of the CUDA context
|
||||
* @param devID ID of the CUDA device
|
||||
*
|
||||
* @return pointer to created VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN vt_cupti_ctx_t* vt_cupti_createCtx(CUcontext cuCtx,
|
||||
CUdevice cuDev,
|
||||
uint32_t cuCtxID,
|
||||
uint32_t devID);
|
||||
|
||||
/*
|
||||
* Prepend the given VampirTrace CUPTI context to the global context list.
|
||||
*
|
||||
* @param vtCtx pointer to the VampirTrace CUPTI context to be prepended
|
||||
*/
|
||||
EXTERN void vt_cupti_prependCtx(vt_cupti_ctx_t *vtCtx);
|
||||
|
||||
/*
|
||||
* Get a VampirTrace CUPTI context by CUDA context.
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN vt_cupti_ctx_t* vt_cupti_getCtx(CUcontext cuCtx);
|
||||
|
||||
/*
|
||||
* Get a VampirTrace CUPTI context by CUDA context without locking.
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN vt_cupti_ctx_t* vt_cupti_getCtxNoLock(CUcontext cuCtx);
|
||||
|
||||
/*
|
||||
* Retrieves the VampirTrace CUPTI context for the CUDA context associated with
|
||||
* the calling host thread.
|
||||
*
|
||||
* @param ptid the VampirTrace process/thread ID
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN vt_cupti_ctx_t* vt_cupti_getCurrentCtx(uint32_t ptid);
|
||||
|
||||
/*
|
||||
* Get or if not available create a VampirTrace CUPTI context by CUDA context.
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN vt_cupti_ctx_t* vt_cupti_getCreateCtx(CUcontext cuCtx);
|
||||
|
||||
/*
|
||||
* Remove a context from the global context list and return it.
|
||||
*
|
||||
* @param cuCtx pointer to the CUDA context
|
||||
*
|
||||
* @return the VampirTrace CUPTI context, which has been removed
|
||||
*/
|
||||
EXTERN vt_cupti_ctx_t* vt_cupti_removeCtx(CUcontext *cuCtx);
|
||||
|
||||
/*
|
||||
* Free the allocated memory for this VampirTrace CUPTI context.
|
||||
*
|
||||
* @param vtCtx pointer to the VampirTrace CUPTI context
|
||||
*/
|
||||
EXTERN void vt_cupti_freeCtx(vt_cupti_ctx_t *vtCtx);
|
||||
|
||||
#endif /* VT_CUPTI_COMMON_H */
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "vt_env.h" /* get environment variables */
|
||||
#include "vt_pform.h" /* VampirTrace time measurement */
|
||||
#include "vt_trc.h" /* VampirTrace events */
|
||||
#include "vt_mallocwrap.h" /* wrapping of malloc and free */
|
||||
#include "vt_cupti_events.h"
|
||||
#include "vt_gpu.h"
|
||||
|
||||
@ -25,16 +26,6 @@
|
||||
__FILE__, __LINE__, _msg, errstr); \
|
||||
}
|
||||
|
||||
/* mutexes for locking the CUPTI environment */
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
static VTThrdMutex* VTThrdMutexCupti = NULL;
|
||||
# define VT_CUPTIEVT_LOCK() VTThrd_lock(&VTThrdMutexCupti)
|
||||
# define VT_CUPTIEVT_UNLOCK() VTThrd_unlock(&VTThrdMutexCupti)
|
||||
#else /* VT_MT || VT_HYB */
|
||||
# define VT_CUPTIEVT_LOCK()
|
||||
# define VT_CUPTIEVT_UNLOCK()
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
|
||||
/* some of CUPTI API functions have changed */
|
||||
#if (defined(CUPTI_API_VERSION) && (CUPTI_API_VERSION >= 2))
|
||||
|
||||
@ -81,8 +72,7 @@ static uint8_t vt_cuptievt_finalized = 0;
|
||||
/* VampirTrace counter group ID */
|
||||
static uint32_t vt_cuptievt_cgid;
|
||||
|
||||
static vt_cuptievt_dev_t *vtcuptievtCapList = NULL;
|
||||
static vt_cuptievt_ctx_t *vtcuptievtCtxList = NULL;
|
||||
static vt_cupti_device_t *vtcuptievtCapList = NULL;
|
||||
|
||||
/***** --- Declaration of internally used functions --- *****/
|
||||
|
||||
@ -92,24 +82,24 @@ static vt_cuptievt_ctx_t *vtcuptievtCtxList = NULL;
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
*/
|
||||
static void vt_cuptievt_start(vt_cuptievt_ctx_t *vtcuptiCtx);
|
||||
static void vt_cuptievt_start(vt_cupti_events_t *vtcuptiEvtCtx);
|
||||
|
||||
/*
|
||||
* Disables recording of CUPTI counters.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
*/
|
||||
static void vt_cuptievt_stop(vt_cuptievt_ctx_t *vtcuptiCtx);
|
||||
static void vt_cuptievt_stop(vt_cupti_events_t *vtcuptiEvtCtx);
|
||||
|
||||
/*
|
||||
* Initialize a VampirTrace CUPTI context.
|
||||
* Initialize a VampirTrace CUPTI events context. This includes the creation/
|
||||
* memory allocation.
|
||||
*
|
||||
* @param ptid the VampirTrace process/thread id
|
||||
* @param cuCtx the CUDA context
|
||||
* @param cuDev the CUDA device
|
||||
*
|
||||
* @return pointer to the created VampirTrace CUPTI context
|
||||
*/
|
||||
static vt_cuptievt_ctx_t* vt_cuptievt_initCtx(uint32_t ptid, CUcontext cuCtx);
|
||||
static void vt_cuptievt_initCtx(vt_cupti_ctx_t *vtcuptiCtx);
|
||||
|
||||
/*
|
||||
* Get to current VampirTrace CUPTI context or create a new one, if CUDA context
|
||||
@ -120,30 +110,21 @@ static vt_cuptievt_ctx_t* vt_cuptievt_initCtx(uint32_t ptid, CUcontext cuCtx);
|
||||
*
|
||||
* @return the corresponding VampirTrace host thread structure.
|
||||
*/
|
||||
static vt_cuptievt_ctx_t* vt_cuptievt_getCtx(CUcontext cuCtx, uint32_t ptid);
|
||||
static vt_cupti_ctx_t* vt_cuptievt_getOrCreateCtx(CUcontext cuCtx, uint32_t ptid);
|
||||
|
||||
/*
|
||||
* Free the memory allocated for the given VampirTrace CUPTI context.
|
||||
* Free the memory allocated for the given VampirTrace CUPTI events context.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param vtcuptiEvtCtx pointer to the VampirTrace CUPTI events context
|
||||
*/
|
||||
static void vt_cuptievt_freeCtx(vt_cuptievt_ctx_t *vtcuptiCtx);
|
||||
|
||||
/*
|
||||
* Remove the given CUDA context from the global VampirTrace CUPTI context list.
|
||||
*
|
||||
* @param cuCtx pointer to the CUDA context
|
||||
*
|
||||
* @return the removed VampirTrace CUPTI context entry
|
||||
*/
|
||||
static vt_cuptievt_ctx_t* vt_cupti_takeCtxFromList(CUcontext *cuCtx);
|
||||
static void vt_cuptievt_freeEventCtx(vt_cupti_events_t *vtcuptiEvtCtx);
|
||||
|
||||
/*
|
||||
* De-initialize the VampirTrace CUPTI context without destroying it.
|
||||
* De-initialize the VampirTrace CUPTI events context without destroying it.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI events context
|
||||
*/
|
||||
static void vt_cuptievt_finish(vt_cuptievt_ctx_t *vtcuptiCtx);
|
||||
static void vt_cuptievt_finish(vt_cupti_events_t *vtcuptiEvtCtx);
|
||||
|
||||
/*
|
||||
* Create a VampirTrace CUPTI event group.
|
||||
@ -152,7 +133,7 @@ static void vt_cuptievt_finish(vt_cuptievt_ctx_t *vtcuptiCtx);
|
||||
*
|
||||
* @return the created VampirTrace CUPTI event group
|
||||
*/
|
||||
static vt_cuptievt_grp_t* vt_cuptievt_createEvtGrp(vt_cuptievt_ctx_t *vtcuptiCtx);
|
||||
static vt_cupti_evtgrp_t* vt_cuptievt_createEvtGrp(vt_cupti_ctx_t *vtcuptiCtx);
|
||||
|
||||
/*
|
||||
* Setup a list of devices with different device capabilities and add the
|
||||
@ -160,7 +141,7 @@ static vt_cuptievt_grp_t* vt_cuptievt_createEvtGrp(vt_cuptievt_ctx_t *vtcuptiCtx
|
||||
*
|
||||
* @return a list of CUDA devices with different device capabilities
|
||||
*/
|
||||
static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void);
|
||||
static vt_cupti_device_t* vt_cuptievt_setupMetricList(void);
|
||||
|
||||
/*
|
||||
* Parse the environment variable for CUPTI metrics (including CUDA device
|
||||
@ -168,7 +149,7 @@ static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void);
|
||||
*
|
||||
* @param capList points to the first element of the capability metric list
|
||||
*/
|
||||
static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList);
|
||||
static void vt_cupti_fillMetricList(vt_cupti_device_t *capList);
|
||||
|
||||
/*
|
||||
* Check whether the CUDA device capability is already listed.
|
||||
@ -179,7 +160,7 @@ static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList);
|
||||
*
|
||||
* @return pointer to the list entry (NULL if not found)
|
||||
*/
|
||||
static vt_cuptievt_dev_t* vt_cupti_checkMetricList(vt_cuptievt_dev_t *capList,
|
||||
static vt_cupti_device_t* vt_cupti_checkMetricList(vt_cupti_device_t *capList,
|
||||
int major, int minor);
|
||||
|
||||
/*
|
||||
@ -187,7 +168,7 @@ static vt_cuptievt_dev_t* vt_cupti_checkMetricList(vt_cuptievt_dev_t *capList,
|
||||
*
|
||||
* @param capList list of CUDA devices with different capabilities
|
||||
*/
|
||||
static void vt_cupti_showAllCounters(vt_cuptievt_dev_t *capList);
|
||||
static void vt_cupti_showAllCounters(vt_cupti_device_t *capList);
|
||||
|
||||
/*
|
||||
* Print all events for a given CUDA device and CUPTI event domain with name
|
||||
@ -201,12 +182,12 @@ static void vt_cuptievt_enumEvents(CUdevice cuDev, CUpti_EventDomainID domainId)
|
||||
|
||||
/* ----------------------- internally used functions ----------------------- */
|
||||
|
||||
static vt_cuptievt_grp_t* vt_cuptievt_createEvtGrp(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
static vt_cupti_evtgrp_t* vt_cuptievt_createEvtGrp(vt_cupti_ctx_t *vtcuptiCtx)
|
||||
{
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = NULL;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = NULL;
|
||||
|
||||
vtcuptiGrp = (vt_cuptievt_grp_t*)malloc(sizeof(vt_cuptievt_grp_t));
|
||||
vtcuptiGrp = (vt_cupti_evtgrp_t*)malloc(sizeof(vt_cupti_evtgrp_t));
|
||||
vtcuptiGrp->evtNum = 0;
|
||||
vtcuptiGrp->enabled = 0;
|
||||
vtcuptiGrp->next = NULL;
|
||||
@ -215,22 +196,28 @@ static vt_cuptievt_grp_t* vt_cuptievt_createEvtGrp(vt_cuptievt_ctx_t *vtcuptiCtx
|
||||
cuptiErr = cuptiEventGroupCreate(vtcuptiCtx->cuCtx, &(vtcuptiGrp->evtGrp), 0);
|
||||
VT_CUPTI_CALL(cuptiErr, "cuptiEventGroupCreate");
|
||||
|
||||
vtcuptiGrp->cuptiEvtIDs = (CUpti_EventID *)malloc(
|
||||
vtcuptiCtx->vtDevCap->evtNum*sizeof(CUpti_EventID));
|
||||
vtcuptiGrp->vtCIDs = (uint32_t *)malloc(
|
||||
vtcuptiCtx->vtDevCap->evtNum*sizeof(uint32_t));
|
||||
{
|
||||
size_t evtNum = vtcuptiCtx->events->vtDevCap->evtNum;
|
||||
|
||||
vtcuptiGrp->cuptiEvtIDs =
|
||||
(CUpti_EventID *)malloc(evtNum*sizeof(CUpti_EventID));
|
||||
|
||||
vtcuptiGrp->vtCIDs =
|
||||
(uint32_t *)malloc(evtNum*sizeof(uint32_t));
|
||||
}
|
||||
|
||||
return vtcuptiGrp;
|
||||
}
|
||||
|
||||
static void vt_cupti_addEvtGrpsToCtx(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
static void vt_cupti_addEvtGrpsToCtx(vt_cupti_ctx_t *vtcuptiCtx)
|
||||
{
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = vt_cuptievt_createEvtGrp(vtcuptiCtx);
|
||||
vt_cuptievt_evt_t *vtcuptiEvt = vtcuptiCtx->vtDevCap->vtcuptiEvtList;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = vt_cuptievt_createEvtGrp(vtcuptiCtx);
|
||||
vt_cupti_events_t *vtcuptiEvents = vtcuptiCtx->events;
|
||||
vt_cupti_evtctr_t *vtcuptiEvt = vtcuptiEvents->vtDevCap->vtcuptiEvtList;
|
||||
|
||||
/* try to add all events for current context/device */
|
||||
while(vtcuptiEvt != NULL && vtcuptiGrp->evtNum < vtcuptiCtx->vtDevCap->evtNum){
|
||||
while(vtcuptiEvt != NULL && vtcuptiGrp->evtNum < vtcuptiEvents->vtDevCap->evtNum){
|
||||
cuptiErr = cuptiEventGroupAddEvent(vtcuptiGrp->evtGrp,
|
||||
vtcuptiEvt->cuptiEvtID);
|
||||
|
||||
@ -252,8 +239,8 @@ static void vt_cupti_addEvtGrpsToCtx(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
|
||||
/* prepend last group to list, if it is not empty */
|
||||
if(vtcuptiGrp->evtNum > 0){
|
||||
vtcuptiGrp->next = vtcuptiCtx->vtGrpList;
|
||||
vtcuptiCtx->vtGrpList = vtcuptiGrp;
|
||||
vtcuptiGrp->next = vtcuptiEvents->vtGrpList;
|
||||
vtcuptiEvents->vtGrpList = vtcuptiGrp;
|
||||
}
|
||||
|
||||
/* create new VampirTrace CUPTI event group */
|
||||
@ -271,72 +258,53 @@ static void vt_cupti_addEvtGrpsToCtx(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
|
||||
/* prepend last group to list, if it is not empty */
|
||||
if(vtcuptiGrp->evtNum > 0){
|
||||
vtcuptiGrp->next = vtcuptiCtx->vtGrpList;
|
||||
vtcuptiCtx->vtGrpList = vtcuptiGrp;
|
||||
vtcuptiGrp->next = vtcuptiEvents->vtGrpList;
|
||||
vtcuptiEvents->vtGrpList = vtcuptiGrp;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes a CUPTI host thread and create the event group.
|
||||
*
|
||||
* @param ptid the VampirTrace thread id
|
||||
* @param cuCtx optionally given CUDA context
|
||||
*
|
||||
* @return the created VampirTrace CUPTI host thread structure
|
||||
* @param vtcuptiCtx optionally given CUDA context
|
||||
*/
|
||||
static vt_cuptievt_ctx_t* vt_cuptievt_initCtx(uint32_t ptid, CUcontext cuCtx)
|
||||
static void vt_cuptievt_initCtx(vt_cupti_ctx_t *vtcuptiCtx)
|
||||
{
|
||||
vt_cuptievt_ctx_t *vtcuptiCtx = NULL;
|
||||
uint64_t time;
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Initializing VampirTrace CUPTI context (ptid=%d)",
|
||||
ptid);
|
||||
vt_cupti_events_t *vtcuptiEvtCtx = NULL;
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(ptid, &time, vt_cuptievt_rid_init);
|
||||
|
||||
/* initialize CUDA driver API, if necessary and get context handle */
|
||||
if(cuCtx == NULL){
|
||||
#if (defined(CUDA_VERSION) && (CUDA_VERSION < 4000))
|
||||
CHECK_CU_ERROR(cuCtxPopCurrent(&cuCtx), "cuCtxPopCurrent");
|
||||
CHECK_CU_ERROR(cuCtxPushCurrent(cuCtx), "cuCtxPushCurrent");
|
||||
#else
|
||||
CHECK_CU_ERROR(cuCtxGetCurrent(&cuCtx), "cuCtxGetCurrent");
|
||||
#endif
|
||||
}
|
||||
vt_cntl_msg(2, "[CUPTI Events] Initializing VampirTrace CUPTI events context");
|
||||
|
||||
/* get a pointer to eventIDArray */
|
||||
{
|
||||
CUresult cuErr = CUDA_SUCCESS;
|
||||
int dev_major, dev_minor;
|
||||
CUdevice cuDev = 0;
|
||||
vt_cuptievt_dev_t *cuptiDev;
|
||||
vt_cupti_device_t *cuptiDev;
|
||||
|
||||
/*CHECK_CU_ERROR(cuCtxGetDevice(&cuDev), "cuCtxGetDevice");*/
|
||||
|
||||
CHECK_CU_ERROR(cuCtxGetDevice(&cuDev), "cuCtxGetDevice");
|
||||
|
||||
cuErr = cuDeviceComputeCapability(&dev_major, &dev_minor, cuDev);
|
||||
cuErr = cuDeviceComputeCapability(&dev_major, &dev_minor, vtcuptiCtx->cuDev);
|
||||
CHECK_CU_ERROR(cuErr, "cuDeviceComputeCapability");
|
||||
|
||||
/* check if device capability already listed */
|
||||
VT_CUPTIEVT_LOCK();
|
||||
VT_CUPTI_LOCK();
|
||||
cuptiDev = vtcuptievtCapList;
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
|
||||
cuptiDev = vt_cupti_checkMetricList(cuptiDev, dev_major, dev_minor);
|
||||
if(cuptiDev){
|
||||
vtcuptiCtx = (vt_cuptievt_ctx_t*)malloc(sizeof(vt_cuptievt_ctx_t));
|
||||
if(vtcuptiCtx == NULL)
|
||||
vt_error_msg("malloc(sizeof(VTCUPTIhostThrd)) failed!");
|
||||
vtcuptiCtx->cuCtx = cuCtx;
|
||||
vtcuptiCtx->vtDevCap = cuptiDev;
|
||||
vtcuptiCtx->vtGrpList = NULL;
|
||||
vtcuptiCtx->counterData = NULL;
|
||||
vtcuptiCtx->cuptiEvtIDs = NULL;
|
||||
vtcuptiCtx->next = NULL;
|
||||
if(cuptiDev){
|
||||
/* allocate the VampirTrace CUPTI events context */
|
||||
vtcuptiEvtCtx = (vt_cupti_events_t *)malloc(sizeof(vt_cupti_events_t));
|
||||
if(vtcuptiEvtCtx == NULL)
|
||||
vt_error_msg("malloc(sizeof(vt_cupti_events_t)) failed!");
|
||||
|
||||
vtcuptiEvtCtx->vtDevCap = cuptiDev;
|
||||
vtcuptiEvtCtx->vtGrpList = NULL;
|
||||
vtcuptiEvtCtx->counterData = NULL;
|
||||
vtcuptiEvtCtx->cuptiEvtIDs = NULL;
|
||||
|
||||
vtcuptiCtx->events = vtcuptiEvtCtx;
|
||||
}else{
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(ptid, &time);
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,27 +313,18 @@ static vt_cuptievt_ctx_t* vt_cuptievt_initCtx(uint32_t ptid, CUcontext cuCtx)
|
||||
|
||||
/* allocate memory for CUPTI counter reads */
|
||||
{
|
||||
size_t allocSize = vtcuptiCtx->vtGrpList->evtNum;
|
||||
size_t allocSize = vtcuptiEvtCtx->vtGrpList->evtNum;
|
||||
|
||||
vtcuptiCtx->counterData = (uint64_t *)malloc(allocSize*sizeof(uint64_t));
|
||||
vtcuptiCtx->cuptiEvtIDs = (CUpti_EventID *)malloc(allocSize*sizeof(CUpti_EventID));
|
||||
vtcuptiEvtCtx->counterData =
|
||||
(uint64_t *)malloc(allocSize*sizeof(uint64_t));
|
||||
vtcuptiEvtCtx->cuptiEvtIDs =
|
||||
(CUpti_EventID *)malloc(allocSize*sizeof(CUpti_EventID));
|
||||
}
|
||||
|
||||
/* add VampirTrace CUPTI context entry to list (as first element) */
|
||||
VT_CUPTIEVT_LOCK();
|
||||
vtcuptiCtx->next = vtcuptievtCtxList;
|
||||
vtcuptievtCtxList = vtcuptiCtx;
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(ptid, &time);
|
||||
|
||||
return vtcuptiCtx;
|
||||
}
|
||||
|
||||
static void vt_cuptievt_freeCtx(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
static void vt_cuptievt_freeEventCtx(vt_cupti_events_t *vtcuptiEvtCtx)
|
||||
{
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
|
||||
while(vtcuptiGrp != NULL){
|
||||
free(vtcuptiGrp->cuptiEvtIDs);
|
||||
@ -375,11 +334,8 @@ static void vt_cuptievt_freeCtx(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
}
|
||||
|
||||
/* free memory for CUPTI counter reads */
|
||||
free(vtcuptiCtx->counterData);
|
||||
free(vtcuptiCtx->cuptiEvtIDs);
|
||||
|
||||
/* free the VampirTrace CUPTI context structure itself */
|
||||
free(vtcuptiCtx);
|
||||
free(vtcuptiEvtCtx->counterData);
|
||||
free(vtcuptiEvtCtx->cuptiEvtIDs);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -387,43 +343,44 @@ static void vt_cuptievt_freeCtx(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
*
|
||||
* @param cuCtx the CUDA context
|
||||
* @param ptid the active VampirTrace thread id
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
static vt_cuptievt_ctx_t* vt_cuptievt_getCtx(CUcontext cuCtx, uint32_t ptid)
|
||||
static vt_cupti_ctx_t* vt_cuptievt_getOrCreateCtx(CUcontext cuCtx, uint32_t ptid)
|
||||
{
|
||||
vt_cuptievt_ctx_t *vtcuptiCtx = NULL;
|
||||
|
||||
/* check, if there has been at least one VampirTrace CUPTI context created */
|
||||
if(vtcuptievtCtxList == NULL) vt_cupti_events_init();
|
||||
vt_cupti_ctx_t *vtcuptiCtx = NULL;
|
||||
|
||||
uint64_t time;
|
||||
|
||||
/* check, if the current VampirTrace thread is enabled for GPU counters */
|
||||
if((vt_gpu_prop[ptid] & VTGPU_NO_PC) == VTGPU_NO_PC)
|
||||
return NULL;
|
||||
|
||||
/* check if CUDA context is listed (linear search) */
|
||||
VT_CUPTIEVT_LOCK();
|
||||
vtcuptiCtx = vtcuptievtCtxList;
|
||||
while(vtcuptiCtx != NULL){
|
||||
if(vtcuptiCtx->cuCtx == cuCtx){
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
/*vt_cntl_msg(1, "[CUPTI EVENTS] host thread %d (MPI rank %d)", ptid, vt_my_trace);*/
|
||||
return vtcuptiCtx;
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(ptid, &time, vt_cuptievt_rid_init);
|
||||
|
||||
/* retrieve a global VampirTrace CUPTI context */
|
||||
vtcuptiCtx = vt_cupti_getCreateCtx(cuCtx);
|
||||
|
||||
/* if the event context is not available yet, then create it */
|
||||
if(NULL == vtcuptiCtx->events){
|
||||
|
||||
vt_cuptievt_initCtx(vtcuptiCtx);
|
||||
|
||||
/* start gathering counter values, if context was successfully initialized */
|
||||
if(NULL != vtcuptiCtx->events){
|
||||
vt_cuptievt_start(vtcuptiCtx->events);
|
||||
}else{
|
||||
/* no performance counters for this thread available */
|
||||
vt_gpu_prop[ptid] |= VTGPU_NO_PC;
|
||||
vt_cntl_msg(2, "[CUPTI Events] Could not initialize!");
|
||||
}
|
||||
vtcuptiCtx = vtcuptiCtx->next;
|
||||
|
||||
}
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Context for VT tid=%d unknown! Creating ... ",
|
||||
ptid);
|
||||
|
||||
vtcuptiCtx = vt_cuptievt_initCtx(ptid, NULL);
|
||||
if(vtcuptiCtx != NULL){
|
||||
vt_cuptievt_start(vtcuptiCtx);
|
||||
}else{
|
||||
/* no performance counters for this thread available */
|
||||
vt_gpu_prop[ptid] |= VTGPU_NO_PC;
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Could not initialize!");
|
||||
}
|
||||
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(ptid, &time);
|
||||
|
||||
return vtcuptiCtx;
|
||||
}
|
||||
|
||||
@ -433,7 +390,7 @@ static vt_cuptievt_ctx_t* vt_cuptievt_getCtx(CUcontext cuCtx, uint32_t ptid)
|
||||
*
|
||||
* @param capList points to the first element of the capability metric list
|
||||
*/
|
||||
static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList)
|
||||
static void vt_cupti_fillMetricList(vt_cupti_device_t *capList)
|
||||
{
|
||||
char *metricString = vt_env_cupti_events();
|
||||
char *metric_sep = vt_env_metrics_sep();
|
||||
@ -443,8 +400,8 @@ static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList)
|
||||
|
||||
while (metric != NULL){
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
vt_cuptievt_dev_t *cuptiDev = NULL;
|
||||
vt_cuptievt_evt_t *vtcuptiEvt = NULL;
|
||||
vt_cupti_device_t *cuptiDev = NULL;
|
||||
vt_cupti_evtctr_t *vtcuptiEvt = NULL;
|
||||
int metr_major = 0;
|
||||
int metr_minor = 0;
|
||||
|
||||
@ -468,7 +425,7 @@ static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList)
|
||||
continue;
|
||||
}
|
||||
|
||||
vtcuptiEvt = (vt_cuptievt_evt_t*)malloc(sizeof(vt_cuptievt_evt_t));
|
||||
vtcuptiEvt = (vt_cupti_evtctr_t*)malloc(sizeof(vt_cupti_evtctr_t));
|
||||
cuptiErr = cuptiEventGetIdFromName(cuptiDev->cuDev, metric,
|
||||
&vtcuptiEvt->cuptiEvtID);
|
||||
if(cuptiErr != CUPTI_SUCCESS){
|
||||
@ -498,7 +455,7 @@ static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList)
|
||||
|
||||
cuptiDev = capList;
|
||||
while(cuptiDev != NULL){
|
||||
vtcuptiEvt = (vt_cuptievt_evt_t*)malloc(sizeof(vt_cuptievt_evt_t));
|
||||
vtcuptiEvt = (vt_cupti_evtctr_t*)malloc(sizeof(vt_cupti_evtctr_t));
|
||||
cuptiErr = cuptiEventGetIdFromName(cuptiDev->cuDev, metric,
|
||||
&vtcuptiEvt->cuptiEvtID);
|
||||
|
||||
@ -542,10 +499,10 @@ static void vt_cupti_fillMetricList(vt_cuptievt_dev_t *capList)
|
||||
*
|
||||
* @return pointer to the list entry (NULL if not found)
|
||||
*/
|
||||
static vt_cuptievt_dev_t* vt_cupti_checkMetricList(vt_cuptievt_dev_t *capList,
|
||||
static vt_cupti_device_t* vt_cupti_checkMetricList(vt_cupti_device_t *capList,
|
||||
int major, int minor)
|
||||
{
|
||||
vt_cuptievt_dev_t *cuptiDev;
|
||||
vt_cupti_device_t *cuptiDev;
|
||||
|
||||
/* check if device capability is already listed and return it if found */
|
||||
cuptiDev = capList;
|
||||
@ -565,11 +522,13 @@ static vt_cuptievt_dev_t* vt_cupti_checkMetricList(vt_cuptievt_dev_t *capList,
|
||||
*
|
||||
* @return a list of CUDA devices with different device capabilities
|
||||
*/
|
||||
static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void)
|
||||
static vt_cupti_device_t* vt_cuptievt_setupMetricList(void)
|
||||
{
|
||||
CUresult err;
|
||||
int deviceCount, id;
|
||||
vt_cuptievt_dev_t *capList = NULL;
|
||||
vt_cupti_device_t *capList = NULL;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* CUDA initialization */
|
||||
CHECK_CU_ERROR(cuInit(0), "cuInit");
|
||||
@ -584,7 +543,7 @@ static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void)
|
||||
/* create list with available compute capabilities */
|
||||
for(id = 0; id < deviceCount; id++){
|
||||
CUdevice cuDev;
|
||||
vt_cuptievt_dev_t *cuptiDev;
|
||||
vt_cupti_device_t *cuptiDev;
|
||||
int dev_major, dev_minor;
|
||||
|
||||
err = cuDeviceGet(&cuDev, id);
|
||||
@ -598,7 +557,7 @@ static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void)
|
||||
|
||||
if(cuptiDev == NULL){
|
||||
/* allocate memory for device list entry */
|
||||
cuptiDev = (vt_cuptievt_dev_t *)malloc(sizeof(vt_cuptievt_dev_t));
|
||||
cuptiDev = (vt_cupti_device_t *)malloc(sizeof(vt_cupti_device_t));
|
||||
cuptiDev->dev_major = dev_major;
|
||||
cuptiDev->dev_minor = dev_minor;
|
||||
cuptiDev->cuDev = cuDev;
|
||||
@ -616,11 +575,11 @@ static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void)
|
||||
|
||||
/* cleanup list: remove entries, which don't have metrics */
|
||||
{
|
||||
vt_cuptievt_dev_t *curr = capList;
|
||||
vt_cuptievt_dev_t *last = capList;
|
||||
vt_cupti_device_t *curr = capList;
|
||||
vt_cupti_device_t *last = capList;
|
||||
|
||||
while(curr != NULL){
|
||||
vt_cuptievt_dev_t *freeDev = curr;
|
||||
vt_cupti_device_t *freeDev = curr;
|
||||
curr = curr->next;
|
||||
|
||||
if(freeDev->evtNum == 0){
|
||||
@ -634,6 +593,8 @@ static vt_cuptievt_dev_t* vt_cuptievt_setupMetricList(void)
|
||||
}else last = freeDev;
|
||||
}
|
||||
}
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return capList;
|
||||
}
|
||||
@ -715,7 +676,7 @@ static void vt_cuptievt_enumEvents(CUdevice cuDev, CUpti_EventDomainID domainId)
|
||||
*
|
||||
* @param capList list of CUDA devices with different capabilities
|
||||
*/
|
||||
static void vt_cupti_showAllCounters(vt_cuptievt_dev_t *capList)
|
||||
static void vt_cupti_showAllCounters(vt_cupti_device_t *capList)
|
||||
{
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
CUpti_EventDomainID *domainId = NULL;
|
||||
@ -766,29 +727,30 @@ static void vt_cupti_showAllCounters(vt_cuptievt_dev_t *capList)
|
||||
* -> vt_cupti_showAllCounters
|
||||
*/
|
||||
vt_cuptievt_initialized = 1;
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
static void vt_cuptievt_start(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
static void vt_cuptievt_start(vt_cupti_events_t *vtcuptiEvtCtx)
|
||||
{
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = NULL;
|
||||
vt_cuptievt_grp_t *lastGrp = NULL;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = NULL;
|
||||
vt_cupti_evtgrp_t *lastGrp = NULL;
|
||||
|
||||
if(vtcuptiCtx == NULL) return;
|
||||
if(vtcuptiEvtCtx == NULL)
|
||||
return;
|
||||
|
||||
/* start all groups */
|
||||
vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
lastGrp = vtcuptiCtx->vtGrpList;
|
||||
vtcuptiGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
lastGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
while(vtcuptiGrp != NULL){
|
||||
cuptiErr = cuptiEventGroupEnable(vtcuptiGrp->evtGrp);
|
||||
|
||||
/* if the event group could not be enabled, remove it */
|
||||
if(cuptiErr != CUPTI_SUCCESS){
|
||||
size_t i;
|
||||
vt_cuptievt_grp_t *freeGrp = vtcuptiGrp;
|
||||
vt_cupti_evtgrp_t *freeGrp = vtcuptiGrp;
|
||||
size_t valueSize = 32;
|
||||
char name[32];
|
||||
|
||||
@ -796,17 +758,17 @@ static void vt_cuptievt_start(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
|
||||
/* give user information about the group, which cannot be enabled */
|
||||
for(i = 0; i < freeGrp->evtNum; i++){
|
||||
VTCUPTIEVENTGETATTRIBUTE(vtcuptiCtx->vtDevCap->cuDev,
|
||||
VTCUPTIEVENTGETATTRIBUTE(vtcuptiEvtCtx->vtDevCap->cuDev,
|
||||
*(freeGrp->cuptiEvtIDs)+i,
|
||||
CUPTI_EVENT_ATTR_NAME,
|
||||
&valueSize, (char*)name);
|
||||
vt_warning("[CUPTI EVENTS] Event '%s' (%d) cannot be enabled",
|
||||
vt_warning("[CUPTI Events] Event '%s' (%d) cannot be enabled",
|
||||
name, *(freeGrp->cuptiEvtIDs)+i);
|
||||
}
|
||||
|
||||
/* group is first element in linked list */
|
||||
if(vtcuptiCtx->vtGrpList == freeGrp){
|
||||
vtcuptiCtx->vtGrpList = vtcuptiCtx->vtGrpList->next;
|
||||
if(vtcuptiEvtCtx->vtGrpList == freeGrp){
|
||||
vtcuptiEvtCtx->vtGrpList = vtcuptiEvtCtx->vtGrpList->next;
|
||||
}else{/* has to be at least the second group in linked list */
|
||||
lastGrp->next = freeGrp->next;
|
||||
}
|
||||
@ -825,17 +787,19 @@ static void vt_cuptievt_start(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
/*
|
||||
* Stop CUPTI counter capturing by disabling the CUPTI event groups.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param vtcuptiEvtCtx pointer to the VampirTrace CUPTI events context
|
||||
*/
|
||||
static void vt_cuptievt_stop(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
static void vt_cuptievt_stop(vt_cupti_events_t *vtcuptiEvtCtx)
|
||||
{
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = NULL;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = NULL;
|
||||
|
||||
/*vt_cntl_msg(1, "[CUPTI EVENTS] vt_cupti_stop() ... ");*/
|
||||
|
||||
if(vtcuptiCtx == NULL || vt_gpu_debug) return;
|
||||
if(vtcuptiEvtCtx == NULL || vt_gpu_debug)
|
||||
return;
|
||||
|
||||
/* stop counter reading for all groups */
|
||||
vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
vtcuptiGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
while(vtcuptiGrp != NULL){
|
||||
if(vtcuptiGrp->enabled){
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
@ -851,25 +815,26 @@ static void vt_cuptievt_stop(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
}
|
||||
|
||||
/*
|
||||
* De-initialize the VampirTrace CUPTI context without destroying it.
|
||||
* De-initialize the VampirTrace CUPTI event context without destroying it.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param vtcuptiEvtCtx pointer to the VampirTrace CUPTI events context
|
||||
*/
|
||||
static void vt_cuptievt_finish(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
static void vt_cuptievt_finish(vt_cupti_events_t *vtcuptiEvtCtx)
|
||||
{
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
|
||||
if(vtcuptiCtx == NULL || vt_gpu_debug) return;
|
||||
if(vtcuptiEvtCtx == NULL || vt_gpu_debug)
|
||||
return;
|
||||
|
||||
/*uint64_t time = vt_pform_wtime();
|
||||
vt_cupti_resetCounter(vtcuptiCtx, 0, &time);*/
|
||||
|
||||
/* stop CUPTI counter capturing */
|
||||
vt_cuptievt_stop(vtcuptiCtx);
|
||||
vt_cuptievt_stop(vtcuptiEvtCtx);
|
||||
|
||||
/* destroy all CUPTI event groups, which have been created */
|
||||
{
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
|
||||
while(vtcuptiGrp != NULL){
|
||||
cuptiErr = cuptiEventGroupRemoveAllEvents(vtcuptiGrp->evtGrp);
|
||||
@ -883,70 +848,33 @@ static void vt_cuptievt_finish(vt_cuptievt_ctx_t *vtcuptiCtx)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the given CUDA context from the global VampirTrace CUPTI context list.
|
||||
*
|
||||
* @param cuCtx pointer to the CUDA context
|
||||
*
|
||||
* @return the removed VampirTrace CUPTI context entry
|
||||
*/
|
||||
static vt_cuptievt_ctx_t* vt_cupti_takeCtxFromList(CUcontext *cuCtx)
|
||||
{
|
||||
vt_cuptievt_ctx_t *currCtx = NULL;
|
||||
vt_cuptievt_ctx_t *lastCtx = NULL;
|
||||
|
||||
VT_CUPTIEVT_LOCK();
|
||||
currCtx = vtcuptievtCtxList;
|
||||
lastCtx = vtcuptievtCtxList;
|
||||
while(currCtx != NULL){
|
||||
if(currCtx->cuCtx == *cuCtx){
|
||||
/* if first element in list */
|
||||
if(currCtx == vtcuptievtCtxList){
|
||||
vtcuptievtCtxList = vtcuptievtCtxList->next;
|
||||
}else{
|
||||
lastCtx->next = currCtx->next;
|
||||
}
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
return currCtx;
|
||||
}
|
||||
lastCtx = currCtx;
|
||||
currCtx = currCtx->next;
|
||||
}
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Context structure not found!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* -------------START: Implementation of public functions ------------------ */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Initialize Mutex, VampirTrace IDs and registers the finalize function.
|
||||
* Initialize VampirTrace IDs and registers the finalize function.
|
||||
* This may be done implicitly by vt_cupti_count().
|
||||
*/
|
||||
void vt_cupti_events_init()
|
||||
{
|
||||
if(!vt_cuptievt_initialized){
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTThrd_createMutex(&VTThrdMutexCupti);
|
||||
#endif
|
||||
VT_CUPTIEVT_LOCK();
|
||||
if(!vt_cuptievt_initialized){ /* fast check without lock */
|
||||
vt_cupti_init();
|
||||
VT_CUPTI_LOCK();
|
||||
if(!vt_cuptievt_initialized){
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Initializing ... ");
|
||||
vt_cntl_msg(2, "[CUPTI Events] Initializing ... ");
|
||||
|
||||
/* create VampirTrace counter group ID only once */
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
#endif
|
||||
#endif
|
||||
vt_cuptievt_rid_init = vt_def_region(VT_MASTER_THREAD, "vtcuptiHostThreadInit",
|
||||
VT_NO_ID, VT_NO_LNO, VT_NO_LNO, "VT_CUPTI", VT_FUNCTION);
|
||||
|
||||
vt_cuptievt_cgid = vt_def_counter_group(VT_MASTER_THREAD, "CUPTI");
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vtcuptievtCapList = vt_cuptievt_setupMetricList();
|
||||
|
||||
@ -955,43 +883,41 @@ void vt_cupti_events_init()
|
||||
atexit(vt_cupti_events_finalize);
|
||||
|
||||
vt_cuptievt_initialized = 1;
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
VT_CUPTI_UNLOCK();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalizes the VampirTrace CUPTI implementation.
|
||||
* Finalizes the VampirTrace CUPTI events interface.
|
||||
*/
|
||||
void vt_cupti_events_finalize()
|
||||
{
|
||||
if(!vt_cuptievt_finalized){
|
||||
if(!vt_cuptievt_finalized && vt_cuptievt_initialized){ /* fast check without lock */
|
||||
VT_CUPTI_LOCK();
|
||||
if(!vt_cuptievt_finalized && vt_cuptievt_initialized){
|
||||
vt_cupti_ctx_t *vtcuptiCtxList = vt_cupti_ctxList;
|
||||
|
||||
VT_CUPTIEVT_LOCK();
|
||||
if(!vt_cuptievt_finalized){
|
||||
vt_cntl_msg(2, "[CUPTI Events] Finalizing ...");
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Finalizing ...");
|
||||
/* free VampirTrace CUPTI events context structures */
|
||||
while(vtcuptiCtxList != NULL){
|
||||
vt_cuptievt_finish(vtcuptiCtxList->events);
|
||||
|
||||
/* free VampirTrace CUPTI context structures (should already be freed) */
|
||||
while(vtcuptievtCtxList != NULL){
|
||||
vt_cuptievt_ctx_t *tmp = vtcuptievtCtxList;
|
||||
vtcuptiCtxList = vtcuptiCtxList->next;
|
||||
|
||||
vt_cuptievt_finish(vtcuptievtCtxList);
|
||||
|
||||
vtcuptievtCtxList = vtcuptievtCtxList->next;
|
||||
|
||||
free(tmp);
|
||||
tmp = NULL;
|
||||
free(vtcuptiCtxList->events);
|
||||
vtcuptiCtxList->events = NULL;
|
||||
}
|
||||
|
||||
/* free capability metric list */
|
||||
while(vtcuptievtCapList != NULL){
|
||||
vt_cuptievt_dev_t *tmp = vtcuptievtCapList;
|
||||
vt_cupti_device_t *tmp = vtcuptievtCapList;
|
||||
vtcuptievtCapList = vtcuptievtCapList->next;
|
||||
|
||||
/* free VampirTrace CUPTI events */
|
||||
while(tmp->vtcuptiEvtList != NULL){
|
||||
vt_cuptievt_evt_t *tmpEvt = tmp->vtcuptiEvtList;
|
||||
vt_cupti_evtctr_t *tmpEvt = tmp->vtcuptiEvtList;
|
||||
tmp->vtcuptiEvtList = tmp->vtcuptiEvtList->next;
|
||||
free(tmpEvt);
|
||||
tmpEvt = NULL;
|
||||
@ -1002,24 +928,21 @@ void vt_cupti_events_finalize()
|
||||
}
|
||||
|
||||
vt_cuptievt_finalized = 1;
|
||||
VT_CUPTIEVT_UNLOCK();
|
||||
|
||||
#if (defined(VT_MT) || defined (VT_HYB))
|
||||
VTTHRD_LOCK_ENV();
|
||||
VTThrd_deleteMutex(&VTThrdMutexCupti);
|
||||
VTTHRD_UNLOCK_ENV();
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
VT_CUPTI_UNLOCK();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the VampirTrace CUPTI context for the CUDA context associated with
|
||||
* the calling host thread.
|
||||
* Retrieves the VampirTrace CUPTI context for the CUDA context associated with
|
||||
* the calling host thread. Initiates context creation, if it is not available
|
||||
* yet.
|
||||
*
|
||||
* @param ptid the VampirTrace thread id of the calling host thread
|
||||
*
|
||||
* @return VampirTrace CUPTI context
|
||||
*/
|
||||
vt_cuptievt_ctx_t* vt_cuptievt_getCurrentContext(uint32_t ptid)
|
||||
vt_cupti_ctx_t* vt_cuptievt_getOrCreateCurrentCtx(uint32_t ptid)
|
||||
{
|
||||
CUcontext cuCtx = NULL;
|
||||
|
||||
@ -1037,34 +960,34 @@ vt_cuptievt_ctx_t* vt_cuptievt_getCurrentContext(uint32_t ptid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return vt_cuptievt_getCtx(cuCtx, ptid);
|
||||
return vt_cuptievt_getOrCreateCtx(cuCtx, ptid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request the CUTPI counter values and write it to the given VampirTrace
|
||||
* stream with the given timestamps.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param vtcuptiEvtCtx pointer to the VampirTrace CUPTI events context
|
||||
* @param strmid the stream id for the counter values
|
||||
* @param time the VampirTrace timestamps
|
||||
*/
|
||||
void vt_cuptievt_writeCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
void vt_cuptievt_writeCounter(vt_cupti_events_t *vtcuptiEvtCtx, uint32_t strmid,
|
||||
uint64_t *time)
|
||||
{
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = NULL;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = NULL;
|
||||
|
||||
size_t bufferSizeBytes;
|
||||
size_t arraySizeBytes;
|
||||
size_t numCountersRead;
|
||||
|
||||
if(vtcuptiCtx == NULL){
|
||||
if(vtcuptiEvtCtx == NULL){
|
||||
VT_CHECK_THREAD;
|
||||
vtcuptiCtx = vt_cuptievt_getCurrentContext(VT_MY_THREAD);
|
||||
if(vtcuptiCtx == NULL) return;
|
||||
vtcuptiEvtCtx = vt_cuptievt_getOrCreateCurrentCtx(VT_MY_THREAD)->events;
|
||||
if(vtcuptiEvtCtx == NULL) return;
|
||||
}
|
||||
|
||||
vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
vtcuptiGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
while(vtcuptiGrp != NULL){
|
||||
/* read events only, if the event group is enabled */
|
||||
if(vtcuptiGrp->enabled){
|
||||
@ -1075,8 +998,8 @@ void vt_cuptievt_writeCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
/* read events */
|
||||
cuptiErr = cuptiEventGroupReadAllEvents(vtcuptiGrp->evtGrp,
|
||||
CUPTI_EVENT_READ_FLAG_NONE,
|
||||
&bufferSizeBytes, vtcuptiCtx->counterData,
|
||||
&arraySizeBytes, vtcuptiCtx->cuptiEvtIDs,
|
||||
&bufferSizeBytes, vtcuptiEvtCtx->counterData,
|
||||
&arraySizeBytes, vtcuptiEvtCtx->cuptiEvtIDs,
|
||||
&numCountersRead);
|
||||
VT_CUPTI_CALL(cuptiErr, "cuptiEventGroupReadAllEvents");
|
||||
|
||||
@ -1095,9 +1018,9 @@ void vt_cuptievt_writeCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
for(j = 0; j < numCountersRead; j++){
|
||||
size_t i;
|
||||
for(i = 0; i < vtcuptiGrp->evtNum; i++){
|
||||
if(vtcuptiCtx->cuptiEvtIDs[j] == *(vtcuptiGrp->cuptiEvtIDs+i)){
|
||||
if(vtcuptiEvtCtx->cuptiEvtIDs[j] == *(vtcuptiGrp->cuptiEvtIDs+i)){
|
||||
/* write the counter value as VampirTrace counter */
|
||||
vt_count(strmid, time, *(vtcuptiGrp->vtCIDs+i), vtcuptiCtx->counterData[i]);
|
||||
vt_count(strmid, time, *(vtcuptiGrp->vtCIDs+i), vtcuptiEvtCtx->counterData[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1113,23 +1036,26 @@ void vt_cuptievt_writeCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
/*
|
||||
* Reset the VampirTrace counter values (to zero) for active CUPTI counters.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param vtcuptiEvtCtx pointer to the VampirTrace CUPTI events context
|
||||
* @param strmid the stream id for the counter values
|
||||
* @param time the VampirTrace timestamps
|
||||
*/
|
||||
void vt_cuptievt_resetCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
void vt_cuptievt_resetCounter(vt_cupti_events_t *vtcuptiEvtCtx, uint32_t strmid,
|
||||
uint64_t *time)
|
||||
{
|
||||
size_t i;
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = NULL;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = NULL;
|
||||
|
||||
if(vtcuptiCtx == NULL){
|
||||
/* create a VampirTrace CUPTI events context, if it is not available */
|
||||
if(vtcuptiEvtCtx == NULL){
|
||||
VT_CHECK_THREAD;
|
||||
vtcuptiCtx = vt_cuptievt_getCurrentContext(VT_MY_THREAD);
|
||||
if(vtcuptiCtx == NULL) return;
|
||||
vtcuptiEvtCtx = vt_cuptievt_getOrCreateCurrentCtx(VT_MY_THREAD)->events;
|
||||
if(vtcuptiEvtCtx == NULL) return;
|
||||
}
|
||||
|
||||
vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
if(vtcuptiEvtCtx==NULL) vt_warning("vtcuptiEvtCtx==NULL");
|
||||
if(vtcuptiEvtCtx->vtGrpList==NULL) vt_warning("vtGrpList==NULL");
|
||||
vtcuptiGrp = vtcuptiEvtCtx->vtGrpList;
|
||||
while(vtcuptiGrp != NULL){
|
||||
for(i = 0; i < vtcuptiGrp->evtNum; i++){
|
||||
vt_count(strmid, time, *(vtcuptiGrp->vtCIDs+i), 0);
|
||||
@ -1151,7 +1077,7 @@ void vt_cuptievt_resetCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
*/
|
||||
void vt_cuptievt_finalize_device(uint32_t ptid, uint8_t cleanExit){
|
||||
CUptiResult cuptiErr = CUPTI_SUCCESS;
|
||||
vt_cuptievt_ctx_t *vtcuptiCtx = NULL;
|
||||
vt_cupti_ctx_t *vtcuptiCtx = NULL;
|
||||
|
||||
vt_cntl_msg(2, "[CUPTI EVENTS] Finalize device ... ");
|
||||
|
||||
@ -1165,7 +1091,7 @@ void vt_cuptievt_finalize_device(uint32_t ptid, uint8_t cleanExit){
|
||||
CHECK_CU_ERROR(cuCtxGetCurrent(&cuCtx), "cuCtxGetCurrent");
|
||||
#endif
|
||||
|
||||
vtcuptiCtx = vt_cupti_takeCtxFromList(&cuCtx);
|
||||
vtcuptiCtx = vt_cupti_removeCtx(&cuCtx);
|
||||
if(vtcuptiCtx == NULL) return;
|
||||
}
|
||||
|
||||
@ -1175,11 +1101,11 @@ void vt_cuptievt_finalize_device(uint32_t ptid, uint8_t cleanExit){
|
||||
vt_cupti_resetCounter(vtcuptiCtx, 0, &time);*/
|
||||
|
||||
/* stop CUPTI counter capturing */
|
||||
vt_cuptievt_stop(vtcuptiCtx);
|
||||
vt_cuptievt_stop(vtcuptiCtx->events);
|
||||
|
||||
/* destroy all CUPTI event groups, which have been created */
|
||||
{
|
||||
vt_cuptievt_grp_t *vtcuptiGrp = vtcuptiCtx->vtGrpList;
|
||||
vt_cupti_evtgrp_t *vtcuptiGrp = vtcuptiCtx->events->vtGrpList;
|
||||
|
||||
while(vtcuptiGrp != NULL){
|
||||
cuptiErr = cuptiEventGroupRemoveAllEvents(vtcuptiGrp->evtGrp);
|
||||
@ -1193,8 +1119,8 @@ void vt_cuptievt_finalize_device(uint32_t ptid, uint8_t cleanExit){
|
||||
}
|
||||
}
|
||||
|
||||
/* free VampirTrace CUPTI context */
|
||||
vt_cuptievt_freeCtx(vtcuptiCtx);
|
||||
/* free VampirTrace CUPTI event context */
|
||||
vt_cuptievt_freeEventCtx(vtcuptiCtx->events);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
@ -13,73 +13,26 @@
|
||||
#ifndef VT_CUPTI_EVENTS_H
|
||||
#define VT_CUPTI_EVENTS_H
|
||||
|
||||
#if (defined(VT_CUPTI_EVENTS))
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "vt_cupti.h"
|
||||
#include "vt_inttypes.h" /* VampirTrace integer types */
|
||||
#include "vt_inttypes.h" /* VampirTrace integer types */
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI event (single linked list element)
|
||||
*/
|
||||
typedef struct vtcuptievtevt_st
|
||||
{
|
||||
CUpti_EventID cuptiEvtID; /**< CUPTI event ID */
|
||||
uint32_t vtCID; /**< VampirTrace counter ID */
|
||||
/*CUpti_EventDomainID cuptiDomainID; *< CUPTI domain ID */
|
||||
struct vtcuptievtevt_st *next;
|
||||
}vt_cuptievt_evt_t;
|
||||
|
||||
/*
|
||||
* Structure that stores events to be trace for specific device capability
|
||||
* (single linked list element)
|
||||
*/
|
||||
typedef struct vtcuptievtdev_st
|
||||
{
|
||||
int dev_major; /**< Major CUDA device capability */
|
||||
int dev_minor; /**< Minor CUDA device capability */
|
||||
CUdevice cuDev; /**< CUDA device */
|
||||
vt_cuptievt_evt_t *vtcuptiEvtList; /**< list of events to be traced for this device*/
|
||||
size_t evtNum; /**< Number of tracable CUPTI events */
|
||||
struct vtcuptievtdev_st *next;
|
||||
}vt_cuptievt_dev_t;
|
||||
|
||||
/*
|
||||
* VampirTrace CUPTI event group and its counters and properties.
|
||||
*/
|
||||
typedef struct vtcuptievtgrp_st
|
||||
{
|
||||
CUpti_EventGroup evtGrp; /**< CUPTI event group, created for this context */
|
||||
CUpti_EventID *cuptiEvtIDs; /**< CUPTI event IDs to be traced */
|
||||
uint32_t *vtCIDs; /**< VampirTrace counter ids */
|
||||
size_t evtNum; /**< number of CUPTI events in this group */
|
||||
uint8_t enabled; /**< is the threads CUPTI capturing enabled */
|
||||
struct vtcuptievtgrp_st *next;
|
||||
}vt_cuptievt_grp_t;
|
||||
|
||||
/*
|
||||
* The VampirTrace CUPTI context has the CUDA context as key and contains
|
||||
* further information about its device and counters.
|
||||
*/
|
||||
typedef struct vtcuptievtctx_st
|
||||
{
|
||||
CUcontext cuCtx; /**< CUDA context (primary key) */
|
||||
vt_cuptievt_dev_t *vtDevCap; /**< pointer to device capability (events, ...) */
|
||||
vt_cuptievt_grp_t *vtGrpList; /**< list of VT CUPTI event groups */
|
||||
uint64_t *counterData; /**< preallocated buffer for counter data */
|
||||
CUpti_EventID *cuptiEvtIDs; /**< preallocated buffer for CUPTI event IDs*/
|
||||
struct vtcuptievtctx_st *next;
|
||||
}vt_cuptievt_ctx_t;
|
||||
#include "vt_cupti_common.h" /* CUPTI common structures, functions, etc. */
|
||||
|
||||
/*
|
||||
* Initialize Mutex, VampirTrace IDs and registers the finalize function.
|
||||
* Initialize VampirTrace IDs and registers the finalize function.
|
||||
* This may be done implicitly by vt_cuptievt_count().
|
||||
*/
|
||||
void vt_cupti_events_init(void);
|
||||
EXTERN void vt_cupti_events_init(void);
|
||||
|
||||
/*
|
||||
* Finalizes the VampirTrace CUPTI implementation.
|
||||
*/
|
||||
void vt_cupti_events_finalize(void);
|
||||
EXTERN void vt_cupti_events_finalize(void);
|
||||
|
||||
/*
|
||||
* Finalizes CUPTI device.
|
||||
@ -87,26 +40,26 @@ void vt_cupti_events_finalize(void);
|
||||
* @param ptid the VampirTrace process/thread id
|
||||
* @param cleanExit 1 to cleanup CUPTI event group, otherwise 0
|
||||
*/
|
||||
void vt_cuptievt_finalize_device(uint32_t ptid, uint8_t cleanExit);
|
||||
|
||||
EXTERN void vt_cuptievt_finalize_device(uint32_t ptid, uint8_t cleanExit);
|
||||
|
||||
/*
|
||||
* Returns the VampirTrace CUPTI context for the CUDA context associated with
|
||||
* the calling host thread.
|
||||
* the calling host thread. Makes sure to also create a VampirTrace CUPTI event
|
||||
* context.
|
||||
*
|
||||
* @param ptid the VampirTrace thread id of the calling host thread
|
||||
*/
|
||||
vt_cuptievt_ctx_t* vt_cuptievt_getCurrentContext(uint32_t ptid);
|
||||
EXTERN vt_cupti_ctx_t* vt_cuptievt_getOrCreateCurrentCtx(uint32_t ptid);
|
||||
|
||||
/*
|
||||
* Request the CUTPI counter values and write it to the given VampirTrace
|
||||
* Request the CUPTI counter values and write it to the given VampirTrace
|
||||
* stream with the given timestamps.
|
||||
*
|
||||
* @param vtcuptiCtx pointer to the VampirTrace CUPTI context
|
||||
* @param strmid the stream id for the counter values
|
||||
* @param time the VampirTrace timestamps
|
||||
*/
|
||||
void vt_cuptievt_writeCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
EXTERN void vt_cuptievt_writeCounter(vt_cupti_events_t *vtcuptiEvtCtx, uint32_t strmid,
|
||||
uint64_t *time);
|
||||
|
||||
/*
|
||||
@ -116,10 +69,8 @@ void vt_cuptievt_writeCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
* @param strmid the stream id for the counter values
|
||||
* @param time the VampirTrace timestamps
|
||||
*/
|
||||
void vt_cuptievt_resetCounter(vt_cuptievt_ctx_t *vtcuptiCtx, uint32_t strmid,
|
||||
EXTERN void vt_cuptievt_resetCounter(vt_cupti_events_t *vtcuptiEvtCtx, uint32_t strmid,
|
||||
uint64_t *time);
|
||||
|
||||
#endif /* VT_CUPTI_EVENTS */
|
||||
|
||||
#endif /* VT_CUPTI_EVENTS_H */
|
||||
|
||||
|
@ -146,11 +146,6 @@ typedef unsigned char* buffer_t;
|
||||
#define VT_LOOP 3
|
||||
#define VT_USER_REGION 4
|
||||
|
||||
#define VT_LIBC 5
|
||||
#define VT_LIBC_IO 6
|
||||
|
||||
#define VT_MEMORY 7
|
||||
|
||||
#define VT_MPI_FUNCTION 8
|
||||
#define VT_MPI_COLL_BARRIER 9
|
||||
#define VT_MPI_COLL_ONE2ALL 10
|
||||
@ -328,4 +323,7 @@ typedef unsigned char* buffer_t;
|
||||
|
||||
#define VT_MAX_GETHOSTID_RETRIES 10
|
||||
|
||||
#define VT_DYNINST_CONT_SIGNUM SIGUSR1
|
||||
#define VT_DYNINST_ERROR_SIGNUM SIGUSR2
|
||||
|
||||
#endif /* _VT_DEFS_H */
|
||||
|
@ -10,43 +10,65 @@
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "vt_comp.h"
|
||||
#include "vt_defs.h"
|
||||
#include "vt_dyninst.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
#include "util/installdirs.h"
|
||||
|
||||
static int dyn_init = 1; /* is initialization needed? */
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
static uint32_t* rtab = NULL; /* region id lookup table */
|
||||
/* macro for getting id of calling thread */
|
||||
#define GET_THREAD_ID(tid) \
|
||||
VT_CHECK_THREAD; \
|
||||
(tid) = VT_MY_THREAD
|
||||
|
||||
/*
|
||||
* Register new region
|
||||
*/
|
||||
/* flag: attaching the Dyninst mutator to the current process? */
|
||||
uint8_t vt_dyn_attaching = 0;
|
||||
|
||||
static uint32_t register_region(const char* name, const char* file,
|
||||
uint32_t lno, uint32_t loop)
|
||||
/* flag: is initialization needed? */
|
||||
static int dyn_init = 1;
|
||||
|
||||
/* flag: continue execution of mutatee? (set by cont_sighandler) */
|
||||
static volatile int mutatee_cont = 0;
|
||||
/* flag: mutator exited erroneously? (set by error_sighandler) */
|
||||
static volatile int mutator_error = 0;
|
||||
|
||||
/* region id lookup table */
|
||||
static uint32_t* rtab = NULL;
|
||||
|
||||
/* signal handler for continuing execution of mutatee */
|
||||
static void cont_sighandler(int signum)
|
||||
{
|
||||
mutatee_cont = 1;
|
||||
}
|
||||
|
||||
/* signal handler for errors occurring during instrumentation */
|
||||
static void error_sighandler(int signum)
|
||||
{
|
||||
mutator_error = 1;
|
||||
}
|
||||
|
||||
/* register new region (function or loop) */
|
||||
static uint32_t register_region(uint32_t tid, const char* name,
|
||||
const char* file, uint32_t lno, uint32_t loop)
|
||||
{
|
||||
uint32_t fid;
|
||||
|
||||
/* Register file if available
|
||||
*/
|
||||
/* register file if available */
|
||||
if( file[0] )
|
||||
{
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, file);
|
||||
fid = vt_def_scl_file(tid, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -54,149 +76,54 @@ static uint32_t register_region(const char* name, const char* file,
|
||||
lno = VT_NO_LNO;
|
||||
}
|
||||
|
||||
/* Register region and store region identifier */
|
||||
return vt_def_region(VT_CURRENT_THREAD, name, fid, lno, VT_NO_LNO, NULL,
|
||||
/* register region and store its identifier */
|
||||
return vt_def_region(tid, name, fid, lno, VT_NO_LNO, NULL,
|
||||
loop ? VT_LOOP : VT_FUNCTION);
|
||||
}
|
||||
|
||||
void VT_Dyn_start(uint32_t index, const char* name, const char* fname,
|
||||
uint32_t lno, uint32_t loop);
|
||||
void VT_Dyn_end(uint32_t index);
|
||||
void VT_Dyn_attach(void);
|
||||
void VT_Dyn_finalize(void);
|
||||
|
||||
/*
|
||||
* This function is called at the entry of each function
|
||||
*/
|
||||
|
||||
void VT_Dyn_start(uint32_t index, const char* name, const char* fname,
|
||||
uint32_t lno, uint32_t loop)
|
||||
/* finalize Dyninst instrumentation interface */
|
||||
static void dyn_finalize(void)
|
||||
{
|
||||
uint64_t time;
|
||||
uint32_t* rid;
|
||||
if( dyn_init )
|
||||
return;
|
||||
|
||||
vt_libassert(index < VT_MAX_DYNINST_REGIONS);
|
||||
/* free region id table */
|
||||
free(rtab);
|
||||
rtab = NULL;
|
||||
|
||||
/* Ignore events if VT is initializing */
|
||||
if( !dyn_init && !vt_is_alive ) return;
|
||||
|
||||
/* If not yet initialized, initialize VampirTrace */
|
||||
if ( dyn_init )
|
||||
{
|
||||
VT_MEMHOOKS_OFF();
|
||||
dyn_init = 0;
|
||||
rtab = (uint32_t*)calloc(VT_MAX_DYNINST_REGIONS, sizeof(uint32_t));
|
||||
if ( rtab == NULL )
|
||||
vt_error();
|
||||
vt_open();
|
||||
vt_comp_finalize = VT_Dyn_finalize;
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/* If VampirTrace already finalized, return */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* Get region identifier
|
||||
*/
|
||||
rid = &(rtab[index]);
|
||||
if ( *rid == 0 )
|
||||
{
|
||||
/* If region entered the first time, register region
|
||||
*/
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if ( *rid == 0 )
|
||||
*rid = register_region(name, fname, lno, loop);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
*rid = register_region(name, fname, lno, loop);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* Write enter record */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, *rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
dyn_init = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called at the exit of each function
|
||||
*/
|
||||
|
||||
void VT_Dyn_end(uint32_t index)
|
||||
void vt_dyn_attach()
|
||||
{
|
||||
uint64_t time;
|
||||
uint32_t mutatee_pid;
|
||||
|
||||
vt_libassert(index < VT_MAX_DYNINST_REGIONS);
|
||||
/* set flag that we're attaching the Dyninst mutator */
|
||||
vt_dyn_attaching = 1;
|
||||
|
||||
/* If VampirTrace already finalized, return */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
/* If region id isn't present, return */
|
||||
if ( rtab[index] == 0 ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* Write exit record */
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
/*
|
||||
* Mutatee's signal handler ...
|
||||
*/
|
||||
|
||||
void sig_usr1_handler(int signum);
|
||||
void sig_usr2_handler(int signum);
|
||||
volatile int mutatee_cont = 0;
|
||||
volatile int mutator_error = 0;
|
||||
|
||||
/* ... for continue execution of mutatee */
|
||||
void sig_usr1_handler(int signum)
|
||||
{
|
||||
mutatee_cont = 1;
|
||||
}
|
||||
|
||||
/* ... for errors, which occur during attaching mutator process */
|
||||
void sig_usr2_handler(int signum)
|
||||
{
|
||||
mutator_error = 1;
|
||||
mutatee_cont = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is called by the shared Dyninst attach library (libvt-dynatt)
|
||||
*/
|
||||
|
||||
void VT_Dyn_attach()
|
||||
{
|
||||
int mutatee_pid = getpid();
|
||||
/* get mutatee's PID */
|
||||
mutatee_pid = (uint32_t)getpid();
|
||||
|
||||
vt_cntl_msg(1, "[%i]: Attaching instrumentor", mutatee_pid);
|
||||
|
||||
/* Install signal handler for continue execution (SIGUSR1)
|
||||
and abort execution (SIGUSR2)
|
||||
*/
|
||||
if( signal(SIGUSR1, sig_usr1_handler) == SIG_ERR )
|
||||
vt_error_msg("Could not install handler for signal SIGUSR1");
|
||||
/* VampirTrace must be not initialized at this point */
|
||||
vt_libassert(!vt_is_alive);
|
||||
|
||||
if( signal(SIGUSR2, sig_usr2_handler) == SIG_ERR )
|
||||
vt_error_msg("Could not install handler for signal SIGUSR2");
|
||||
/* install signal handler for continuing execution and abort */
|
||||
if( signal(VT_DYNINST_CONT_SIGNUM, cont_sighandler) == SIG_ERR )
|
||||
vt_error_msg("Could not install handler for signal "
|
||||
"VT_DYNINST_CONT_SIGNUM");
|
||||
|
||||
/* The Dyninst attach library (libvt-dynatt) could be set by LD_PRELOAD.
|
||||
Unset this environment variable to avoid recursion. */
|
||||
if( signal(VT_DYNINST_ERROR_SIGNUM, error_sighandler) == SIG_ERR )
|
||||
vt_error_msg("Could not install handler for signal "
|
||||
"VT_DYNINST_ERROR_SIGNUM");
|
||||
|
||||
/* the Dyninst attach library (libvt-dynatt) could be set by LD_PRELOAD;
|
||||
unset this environment variable to avoid recursion */
|
||||
putenv((char*)"LD_PRELOAD=");
|
||||
putenv((char*)"DYLD_INSERT_LIBRARIES="); /* equivalent on MacOS */
|
||||
|
||||
/* Attach Dyninst instrumentor on running executable
|
||||
*/
|
||||
/* attach Dyninst instrumentor on running executable */
|
||||
switch( fork() )
|
||||
{
|
||||
case -1:
|
||||
@ -213,18 +140,16 @@ void VT_Dyn_attach()
|
||||
char* shlibs_arg = NULL;
|
||||
char* mutatee_path = NULL;
|
||||
|
||||
/* Restore original signal handler
|
||||
*/
|
||||
signal(SIGUSR1, SIG_DFL);
|
||||
signal(SIGUSR2, SIG_DFL);
|
||||
/* restore original signal handler */
|
||||
signal(VT_DYNINST_CONT_SIGNUM, SIG_DFL);
|
||||
signal(VT_DYNINST_ERROR_SIGNUM, SIG_DFL);
|
||||
|
||||
/* Try to get path of mutatee
|
||||
*/
|
||||
/* try to get pathname of the mutatee */
|
||||
vt_pform_init();
|
||||
mutatee_path = vt_env_apppath();
|
||||
|
||||
/* Replace all colons by commas in list of shared libraries
|
||||
*/
|
||||
/* replace all colons by commas in the list of shared libraries to
|
||||
be instrumented */
|
||||
if ( shlibs && strlen(shlibs) > 0 )
|
||||
{
|
||||
char* tk;
|
||||
@ -238,6 +163,7 @@ void VT_Dyn_attach()
|
||||
shlibs_arg[strlen(shlibs_arg)-1] = '\0';
|
||||
}
|
||||
|
||||
/* compose mutator command */
|
||||
snprintf(cmd,
|
||||
sizeof(cmd)-1, "%s/vtdyn %s %s %s %s %s %s %s %s %s %s %s "
|
||||
"-p %i %s",
|
||||
@ -254,17 +180,16 @@ void VT_Dyn_attach()
|
||||
mutatee_pid,
|
||||
mutatee_path ? mutatee_path : "");
|
||||
|
||||
if ( shlibs_arg )
|
||||
if( shlibs_arg )
|
||||
free(shlibs_arg);
|
||||
|
||||
/* Start mutator (instrumentor) */
|
||||
/* start mutator */
|
||||
vt_cntl_msg(2, "[%i]: Executing %s", mutatee_pid, cmd);
|
||||
rc = system(cmd);
|
||||
|
||||
/* Kill mutatee, if an error occurred during attaching
|
||||
*/
|
||||
/* kill mutatee, if an error occurred during instrumentation */
|
||||
if(rc != 0)
|
||||
kill(mutatee_pid, SIGUSR2);
|
||||
kill(mutatee_pid, VT_DYNINST_ERROR_SIGNUM);
|
||||
|
||||
exit(rc);
|
||||
|
||||
@ -272,19 +197,17 @@ void VT_Dyn_attach()
|
||||
}
|
||||
default:
|
||||
{
|
||||
/* Wait until mutator send signal to continue execution
|
||||
*/
|
||||
/* wait until mutator sends the signal to continue execution */
|
||||
vt_cntl_msg(1, "[%i]: Waiting until instrumentation is done",
|
||||
mutatee_pid);
|
||||
|
||||
do { usleep(1000); } while(mutatee_cont == 0);
|
||||
|
||||
if ( !mutator_error )
|
||||
if( !mutator_error )
|
||||
{
|
||||
/* Restore original signal handler
|
||||
*/
|
||||
signal(SIGUSR1, SIG_DFL);
|
||||
signal(SIGUSR2, SIG_DFL);
|
||||
/* restore original signal handler */
|
||||
signal(VT_DYNINST_CONT_SIGNUM, SIG_DFL);
|
||||
signal(VT_DYNINST_ERROR_SIGNUM, SIG_DFL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -294,20 +217,93 @@ void VT_Dyn_attach()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* unset flag for attaching the Dyninst mutator */
|
||||
vt_dyn_attaching = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Finalize instrumentation interface
|
||||
*/
|
||||
|
||||
void VT_Dyn_finalize()
|
||||
void vt_dyn_start(uint32_t index, const char* name, const char* fname,
|
||||
uint32_t lno, uint32_t loop)
|
||||
{
|
||||
if ( dyn_init ) return;
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint32_t* rid;
|
||||
|
||||
/* Free region id table
|
||||
*/
|
||||
free( rtab );
|
||||
rtab = NULL;
|
||||
vt_libassert(index < VT_MAX_DYNINST_REGIONS);
|
||||
|
||||
dyn_init = 1;
|
||||
/* ignore events if VT is initializing */
|
||||
if( !dyn_init && !vt_is_alive )
|
||||
return;
|
||||
|
||||
/* if not yet initialized, initialize Dyninst instrumentation interface */
|
||||
if( dyn_init )
|
||||
{
|
||||
dyn_init = 0;
|
||||
vt_open();
|
||||
vt_comp_finalize = dyn_finalize;
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
rtab = (uint32_t*)calloc(VT_MAX_DYNINST_REGIONS, sizeof(uint32_t));
|
||||
if( rtab == NULL )
|
||||
vt_error();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/* if VampirTrace is already finalized, return */
|
||||
if( !vt_is_alive )
|
||||
return;
|
||||
|
||||
/* get calling thread id */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* get region identifier */
|
||||
rid = &(rtab[index]);
|
||||
if( *rid == 0 )
|
||||
{
|
||||
/* if region entered the first time, register region */
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if( *rid == 0 )
|
||||
*rid = register_region(tid, name, fname, lno, loop);
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#else /* VT_MT || VT_HYB */
|
||||
*rid = register_region(tid, name, fname, lno, loop);
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
/* write enter record */
|
||||
vt_enter(tid, &time, *rid);
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
||||
void vt_dyn_end(uint32_t index)
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
|
||||
vt_libassert(index < VT_MAX_DYNINST_REGIONS);
|
||||
|
||||
/* if VampirTrace is already finalized, return */
|
||||
if( !vt_is_alive )
|
||||
return;
|
||||
|
||||
/* if region id isn't present (enter not recognized) , return */
|
||||
if( rtab[index] == 0 )
|
||||
return;
|
||||
|
||||
/* get calling thread id */
|
||||
GET_THREAD_ID(tid);
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* write exit record */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
|
39
ompi/contrib/vt/vt/vtlib/vt_dyninst.h
Обычный файл
39
ompi/contrib/vt/vt/vtlib/vt_dyninst.h
Обычный файл
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#ifndef _VT_DYNINST_H
|
||||
#define _VT_DYNINST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "vt_inttypes.h"
|
||||
|
||||
/* attach Dyninst mutator (vtdyn) to the current process
|
||||
(called during initialization of libvt-dynatt) */
|
||||
EXTERN void vt_dyn_attach(void);
|
||||
|
||||
/* function to be called at the entry of each function or loop */
|
||||
EXTERN void vt_dyn_start(uint32_t index, const char* name, const char* fname,
|
||||
uint32_t lno, uint32_t loop);
|
||||
|
||||
/* function to be called at the exit of each function or loop */
|
||||
EXTERN void vt_dyn_end(uint32_t index);
|
||||
|
||||
/* flag: attaching the Dyninst mutator to the current process? */
|
||||
EXTERN uint8_t vt_dyn_attaching;
|
||||
|
||||
#endif /* _VT_DYNINST_H */
|
||||
|
@ -960,29 +960,6 @@ int vt_env_verbose()
|
||||
return verbose;
|
||||
}
|
||||
|
||||
int vt_env_debug()
|
||||
{
|
||||
static int debug = -1;
|
||||
char* tmp;
|
||||
|
||||
if (debug == -1)
|
||||
{
|
||||
tmp = getenv("VT_DEBUG");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
debug = atoi(tmp);
|
||||
if (debug < 0) debug = 0;
|
||||
|
||||
vt_cntl_msg(2, "VT_DEBUG=%s", tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
debug = 0;
|
||||
}
|
||||
}
|
||||
return debug;
|
||||
}
|
||||
|
||||
int vt_env_do_unify()
|
||||
{
|
||||
static int do_unify = -1;
|
||||
@ -1027,50 +1004,6 @@ int vt_env_do_clean()
|
||||
return do_clean;
|
||||
}
|
||||
|
||||
int vt_env_memtrace()
|
||||
{
|
||||
static int memtrace = -1;
|
||||
char* tmp;
|
||||
|
||||
if (memtrace == -1)
|
||||
{
|
||||
tmp = getenv("VT_MEMTRACE");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
vt_cntl_msg(2, "VT_MEMTRACE=%s", tmp);
|
||||
|
||||
memtrace = parse_bool(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrace = 0;
|
||||
}
|
||||
}
|
||||
return memtrace;
|
||||
}
|
||||
|
||||
int vt_env_memtrace_marker()
|
||||
{
|
||||
static int memtrace_marker = -1;
|
||||
char* tmp;
|
||||
|
||||
if (memtrace_marker == -1)
|
||||
{
|
||||
tmp = getenv("VT_MEMTRACE_MARKER");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
vt_cntl_msg(2, "VT_MEMTRACE_MARKER=%s", tmp);
|
||||
|
||||
memtrace_marker = parse_bool(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrace_marker = 0;
|
||||
}
|
||||
}
|
||||
return memtrace_marker;
|
||||
}
|
||||
|
||||
int vt_env_cpuidtrace()
|
||||
{
|
||||
static int cpuidtrace = -1;
|
||||
@ -1161,26 +1094,80 @@ char* vt_env_iolibpathname()
|
||||
return pathname;
|
||||
}
|
||||
|
||||
int vt_env_libctrace()
|
||||
int vt_env_exectrace()
|
||||
{
|
||||
static int libctrace = -1;
|
||||
static int exectrace = -1;
|
||||
char* tmp;
|
||||
|
||||
if (libctrace == -1)
|
||||
if (exectrace == -1)
|
||||
{
|
||||
tmp = getenv("VT_LIBCTRACE");
|
||||
tmp = getenv("VT_EXECTRACE");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
vt_cntl_msg(2, "VT_LIBCTRACE=%s", tmp);
|
||||
vt_cntl_msg(2, "VT_EXECTRACE=%s", tmp);
|
||||
|
||||
libctrace = parse_bool(tmp);
|
||||
exectrace = parse_bool(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
libctrace = 1;
|
||||
tmp = getenv("VT_LIBCTRACE");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
exectrace = parse_bool(tmp);
|
||||
|
||||
vt_warning("VT_LIBCTRACE is deprecated, use VT_EXECTRACE instead!");
|
||||
}
|
||||
else
|
||||
{
|
||||
exectrace = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return libctrace;
|
||||
return exectrace;
|
||||
}
|
||||
|
||||
int vt_env_memtrace()
|
||||
{
|
||||
static int memtrace = -1;
|
||||
char* tmp;
|
||||
|
||||
if (memtrace == -1)
|
||||
{
|
||||
tmp = getenv("VT_MEMTRACE");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
vt_cntl_msg(2, "VT_MEMTRACE=%s", tmp);
|
||||
|
||||
memtrace = parse_bool(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrace = 0;
|
||||
}
|
||||
}
|
||||
return memtrace;
|
||||
}
|
||||
|
||||
int vt_env_memtrace_marker()
|
||||
{
|
||||
static int memtrace_marker = -1;
|
||||
char* tmp;
|
||||
|
||||
if (memtrace_marker == -1)
|
||||
{
|
||||
tmp = getenv("VT_MEMTRACE_MARKER");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
vt_cntl_msg(2, "VT_MEMTRACE_MARKER=%s", tmp);
|
||||
|
||||
memtrace_marker = parse_bool(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
memtrace_marker = 0;
|
||||
}
|
||||
}
|
||||
return memtrace_marker;
|
||||
}
|
||||
|
||||
int vt_env_omptrace()
|
||||
@ -1810,18 +1797,18 @@ void vt_env_cudatrace()
|
||||
char* error_msg[3] = {
|
||||
"VT_CUDATRACE has been replaced by VT_GPUTRACE!\n"
|
||||
"Usage: export VT_GPUTRACE=option1,option2,option2,...\n"
|
||||
"The following CUDA measurement options are available:\n",
|
||||
|
||||
" cuda : enable CUDA (needed to use CUDA runtime API wrapper)\n"
|
||||
" cupti : use the CUPTI interface instead of the library wrapper\n"
|
||||
" runtime : CUDA runtime API\n"
|
||||
" driver : CUDA driver API\n"
|
||||
" kernel : CUDA kernels\n"
|
||||
" idle : GPU compute idle time\n"
|
||||
" memcpy : CUDA memory copies\n"
|
||||
" memusage: CUDA memory allocation\n"
|
||||
" debug : CUDA tracing debug mode\n"
|
||||
" error : CUDA errors will exit the program\n"
|
||||
"The following CUDA measurement options are available:\n"
|
||||
" cuda : enable CUDA (needed to use CUDA runtime API wrapper)\n"
|
||||
" cupti : use the CUPTI interface instead of the library wrapper\n",
|
||||
" runtime : CUDA runtime API\n"
|
||||
" driver : CUDA driver API\n"
|
||||
" kernel : CUDA kernels\n"
|
||||
" concurrent: enable concurrent kernel tracing at initialization time\n"
|
||||
" idle : GPU compute idle time\n"
|
||||
" memcpy : CUDA memory copies\n"
|
||||
" memusage : CUDA memory allocation\n"
|
||||
" debug : CUDA tracing debug mode\n"
|
||||
" error : CUDA errors will exit the program\n"
|
||||
" yes|default: same as 'cuda,runtime,kernel,memcpy'\n"
|
||||
" no: disable CUDA measurement\n",
|
||||
|
||||
@ -1899,10 +1886,10 @@ int vt_env_cupti_sampling()
|
||||
|
||||
if (cuptisampling == -1)
|
||||
{
|
||||
char* tmp = getenv("VT_CUPTI_SAMPLING");
|
||||
char* tmp = getenv("VT_CUPTI_EVENTS_SAMPLING");
|
||||
if (tmp != NULL && strlen(tmp) > 0)
|
||||
{
|
||||
vt_cntl_msg(2, "VT_CUPTI_SAMPLING=%s", tmp);
|
||||
vt_cntl_msg(2, "VT_CUPTI_EVENTS_SAMPLING=%s", tmp);
|
||||
|
||||
cuptisampling = parse_bool(tmp);
|
||||
}
|
||||
|
@ -50,16 +50,15 @@ EXTERN int vt_env_stat_collop_dtls(void);
|
||||
EXTERN int vt_env_snapshots(void);
|
||||
EXTERN int vt_env_max_snapshots(void);
|
||||
EXTERN int vt_env_verbose(void);
|
||||
EXTERN int vt_env_debug(void);
|
||||
EXTERN int vt_env_do_unify(void);
|
||||
EXTERN int vt_env_do_clean(void);
|
||||
EXTERN int vt_env_memtrace(void);
|
||||
EXTERN int vt_env_memtrace_marker(void);
|
||||
EXTERN int vt_env_cpuidtrace(void);
|
||||
EXTERN int vt_env_iotrace(void);
|
||||
EXTERN int vt_env_iotrace_extended(void);
|
||||
EXTERN char* vt_env_iolibpathname(void);
|
||||
EXTERN int vt_env_libctrace(void);
|
||||
EXTERN int vt_env_exectrace(void);
|
||||
EXTERN int vt_env_memtrace(void);
|
||||
EXTERN int vt_env_memtrace_marker(void);
|
||||
EXTERN int vt_env_omptrace(void);
|
||||
EXTERN int vt_env_mpitrace(void);
|
||||
EXTERN int vt_env_mpi_ignore_filter(void);
|
||||
|
@ -106,14 +106,3 @@ void vt_cntl_msg(int level, const char* fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
void vt_debug_msg(int level, const char* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (vt_env_debug() >= level) {
|
||||
va_start(ap, fmt);
|
||||
vt_print_msg("DEBUG", fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,6 @@ EXTERN void vt_warning(const char* fmt, ...);
|
||||
/* user control message without abort (printed only if VT_VERBOSE is set) */
|
||||
EXTERN void vt_cntl_msg(int level, const char* fmt, ...);
|
||||
|
||||
/* debug messages without abort (printed only if VT_DEBUG is set) */
|
||||
EXTERN void vt_debug_msg(int level, const char* fmt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
962
ompi/contrib/vt/vt/vtlib/vt_execwrap.c
Обычный файл
962
ompi/contrib/vt/vt/vtlib/vt_execwrap.c
Обычный файл
@ -0,0 +1,962 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#define _GNU_SOURCE /* possibly needed for execvpe */
|
||||
#define _SVID_SOURCE /* possibly needed for waitid */
|
||||
#define _BSD_SOURCE /* possibly needed for wait<3|4> */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "vt_defs.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_execwrap.h"
|
||||
#include "vt_fork.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_libwrap.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
#ifdef VT_DYNINST
|
||||
# include "vt_dyninst.h"
|
||||
#endif /* VT_DYNINST */
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#if (defined(HAVE_WAIT3) && HAVE_WAIT3) || (defined(HAVE_WAIT4) && HAVE_WAIT4)
|
||||
# include <sys/resource.h>
|
||||
# include <sys/time.h>
|
||||
#endif /* HAVE_WAIT3 || HAVE_WAIT4 */
|
||||
|
||||
#if !(defined(HAVE___WAIT_STATUS) && HAVE___WAIT_STATUS)
|
||||
# define __WAIT_STATUS int*
|
||||
#endif /* HAVE___WAIT_STATUS */
|
||||
|
||||
|
||||
/* tracing fork and exec* functions is only supported for serial programs;
|
||||
using the following macro to check whether we can intercept these
|
||||
functions */
|
||||
#if (!defined (VT_MPI) && !defined (VT_MT) && !defined(VT_HYB) && !defined(VT_JAVA))
|
||||
# define EXECWRAP_EXEC_AND_FORK
|
||||
#endif /* !VT_MPI && !VT_MT && !VT_HYB && !VT_JAVA */
|
||||
|
||||
|
||||
/* special version of VT_LIBWRAP_FUNC_INIT w/o getting the unique function
|
||||
identifier (VT_LIBWRAP_FUNC_ID) */
|
||||
#define EXECWRAP_FUNC_INIT(_func, _rettype, _argtypes) \
|
||||
_VT_LIBWRAP_FUNC_INIT_DECL_VARS(_func, _rettype, _argtypes); \
|
||||
if( execwrap_lw == VT_LIBWRAP_NULL ) { \
|
||||
VTLibwrap_create(&execwrap_lw, &execwrap_lw_attr); \
|
||||
} \
|
||||
if( VT_LIBWRAP_FUNC_PTR == VT_LIBWRAP_NULL ) { \
|
||||
VTLibwrap_func_init(execwrap_lw, VT_LIBWRAP_FUNC_NAME, NULL, 0, \
|
||||
(void**)(&VT_LIBWRAP_FUNC_PTR), NULL); \
|
||||
}
|
||||
|
||||
/* get unique function identifier
|
||||
(sets VT_LIBWRAP_FUNC_ID, must be called after EXECWRAP_FUNC_INIT!) */
|
||||
#define EXECWRAP_GET_FUNC_ID() \
|
||||
if( VT_LIBWRAP_FUNC_ID == VT_LIBWRAP_NOID ) { \
|
||||
VTLibwrap_func_init(execwrap_lw, VT_LIBWRAP_FUNC_NAME, NULL, 0, \
|
||||
NULL, &VT_LIBWRAP_FUNC_ID); \
|
||||
}
|
||||
|
||||
/* simplified version of VT_LIBWRAP_FUNC_CALL w/o argument for the library
|
||||
wrapper object */
|
||||
#define EXECWRAP_FUNC_CALL(_args) VT_LIBWRAP_FUNC_CALL(execwrap_lw, _args)
|
||||
|
||||
/* check whether tracing of LIBC exec functions is currently enabled */
|
||||
#define EXECWRAP_DO_TRACE() \
|
||||
( vt_is_alive && VT_MY_THREAD_IS_ALIVE && \
|
||||
VTTHRD_MALLOC_TRACING_ENABLED(VTTHRD_MY_VTTHRD) )
|
||||
|
||||
/* maximum number of variable arguments for the execl* functions */
|
||||
#define EXECWRAP_EXECL_MAX_ARGS 1024
|
||||
|
||||
|
||||
/* library wrapper object */
|
||||
static VTLibwrap* execwrap_lw = VT_LIBWRAP_NULL;
|
||||
|
||||
/* library wrapper attributes */
|
||||
static VTLibwrapAttr execwrap_lw_attr = {
|
||||
|
||||
/* The functions to be wrapped are defined in the LIBC which is (dl)opened
|
||||
once by the underlying library wrapping infrastructure. So there is
|
||||
no need to search the actual function pointers in an additional library. */
|
||||
0, /* shlibs_num */
|
||||
{ NULL }, /* shlibs */
|
||||
|
||||
/* Function group to define, finally including the recorded LIBC exec
|
||||
functions */
|
||||
"LIBC-EXEC", /* func_group */
|
||||
|
||||
/* Search for the actual function pointers in the LIBC, (dl)opened once by
|
||||
the underlying library wrapping infrastructure */
|
||||
1, /* libc */
|
||||
|
||||
/* Do not initialize VampirTrace when creating the library wrapper object,
|
||||
resp. when a wrapper function is entered */
|
||||
1 /* wait_for_init */
|
||||
};
|
||||
|
||||
#ifdef EXECWRAP_EXEC_AND_FORK
|
||||
|
||||
/* pointer to global environ variable of external LIBC */
|
||||
static char*** execwrap_libc_environ = NULL;
|
||||
|
||||
/* function to convert variable arguments of the execl* functions to an array
|
||||
for calling the corresponding execv* function */
|
||||
static void execwrap_execl_valist_to_argv(va_list ap, const char* last,
|
||||
const char* argv[EXECWRAP_EXECL_MAX_ARGS])
|
||||
{
|
||||
const char* tmp;
|
||||
uint32_t i = 0;
|
||||
|
||||
argv[i++] = last;
|
||||
while((tmp = va_arg(ap, const char*)))
|
||||
{
|
||||
vt_libassert(i < EXECWRAP_EXECL_MAX_ARGS-1);
|
||||
argv[i++] = tmp;
|
||||
}
|
||||
argv[i] = NULL;
|
||||
}
|
||||
|
||||
#endif /* EXECWRAP_EXEC_AND_FORK */
|
||||
|
||||
/* exec wrapper initialization/finalization functions called by
|
||||
vt_open/vt_close*/
|
||||
|
||||
void vt_execwrap_init()
|
||||
{
|
||||
#ifdef EXECWRAP_EXEC_AND_FORK
|
||||
/* get pointer to global environ variable of external LIBC */
|
||||
void* libc_handle = vt_libwrap_get_libc_handle();
|
||||
vt_libassert(libc_handle);
|
||||
execwrap_libc_environ = (char***)dlsym(libc_handle, "environ");
|
||||
vt_libassert(execwrap_libc_environ);
|
||||
#endif /* EXECWRAP_EXEC_AND_FORK */
|
||||
}
|
||||
|
||||
void vt_execwrap_finalize()
|
||||
{
|
||||
/* delete library wrapper object, if necessary */
|
||||
if( execwrap_lw != VT_LIBWRAP_NULL )
|
||||
VTLibwrap_delete(execwrap_lw);
|
||||
}
|
||||
|
||||
|
||||
/* wrapper functions */
|
||||
|
||||
#ifdef EXECWRAP_EXEC_AND_FORK
|
||||
|
||||
/* -- unistd.h:execl -- */
|
||||
int execl(const char* path, const char* arg, ...)
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
va_list ap;
|
||||
const char* argv[EXECWRAP_EXECL_MAX_ARGS];
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execl", int, (const char*, const char*, ...));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* convert va_list to an array for the following execv call */
|
||||
va_start(ap, arg);
|
||||
execwrap_execl_valist_to_argv(ap, arg, argv);
|
||||
va_end(ap);
|
||||
|
||||
/* resume LIBC exec tracing to prevent recording the following execv call */
|
||||
VT_SUSPEND_EXEC_TRACING(tid);
|
||||
|
||||
/* call the execv wrapper function */
|
||||
ret = execv(path, (char* const*)argv);
|
||||
|
||||
/* this point cannot be reached */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- unistd.h:execlp -- */
|
||||
int execlp(const char* file, const char* arg, ...)
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
va_list ap;
|
||||
const char* argv[EXECWRAP_EXECL_MAX_ARGS];
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execlp", int, (const char*, const char*, ...));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* convert va_list to an array for the following execvp call */
|
||||
va_start(ap, arg);
|
||||
execwrap_execl_valist_to_argv(ap, arg, argv);
|
||||
va_end(ap);
|
||||
|
||||
/* suspend LIBC exec tracing to prevent recording the following execvp call */
|
||||
VT_SUSPEND_EXEC_TRACING(tid);
|
||||
|
||||
/* call the execvp wrapper function */
|
||||
ret = execvp(file, (char* const*)argv);
|
||||
|
||||
/* this point cannot be reached */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- unistd.h:execle -- */
|
||||
int execle(const char* path, const char* arg, ...)
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
va_list ap;
|
||||
const char* argv[EXECWRAP_EXECL_MAX_ARGS];
|
||||
char* const* envp;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execle", int, (const char*, const char*, ...));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* convert va_list to an array for the following execve call */
|
||||
va_start(ap, arg);
|
||||
execwrap_execl_valist_to_argv(ap, arg, argv);
|
||||
envp = va_arg(ap, char* const*);
|
||||
va_end(ap);
|
||||
|
||||
/* suspend LIBC exec tracing to prevent recording the following execve call */
|
||||
VT_SUSPEND_EXEC_TRACING(tid);
|
||||
|
||||
/* call the execve wrapper function */
|
||||
ret = execve(path, (char* const*)argv, envp);
|
||||
|
||||
/* this point cannot be reached */
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- unistd.h:execv -- */
|
||||
int execv(const char* path, char* const argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execv", int, (const char*, char* const[]));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* close VT for this process, in hope that the following execv call
|
||||
succeeds */
|
||||
vt_close();
|
||||
|
||||
/* set environ of external LIBC */
|
||||
*execwrap_libc_environ = environ;
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((path, argv));
|
||||
|
||||
/* an error occurred if reaching this point; cannot continue, because VT is
|
||||
already closed */
|
||||
|
||||
/* get errno from external LIBC and abort */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
vt_error_msg("%s failed: %s", VT_LIBWRAP_FUNC_NAME, strerror(errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- unistd.h:execvp -- */
|
||||
int execvp(const char* file, char* const argv[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execvp", int, (const char*, char* const[]));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* close VT for this process, in hope that the following execvp call
|
||||
succeeds */
|
||||
vt_close();
|
||||
|
||||
/* set environ of external LIBC */
|
||||
*execwrap_libc_environ = environ;
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((file, argv));
|
||||
|
||||
/* an error occurred if reaching this point; cannot continue, because VT is
|
||||
already closed */
|
||||
|
||||
/* get errno from external LIBC and abort */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
vt_error_msg("%s failed: %s", VT_LIBWRAP_FUNC_NAME, strerror(errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- unistd.h:execve -- */
|
||||
int execve(const char* path, char* const argv[], char* const envp[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execve", int,
|
||||
(const char*, char* const[], char* const[]));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* close VT for this process, in hope that the following execve call
|
||||
succeeds */
|
||||
vt_close();
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((path, argv, envp));
|
||||
|
||||
/* an error occurred if reaching this point; cannot continue, because VT is
|
||||
already closed */
|
||||
|
||||
/* get errno from external LIBC and abort */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
vt_error_msg("%s failed: %s", VT_LIBWRAP_FUNC_NAME, strerror(errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(HAVE_EXECVPE) && HAVE_EXECVPE
|
||||
|
||||
/* -- unistd.h:execvpe -- */
|
||||
int execvpe(const char* file, char* const argv[], char* const envp[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("execvpe", int,
|
||||
(const char*, char* const[], char* const[]));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* close VT for this process, in hope that the following execvpe call
|
||||
succeeds */
|
||||
vt_close();
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((file, argv, envp));
|
||||
|
||||
/* an error occurred if reaching this point; cannot continue, because VT is
|
||||
already closed */
|
||||
|
||||
/* get errno from external LIBC and abort */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
vt_error_msg("%s failed: %s", VT_LIBWRAP_FUNC_NAME, strerror(errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_EXECVPE */
|
||||
|
||||
#if defined(HAVE_FEXECVE) && HAVE_FEXECVE
|
||||
|
||||
/* -- unistd.h:fexecve -- */
|
||||
int fexecve(int fd, char* const argv[], char* const envp[])
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("fexecve", int, (int, char* const[], char* const[]));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* close VT for this process, in hope that the following fexecve call
|
||||
succeeds */
|
||||
vt_close();
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((fd, argv, envp));
|
||||
|
||||
/* an error occurred if reaching this point; cannot continue, because VT is
|
||||
already closed */
|
||||
|
||||
/* get errno from external LIBC and abort */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
vt_error_msg("%s failed: %s", VT_LIBWRAP_FUNC_NAME, strerror(errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_FEXECVE */
|
||||
|
||||
/* -- unistd.h:fork -- */
|
||||
pid_t fork()
|
||||
{
|
||||
pid_t ret;
|
||||
|
||||
uint32_t tid = VT_MASTER_THREAD;
|
||||
uint64_t time;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("fork", pid_t, (void));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* record function enter event, if tracing of LIBC exec functions
|
||||
is enabled */
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
/* get calling thread id */
|
||||
/*tid = VT_MY_THREAD;*/
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
}
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL(());
|
||||
|
||||
/* handle fork, if succeeded */
|
||||
#ifdef VT_DYNINST
|
||||
/* ... and we're not attaching the Dyninst mutator */
|
||||
if( !vt_dyn_attaching )
|
||||
#endif /* VT_DYNINST */
|
||||
{
|
||||
if( ret != -1 )
|
||||
vt_fork(ret);
|
||||
}
|
||||
|
||||
if( EXECWRAP_DO_TRACE() && ret != 0 )
|
||||
{
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* EXECWRAP_EXEC_AND_FORK */
|
||||
|
||||
/* -- stdlib.h:system -- */
|
||||
int system(const char* command)
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_CURRENT_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("system", int, (const char*));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((command));
|
||||
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((command));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- sys/wait.h:wait -- */
|
||||
|
||||
pid_t wait(__WAIT_STATUS status)
|
||||
{
|
||||
pid_t ret;
|
||||
|
||||
uint32_t tid = VT_CURRENT_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("wait", pid_t, (__WAIT_STATUS));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((status));
|
||||
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((status));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- sys/wait.h:waitpid -- */
|
||||
pid_t waitpid(pid_t pid, int* status, int options)
|
||||
{
|
||||
pid_t ret;
|
||||
|
||||
uint32_t tid = VT_CURRENT_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("waitpid", pid_t, (pid_t, int*, int));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((pid, status, options));
|
||||
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((pid, status, options));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WAITID) && HAVE_WAITID
|
||||
|
||||
/* -- sys/wait.h:waitid -- */
|
||||
int waitid(idtype_t idtype, id_t id, siginfo_t* infop, int options)
|
||||
{
|
||||
int ret;
|
||||
|
||||
uint32_t tid = VT_CURRENT_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("waitid", int, (idtype_t, id_t, siginfo_t*, int));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((idtype, id, infop, options));
|
||||
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((idtype, id, infop, options));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_WAITID */
|
||||
|
||||
#if defined(HAVE_WAIT3) && HAVE_WAIT3
|
||||
|
||||
/* -- sys/wait.h:wait3 -- */
|
||||
pid_t wait3(__WAIT_STATUS status, int options, struct rusage* rusage)
|
||||
{
|
||||
pid_t ret;
|
||||
|
||||
uint32_t tid = VT_CURRENT_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("wait3", pid_t, (__WAIT_STATUS, int, struct rusage*));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((status, options, rusage));
|
||||
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((status, options, rusage));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_WAIT3 */
|
||||
|
||||
#if defined(HAVE_WAIT4) && HAVE_WAIT4
|
||||
|
||||
/* -- sys/wait.h:wait4 -- */
|
||||
pid_t wait4(pid_t pid, __WAIT_STATUS status, int options, struct rusage* rusage)
|
||||
{
|
||||
pid_t ret;
|
||||
|
||||
uint32_t tid = VT_CURRENT_THREAD;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
EXECWRAP_FUNC_INIT("wait4", pid_t,
|
||||
(pid_t, __WAIT_STATUS, int, struct rusage*));
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
if( EXECWRAP_DO_TRACE() )
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
EXECWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
(void)vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((pid, status, options, rusage));
|
||||
|
||||
/* record function exit event */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(tid, &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = EXECWRAP_FUNC_CALL((pid, status, options, rusage));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC */
|
||||
errno = vt_libwrap_get_libc_errno();
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_WAIT4 */
|
59
ompi/contrib/vt/vt/vtlib/vt_execwrap.h
Обычный файл
59
ompi/contrib/vt/vt/vtlib/vt_execwrap.h
Обычный файл
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#ifndef _VT_EXECWRAP_H
|
||||
#define _VT_EXECWRAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "vt_defs.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
#ifdef VT_EXECWRAP
|
||||
|
||||
/* macro for temporarily suspend EXEC tracing */
|
||||
#define VT_SUSPEND_EXEC_TRACING(tid) \
|
||||
if( vt_is_alive && VT_MY_THREAD_IS_ALIVE ) { \
|
||||
VTThrd* _thrd = \
|
||||
((tid) == VT_CURRENT_THREAD) ? VTTHRD_MY_VTTHRD : VTThrdv[(tid)]; \
|
||||
VTTHRD_EXEC_TRACING_ENABLED(_thrd) = 0; \
|
||||
VTTHRD_EXEC_TRACING_SUSPEND_CNT(_thrd)++; \
|
||||
}
|
||||
|
||||
/* macro for resuming from EXEC tracing suspension */
|
||||
#define VT_RESUME_EXEC_TRACING(tid) \
|
||||
if( vt_is_alive && VT_MY_THREAD_IS_ALIVE ) { \
|
||||
VTThrd* _thrd = \
|
||||
((tid) == VT_CURRENT_THREAD) ? VTTHRD_MY_VTTHRD : VTThrdv[(tid)]; \
|
||||
if( VTTHRD_EXEC_TRACING_SUSPEND_CNT(_thrd) == 0 || \
|
||||
--VTTHRD_EXEC_TRACING_SUSPEND_CNT(_thrd) == 0 ) { \
|
||||
VTTHRD_EXEC_TRACING_ENABLED(_thrd) = \
|
||||
VTTHRD_EXEC_TRACING_STATE(_thrd); \
|
||||
} \
|
||||
}
|
||||
|
||||
EXTERN void vt_execwrap_init(void);
|
||||
EXTERN void vt_execwrap_finalize(void);
|
||||
|
||||
#else /* VT_EXECWRAP */
|
||||
|
||||
#define VT_SUSPEND_EXEC_TRACING(tid)
|
||||
#define VT_RESUME_EXEC_TRACING(tid)
|
||||
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#endif /* _VT_EXECWRAP_H */
|
@ -17,7 +17,7 @@
|
||||
#include "vt_fork.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_iowrap.h"
|
||||
#include "vt_libcwrap.h"
|
||||
#include "vt_execwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
@ -163,7 +163,7 @@ void vt_fork_waitchilds()
|
||||
|
||||
if ( nchilds == 0 ) return;
|
||||
|
||||
VT_SUSPEND_LIBC_TRACING();
|
||||
VT_SUSPEND_EXEC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* wait until all child processes are terminated */
|
||||
for( i = 0; i < nchilds; i++ )
|
||||
@ -177,7 +177,7 @@ void vt_fork_waitchilds()
|
||||
(int)childv[i], nchilds-i-1);
|
||||
}
|
||||
|
||||
VT_RESUME_LIBC_TRACING();
|
||||
VT_RESUME_EXEC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
uint32_t vt_fork_get_num_childs()
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if (!defined (VT_MPI) && !defined (VT_MT) && !defined(VT_HYB) && !defined(VT_JAVA) && (defined(HAVE_FORK) && HAVE_FORK))
|
||||
#if (!defined (VT_MPI) && !defined (VT_MT) && !defined(VT_HYB) && !defined(VT_JAVA))
|
||||
|
||||
#define VT_FORK
|
||||
|
||||
@ -38,6 +38,6 @@ EXTERN uint32_t vt_fork_get_num_childs(void);
|
||||
EXTERN uint32_t vt_fork_get_num_childs_tot(void);
|
||||
EXTERN char* vt_fork_get_trcid_filename(void);
|
||||
|
||||
#endif /* !VT_MPI && !VT_MT && !VT_HYB && HAVE_FORK */
|
||||
#endif /* !VT_MPI && !VT_MT && !VT_HYB */
|
||||
|
||||
#endif /* _VT_FORK_H */
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "vt_gpu.h"
|
||||
#include "vt_env.h" /* get environment variables */
|
||||
#include "vt_pform.h" /* VampirTrace time measurement */
|
||||
#include "vt_mallocwrap.h" /* wrapping of malloc and free */
|
||||
|
||||
#include <string.h> /* needed for hashing and manual CUDA kernel demangling */
|
||||
|
||||
@ -55,8 +56,11 @@ static void vt_gpu_createGroups(void);
|
||||
void vt_gpu_init(void)
|
||||
{
|
||||
if(!vt_gpu_initialized){
|
||||
|
||||
/* create group property list for threads */
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
vt_gpu_prop = (uint8_t*)calloc(VTThrdMaxNum, sizeof(uint8_t));
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* get a communicator id for GPU communication */
|
||||
vt_gpu_commCID = vt_get_curid();
|
||||
@ -151,6 +155,9 @@ uint32_t vt_gpu_get_config(void)
|
||||
}else if(strcmp(feature, "kernel") == 0){
|
||||
vt_gpu_config |= VT_GPU_TRACE_KERNEL;
|
||||
vt_gpu_trace_kernels = 1;
|
||||
}else if(strcmp(feature, "concurrent") == 0){
|
||||
vt_gpu_config |= VT_GPU_TRACE_CONCURRENT_KERNEL;
|
||||
vt_gpu_trace_kernels = 1;
|
||||
}else if(strcmp(feature, "idle") == 0){
|
||||
vt_gpu_config |= VT_GPU_TRACE_IDLE;
|
||||
vt_gpu_trace_idle = 1;
|
||||
@ -423,14 +430,18 @@ static vt_gpu_hn_string_t* vt_gpu_string_htab[VT_GPU_HASHTABLE_SIZE];
|
||||
void* vt_gpu_stringHashPut(const char* n, uint32_t rid)
|
||||
{
|
||||
uint32_t id = vt_hash(n, strlen(n), 0) & (VT_GPU_HASHTABLE_SIZE - 1);
|
||||
vt_gpu_hn_string_t *add =
|
||||
(vt_gpu_hn_string_t*)malloc(sizeof(vt_gpu_hn_string_t));
|
||||
vt_gpu_hn_string_t *add = NULL;
|
||||
|
||||
add->sname = strdup(n);
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
add = (vt_gpu_hn_string_t*)malloc(sizeof(vt_gpu_hn_string_t));
|
||||
add->sname = strdup(n);
|
||||
add->rid = rid;
|
||||
add->next = vt_gpu_string_htab[id];
|
||||
vt_gpu_string_htab[id] = add;
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return add;
|
||||
}
|
||||
|
||||
@ -453,6 +464,8 @@ void vt_gpu_stringhashClear()
|
||||
{
|
||||
int i;
|
||||
vt_gpu_hn_string_t* tmp_node;
|
||||
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
for ( i = 0; i < VT_GPU_HASHTABLE_SIZE; i++ )
|
||||
{
|
||||
@ -464,4 +477,6 @@ void vt_gpu_stringhashClear()
|
||||
vt_gpu_string_htab[i] = tmp_node;
|
||||
}
|
||||
}
|
||||
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
@ -26,21 +26,30 @@
|
||||
#include "vt_error.h" /* VampirTrace warning and error messages */
|
||||
|
||||
/* definition for the GPU tracing features/configuration */
|
||||
#define VT_GPU_TRACE_CUDA (1 << 0)
|
||||
#define VT_GPU_TRACE_CUPTI (1 << 1)
|
||||
#define VT_GPU_TRACE_OPENCL (1 << 2)
|
||||
#define VT_GPU_TRACE_RUNTIME_API (1 << 3)
|
||||
#define VT_GPU_TRACE_DRIVER_API (1 << 4)
|
||||
#define VT_GPU_TRACE_KERNEL (1 << 5)
|
||||
#define VT_GPU_TRACE_IDLE (1 << 6)
|
||||
#define VT_GPU_TRACE_MEMCPY (1 << 7)
|
||||
#define VT_GPU_TRACE_MEMUSAGE (1 << 8)
|
||||
#define VT_GPU_TRACE_DEBUG (1 << 9)
|
||||
#define VT_GPU_TRACE_ERROR (1 << 10)
|
||||
#define VT_GPU_TRACE_STREAM_REUSE (1 << 11)
|
||||
#define VT_GPU_TRACE_DEFAULT \
|
||||
#define VT_GPU_TRACE_CUDA (1 << 0)
|
||||
#define VT_GPU_TRACE_CUPTI (1 << 1)
|
||||
#define VT_GPU_TRACE_OPENCL (1 << 2)
|
||||
#define VT_GPU_TRACE_RUNTIME_API (1 << 3)
|
||||
#define VT_GPU_TRACE_DRIVER_API (1 << 4)
|
||||
#define VT_GPU_TRACE_KERNEL (1 << 5)
|
||||
#define VT_GPU_TRACE_CONCURRENT_KERNEL (1 << 6)
|
||||
#define VT_GPU_TRACE_IDLE (1 << 7)
|
||||
#define VT_GPU_TRACE_MEMCPY (1 << 8)
|
||||
#define VT_GPU_TRACE_MEMUSAGE (1 << 9)
|
||||
#define VT_GPU_TRACE_DEBUG (1 << 10)
|
||||
#define VT_GPU_TRACE_ERROR (1 << 11)
|
||||
#define VT_GPU_TRACE_STREAM_REUSE (1 << 12)
|
||||
|
||||
/* set the default tracing configuration */
|
||||
#if defined(VT_CUDARTWRAP)
|
||||
# define VT_GPU_TRACE_DEFAULT \
|
||||
(VT_GPU_TRACE_CUDA | VT_GPU_TRACE_RUNTIME_API | VT_GPU_TRACE_OPENCL | \
|
||||
VT_GPU_TRACE_KERNEL | VT_GPU_TRACE_MEMCPY)
|
||||
#else
|
||||
# define VT_GPU_TRACE_DEFAULT \
|
||||
(VT_GPU_TRACE_CUPTI | VT_GPU_TRACE_RUNTIME_API | VT_GPU_TRACE_OPENCL | \
|
||||
VT_GPU_TRACE_KERNEL | VT_GPU_TRACE_MEMCPY)
|
||||
#endif
|
||||
|
||||
/* defines the maximum string length of a function/kernel executed on GPU */
|
||||
#define VTGPU_KERNEL_STRING_SIZE 256
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "vt_env.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_libwrap.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
#include "vt_thrd.h"
|
||||
@ -174,7 +174,7 @@ void vt_iowrap_init()
|
||||
{
|
||||
static int lib_inited = 0;
|
||||
|
||||
vt_debug_msg(DBG_INIT, "iowrap_init: init check");
|
||||
vt_cntl_msg(DBG_INIT, "iowrap_init: init check");
|
||||
if (lib_inited)
|
||||
return;
|
||||
lib_inited = 1;
|
||||
@ -296,7 +296,7 @@ void vt_iowrap_init()
|
||||
|
||||
void vt_iowrap_reg()
|
||||
{
|
||||
vt_debug_msg(DBG_INIT, "iowrap_reg: vt_def_scl_file()");
|
||||
vt_cntl_msg(DBG_INIT, "iowrap_reg: vt_def_scl_file()");
|
||||
vt_fid = vt_def_scl_file( VT_CURRENT_THREAD, "I/O" );
|
||||
|
||||
VT_IOWRAP_REG_FUNC(open);
|
||||
@ -431,11 +431,11 @@ int open(const char *path, int flags, ...)
|
||||
if not, executes the I/O function and returns */
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, path, flags, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s, %i", path, mode);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s, %i", path, mode);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, path, flags, mode);
|
||||
|
||||
VT_IOWRAP_MAP_OPENFLAGSEXT( flags, mode);
|
||||
@ -472,11 +472,11 @@ int open64(const char *path, int flags, ...)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, path, flags, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s", path);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s", path);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, path, flags, mode);
|
||||
|
||||
VT_IOWRAP_MAP_OPENFLAGSEXT( flags, mode);
|
||||
@ -500,11 +500,11 @@ int creat(const char *path, mode_t mode)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, path, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s", path);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s", path);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, path, mode);
|
||||
|
||||
VT_IOWRAP_MAP_OPENFLAGSEXT( dummy, mode);
|
||||
@ -528,11 +528,11 @@ int creat64(const char *path, mode_t mode)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, path, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s", path);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s", path);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, path, mode);
|
||||
|
||||
VT_IOWRAP_MAP_OPENFLAGSEXT( dummy, mode);
|
||||
@ -554,11 +554,11 @@ int dup(int oldfd)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, oldfd);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", oldfd);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", oldfd);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, oldfd);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC_DUP( ret==-1, oldfd, ret);
|
||||
@ -578,11 +578,11 @@ int dup2(int oldfd, int newfd)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, oldfd, newfd);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i", oldfd, newfd);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i", oldfd, newfd);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, oldfd, newfd);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC_DUP( ret!=newfd, oldfd, ret);
|
||||
@ -602,11 +602,11 @@ int close(int fd)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, fd);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", fd);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", fd);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, fd);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC( ret==-1, fd);
|
||||
@ -626,11 +626,11 @@ off_t lseek(int fd, off_t offset, int whence)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, offset, whence);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, " OFF_T_STRARG ", %i", fd, offset, whence);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, " OFF_T_STRARG ", %i", fd, offset, whence);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, offset, whence);
|
||||
|
||||
VT_IOWRAP_2_EXTENDED_ARGUMENTS( key_type_offset, offset, key_type_whence, whence);
|
||||
@ -652,11 +652,11 @@ off64_t lseek64(int fd, off64_t offset, int whence)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, offset, whence);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %lli, %i", fd, (long long)offset, whence);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %lli, %i", fd, (long long)offset, whence);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, offset, whence);
|
||||
|
||||
VT_IOWRAP_2_EXTENDED_ARGUMENTS( key_type_offset, offset, key_type_whence, whence);
|
||||
@ -678,11 +678,11 @@ ssize_t read(int fd, void *buf, size_t count)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, buf, count);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu", fd, count);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu", fd, count);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, buf, count);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -703,11 +703,11 @@ ssize_t write(int fd, const void *buf, size_t count)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, buf, count);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu", fd, count);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu", fd, count);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, buf, count);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -728,11 +728,11 @@ ssize_t readv(int fd, const struct iovec *iov, int count)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, iov, count);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i iovecs", fd, count);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i iovecs", fd, count);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, iov, count);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -753,11 +753,11 @@ ssize_t writev(int fd, const struct iovec *iov, int count)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, iov, count);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i iovecs", fd, count);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i iovecs", fd, count);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, iov, count);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -778,11 +778,11 @@ ssize_t pread(int fd, void *buf, size_t count, off_t offset)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING4(ret, fd, buf, count, offset);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, " OFF_T_STRARG, fd, count, offset);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, " OFF_T_STRARG, fd, count, offset);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, ret, fd, buf, count, offset);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -804,11 +804,11 @@ ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING4(ret, fd, buf, count, offset);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, " OFF_T_STRARG, fd, count, offset);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, " OFF_T_STRARG, fd, count, offset);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, ret, fd, buf, count, offset);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -831,11 +831,11 @@ ssize_t pread64(int fd, void *buf, size_t count, off64_t offset)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING4(ret, fd, buf, count, offset);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, %lli", fd, count, (long long)offset);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, %lli", fd, count, (long long)offset);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, ret, fd, buf, count, offset);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -859,11 +859,11 @@ ssize_t pwrite64(int fd, const void *buf, size_t count, off64_t offset)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING4(ret, fd, buf, count, offset);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, %lli", fd, count, (long long)offset);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu, %lli", fd, count, (long long)offset);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, ret, fd, buf, count, offset);
|
||||
num_bytes = ret;
|
||||
|
||||
@ -888,11 +888,11 @@ FILE *fopen(const char *path, const char *mode)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, path, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s, %s", path, mode);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s, %s", path, mode);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, path, mode);
|
||||
tmp=(ret!=NULL) ? fileno(ret): 0;
|
||||
|
||||
@ -917,11 +917,11 @@ FILE *fopen64(const char *path, const char *mode)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, path, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s, %s", path, mode);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s, %s", path, mode);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, path, mode);
|
||||
tmp=(ret!=NULL) ? fileno(ret): 0;
|
||||
|
||||
@ -944,11 +944,11 @@ FILE *fdopen(int fd, const char *mode)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, fd, mode);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %s", fd, mode);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %s", fd, mode);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, fd, mode);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC( ret==NULL, fd );
|
||||
@ -969,13 +969,13 @@ int fclose(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
tmp = (stream!=NULL) ? fileno(stream) : 0;
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, stream);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC( ret!=0, tmp );
|
||||
@ -996,13 +996,13 @@ int fseek(FILE *stream, long offset, int whence)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, stream, offset, whence);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %li, %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %li, %i",
|
||||
stream != NULL ? fileno(stream) : -1,
|
||||
offset, whence);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, stream, offset, whence);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1026,13 +1026,13 @@ int fseeko(FILE *stream, off_t offset, int whence)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, stream, offset, whence);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, " OFF_T_STRARG ", %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, " OFF_T_STRARG ", %i",
|
||||
stream != NULL ? fileno(stream) : -1,
|
||||
offset, whence);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, stream, offset, whence);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1057,13 +1057,13 @@ int fseeko64(FILE *stream, off64_t offset, int whence)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, stream, offset, whence);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %lli, %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %lli, %i",
|
||||
stream != NULL ? fileno(stream) : -1,
|
||||
(long long)offset, whence);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, stream, offset, whence);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1086,12 +1086,12 @@ void rewind(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING_VOID1(stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1 );
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID1(VT_IOWRAP_THISFUNCNAME, stream);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1110,12 +1110,12 @@ int fsetpos(FILE *stream, const fpos_t *pos) {
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, stream, pos);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, stream, pos);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1137,12 +1137,12 @@ int fsetpos64(FILE *stream, const fpos64_t *pos) {
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, stream, pos);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, stream, pos);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1164,13 +1164,13 @@ size_t fread(void *buf, size_t size, size_t nmemb, FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING4(ret, buf, size, nmemb, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu x %zu",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu x %zu",
|
||||
stream != NULL ? fileno(stream) : -1,
|
||||
nmemb, size);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, ret, buf, size, nmemb, stream);
|
||||
num_bytes = (ssize_t)(size*ret);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1194,13 +1194,13 @@ size_t fwrite( const void *buf, size_t size, size_t nmemb, FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING4(ret, buf, size, nmemb, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu x %zu",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %zu x %zu",
|
||||
stream != NULL ? fileno(stream) : -1,
|
||||
nmemb, size);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, ret, buf, size, nmemb, stream);
|
||||
num_bytes = (ssize_t)(size*ret);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1224,12 +1224,12 @@ int fgetc(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, stream);
|
||||
num_bytes=1;
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1256,12 +1256,12 @@ int getc(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, stream);
|
||||
num_bytes=1;
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1284,12 +1284,12 @@ char *fgets(char *s, int size, FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, s, size, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i bytes max, @%p",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i bytes max, @%p",
|
||||
stream != NULL ? fileno(stream) : -1, size, s);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, s, size, stream);
|
||||
num_bytes=strlen(s);
|
||||
tmp=(ret!=NULL) ? fileno(stream): 0;
|
||||
@ -1311,11 +1311,11 @@ char *gets(char *s)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, s);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": @%p", s);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": @%p", s);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, s);
|
||||
num_bytes = (ssize_t)strlen(s);
|
||||
|
||||
@ -1337,12 +1337,12 @@ int fputc(int c, FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, c, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, c, stream);
|
||||
num_bytes=1;
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1369,12 +1369,12 @@ int putc(int c, FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, c, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, c, stream);
|
||||
num_bytes=1;
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1397,12 +1397,12 @@ int fputs(const char *s, FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING2(ret, s, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %p",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %p",
|
||||
stream != NULL ? fileno(stream) : -1, s);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, ret, s, stream);
|
||||
num_bytes = (ssize_t)strlen(s);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
@ -1424,11 +1424,11 @@ int puts(const char *s)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, s);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %p", s);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %p", s);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, s);
|
||||
num_bytes = (ssize_t)strlen(s);
|
||||
|
||||
@ -1450,12 +1450,12 @@ int fscanf(FILE *stream, const char *format, ...)
|
||||
VT_IOWRAP_INIT_IOFUNC();
|
||||
|
||||
if( DO_TRACE() ) {
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %s",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %s",
|
||||
stream != NULL ? fileno(stream) : -1, format);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "vfscanf");
|
||||
vt_cntl_msg(DBG_IO, "vfscanf");
|
||||
va_start (arg, format);
|
||||
ret = vfscanf(stream, format, arg);
|
||||
va_end (arg);
|
||||
@ -1495,12 +1495,12 @@ int fprintf(FILE *stream, const char *format, ...)
|
||||
VT_IOWRAP_INIT_IOFUNC();
|
||||
|
||||
if( DO_TRACE() ) {
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %s",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %s",
|
||||
stream != NULL ? fileno(stream) : -1, format);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "vfprintf");
|
||||
vt_cntl_msg(DBG_IO, "vfprintf");
|
||||
va_start (arg, format);
|
||||
#if defined(HAVE___FPRINTF_CHK) && HAVE___FPRINTF_CHK
|
||||
ret = __vfprintf_chk(stream, flag, format, arg);
|
||||
@ -1542,11 +1542,11 @@ int unlink(const char *path)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, path);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s\n", path);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %s\n", path);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME) "\n");
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME) "\n");
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, path);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC_PATH(ret, path);
|
||||
@ -1569,12 +1569,12 @@ void flockfile(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING_VOID1(stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID1(VT_IOWRAP_THISFUNCNAME, stream);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1599,12 +1599,12 @@ int ftrylockfile(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, stream);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1630,12 +1630,12 @@ void funlockfile(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING_VOID1(stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID1(VT_IOWRAP_THISFUNCNAME, stream);
|
||||
tmp=(stream!=NULL) ? fileno(stream): 0;
|
||||
|
||||
@ -1658,12 +1658,12 @@ int lockf(int fd, int function, off_t size)
|
||||
(void)num_bytes;
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, function, size);
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i, %llu", fd, function, (unsigned long long)size);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i, %llu", fd, function, (unsigned long long)size);
|
||||
|
||||
if( function == F_TEST )
|
||||
{
|
||||
/* Do not record lock tests */
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, function, size);
|
||||
return ret;
|
||||
}
|
||||
@ -1674,7 +1674,7 @@ int lockf(int fd, int function, off_t size)
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, function, size);
|
||||
|
||||
switch( function ) {
|
||||
@ -1690,13 +1690,13 @@ int lockf(int fd, int function, off_t size)
|
||||
break;
|
||||
}
|
||||
time = vt_pform_wtime();
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) );
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) );
|
||||
if( was_recorded ) {
|
||||
vampir_file_t* file = get_vampir_file( fd );
|
||||
uint32_t fid = file->vampir_file_id;
|
||||
if( fid ) {
|
||||
if( ret != 0 ) {
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time);
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time);
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, fid, (uint64_t)(fd)+1, matchingid, ioop | VT_IOFLAG_IOFAILED, (uint64_t)num_bytes );
|
||||
} else {
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, fid, (uint64_t)(fd)+1, matchingid, ioop, (uint64_t)num_bytes );
|
||||
@ -1704,7 +1704,7 @@ int lockf(int fd, int function, off_t size)
|
||||
}
|
||||
}
|
||||
vt_exit( VT_CURRENT_THREAD, &time );
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1736,7 +1736,7 @@ int fcntl(int fd, int cmd, ...)
|
||||
va_end(ap);
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING3(ret, fd, cmd, arg);
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i, %p", fd, cmd, arg);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i, %i, %p", fd, cmd, arg);
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
@ -1764,7 +1764,7 @@ int fcntl(int fd, int cmd, ...)
|
||||
/* Linux specific operations */
|
||||
default:
|
||||
/* Operations other than locking are not traced */
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, cmd, arg);
|
||||
return ret;
|
||||
}
|
||||
@ -1789,17 +1789,17 @@ int fcntl(int fd, int cmd, ...)
|
||||
break;
|
||||
}
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, ret, fd, cmd, arg);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) );
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) );
|
||||
if( was_recorded ) {
|
||||
vampir_file_t* file = get_vampir_file( fd );
|
||||
uint32_t fid = file->vampir_file_id;
|
||||
if( fid ) {
|
||||
if( ret == -1 ) {
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time);
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time);
|
||||
vt_ioend( &time, fid, matchingid, file->handle, ioop | VT_IOFLAG_IOFAILED, (uint64_t)num_bytes );
|
||||
}
|
||||
else {
|
||||
@ -1808,7 +1808,7 @@ int fcntl(int fd, int cmd, ...)
|
||||
}
|
||||
}
|
||||
vt_exit( &time );
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return ret;
|
||||
#undef VT_IOWRAP_THISFUNCNAME
|
||||
@ -1826,11 +1826,11 @@ void sync(void)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING_VOID0();
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID0(VT_IOWRAP_THISFUNCNAME);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC_CUSTOM(0, all_files_fid, 0);
|
||||
@ -1851,12 +1851,12 @@ int fflush(FILE *stream)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, stream);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i",
|
||||
stream != NULL ? fileno(stream) : -1);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, stream);
|
||||
if (stream == NULL) {
|
||||
VT_IOWRAP_LEAVE_IOFUNC_CUSTOM(ret!=0, all_files_fid, 0);
|
||||
@ -1881,11 +1881,11 @@ int fsync(int fd)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, fd);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", fd);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", fd);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, fd);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC( ret==-1, fd);
|
||||
@ -1906,11 +1906,11 @@ int fdatasync(int fd)
|
||||
|
||||
VT_IOWRAP_CHECK_TRACING1(ret, fd);
|
||||
|
||||
vt_debug_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", fd);
|
||||
vt_cntl_msg(DBG_IO, stringify(VT_IOWRAP_THISFUNCNAME) ": %i", fd);
|
||||
|
||||
VT_IOWRAP_ENTER_IOFUNC();
|
||||
|
||||
vt_debug_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
vt_cntl_msg(DBG_IO, "real_" stringify(VT_IOWRAP_THISFUNCNAME));
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, ret, fd);
|
||||
|
||||
VT_IOWRAP_LEAVE_IOFUNC( ret==-1, fd);
|
||||
|
@ -81,12 +81,12 @@
|
||||
#define VT_ENABLE_IO_TRACING() \
|
||||
VT_CHECK_THREAD; \
|
||||
VTTHRD_IO_TRACING_ENABLED(VTTHRD_MY_VTTHRD) = 1; \
|
||||
vt_debug_msg( DBG_INIT, "ENABLED I/O tracing (susp=%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(VTTHRD_MY_VTTHRD), __LINE__ )
|
||||
vt_cntl_msg( DBG_INIT, "ENABLED I/O tracing (susp=%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(VTTHRD_MY_VTTHRD), __LINE__ )
|
||||
|
||||
#define VT_DISABLE_IO_TRACING() \
|
||||
VT_CHECK_THREAD; \
|
||||
VTTHRD_IO_TRACING_ENABLED(VTTHRD_MY_VTTHRD) = 0; \
|
||||
vt_debug_msg( DBG_INIT, "DISABLED I/O tracing (susp=%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(VTTHRD_MY_VTTHRD), __LINE__ )
|
||||
vt_cntl_msg( DBG_INIT, "DISABLED I/O tracing (susp=%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(VTTHRD_MY_VTTHRD), __LINE__ )
|
||||
|
||||
#define VT_SUSPEND_IO_TRACING(tid) \
|
||||
{ \
|
||||
@ -101,11 +101,11 @@
|
||||
VTTHRD_IO_TRACING_STATE(thrd) = VTTHRD_IO_TRACING_ENABLED(thrd); \
|
||||
VTTHRD_IO_TRACING_SUSPEND_CNT(thrd)++; \
|
||||
VTTHRD_IO_TRACING_ENABLED(thrd) = 0; \
|
||||
vt_debug_msg( DBG_INIT, "SUSPENDED I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
vt_cntl_msg( DBG_INIT, "SUSPENDED I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
} \
|
||||
else { \
|
||||
VTTHRD_IO_TRACING_SUSPEND_CNT(thrd)++; \
|
||||
vt_debug_msg( DBG_INIT, "SUSPENDED I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
vt_cntl_msg( DBG_INIT, "SUSPENDED I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -118,10 +118,10 @@
|
||||
} else { \
|
||||
thrd = VTThrdv[tid]; \
|
||||
} \
|
||||
vt_debug_msg( DBG_INIT, "TRY RESUME I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
vt_cntl_msg( DBG_INIT, "TRY RESUME I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
if( VTTHRD_IO_TRACING_SUSPEND_CNT(thrd) > 0 ) { \
|
||||
if( (--VTTHRD_IO_TRACING_SUSPEND_CNT(thrd)) == 0 ) { \
|
||||
vt_debug_msg( DBG_INIT, "RESUMED I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
vt_cntl_msg( DBG_INIT, "RESUMED I/O tracing (%hhu) at " __FILE__ ", %i", VTTHRD_IO_TRACING_SUSPEND_CNT(thrd), __LINE__ ); \
|
||||
VTTHRD_IO_TRACING_ENABLED(thrd) = VTTHRD_IO_TRACING_STATE(thrd); \
|
||||
} \
|
||||
} \
|
||||
@ -306,10 +306,10 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
#define fdatasync_FUNCTYPE VT_IOOP_SYNC
|
||||
|
||||
/* #define IOWRAP_REGION_DESCR_LEN 256 */
|
||||
#define DBG_INIT 1
|
||||
#define DBG_IO 2
|
||||
#define DBG_VT_CALL 3
|
||||
#define DBG_TRACECHK 4
|
||||
#define DBG_INIT 10
|
||||
#define DBG_IO 11
|
||||
#define DBG_VT_CALL 12
|
||||
#define DBG_TRACECHK 13
|
||||
#define DBG_FULL 255
|
||||
|
||||
/* modes for open/creat */
|
||||
@ -334,16 +334,16 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
#define VT_IOWRAP_INIT_FUNC(FUNC_NAME) \
|
||||
{ \
|
||||
if (!iofunctions[FUNC_IDX(FUNC_NAME)].lib_func.p) { \
|
||||
vt_debug_msg(DBG_INIT, "init_func: dlsym(" stringify(FUNC_NAME) ") --> "); \
|
||||
vt_cntl_msg(DBG_INIT, "init_func: dlsym(" stringify(FUNC_NAME) ") --> "); \
|
||||
(void)dlerror(); \
|
||||
iofunctions[FUNC_IDX(FUNC_NAME)].lib_func.p = \
|
||||
dlsym( iolib_handle, stringify(FUNC_NAME) ); \
|
||||
vt_debug_msg(DBG_INIT, "%p", iofunctions[FUNC_IDX(FUNC_NAME)].lib_func.p); \
|
||||
vt_cntl_msg(DBG_INIT, "%p", iofunctions[FUNC_IDX(FUNC_NAME)].lib_func.p); \
|
||||
if (!iofunctions[FUNC_IDX(FUNC_NAME)].lib_func.p) \
|
||||
symload_fail( stringify(FUNC_NAME), dlerror() ); \
|
||||
} \
|
||||
else { \
|
||||
vt_debug_msg(DBG_INIT, "init_func: " stringify(FUNC_NAME) " was already looked up: %p", \
|
||||
vt_cntl_msg(DBG_INIT, "init_func: " stringify(FUNC_NAME) " was already looked up: %p", \
|
||||
iofunctions[FUNC_IDX(FUNC_NAME)].lib_func.p); \
|
||||
} \
|
||||
}
|
||||
@ -351,16 +351,17 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
/** Setup VT region and tracing specific settings
|
||||
* ... to be used in global initialization after RFG initialization
|
||||
*/
|
||||
#define VT_IOWRAP_FUNCGRP "LIBC-I/O" /* group for I/O functions */
|
||||
#define VT_IOWRAP_REG_FUNC(FUNC_NAME) \
|
||||
{ \
|
||||
vt_debug_msg(DBG_INIT, "reg_func: vt_def_region(" stringify(FUNC_NAME) ")"); \
|
||||
vt_cntl_msg(DBG_INIT, "reg_func: vt_def_region(" stringify(FUNC_NAME) ")"); \
|
||||
iofunctions[FUNC_IDX(FUNC_NAME)].vt_func_id = \
|
||||
vt_def_region( VT_CURRENT_THREAD, stringify(FUNC_NAME), \
|
||||
vt_fid, \
|
||||
VT_NO_LNO, \
|
||||
VT_NO_LNO, \
|
||||
NULL, \
|
||||
VT_LIBC_IO ); \
|
||||
VT_IOWRAP_FUNCGRP, \
|
||||
VT_FUNCTION ); \
|
||||
iofunctions[FUNC_IDX(FUNC_NAME)].traceme = 1; \
|
||||
}
|
||||
|
||||
@ -474,10 +475,8 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
uint64_t matchingid = 0; \
|
||||
ssize_t num_bytes=0; \
|
||||
uint8_t was_recorded; \
|
||||
uint8_t enable_memhooks=0; \
|
||||
{ \
|
||||
if( VT_MEMHOOKS_ENABLED() ) \
|
||||
{ VT_MEMHOOKS_OFF(); enable_memhooks = 1; } \
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
if (!iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p) { \
|
||||
get_iolib_handle(); \
|
||||
(void)dlerror(); \
|
||||
@ -485,7 +484,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
dlsym( iolib_handle, stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if (!iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p) \
|
||||
symload_fail( stringify(VT_IOWRAP_THISFUNCNAME), dlerror() ); \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_INIT_IOFUNC(): " stringify(VT_IOWRAP_THISFUNCNAME) " --> %p", iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_INIT_IOFUNC(): " stringify(VT_IOWRAP_THISFUNCNAME) " --> %p", iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p); \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -494,10 +493,8 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
#define VT_IOWRAP_INIT_IOFUNC_OPEN() \
|
||||
uint64_t matchingid = 0; \
|
||||
uint8_t was_recorded; \
|
||||
uint8_t enable_memhooks=0; \
|
||||
{ \
|
||||
if( VT_MEMHOOKS_ENABLED() ) \
|
||||
{ VT_MEMHOOKS_OFF(); enable_memhooks = 1; } \
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
if (!iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p) { \
|
||||
get_iolib_handle(); \
|
||||
(void)dlerror(); \
|
||||
@ -505,7 +502,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
dlsym( iolib_handle, stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if (!iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p) \
|
||||
symload_fail( stringify(VT_IOWRAP_THISFUNCNAME), dlerror() ); \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_INIT_IOFUNC_OPEN(): " stringify(VT_IOWRAP_THISFUNCNAME) " --> %p", iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_INIT_IOFUNC_OPEN(): " stringify(VT_IOWRAP_THISFUNCNAME) " --> %p", iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].lib_func.p); \
|
||||
} \
|
||||
}
|
||||
|
||||
@ -514,42 +511,47 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
#if 0
|
||||
#define VT_IOWRAP_CHECK_TRACING(RET, ...) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC(VT_IOWRAP_THISFUNCNAME, RET, __VA_ARGS__); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return RET; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#define VT_IOWRAP_CHECK_TRACING1(RET, ARG1) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC1(VT_IOWRAP_THISFUNCNAME, RET, ARG1); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return RET; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING2(RET, ARG1, ARG2) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC2(VT_IOWRAP_THISFUNCNAME, RET, ARG1, ARG2); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return RET; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING3(RET, ARG1, ARG2, ARG3) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC3(VT_IOWRAP_THISFUNCNAME, RET, ARG1, ARG2, ARG3); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return RET; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING4(RET, ARG1, ARG2, ARG3, ARG4) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC4(VT_IOWRAP_THISFUNCNAME, RET, ARG1, ARG2, ARG3, ARG4); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return RET; \
|
||||
} \
|
||||
}
|
||||
@ -557,50 +559,56 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
#if 0
|
||||
#define VT_IOWRAP_CHECK_TRACING_VOID(...) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID(VT_IOWRAP_THISFUNCNAME, __VA_ARGS__); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#endif
|
||||
#define VT_IOWRAP_CHECK_TRACING_VOID0() \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID0(VT_IOWRAP_THISFUNCNAME); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING_VOID1(ARG1) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID1(VT_IOWRAP_THISFUNCNAME, ARG1); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING_VOID2(ARG1, ARG2) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID2(VT_IOWRAP_THISFUNCNAME, ARG1, ARG2); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING_VOID3(ARG1, ARG2, ARG3) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID3(VT_IOWRAP_THISFUNCNAME, ARG1, ARG2, ARG3); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
#define VT_IOWRAP_CHECK_TRACING_VOID4(ARG1, ARG2, ARG3, ARG4) \
|
||||
{ \
|
||||
vt_debug_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_TRACECHK, "Macro VT_IOWRAP_CHECK_TRACING_VOID(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( !DO_TRACE() ) { \
|
||||
VT_IOWRAP_CALL_LIBFUNC_VOID4(VT_IOWRAP_THISFUNCNAME, ARG1, ARG2, ARG3, ARG4); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
@ -610,7 +618,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
#define VT_IOWRAP_ENTER_IOFUNC() \
|
||||
{ \
|
||||
enter_time = vt_pform_wtime(); \
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_enter(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)enter_time); \
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_enter(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)enter_time); \
|
||||
was_recorded = vt_enter( VT_CURRENT_THREAD, &enter_time, iofunctions[FUNC_IDX(VT_IOWRAP_THISFUNCNAME)].vt_func_id ); \
|
||||
if( was_recorded ) { \
|
||||
matchingid = VTTHRD_IO_NEXT_MATCHINGID(VTTHRD_MY_VTTHRD); \
|
||||
@ -626,7 +634,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
{ \
|
||||
int preserve_errno = errno; \
|
||||
uint64_t time = vt_pform_wtime(); \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( was_recorded ) { \
|
||||
uint32_t ioop = VT_IOWRAP_FUNCTYPE(VT_IOWRAP_THISFUNCNAME); \
|
||||
uint32_t fid; \
|
||||
@ -644,11 +652,11 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
if( ERROR_CONDITION ) { \
|
||||
ioop |= VT_IOFLAG_IOFAILED; \
|
||||
} \
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, fid, matchingid, handle, ioop, (uint64_t)num_bytes ); \
|
||||
} \
|
||||
vt_exit( VT_CURRENT_THREAD, &time ); \
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON(); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
errno = preserve_errno; \
|
||||
}
|
||||
|
||||
@ -657,17 +665,17 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
{ \
|
||||
int preserve_errno = errno; \
|
||||
uint64_t time = vt_pform_wtime(); \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( was_recorded ) { \
|
||||
uint32_t ioop = VT_IOWRAP_FUNCTYPE(VT_IOWRAP_THISFUNCNAME); \
|
||||
if( ERROR_CONDITION ) { \
|
||||
ioop |= VT_IOFLAG_IOFAILED; \
|
||||
} \
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, FID, matchingid, HANDLE, ioop, (uint64_t)num_bytes ); \
|
||||
} \
|
||||
vt_exit( VT_CURRENT_THREAD, &time ); \
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON(); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
errno = preserve_errno; \
|
||||
}
|
||||
|
||||
@ -683,7 +691,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
uint32_t fid; \
|
||||
vampir_file_t* file; \
|
||||
uint64_t handle; \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC_OPEN(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC_OPEN(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( ERROR_CONDITION ) { \
|
||||
if( was_recorded ) { \
|
||||
if( path && strlen(path) > 0 ) { \
|
||||
@ -705,12 +713,12 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
} \
|
||||
} \
|
||||
if( was_recorded ) { \
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
VT_IOWRAP_1_EXTENDED_ARGUMENT( key_type_mode, open_flags) \
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, fid, matchingid, handle, ioop, 0 ); \
|
||||
} \
|
||||
vt_exit( VT_CURRENT_THREAD, &time ); \
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON(); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
errno = preserve_errno; \
|
||||
}
|
||||
|
||||
@ -725,7 +733,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
vampir_file_t* file; \
|
||||
uint32_t fid; \
|
||||
uint64_t handle; \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC_DUP(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC_DUP(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
file = get_vampir_file( OLDFD ); \
|
||||
fid = file->vampir_file_id; \
|
||||
handle = file->handle; \
|
||||
@ -736,11 +744,11 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
vt_iofile_dupfd( OLDFD, NEWFD ); \
|
||||
} \
|
||||
if( was_recorded ) { \
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, fid, matchingid, handle, ioop, (uint64_t)num_bytes ); \
|
||||
} \
|
||||
vt_exit( VT_CURRENT_THREAD, &time ); \
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON(); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
errno = preserve_errno; \
|
||||
}
|
||||
|
||||
@ -750,7 +758,7 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
{ \
|
||||
int preserve_errno = errno; \
|
||||
uint64_t time = vt_pform_wtime(); \
|
||||
vt_debug_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC_PATH(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
vt_cntl_msg( DBG_INIT, "Macro VT_IOWRAP_LEAVE_IOFUNC_PATH(), Function " stringify(VT_IOWRAP_THISFUNCNAME) ); \
|
||||
if( was_recorded ) { \
|
||||
uint32_t ioop = VT_IOWRAP_FUNCTYPE(VT_IOWRAP_THISFUNCNAME); \
|
||||
uint32_t fid; \
|
||||
@ -766,11 +774,11 @@ EXTERN int(*libc_fprintf)(FILE *, const char *, ...);
|
||||
else { \
|
||||
fid = vt_iofile_id(PATH); \
|
||||
} \
|
||||
vt_debug_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_cntl_msg(DBG_VT_CALL, "vt_ioend(" stringify(VT_IOWRAP_THISFUNCNAME) "), stamp %llu", (unsigned long long)time); \
|
||||
vt_ioend( VT_CURRENT_THREAD, &time, fid, matchingid, 0, ioop, 0 ); \
|
||||
} \
|
||||
vt_exit( VT_CURRENT_THREAD, &time ); \
|
||||
if( enable_memhooks ) VT_MEMHOOKS_ON(); \
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD); \
|
||||
errno = preserve_errno; \
|
||||
}
|
||||
|
||||
|
@ -1,542 +0,0 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "vt_defs.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_fork.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_iowrap.h"
|
||||
#include "vt_libcwrap.h"
|
||||
#include "vt_libwrap.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if (defined(HAVE_WAIT) && HAVE_WAIT) || (defined(HAVE_WAITPID) && HAVE_WAITPID)
|
||||
# include <sys/types.h>
|
||||
# include <sys/wait.h>
|
||||
# ifndef __WAIT_STATUS_DEFN
|
||||
# define WAIT_STATUS_TYPE int*
|
||||
# else
|
||||
# define WAIT_STATUS_TYPE __WAIT_STATUS
|
||||
# endif /* __WAIT_STATUS_DEFN */
|
||||
#endif /* HAVE_WAIT || HAVE_WAITPID */
|
||||
|
||||
#define execl_FUNCIDX 0
|
||||
#define execl_FUNCDEF (int (*)(const char*, const char*, ...))
|
||||
#define execle_FUNCIDX 1
|
||||
#define execle_FUNCDEF (int (*)(const char*, const char*, ...))
|
||||
#define execlp_FUNCIDX 2
|
||||
#define execlp_FUNCDEF (int (*)(const char*, const char*, ...))
|
||||
#define execv_FUNCIDX 3
|
||||
#define execv_FUNCDEF (int (*)(const char*, char* const[]))
|
||||
#define execve_FUNCIDX 4
|
||||
#define execve_FUNCDEF (int (*)(const char*, char* const[], char* const[]))
|
||||
#define execvp_FUNCIDX 5
|
||||
#define execvp_FUNCDEF (int (*)(const char*, char* const[]))
|
||||
#define fork_FUNCIDX 6
|
||||
#define fork_FUNCDEF (pid_t (*)(void))
|
||||
#define system_FUNCIDX 7
|
||||
#define system_FUNCDEF (int (*)(const char*))
|
||||
#define wait_FUNCIDX 8
|
||||
#define wait_FUNCDEF (pid_t (*)(WAIT_STATUS_TYPE status))
|
||||
#define waitpid_FUNCIDX 9
|
||||
#define waitpid_FUNCDEF (pid_t (*)(pid_t, int*, int))
|
||||
#define LIBC_FUNC_NUM 10
|
||||
|
||||
#define FUNCIDX(fname) fname ## _FUNCIDX
|
||||
#define FUNCDEF(fname) fname ## _FUNCDEF
|
||||
|
||||
/* macro: defines function */
|
||||
#define INIT_FUNC(fname) \
|
||||
libc_funcs[FUNCIDX(fname)].traceme = 1; \
|
||||
libc_funcs[FUNCIDX(fname)].rid = \
|
||||
vt_def_region(VT_CURRENT_THREAD, #fname, libc_fid, VT_NO_LNO, \
|
||||
VT_NO_LNO, NULL, VT_LIBC); \
|
||||
GET_REAL_FUNC(fname);
|
||||
|
||||
/* macro: gets (real) function pointer */
|
||||
#define GET_REAL_FUNC(fname) \
|
||||
if( !libc_funcs[FUNCIDX(fname)].fptr.p ) { \
|
||||
libc_handle = vt_libwrap_get_libc_handle(); \
|
||||
(void)dlerror(); /* clear any existing error */ \
|
||||
libc_funcs[FUNCIDX(fname)].fptr.p = dlsym(libc_handle, #fname); \
|
||||
if( !libc_funcs[FUNCIDX(fname)].fptr.p ) { \
|
||||
printf("VampirTrace: FATAL: dlsym() error for symbol %s: %s\n",\
|
||||
#fname, dlerror()); \
|
||||
exit(EXIT_FAILURE); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* macro: calls (real) function */
|
||||
#define CALL_FUNC(fname, fret, fargs) \
|
||||
GET_REAL_FUNC(fname); \
|
||||
vt_libwrap_set_libc_errno(errno); \
|
||||
fret = (FUNCDEF(fname)(libc_funcs[FUNCIDX(fname)].fptr.f))fargs; \
|
||||
errno = vt_libwrap_get_libc_errno()
|
||||
|
||||
/* macro: checks if we shall trace right now
|
||||
* Tracing can be disabled globally via vt_libc_tracing_enabled = 0
|
||||
* or for each function separately via libc_funcs[IDX].traceme = 0 */
|
||||
#define DO_TRACE(fname) \
|
||||
(vt_libc_tracing_enabled && libc_funcs[FUNCIDX(fname)].traceme)
|
||||
|
||||
struct libc_func {
|
||||
uint8_t traceme;
|
||||
uint32_t rid;
|
||||
|
||||
/* The following is necessary to avoid "warning: ISO C forbids conversion of
|
||||
* object pointer to function pointer type". If the function calls break on
|
||||
* some platform, the cause would most possibly lie here.
|
||||
* Then sizeof(void *) != sizeof(<function pointer>)
|
||||
*/
|
||||
union {
|
||||
void *p;
|
||||
void (*f)(void);
|
||||
} fptr;
|
||||
};
|
||||
|
||||
/* flag for enabling and disabling tracing */
|
||||
int vt_libc_tracing_enabled = 0;
|
||||
int vt_libc_tracing_state = 0;
|
||||
|
||||
static uint32_t libc_fid = VT_NO_ID;
|
||||
static struct libc_func libc_funcs[LIBC_FUNC_NUM];
|
||||
static void *libc_handle = NULL;
|
||||
|
||||
void vt_libcwrap_init(void)
|
||||
{
|
||||
/* get file-id for LIBC functions */
|
||||
libc_fid = vt_def_scl_file(VT_CURRENT_THREAD, "LIBC");
|
||||
|
||||
#if (!defined (VT_MPI) && !defined (VT_MT) && !defined(VT_HYB) && !defined(VT_JAVA))
|
||||
|
||||
#if defined(HAVE_EXECL) && HAVE_EXECL
|
||||
INIT_FUNC(execl);
|
||||
#endif /* HAVE_EXECL */
|
||||
|
||||
#if defined(HAVE_EXECLE) && HAVE_EXECLE
|
||||
INIT_FUNC(execle);
|
||||
#endif /* HAVE_EXECLE */
|
||||
|
||||
#if defined(HAVE_EXECLP) && HAVE_EXECLP
|
||||
INIT_FUNC(execlp);
|
||||
#endif /* HAVE_EXECLP */
|
||||
|
||||
#if defined(HAVE_EXECV) && HAVE_EXECV
|
||||
INIT_FUNC(execv);
|
||||
#endif /* HAVE_EXECV */
|
||||
|
||||
#if defined(HAVE_EXECVE) && HAVE_EXECVE
|
||||
INIT_FUNC(execve);
|
||||
#endif /* HAVE_EXECVE */
|
||||
|
||||
#if defined(HAVE_EXECVP) && HAVE_EXECVP
|
||||
INIT_FUNC(execvp);
|
||||
#endif /* HAVE_EXECVP */
|
||||
|
||||
#if defined(HAVE_FORK) && HAVE_FORK
|
||||
INIT_FUNC(fork);
|
||||
#endif /* HAVE_FORK */
|
||||
|
||||
#endif /* !VT_MPI && !VT_MT && !VT_HYB && !VT_JAVA */
|
||||
|
||||
#if defined(HAVE_SYSTEM) && HAVE_SYSTEM
|
||||
INIT_FUNC(system);
|
||||
#endif /* HAVE_SYSTEM */
|
||||
|
||||
#if defined(HAVE_WAIT) && HAVE_WAIT
|
||||
INIT_FUNC(wait);
|
||||
#endif /* HAVE_WAIT */
|
||||
|
||||
#if defined(HAVE_WAITPID) && HAVE_WAITPID
|
||||
INIT_FUNC(waitpid);
|
||||
#endif /* HAVE_WAITPID */
|
||||
}
|
||||
|
||||
void vt_libcwrap_finalize(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#if (!defined (VT_MPI) && !defined (VT_MT) && !defined(VT_HYB) && !defined(VT_JAVA))
|
||||
|
||||
/* -- execl -- */
|
||||
|
||||
#if defined(HAVE_EXECL) && HAVE_EXECL
|
||||
int execl(const char* path, const char* arg, ...)
|
||||
{
|
||||
int rc;
|
||||
char* argv[100];
|
||||
char* tmp;
|
||||
int i;
|
||||
va_list ap;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
va_start(ap, arg);
|
||||
|
||||
i = 0;
|
||||
argv[i++] = (char*)arg;
|
||||
while((tmp = va_arg(ap, char*) ))
|
||||
argv[i++] = tmp;
|
||||
argv[i] = NULL;
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if ( DO_TRACE(execl) )
|
||||
{
|
||||
/* mark enter function */
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(execl)].rid);
|
||||
}
|
||||
|
||||
/* close VT for current process */
|
||||
vt_close();
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(execv, rc, (path, argv));
|
||||
|
||||
vt_warning("execl failed: %s", strerror(errno));
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_EXECL */
|
||||
|
||||
/* -- execle -- */
|
||||
|
||||
#if defined(HAVE_EXECLE) && HAVE_EXECLE
|
||||
int execle(const char* path, const char* arg, ...)
|
||||
{
|
||||
int rc;
|
||||
char* argv[100];
|
||||
char** envp;
|
||||
char* tmp;
|
||||
int i;
|
||||
va_list ap;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
va_start(ap, arg);
|
||||
|
||||
i = 0;
|
||||
argv[i++] = (char*)arg;
|
||||
while((tmp = va_arg(ap, char*) ))
|
||||
argv[i++] = tmp;
|
||||
argv[i] = NULL;
|
||||
envp = va_arg(ap, char**);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if ( DO_TRACE(execle) )
|
||||
{
|
||||
/* mark enter function */
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(execle)].rid);
|
||||
}
|
||||
|
||||
/* close VT for current process */
|
||||
vt_close();
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(execve, rc, (path, argv, envp));
|
||||
|
||||
vt_warning("execle failed: %s", strerror(errno));
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_EXECLE */
|
||||
|
||||
/* -- execlp -- */
|
||||
|
||||
#if defined(HAVE_EXECLP) && HAVE_EXECLP
|
||||
int execlp(const char* file, const char* arg, ...)
|
||||
{
|
||||
int rc;
|
||||
char* argv[100];
|
||||
char* tmp;
|
||||
int i;
|
||||
va_list ap;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
va_start(ap, arg);
|
||||
|
||||
i = 0;
|
||||
argv[i++] = (char*)arg;
|
||||
while((tmp = va_arg(ap, char*) ))
|
||||
argv[i++] = tmp;
|
||||
argv[i] = NULL;
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if ( DO_TRACE(execlp) )
|
||||
{
|
||||
/* mark enter function */
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(execlp)].rid);
|
||||
}
|
||||
|
||||
/* close VT for current process */
|
||||
vt_close();
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(execvp, rc, (file, argv));
|
||||
|
||||
vt_warning("execlp failed: %s", strerror(errno));
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_EXECLP */
|
||||
|
||||
/* -- execv -- */
|
||||
|
||||
#if defined(HAVE_EXECV) && HAVE_EXECV
|
||||
int execv(const char* path, char* const argv[])
|
||||
{
|
||||
int rc;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(execv) )
|
||||
{
|
||||
/* mark enter function */
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(execv)].rid);
|
||||
}
|
||||
|
||||
/* close VT for current process */
|
||||
vt_close();
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(execv, rc, (path, argv));
|
||||
|
||||
vt_warning("execv failed: %s", strerror(errno));
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_EXECV */
|
||||
|
||||
/* -- execve -- */
|
||||
|
||||
#if defined(HAVE_EXECVE) && HAVE_EXECVE
|
||||
int execve(const char* file, char* const argv[], char* const envp[])
|
||||
{
|
||||
int rc;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(execve) )
|
||||
{
|
||||
/* mark enter function */
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(execve)].rid);
|
||||
}
|
||||
|
||||
/* close VT for current process */
|
||||
vt_close();
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(execve, rc, (file, argv, envp));
|
||||
|
||||
vt_warning("execve failed: %s", strerror(errno));
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_EXECVE */
|
||||
|
||||
/* -- execvp -- */
|
||||
|
||||
#if defined(HAVE_EXECVP) && HAVE_EXECVP
|
||||
int execvp(const char* path, char* const argv[])
|
||||
{
|
||||
int rc;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(execvp) )
|
||||
{
|
||||
/* mark enter function */
|
||||
uint64_t time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(execvp)].rid);
|
||||
}
|
||||
|
||||
/* close VT for current process */
|
||||
vt_close();
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(execvp, rc, (path, argv));
|
||||
|
||||
vt_warning("execvp failed: %s", strerror(errno));
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_EXECVP */
|
||||
|
||||
/* -- fork -- */
|
||||
|
||||
#if defined(HAVE_FORK) && HAVE_FORK
|
||||
|
||||
pid_t fork(void)
|
||||
{
|
||||
pid_t rc;
|
||||
int preserve_errno;
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(fork) )
|
||||
{
|
||||
/* mark enter function */
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(fork)].rid);
|
||||
}
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(fork, rc, ());
|
||||
preserve_errno = errno;
|
||||
|
||||
if ( DO_TRACE(fork) )
|
||||
{
|
||||
/* handle fork, if succeeded */
|
||||
if ( rc != -1 )
|
||||
vt_fork(rc);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
/* mark leave function */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
}
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
|
||||
errno = preserve_errno;
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_FORK */
|
||||
|
||||
#endif /* !VT_MPI && !VT_MT && !VT_HYB && !VT_JAVA */
|
||||
|
||||
/* -- system -- */
|
||||
|
||||
#if defined(HAVE_SYSTEM) && HAVE_SYSTEM
|
||||
int system(const char* string)
|
||||
{
|
||||
int rc;
|
||||
int preserve_errno;
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(system) )
|
||||
{
|
||||
/* mark enter function */
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(system)].rid);
|
||||
}
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(system, rc, (string));
|
||||
preserve_errno = errno;
|
||||
|
||||
if ( DO_TRACE(system) )
|
||||
{
|
||||
/* mark leave function */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
|
||||
errno = preserve_errno;
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_SYSTEM */
|
||||
|
||||
/* -- wait -- */
|
||||
|
||||
#if defined(HAVE_WAIT) && HAVE_WAIT
|
||||
pid_t wait(WAIT_STATUS_TYPE status)
|
||||
{
|
||||
pid_t rc;
|
||||
int preserve_errno;
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(wait) )
|
||||
{
|
||||
/* mark enter function */
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(wait)].rid);
|
||||
}
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(wait, rc, (status));
|
||||
preserve_errno = errno;
|
||||
|
||||
if ( DO_TRACE(wait) )
|
||||
{
|
||||
/* mark leave function */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
|
||||
errno = preserve_errno;
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_WAIT */
|
||||
|
||||
/* -- waitpid -- */
|
||||
|
||||
#if defined(HAVE_WAITPID) && HAVE_WAITPID
|
||||
pid_t waitpid(pid_t pid, int* status, int options)
|
||||
{
|
||||
pid_t rc;
|
||||
int preserve_errno;
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
|
||||
if ( DO_TRACE(waitpid) )
|
||||
{
|
||||
/* mark enter function */
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, libc_funcs[FUNCIDX(waitpid)].rid);
|
||||
}
|
||||
|
||||
/* call (real) function */
|
||||
CALL_FUNC(waitpid, rc, (pid, status, options));
|
||||
preserve_errno = errno;
|
||||
|
||||
if ( DO_TRACE(waitpid) )
|
||||
{
|
||||
/* mark leave function */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
|
||||
errno = preserve_errno;
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_WAITPID */
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#ifndef _VT_LIBCWRAP_H
|
||||
#define _VT_LIBCWRAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#if (defined(VT_LIBCWRAP))
|
||||
|
||||
#define VT_ENABLE_LIBC_TRACING() vt_libc_tracing_enabled = 1
|
||||
#define VT_DISABLE_LIBC_TRACING() vt_libc_tracing_enabled = 0
|
||||
#define VT_SUSPEND_LIBC_TRACING() \
|
||||
vt_libc_tracing_state = vt_libc_tracing_enabled; \
|
||||
vt_libc_tracing_enabled = 0
|
||||
#define VT_RESUME_LIBC_TRACING() \
|
||||
vt_libc_tracing_enabled = vt_libc_tracing_state
|
||||
|
||||
/* libc wrapper initialization */
|
||||
EXTERN void vt_libcwrap_init(void);
|
||||
|
||||
/* libc wrapper finalization */
|
||||
EXTERN void vt_libcwrap_finalize(void);
|
||||
|
||||
EXTERN int vt_libc_tracing_enabled;
|
||||
EXTERN int vt_libc_tracing_state;
|
||||
|
||||
#else /* VT_LIBCWRAP */
|
||||
|
||||
#define VT_ENABLE_LIBC_TRACING()
|
||||
#define VT_DISABLE_LIBC_TRACING()
|
||||
#define VT_SUSPEND_LIBC_TRACING()
|
||||
#define VT_RESUME_LIBC_TRACING()
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _VT_LIBCWRAP_H */
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "vt_error.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_libwrap.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -29,14 +29,14 @@
|
||||
#include <string.h>
|
||||
|
||||
/* maximum number of library wrapper objects */
|
||||
#define MAX_LW 16
|
||||
#define MAX_LWS 16
|
||||
|
||||
/* maximum number of handles for shared libraries
|
||||
=VT_LIBWRAP_MAX_SHLIBS [+1 for RTLD_NEXT] */
|
||||
=VT_LIBWRAP_MAX_SHLIBS +1(LIBC's handle) [+1(RTLD_NEXT)] */
|
||||
#if defined(HAVE_DECL_RTLD_NEXT) && HAVE_DECL_RTLD_NEXT
|
||||
# define MAX_HANDLES (VT_LIBWRAP_MAX_SHLIBS+1)
|
||||
# define MAX_HANDLES (VT_LIBWRAP_MAX_SHLIBS+1+1)
|
||||
#else /* HAVE_DECL_RTLD_NEXT */
|
||||
# define MAX_HANDLES VT_LIBWRAP_MAX_SHLIBS
|
||||
# define MAX_HANDLES (VT_LIBWRAP_MAX_SHLIBS+1)
|
||||
#endif /* HAVE_DECL_RTLD_NEXT */
|
||||
|
||||
/* data structure for library wrapper object */
|
||||
@ -47,8 +47,8 @@ struct VTLibwrap_struct
|
||||
uint32_t handlen; /* number of handles */
|
||||
};
|
||||
|
||||
static VTLibwrap* lwv[MAX_LW]; /* vector of library wrapper objects */
|
||||
static uint32_t lwn = 0; /* number of library wrapper objects */
|
||||
static VTLibwrap lwv[MAX_LWS]; /* vector of library wrapper objects */
|
||||
static uint32_t lwn = 0; /* number of library wrapper objects */
|
||||
|
||||
/* default library wrapper attributes */
|
||||
static VTLibwrapAttr default_attr = VT_LIBWRAP_ATTR_DEFAULT;
|
||||
@ -194,7 +194,7 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr)
|
||||
uint8_t error = 0;
|
||||
char error_msg[1024] = "";
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
VTThrd_lock(&lw_create_mutex);
|
||||
@ -210,23 +210,16 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr)
|
||||
}
|
||||
|
||||
/* maximum number of library wrapper objects reached ? */
|
||||
if( lwn + 1 > MAX_LW )
|
||||
if( lwn + 1 >= MAX_LWS )
|
||||
{
|
||||
error = 1;
|
||||
snprintf(error_msg, sizeof(error_msg) - 1,
|
||||
"Cannot create more than %d library wrapper objects", MAX_LW);
|
||||
"Cannot create more than %d library wrapper objects", MAX_LWS);
|
||||
break;
|
||||
}
|
||||
|
||||
/* allocate new library wrapper object */
|
||||
*lw = (VTLibwrap*)calloc(1, sizeof(VTLibwrap));
|
||||
if( *lw == NULL )
|
||||
{
|
||||
error = 1;
|
||||
snprintf(error_msg, sizeof(error_msg) - 1,
|
||||
"Cannot allocate memory for library wrapper object");
|
||||
break;
|
||||
}
|
||||
/* get next unused library wrapper object from vector */
|
||||
*lw = &(lwv[lwn++]);
|
||||
|
||||
/* if not attributes given, use the default attributes */
|
||||
(*lw)->attr = lwattr ? lwattr : &default_attr;
|
||||
@ -235,6 +228,8 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr)
|
||||
if( (*lw)->attr->init_func )
|
||||
(*lw)->attr->init_func((*lw)->attr);
|
||||
|
||||
(*lw)->handlen = 0;
|
||||
|
||||
/* shared libraries specified ? */
|
||||
if( (*lw)->attr->shlibs_num > 0 )
|
||||
{
|
||||
@ -274,10 +269,15 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr)
|
||||
if( error ) break;
|
||||
}
|
||||
|
||||
/* append LIBC's handle to the vector of handles, if desired */
|
||||
if( (*lw)->attr->libc )
|
||||
(*lw)->handlev[(*lw)->handlen++] = vt_libwrap_get_libc_handle();
|
||||
|
||||
/* append 'RTLD_NEXT' to the vector of handles, if possible */
|
||||
#if defined(HAVE_DECL_RTLD_NEXT) && HAVE_DECL_RTLD_NEXT
|
||||
(*lw)->handlev[(*lw)->handlen++] = RTLD_NEXT;
|
||||
#else /* HAVE_DECL_RTLD_NEXT */
|
||||
#endif /* HAVE_DECL_RTLD_NEXT */
|
||||
|
||||
if( (*lw)->handlen == 0 )
|
||||
{
|
||||
error = 1;
|
||||
@ -286,10 +286,6 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr)
|
||||
"specified");
|
||||
break;
|
||||
}
|
||||
#endif /* HAVE_DECL_RTLD_NEXT */
|
||||
|
||||
/* store new library wrapper object */
|
||||
lwv[lwn++] = *lw;
|
||||
} while(0);
|
||||
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
@ -307,35 +303,32 @@ void VTLibwrap_create(VTLibwrap** lw, VTLibwrapAttr* lwattr)
|
||||
/* initialize VampirTrace, if necessary */
|
||||
if( !(*lw)->attr->wait_for_init && !vt_is_alive )
|
||||
vt_open();
|
||||
else
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
}
|
||||
|
||||
void VTLibwrap_delete(VTLibwrap** lw)
|
||||
void VTLibwrap_delete(VTLibwrap* lw)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
vt_libassert(*lw);
|
||||
vt_libassert(lw);
|
||||
|
||||
/* close all opened handles */
|
||||
for( i = 0; i < (*lw)->handlen; i++ )
|
||||
for( i = 0; i < lw->handlen; i++ )
|
||||
{
|
||||
#if defined(HAVE_DECL_RTLD_NEXT) && HAVE_DECL_RTLD_NEXT
|
||||
if( (*lw)->handlev[i] != RTLD_NEXT )
|
||||
if( lw->handlev[i] != RTLD_NEXT )
|
||||
{
|
||||
#endif /* HAVE_DECL_RTLD_NEXT */
|
||||
(void)dlerror();
|
||||
if( dlclose((*lw)->handlev[i]) != 0 )
|
||||
if( dlclose(lw->handlev[i]) != 0 )
|
||||
vt_error_msg("dlclose(\"%s\") failed: %s",
|
||||
(*lw)->attr->shlibs[i], dlerror());
|
||||
lw->attr->shlibs[i], dlerror());
|
||||
#if defined(HAVE_DECL_RTLD_NEXT) && HAVE_DECL_RTLD_NEXT
|
||||
}
|
||||
#endif /* HAVE_DECL_RTLD_NEXT */
|
||||
}
|
||||
|
||||
free(*lw);
|
||||
*lw = VT_LIBWRAP_NULL;
|
||||
}
|
||||
|
||||
void VTLibwrap_delete_all()
|
||||
@ -344,7 +337,7 @@ void VTLibwrap_delete_all()
|
||||
|
||||
/* delete all library wrapper objects */
|
||||
for( i = 0; i < lwn; i++ )
|
||||
if( lwv[i] != VT_LIBWRAP_NULL ) VTLibwrap_delete(&(lwv[i]));
|
||||
VTLibwrap_delete(&(lwv[i]));
|
||||
}
|
||||
|
||||
void VTLibwrap_func_init(const VTLibwrap* lw, const char* func,
|
||||
@ -355,9 +348,9 @@ void VTLibwrap_func_init(const VTLibwrap* lw, const char* func,
|
||||
|
||||
vt_libassert(lw);
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
if( !(*funcptr) )
|
||||
if( funcptr && !(*funcptr) )
|
||||
{
|
||||
/* array for dlsym error messages */
|
||||
char dlsym_errors[MAX_HANDLES][256];
|
||||
@ -365,6 +358,7 @@ void VTLibwrap_func_init(const VTLibwrap* lw, const char* func,
|
||||
/* search all handles for function */
|
||||
for( i = 0; i < lw->handlen && !(*funcptr); i++ )
|
||||
{
|
||||
/* get pointer to actual library function */
|
||||
(void)dlerror();
|
||||
*funcptr = dlsym(lw->handlev[i], func);
|
||||
|
||||
@ -416,35 +410,32 @@ void VTLibwrap_func_init(const VTLibwrap* lw, const char* func,
|
||||
}
|
||||
|
||||
/* get function identifier, if necessary */
|
||||
if( vt_is_alive )
|
||||
if( funcid && *funcid == VT_LIBWRAP_NOID && vt_is_alive )
|
||||
{
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if( *funcid == VT_LIBWRAP_NOID )
|
||||
{
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
VTTHRD_LOCK_IDS();
|
||||
if( *funcid == VT_LIBWRAP_NOID )
|
||||
{
|
||||
#endif /* VT_MT || VT_HYB || VT_JAVA */
|
||||
uint32_t fid = VT_NO_ID;
|
||||
uint32_t lno = VT_NO_LNO;
|
||||
uint32_t fid = VT_NO_ID;
|
||||
uint32_t lno = VT_NO_LNO;
|
||||
|
||||
/* register source file, if available */
|
||||
if( file != NULL && line > 0 )
|
||||
{
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, file);
|
||||
lno = line;
|
||||
}
|
||||
/* register function */
|
||||
*funcid = vt_def_region(VT_CURRENT_THREAD, func, fid, lno, VT_NO_LNO,
|
||||
lw->attr->func_group, VT_FUNCTION);
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
}
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif /* VT_MT || VT_HYB || VT_JAVA */
|
||||
/* register source file, if available */
|
||||
if( file != NULL && line > 0 )
|
||||
{
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, file);
|
||||
lno = line;
|
||||
}
|
||||
/* register function */
|
||||
*funcid = vt_def_region(VT_CURRENT_THREAD, func, fid, lno, VT_NO_LNO,
|
||||
lw->attr->func_group, VT_FUNCTION);
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
}
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif /* VT_MT || VT_HYB || VT_JAVA */
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VTLibwrap_func_start(const VTLibwrap* lw, const int funcid)
|
||||
@ -455,7 +446,7 @@ void VTLibwrap_func_start(const VTLibwrap* lw, const int funcid)
|
||||
|
||||
if( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_libassert(funcid != VT_LIBWRAP_NOID);
|
||||
|
||||
@ -463,7 +454,7 @@ void VTLibwrap_func_start(const VTLibwrap* lw, const int funcid)
|
||||
|
||||
(void)vt_enter(VT_CURRENT_THREAD, &time, funcid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VTLibwrap_func_end(const VTLibwrap* lw, const int funcid)
|
||||
@ -474,7 +465,7 @@ void VTLibwrap_func_end(const VTLibwrap* lw, const int funcid)
|
||||
|
||||
if( !vt_is_alive ) return;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_libassert(funcid != VT_LIBWRAP_NOID);
|
||||
|
||||
@ -482,5 +473,5 @@ void VTLibwrap_func_end(const VTLibwrap* lw, const int funcid)
|
||||
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
836
ompi/contrib/vt/vt/vtlib/vt_mallocwrap.c
Обычный файл
836
ompi/contrib/vt/vt/vtlib/vt_mallocwrap.c
Обычный файл
@ -0,0 +1,836 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#define _BSD_SOURCE /* possibly needed for valloc */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "vt_defs.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_libwrap.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#if (defined(HAVE_MEMALIGN) && HAVE_MEMALIGN) || \
|
||||
(defined(HAVE_VALLOC) && HAVE_VALLOC)
|
||||
# include <malloc.h>
|
||||
#endif /* HAVE_MEMALIGN || HAVE_VALLOC */
|
||||
|
||||
|
||||
/* define the following macro to enable tracing the calloc function which
|
||||
needs a quite dirty hack to make it work (see comments in the calloc
|
||||
wrapper function below) */
|
||||
#define MALLOCWRAP_CALLOC
|
||||
|
||||
|
||||
/* special version of VT_LIBWRAP_FUNC_INIT w/o getting the actual function
|
||||
pointer (VT_LIBWRAP_FUNC_PTR) and the unique function identifier
|
||||
(VT_LIBWRAP_FUNC_ID) */
|
||||
#define MALLOCWRAP_FUNC_INIT(_func, _rettype, _argtypes) \
|
||||
_VT_LIBWRAP_FUNC_INIT_DECL_VARS(_func, _rettype, _argtypes); \
|
||||
if( mallocwrap_lw == VT_LIBWRAP_NULL ) { \
|
||||
VTLibwrap_create(&mallocwrap_lw, &mallocwrap_lw_attr); \
|
||||
}
|
||||
|
||||
/* get pointer to actual library function
|
||||
(sets VT_LIBWRAP_FUNC_PTR, must be called after MALLOCWRAP_FUNC_INIT!) */
|
||||
#define MALLOCWRAP_GET_FUNC_PTR() \
|
||||
if( VT_LIBWRAP_FUNC_PTR == VT_LIBWRAP_NULL ) { \
|
||||
VTLibwrap_func_init(mallocwrap_lw, VT_LIBWRAP_FUNC_NAME, NULL, 0, \
|
||||
(void**)(&VT_LIBWRAP_FUNC_PTR), NULL); \
|
||||
}
|
||||
|
||||
/* get unique function identifier
|
||||
(sets VT_LIBWRAP_FUNC_ID, must be called after MALLOCWRAP_FUNC_INIT!) */
|
||||
#define MALLOCWRAP_GET_FUNC_ID() \
|
||||
if( VT_LIBWRAP_FUNC_ID == VT_LIBWRAP_NOID ) { \
|
||||
VTLibwrap_func_init(mallocwrap_lw, VT_LIBWRAP_FUNC_NAME, NULL, 0, \
|
||||
NULL, &VT_LIBWRAP_FUNC_ID); \
|
||||
}
|
||||
|
||||
/* simplified version of VT_LIBWRAP_FUNC_CALL w/o argument for the library
|
||||
wrapper object */
|
||||
#define MALLOCWRAP_FUNC_CALL(_args) VT_LIBWRAP_FUNC_CALL(mallocwrap_lw, _args)
|
||||
|
||||
/* check whether tracing of LIBC memory (de)allocation functions is
|
||||
currently enabled */
|
||||
#define MALLOCWRAP_DO_TRACE() \
|
||||
( vt_is_alive && VT_MY_THREAD_IS_ALIVE && \
|
||||
VTTHRD_MALLOC_TRACING_ENABLED(VTTHRD_MY_VTTHRD) )
|
||||
|
||||
/* library wrapper object */
|
||||
static VTLibwrap* mallocwrap_lw = VT_LIBWRAP_NULL;
|
||||
|
||||
/* library wrapper attributes */
|
||||
static VTLibwrapAttr mallocwrap_lw_attr = {
|
||||
|
||||
/* The functions to be wrapped are defined in the LIBC which is linked to
|
||||
the application. So there is no need to search the actual function
|
||||
pointers in an additional library. */
|
||||
0, /* shlibs_num */
|
||||
{ NULL }, /* shlibs */
|
||||
|
||||
/* Function group to define, finally including the recorded LIBC memory
|
||||
(de)allocation functions */
|
||||
"LIBC-MALLOC", /* func_group */
|
||||
|
||||
/* Do not search the actual function pointers in an external LIBC, because
|
||||
dlopen calls malloc which would result in an infinite recursion when
|
||||
determining the actual function pointer of malloc. Using RTLD_NEXT
|
||||
instead. */
|
||||
0, /* libc */
|
||||
|
||||
/* Do not initialize VampirTrace when creating the library wrapper object,
|
||||
resp. when a wrapper function is entered */
|
||||
1 /* wait_for_init */
|
||||
};
|
||||
|
||||
/* id of memory related counter group */
|
||||
static uint32_t mallocwrap_counter_group_id = 0;
|
||||
|
||||
/* id of memory allocation counter */
|
||||
static uint32_t mallocwrap_counter_id = 0;
|
||||
|
||||
/* ids of memory (de)allocation markers */
|
||||
static uint32_t mallocwrap_marker_alloc_id = 0;
|
||||
static uint32_t mallocwrap_marker_free_id = 0;
|
||||
|
||||
/* flag: write memory (de)allocation markers? (env. VT_MEMTRACE_MARKER) */
|
||||
static uint32_t mallocwrap_write_markers = 0;
|
||||
|
||||
|
||||
/* memory allocation wrapper initialization/finalization functions called
|
||||
by vt_open/vt_close */
|
||||
|
||||
void vt_mallocwrap_init()
|
||||
{
|
||||
/* define memory related counter group */
|
||||
mallocwrap_counter_group_id =
|
||||
vt_def_counter_group(VT_CURRENT_THREAD, "Memory");
|
||||
|
||||
/* define memory allocation counter */
|
||||
mallocwrap_counter_id =
|
||||
vt_def_counter(VT_CURRENT_THREAD, "Memory Allocation", "Bytes",
|
||||
VT_CNTR_ABS | VT_CNTR_NEXT, mallocwrap_counter_group_id, 0);
|
||||
|
||||
/* define memory (de)allocation markers, if desired
|
||||
(env. VT_MEMTRACE_MARKER) */
|
||||
if( (mallocwrap_write_markers = vt_env_memtrace_marker()) )
|
||||
{
|
||||
mallocwrap_marker_alloc_id =
|
||||
vt_def_marker(VT_CURRENT_THREAD, "Memory Allocation", VT_MARKER_HINT);
|
||||
mallocwrap_marker_free_id =
|
||||
vt_def_marker(VT_CURRENT_THREAD, "Memory Deallocation", VT_MARKER_HINT);
|
||||
}
|
||||
}
|
||||
|
||||
void vt_mallocwrap_finalize()
|
||||
{
|
||||
/* delete library wrapper object, if necessary */
|
||||
if( mallocwrap_lw != VT_LIBWRAP_NULL )
|
||||
VTLibwrap_delete(mallocwrap_lw);
|
||||
}
|
||||
|
||||
|
||||
/* wrapper functions */
|
||||
|
||||
/* -- stdlib.h:malloc -- */
|
||||
void* malloc(size_t size)
|
||||
{
|
||||
void* ret;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("malloc", void*, (size_t));
|
||||
|
||||
/* once, get the actual function pointer */
|
||||
MALLOCWRAP_GET_FUNC_PTR();
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((size));
|
||||
|
||||
/* get total allocated memory */
|
||||
if( ret != NULL )
|
||||
{
|
||||
/* bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ret - SIZEOF_VOIDP ) );*/
|
||||
bytes = (uint64_t)malloc_usable_size(ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
*counter_val += bytes;
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
vt_marker(tid, &time, mallocwrap_marker_alloc_id,
|
||||
"Allocated %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((size));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC (not necessary if using RTLD_NEXT) */
|
||||
/*errno = vt_libwrap_get_libc_errno();*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef MALLOCWRAP_CALLOC
|
||||
|
||||
/* -- stdlib.h:calloc -- */
|
||||
void* calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void* ret;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("calloc", void*, (size_t, size_t));
|
||||
|
||||
/* once, get the actual function pointer
|
||||
|
||||
NOTE: The dlsym function which is used to determine the actual function
|
||||
pointer of calloc uses itself this function, which would ends up in an
|
||||
infinite recursion.
|
||||
In order to make it work we have to perform a quite dirty hack found on
|
||||
http://blog.bigpixel.ro/2010/09/interposing-calloc-on-linux:
|
||||
While we are trying to get the actual function pointer, we're returning
|
||||
NULL for the memory which needs to be allocated by dlsym, in hope that
|
||||
dlsym can handle this situation.
|
||||
If this workaround causes any problems, just undefine the MALLOCWRAP_CALLOC
|
||||
macro above to disable the calloc wrapper function completely. */
|
||||
if( VT_LIBWRAP_FUNC_PTR == VT_LIBWRAP_NULL )
|
||||
{
|
||||
/* flag for indicating that we are trying to get the actual function
|
||||
pointer of calloc */
|
||||
static uint8_t getting_func_ptr = 0;
|
||||
if( !getting_func_ptr )
|
||||
{
|
||||
/* before trying to get the actual function pointer of calloc, set
|
||||
an indicator in order to return NULL from the next calloc called from
|
||||
dlsym */
|
||||
getting_func_ptr = 1;
|
||||
VTLibwrap_func_init(mallocwrap_lw, VT_LIBWRAP_FUNC_NAME, NULL, 0,
|
||||
(void**)(&VT_LIBWRAP_FUNC_PTR), NULL);
|
||||
getting_func_ptr = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* assumed that this calloc is called from dlsym, return NULL */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get current timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((nmemb, size));
|
||||
|
||||
/* get total allocated memory */
|
||||
if( ret != NULL )
|
||||
{
|
||||
/* bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ret - SIZEOF_VOIDP ) );*/
|
||||
bytes = (uint64_t)malloc_usable_size(ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
*counter_val += bytes;
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
vt_marker(tid, &time, mallocwrap_marker_alloc_id,
|
||||
"Allocated %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((nmemb, size));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC (not necessary if using RTLD_NEXT) */
|
||||
/*errno = vt_libwrap_get_libc_errno();*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* MALLOCWRAP_CALLOC */
|
||||
|
||||
/* -- stdlib.h:realloc -- */
|
||||
void* realloc(void* ptr, size_t size)
|
||||
{
|
||||
void* ret;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("realloc", void*, (void*, size_t));
|
||||
|
||||
/* once, get the actual function pointer */
|
||||
MALLOCWRAP_GET_FUNC_PTR();
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t bytes1;
|
||||
uint64_t bytes2;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get current timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* get total allocated memory before realloc */
|
||||
if( ptr != NULL )
|
||||
{
|
||||
/* bytes1 = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ptr - SIZEOF_VOIDP ) );*/
|
||||
bytes1 = (uint64_t)malloc_usable_size(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes1 = bytes = 0;
|
||||
}
|
||||
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((ptr, size));
|
||||
|
||||
/* get total allocated memory after realloc */
|
||||
if( ret != NULL )
|
||||
{
|
||||
/* bytes2 = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ret - SIZEOF_VOIDP ) );*/
|
||||
bytes2 = (uint64_t)malloc_usable_size(ret);
|
||||
bytes = bytes2 < bytes1 ? bytes1 - bytes2 : bytes2 - bytes1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes2 = bytes = 0;
|
||||
}
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
if( bytes2 < bytes1 )
|
||||
{
|
||||
if( bytes <= *counter_val )
|
||||
*counter_val -= bytes;
|
||||
else
|
||||
*counter_val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*counter_val += bytes;
|
||||
}
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
static const char* marker_prefix_alloced = "Allocated";
|
||||
static const char* marker_prefix_freed = "Freed";
|
||||
|
||||
uint32_t marker_id;
|
||||
const char* marker_prefix;
|
||||
|
||||
if ( bytes2 < bytes1 )
|
||||
{
|
||||
marker_id = mallocwrap_marker_free_id;
|
||||
marker_prefix = marker_prefix_freed;
|
||||
}
|
||||
else
|
||||
{
|
||||
marker_id = mallocwrap_marker_alloc_id;
|
||||
marker_prefix = marker_prefix_alloced;
|
||||
}
|
||||
|
||||
vt_marker(tid, &time, marker_id,
|
||||
"%s %llu Bytes", marker_prefix, (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((ptr, size));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC (not necessary if using RTLD_NEXT) */
|
||||
/*errno = vt_libwrap_get_libc_errno();*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* -- stdlib.h:free -- */
|
||||
void free(void* ptr)
|
||||
{
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("free", void, (void*));
|
||||
|
||||
/* once, get the actual function pointer */
|
||||
MALLOCWRAP_GET_FUNC_PTR();
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get current timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* get total allocated memory to be freed */
|
||||
if( ptr != NULL )
|
||||
{
|
||||
/* bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ptr - SIZEOF_VOIDP ) );*/
|
||||
bytes = (uint64_t)malloc_usable_size(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* call the actual library function */
|
||||
MALLOCWRAP_FUNC_CALL((ptr));
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
if( bytes <= *counter_val )
|
||||
*counter_val -= bytes;
|
||||
else
|
||||
*counter_val = 0;
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
vt_marker(tid, &time, mallocwrap_marker_free_id,
|
||||
"Freed %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
MALLOCWRAP_FUNC_CALL((ptr));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC (not necessary if using RTLD_NEXT) */
|
||||
/*errno = vt_libwrap_get_libc_errno();*/
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_POSIX_MEMALIGN) && HAVE_POSIX_MEMALIGN
|
||||
|
||||
/* -- stdlib.h:posix_memalign -- */
|
||||
int posix_memalign(void** memptr, size_t alignment, size_t size)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("posix_memalign", int, (void**, size_t, size_t));
|
||||
|
||||
/* once, get the actual function pointer */
|
||||
MALLOCWRAP_GET_FUNC_PTR();
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get current timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((memptr, alignment, size));
|
||||
|
||||
/* get total allocated memory */
|
||||
if( ret == 0 && memptr != NULL )
|
||||
{
|
||||
/* bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)*memptr - SIZEOF_VOIDP ) );*/
|
||||
bytes = (uint64_t)malloc_usable_size(*memptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
*counter_val += bytes;
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
vt_marker(tid, &time, mallocwrap_marker_alloc_id,
|
||||
"Allocated %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((memptr, alignment, size));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_POSIX_MEMALIGN */
|
||||
|
||||
#if defined(HAVE_MEMALIGN) && HAVE_MEMALIGN
|
||||
|
||||
/* -- malloc.h:memalign -- */
|
||||
void* memalign(size_t boundary, size_t size)
|
||||
{
|
||||
void* ret;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("memalign", void*, (size_t, size_t));
|
||||
|
||||
/* once, get the actual function pointer */
|
||||
MALLOCWRAP_GET_FUNC_PTR();
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get current timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((boundary, size));
|
||||
|
||||
/* get total allocated memory */
|
||||
if( ret != NULL )
|
||||
{
|
||||
/* bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ret - SIZEOF_VOIDP ) );*/
|
||||
bytes = (uint64_t)malloc_usable_size(ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
*counter_val += bytes;
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
vt_marker(tid, &time, mallocwrap_marker_alloc_id,
|
||||
"Allocated %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((boundary, size));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC (not necessary if using RTLD_NEXT) */
|
||||
/*errno = vt_libwrap_get_libc_errno();*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_MEMALIGN */
|
||||
|
||||
#if defined(HAVE_VALLOC) && HAVE_VALLOC
|
||||
|
||||
/* -- malloc.h:valloc -- */
|
||||
void* valloc(size_t size)
|
||||
{
|
||||
void* ret;
|
||||
|
||||
/* initialize this wrapper function */
|
||||
MALLOCWRAP_FUNC_INIT("valloc", void*, (size_t));
|
||||
|
||||
/* once, get the actual function pointer */
|
||||
MALLOCWRAP_GET_FUNC_PTR();
|
||||
|
||||
if( MALLOCWRAP_DO_TRACE() )
|
||||
{
|
||||
uint32_t tid;
|
||||
uint64_t time;
|
||||
uint64_t bytes;
|
||||
uint64_t* counter_val;
|
||||
uint8_t was_recorded;
|
||||
|
||||
/* get calling thread id */
|
||||
tid = VT_MY_THREAD;
|
||||
|
||||
/* suspend LIBC memory (de)allocation tracing */
|
||||
VT_SUSPEND_MALLOC_TRACING(tid);
|
||||
|
||||
/* get current timestamp for the following function enter event */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
/* once, get unique function identifier */
|
||||
MALLOCWRAP_GET_FUNC_ID();
|
||||
|
||||
/* record function enter event */
|
||||
was_recorded = vt_enter(tid, &time, VT_LIBWRAP_FUNC_ID);
|
||||
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((size));
|
||||
|
||||
/* get total allocated memory */
|
||||
if( ret != NULL )
|
||||
{
|
||||
/* bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ret - SIZEOF_VOIDP ) );*/
|
||||
bytes = (uint64_t)malloc_usable_size(ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* get pointer to thread's memory allocation counter value and update */
|
||||
counter_val = &(VTTHRD_MALLOC_TRACING_COUNTER_VAL(VTThrdv[tid]));
|
||||
*counter_val += bytes;
|
||||
|
||||
/* get timestamp for the following function exit event [+ marker] */
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( mallocwrap_write_markers )
|
||||
{
|
||||
vt_marker(tid, &time, mallocwrap_marker_alloc_id,
|
||||
"Allocated %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(tid, &time, mallocwrap_counter_id, *counter_val);
|
||||
}
|
||||
|
||||
/* record function exit event */
|
||||
vt_exit(tid, &time);
|
||||
|
||||
/* resume LIBC memory (de)allocation tracing */
|
||||
VT_RESUME_MALLOC_TRACING(tid);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* call the actual library function */
|
||||
ret = MALLOCWRAP_FUNC_CALL((size));
|
||||
}
|
||||
|
||||
/* get errno from external LIBC (not necessary if using RTLD_NEXT) */
|
||||
/*errno = vt_libwrap_get_libc_errno();*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* HAVE_VALLOC */
|
59
ompi/contrib/vt/vt/vtlib/vt_mallocwrap.h
Обычный файл
59
ompi/contrib/vt/vt/vtlib/vt_mallocwrap.h
Обычный файл
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#ifndef _VT_MALLOCWRAP_H
|
||||
#define _VT_MALLOCWRAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#include "vt_defs.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
#ifdef VT_MALLOCWRAP
|
||||
|
||||
/* macro for temporarily suspend MALLOC tracing */
|
||||
#define VT_SUSPEND_MALLOC_TRACING(tid) \
|
||||
if( vt_is_alive && VT_MY_THREAD_IS_ALIVE ) { \
|
||||
VTThrd* _thrd = \
|
||||
((tid) == VT_CURRENT_THREAD) ? VTTHRD_MY_VTTHRD : VTThrdv[(tid)]; \
|
||||
VTTHRD_MALLOC_TRACING_ENABLED(_thrd) = 0; \
|
||||
VTTHRD_MALLOC_TRACING_SUSPEND_CNT(_thrd)++; \
|
||||
}
|
||||
|
||||
/* macro for resuming from MALLOC tracing suspension */
|
||||
#define VT_RESUME_MALLOC_TRACING(tid) \
|
||||
if( vt_is_alive && VT_MY_THREAD_IS_ALIVE ) { \
|
||||
VTThrd* _thrd = \
|
||||
((tid) == VT_CURRENT_THREAD) ? VTTHRD_MY_VTTHRD : VTThrdv[(tid)]; \
|
||||
if( VTTHRD_MALLOC_TRACING_SUSPEND_CNT(_thrd) == 0 || \
|
||||
--VTTHRD_MALLOC_TRACING_SUSPEND_CNT(_thrd) == 0 ) { \
|
||||
VTTHRD_MALLOC_TRACING_ENABLED(_thrd) = \
|
||||
VTTHRD_MALLOC_TRACING_STATE(_thrd); \
|
||||
} \
|
||||
}
|
||||
|
||||
EXTERN void vt_mallocwrap_init(void);
|
||||
EXTERN void vt_mallocwrap_finalize(void);
|
||||
|
||||
#else /* VT_MALLOCWRAP */
|
||||
|
||||
#define VT_SUSPEND_MALLOC_TRACING(tid)
|
||||
#define VT_RESUME_MALLOC_TRACING(tid)
|
||||
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#endif /* _VT_MALLOCWRAP_H */
|
@ -1,304 +0,0 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "vt_defs.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
|
||||
#define MEMHOOK_REG_MALLOC 0
|
||||
#define MEMHOOK_REG_REALLOC 1
|
||||
#define MEMHOOK_REG_FREE 2
|
||||
|
||||
#define MEMHOOK_MARK_ALLOC 0
|
||||
#define MEMHOOK_MARK_FREE 1
|
||||
|
||||
/* variables to save original hooks */
|
||||
void *(*vt_malloc_hook_org)(size_t size, const void* caller);
|
||||
void *(*vt_realloc_hook_org)(void* ptr, size_t size, const void* caller);
|
||||
void (*vt_free_hook_org)(void* ptr, const void* caller);
|
||||
|
||||
uint8_t vt_memhook_is_initialized = 0;
|
||||
uint8_t vt_memhook_is_enabled = 0;
|
||||
|
||||
/* write marker for each alloc/free event? */
|
||||
uint8_t memalloc_marker = 0;
|
||||
|
||||
/* array of memory allocation region IDs */
|
||||
static uint32_t memhook_regid[3];
|
||||
|
||||
/* memory allocation marker IDs */
|
||||
static uint32_t memalloc_mid[2];
|
||||
|
||||
/* memory allocation counter ID */
|
||||
static uint32_t memalloc_cid;
|
||||
|
||||
/* memory allocation counter value */
|
||||
static uint64_t memalloc_val = 0;
|
||||
|
||||
void vt_memhook_init()
|
||||
{
|
||||
uint32_t fid;
|
||||
uint32_t gid;
|
||||
|
||||
#if (defined(VT_MT) || defined(VT_HYB) || defined(VT_JAVA))
|
||||
vt_error_msg("Memory tracing by GNU C malloc-hooks for threaded application "
|
||||
"not yet supported");
|
||||
#endif /* VT_MT || VT_HYB || VT_JAVA */
|
||||
|
||||
if( vt_memhook_is_initialized ) return;
|
||||
|
||||
vt_malloc_hook_org = __malloc_hook;
|
||||
vt_realloc_hook_org = __realloc_hook;
|
||||
vt_free_hook_org = __free_hook;
|
||||
|
||||
/* define source */
|
||||
fid = vt_def_scl_file(VT_CURRENT_THREAD, "MEM");
|
||||
|
||||
/* define regions */
|
||||
memhook_regid[MEMHOOK_REG_MALLOC] =
|
||||
vt_def_region(VT_CURRENT_THREAD, "malloc", fid, VT_NO_LNO, VT_NO_LNO, NULL,
|
||||
VT_MEMORY);
|
||||
memhook_regid[MEMHOOK_REG_REALLOC] =
|
||||
vt_def_region(VT_CURRENT_THREAD, "realloc", fid, VT_NO_LNO, VT_NO_LNO, NULL,
|
||||
VT_MEMORY);
|
||||
memhook_regid[MEMHOOK_REG_FREE] =
|
||||
vt_def_region(VT_CURRENT_THREAD, "free", fid, VT_NO_LNO, VT_NO_LNO, NULL,
|
||||
VT_MEMORY);
|
||||
|
||||
/* define markers, if necessary */
|
||||
if( (memalloc_marker = vt_env_memtrace_marker()) )
|
||||
{
|
||||
memalloc_mid[MEMHOOK_MARK_ALLOC] =
|
||||
vt_def_marker(VT_CURRENT_THREAD, "Memory Allocation", VT_MARKER_HINT);
|
||||
memalloc_mid[MEMHOOK_MARK_FREE] =
|
||||
vt_def_marker(VT_CURRENT_THREAD, "Memory Deallocation", VT_MARKER_HINT);
|
||||
}
|
||||
|
||||
/* define counter group */
|
||||
gid = vt_def_counter_group(VT_CURRENT_THREAD, "Memory");
|
||||
|
||||
/* define counter */
|
||||
memalloc_cid =
|
||||
vt_def_counter(VT_CURRENT_THREAD, "MEM_ALLOC", "Bytes",
|
||||
VT_CNTR_ABS | VT_CNTR_NEXT,
|
||||
gid, 0);
|
||||
|
||||
vt_memhook_is_initialized = 1;
|
||||
}
|
||||
|
||||
void vt_memhook_finalize()
|
||||
{
|
||||
if( !vt_memhook_is_initialized ) return;
|
||||
|
||||
__malloc_hook = vt_malloc_hook_org;
|
||||
__realloc_hook = vt_realloc_hook_org;
|
||||
__free_hook = vt_free_hook_org;
|
||||
|
||||
vt_memhook_is_initialized = 0;
|
||||
vt_memhook_is_enabled = 0;
|
||||
}
|
||||
|
||||
void* vt_malloc_hook(size_t size, const void* caller)
|
||||
{
|
||||
void* result;
|
||||
uint64_t bytes;
|
||||
uint64_t time;
|
||||
uint8_t was_recorded;
|
||||
|
||||
VT_MEMHOOKS_OFF(); /* restore original hooks */
|
||||
|
||||
time = vt_pform_wtime();
|
||||
was_recorded = vt_enter(VT_CURRENT_THREAD, &time,
|
||||
memhook_regid[MEMHOOK_REG_MALLOC]);
|
||||
|
||||
result = malloc(size); /* call recursively */
|
||||
|
||||
/* get total allocated memory */
|
||||
if ( result != NULL )
|
||||
{
|
||||
bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)result - SIZEOF_VOIDP ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
/* update counter value */
|
||||
memalloc_val += bytes;
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if ( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( memalloc_marker )
|
||||
{
|
||||
vt_marker(VT_CURRENT_THREAD, &time, memalloc_mid[MEMHOOK_MARK_ALLOC],
|
||||
"Allocated %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(VT_CURRENT_THREAD, &time, memalloc_cid, memalloc_val);
|
||||
}
|
||||
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON(); /* restore our own hooks */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void* vt_realloc_hook(void* ptr, size_t size, const void* caller)
|
||||
{
|
||||
void* result;
|
||||
uint64_t bytes;
|
||||
uint64_t bytes1;
|
||||
uint64_t bytes2;
|
||||
uint64_t time;
|
||||
uint8_t was_recorded;
|
||||
|
||||
VT_MEMHOOKS_OFF(); /* restore original hooks */
|
||||
|
||||
time = vt_pform_wtime();
|
||||
was_recorded = vt_enter(VT_CURRENT_THREAD, &time,
|
||||
memhook_regid[MEMHOOK_REG_REALLOC]);
|
||||
|
||||
/* get total allocated memory before realloc */
|
||||
if ( NULL != ptr )
|
||||
{
|
||||
bytes1 = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ptr - SIZEOF_VOIDP ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes1 = bytes = 0;
|
||||
}
|
||||
|
||||
result = realloc(ptr, size); /* call recursively */
|
||||
|
||||
/* get total allocated memory after realloc */
|
||||
if ( NULL != result )
|
||||
{
|
||||
bytes2 = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)result - SIZEOF_VOIDP ) );
|
||||
bytes = bytes2 < bytes1 ? bytes1 - bytes2 : bytes2 - bytes1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes2 = bytes = 0;
|
||||
}
|
||||
|
||||
/* update counter value */
|
||||
if ( bytes2 < bytes1 )
|
||||
{
|
||||
if ( bytes <= memalloc_val )
|
||||
memalloc_val -= bytes;
|
||||
else
|
||||
memalloc_val = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memalloc_val += bytes;
|
||||
}
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( memalloc_marker )
|
||||
{
|
||||
uint32_t marker_type;
|
||||
char* marker_prefix;
|
||||
|
||||
if ( bytes2 < bytes1 )
|
||||
{
|
||||
marker_type = MEMHOOK_MARK_FREE;
|
||||
marker_prefix = "Freed";
|
||||
}
|
||||
else
|
||||
{
|
||||
marker_type = MEMHOOK_MARK_ALLOC;
|
||||
marker_prefix = "Allocated";
|
||||
}
|
||||
|
||||
/* write marker */
|
||||
vt_marker(VT_CURRENT_THREAD, &time, memalloc_mid[marker_type],
|
||||
"%s %llu Bytes", marker_prefix, (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(VT_CURRENT_THREAD, &time, memalloc_cid, memalloc_val);
|
||||
}
|
||||
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON(); /* restore our own hooks */
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void vt_free_hook(void* ptr, const void* caller)
|
||||
{
|
||||
uint64_t bytes;
|
||||
uint64_t time;
|
||||
uint8_t was_recorded;
|
||||
|
||||
VT_MEMHOOKS_OFF(); /* restore original hooks */
|
||||
|
||||
time = vt_pform_wtime();
|
||||
was_recorded = vt_enter(VT_CURRENT_THREAD, &time,
|
||||
memhook_regid[MEMHOOK_REG_FREE]);
|
||||
|
||||
if ( NULL != ptr )
|
||||
{
|
||||
bytes = ( ~ (uint64_t) 3 ) & (uint64_t) *( (size_t*) ( (char*)ptr - SIZEOF_VOIDP ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = 0;
|
||||
}
|
||||
|
||||
free(ptr); /* call recursively */
|
||||
|
||||
/* update counter value */
|
||||
if ( bytes <= memalloc_val )
|
||||
memalloc_val -= bytes;
|
||||
else
|
||||
memalloc_val = 0;
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
if ( was_recorded && bytes > 0 )
|
||||
{
|
||||
/* write marker, if desired */
|
||||
if( memalloc_marker )
|
||||
{
|
||||
vt_marker(VT_CURRENT_THREAD, &time, memalloc_mid[MEMHOOK_MARK_FREE],
|
||||
"Freed %llu Bytes", (unsigned long long)bytes);
|
||||
}
|
||||
|
||||
/* write counter value */
|
||||
vt_count(VT_CURRENT_THREAD, &time, memalloc_cid, memalloc_val);
|
||||
}
|
||||
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON(); /* restore our own hooks */
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/**
|
||||
* VampirTrace
|
||||
* http://www.tu-dresden.de/zih/vampirtrace
|
||||
*
|
||||
* Copyright (c) 2005-2012, ZIH, TU Dresden, Federal Republic of Germany
|
||||
*
|
||||
* Copyright (c) 1998-2005, Forschungszentrum Juelich, Juelich Supercomputing
|
||||
* Centre, Federal Republic of Germany
|
||||
*
|
||||
* See the file COPYING in the package base directory for details
|
||||
**/
|
||||
|
||||
#ifndef _VT_MEMHOOK_H
|
||||
#define _VT_MEMHOOK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
#if (defined(VT_MEMHOOK))
|
||||
|
||||
#include "vt_inttypes.h"
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#define VT_MEMHOOKS_OFF() \
|
||||
if ( vt_memhook_is_initialized && vt_memhook_is_enabled ) { \
|
||||
__malloc_hook = vt_malloc_hook_org; \
|
||||
__realloc_hook = vt_realloc_hook_org; \
|
||||
__free_hook = vt_free_hook_org; \
|
||||
vt_memhook_is_enabled = 0; }
|
||||
#define VT_MEMHOOKS_ON() \
|
||||
if ( vt_memhook_is_initialized && !vt_memhook_is_enabled ) { \
|
||||
__malloc_hook = vt_malloc_hook; \
|
||||
__realloc_hook = vt_realloc_hook; \
|
||||
__free_hook = vt_free_hook; \
|
||||
vt_memhook_is_enabled = 1; }
|
||||
#define VT_MEMHOOKS_ENABLED() vt_memhook_is_enabled
|
||||
|
||||
/* memory hooks initialization */
|
||||
EXTERN void vt_memhook_init(void);
|
||||
|
||||
/* memory hooks finalization */
|
||||
EXTERN void vt_memhook_finalize(void);
|
||||
|
||||
/* Prototypes for our hooks */
|
||||
EXTERN void* vt_malloc_hook(size_t size, const void* caller);
|
||||
EXTERN void* vt_realloc_hook(void* ptr, size_t size, const void* caller);
|
||||
EXTERN void vt_free_hook(void* ptr, const void* caller);
|
||||
|
||||
/* Variables to save original hooks */
|
||||
EXTERN void* (*vt_malloc_hook_org)(size_t, const void *);
|
||||
EXTERN void* (*vt_realloc_hook_org)(void* ptr, size_t size, const void* caller);
|
||||
EXTERN void (*vt_free_hook_org)(void* ptr, const void* caller);
|
||||
|
||||
EXTERN uint8_t vt_memhook_is_initialized;
|
||||
EXTERN uint8_t vt_memhook_is_enabled;
|
||||
|
||||
#else /* VT_MEMHOOK */
|
||||
|
||||
#define VT_MEMHOOKS_OFF()
|
||||
#define VT_MEMHOOKS_ON()
|
||||
#define VT_MEMHOOKS_ENABLED() 0
|
||||
|
||||
#endif /* VT_MEMHOOK */
|
||||
|
||||
#endif /* _VT_MEMHOOK_H */
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include "vt_iowrap.h"
|
||||
#include "vt_metric.h"
|
||||
|
||||
#if !(defined(HAVE_DECL_LONG_LONG) && HAVE_DECL_LONG_LONG)
|
||||
#if !(defined(HAVE_LONG_LONG) && HAVE_LONG_LONG)
|
||||
# define long_long long long
|
||||
#endif /* HAVE_DECL_LONG_LONG */
|
||||
#endif /* HAVE_LONG_LONG */
|
||||
|
||||
#if PAPI_VER_CURRENT >= PAPI_VERSION_NUMBER(3,9,0,0)
|
||||
# define PAPIC
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "vt_env.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_mpicom.h"
|
||||
#include "vt_mpireg.h"
|
||||
#include "vt_mpireq.h"
|
||||
@ -66,10 +66,10 @@
|
||||
|
||||
/* temporary switch off MPI tracing */
|
||||
#define MPI_TRACE_OFF(tid) \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
VT_SUSPEND_MALLOC_TRACING(tid); \
|
||||
VTTHRD_MPI_TRACING_ENABLED(VTThrdv[tid]) = (env_mpitrace && MPI_TRACE_INSIDE)
|
||||
#define MPI_TRACE_ON(tid) \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
VT_RESUME_MALLOC_TRACING(tid); \
|
||||
VTTHRD_MPI_TRACING_ENABLED(VTThrdv[tid]) = env_mpitrace
|
||||
|
||||
/* flag: MPI tracing enabled (env. VT_MPITRACE)? */
|
||||
|
@ -271,6 +271,14 @@ void vt_plugin_cntr_init() {
|
||||
group = all_group;
|
||||
}
|
||||
|
||||
if (info.init == NULL) {
|
||||
vt_error_msg(
|
||||
"Init not implemented in plugin %s\n",
|
||||
current_plugin);
|
||||
/* try loading next */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (info.add_counter == NULL) {
|
||||
vt_error_msg(
|
||||
"Add counter not implemented in plugin %s\n",
|
||||
|
@ -163,10 +163,6 @@ uint32_t VTThrd_create(const char* tname, uint32_t ptid, uint8_t is_virtual)
|
||||
/* set the virtual thread flag */
|
||||
thrd->is_virtual = is_virtual;
|
||||
|
||||
#if (defined (VT_MPI) || defined (VT_HYB))
|
||||
thrd->mpi_tracing_enabled = vt_env_mpitrace();
|
||||
#endif /* VT_MPI || VT_HYB */
|
||||
|
||||
#if defined(VT_GETCPU)
|
||||
thrd->cpuid_val = (uint32_t)-1;
|
||||
#endif /* VT_GETCPU */
|
||||
@ -268,6 +264,8 @@ void VTThrd_open(uint32_t tid)
|
||||
return;
|
||||
|
||||
#if (defined (VT_MPI) || defined (VT_HYB))
|
||||
/* initialize actual mode of MPI tracing operation */
|
||||
thrd->mpi_tracing_enabled = vt_env_mpitrace();
|
||||
/* initialize first matching ID for MPI collective ops. */
|
||||
thrd->mpicoll_next_matchingid = 1;
|
||||
#endif /* VT_MPI || VT_HYB */
|
||||
@ -285,6 +283,18 @@ void VTThrd_open(uint32_t tid)
|
||||
}
|
||||
#endif /* VT_IOWRAP */
|
||||
|
||||
#if defined(VT_EXECWRAP)
|
||||
/* initialize actual mode of EXEC tracing operation */
|
||||
thrd->exec_tracing_state = thrd->exec_tracing_enabled =
|
||||
(uint8_t)vt_env_exectrace();
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#if defined(VT_MALLOCWRAP)
|
||||
/* initialize actual mode of MALLOC tracing operation */
|
||||
thrd->malloc_tracing_state = thrd->malloc_tracing_enabled =
|
||||
(uint8_t)vt_env_memtrace();
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if defined(VT_PLUGIN_CNTR)
|
||||
/* if we really use plugins */
|
||||
if ( vt_plugin_cntr_used && tid != 0 )
|
||||
|
@ -118,6 +118,27 @@ typedef struct
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(VT_EXECWRAP)
|
||||
|
||||
uint8_t exec_tracing_state; /**< save value of enabled flag during
|
||||
suspend */
|
||||
uint8_t exec_tracing_suspend_cnt; /**< save how often suspend was called */
|
||||
uint8_t exec_tracing_enabled; /**< actual mode of EXEC tracing
|
||||
operation */
|
||||
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#if defined(VT_MALLOCWRAP)
|
||||
|
||||
uint8_t malloc_tracing_state; /**< save value of enabled flag during
|
||||
suspend */
|
||||
uint8_t malloc_tracing_suspend_cnt; /**< save how often suspend was called */
|
||||
uint8_t malloc_tracing_enabled; /**< actual mode of memory allocation
|
||||
tracing operation */
|
||||
uint64_t malloc_tracing_counter_val; /**< memory allocation counter value */
|
||||
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if defined(VT_GETCPU)
|
||||
|
||||
uint32_t cpuid_val; /**< cpu id counter value */
|
||||
@ -145,7 +166,7 @@ typedef struct
|
||||
|
||||
#if defined(VT_PLUGIN_CNTR)
|
||||
|
||||
void* plugin_cntr_defines; /**< plugin cntr handle */
|
||||
void* plugin_cntr_defines; /**< plugin cntr handle */
|
||||
|
||||
uint8_t plugin_cntr_writing_post_mortem; /**< flag: writing post mortem
|
||||
counter? */
|
||||
@ -250,10 +271,47 @@ typedef struct
|
||||
(thrd->io_next_matchingid++)
|
||||
|
||||
/* increment handle id counter for I/O operations */
|
||||
#define VTTHRD_IO_NEXT_HANDLE(thrd) (thrd->io_next_handle++)
|
||||
#define VTTHRD_IO_NEXT_HANDLE(thrd) \
|
||||
(thrd->io_next_handle++)
|
||||
|
||||
#endif /* VT_IOWRAP || (HAVE_MPI2_IO && HAVE_MPI2_IO) */
|
||||
|
||||
#if (defined (VT_EXECWRAP))
|
||||
|
||||
/* save value of enabled flag during suspend */
|
||||
#define VTTHRD_EXEC_TRACING_STATE(thrd) \
|
||||
(thrd->exec_tracing_state)
|
||||
|
||||
/* save how often suspend was called */
|
||||
#define VTTHRD_EXEC_TRACING_SUSPEND_CNT(thrd) \
|
||||
(thrd->exec_tracing_suspend_cnt)
|
||||
|
||||
/* actual mode of EXEC tracing operation */
|
||||
#define VTTHRD_EXEC_TRACING_ENABLED(thrd) \
|
||||
(thrd->exec_tracing_enabled)
|
||||
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#if (defined (VT_MALLOCWRAP))
|
||||
|
||||
/* save value of enabled flag during suspend */
|
||||
#define VTTHRD_MALLOC_TRACING_STATE(thrd) \
|
||||
(thrd->malloc_tracing_state)
|
||||
|
||||
/* save how often suspend was called */
|
||||
#define VTTHRD_MALLOC_TRACING_SUSPEND_CNT(thrd) \
|
||||
(thrd->malloc_tracing_suspend_cnt)
|
||||
|
||||
/* actual mode of memory allocation tracing operation */
|
||||
#define VTTHRD_MALLOC_TRACING_ENABLED(thrd) \
|
||||
(thrd->malloc_tracing_enabled)
|
||||
|
||||
/* memory allocation counter value */
|
||||
#define VTTHRD_MALLOC_TRACING_COUNTER_VAL(thrd) \
|
||||
(thrd->malloc_tracing_counter_val)
|
||||
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if (defined (VT_GETCPU))
|
||||
|
||||
/* cpu id counter value */
|
||||
|
@ -27,6 +27,8 @@
|
||||
# include "vt_plugin_cntr_int.h"
|
||||
#endif /* VT_PLUGIN_CNTR */
|
||||
|
||||
#define MAX_MUTEXES 16
|
||||
|
||||
/* data structure which hold the actual Pthread mutex */
|
||||
struct VTThrdMutex_struct
|
||||
{
|
||||
@ -53,10 +55,13 @@ static pthread_key_t pthreadKey;
|
||||
static pthread_mutex_t threadReuseMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t mutexInitMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static VTThrdMutex mutexes[MAX_MUTEXES];
|
||||
static uint32_t mutexesNum = 0;
|
||||
|
||||
static IdleThreadIdListT* idleThreadIds = NULL;
|
||||
|
||||
static uint8_t reuseThreadIds = 0;
|
||||
static uint8_t masterThreadTerminated = 0;
|
||||
static uint8_t reuseThreadIds = 0;
|
||||
static uint8_t masterThreadTerminated = 0;
|
||||
|
||||
static uint32_t idle_tid_list_size(uint32_t ptid)
|
||||
{
|
||||
@ -299,10 +304,17 @@ void VTThrd_createMutex(VTThrdMutex** mutex)
|
||||
pthread_mutex_lock(&mutexInitMutex);
|
||||
if (*mutex == NULL)
|
||||
{
|
||||
*mutex = (VTThrdMutex*)malloc(sizeof(VTThrdMutex));
|
||||
if (*mutex == NULL)
|
||||
vt_error();
|
||||
pthread_mutex_init(&((*mutex)->m), NULL);
|
||||
if (mutexesNum + 1 >= MAX_MUTEXES)
|
||||
{
|
||||
vt_error_msg("Number of thread mutexes exceeds maximum of %d",
|
||||
MAX_MUTEXES);
|
||||
}
|
||||
else
|
||||
{
|
||||
*mutex = &(mutexes[mutexesNum++]);
|
||||
|
||||
pthread_mutex_init(&((*mutex)->m), NULL);
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&mutexInitMutex);
|
||||
}
|
||||
@ -315,7 +327,6 @@ void VTThrd_deleteMutex(VTThrdMutex** mutex)
|
||||
if (*mutex != NULL )
|
||||
{
|
||||
pthread_mutex_destroy(&((*mutex)->m));
|
||||
free(*mutex);
|
||||
*mutex = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&mutexInitMutex);
|
||||
|
@ -30,9 +30,9 @@
|
||||
#include "vt_otf_gen.h"
|
||||
#include "vt_env.h"
|
||||
#include "vt_fork.h"
|
||||
#include "vt_execwrap.h"
|
||||
#include "vt_iowrap.h"
|
||||
#include "vt_libcwrap.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_metric.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_error.h"
|
||||
@ -539,7 +539,7 @@ static void write_def_header(void)
|
||||
}
|
||||
#endif /* VT_UNIMCI */
|
||||
|
||||
#if defined(VT_MEMHOOK)
|
||||
#if defined(VT_MALLOCWRAP)
|
||||
/* VT_MEMTRACE */
|
||||
vt_def_comment(VT_MASTER_THREAD, VT_UNIFY_STRID_VT_COMMENT" VT_MEMTRACE: %s",
|
||||
vt_env_memtrace() ? "yes" : "no");
|
||||
@ -551,7 +551,7 @@ static void write_def_header(void)
|
||||
VT_UNIFY_STRID_VT_COMMENT" VT_MEMTRACE_MARKER: %s",
|
||||
vt_env_memtrace_marker() ? "yes" : "no");
|
||||
}
|
||||
#endif /* VT_MEMHOOK */
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if defined(VT_GETCPU)
|
||||
/* VT_CPUIDTRACE */
|
||||
@ -560,6 +560,12 @@ static void write_def_header(void)
|
||||
vt_env_cpuidtrace() ? "yes" : "no");
|
||||
#endif /* VT_GETCPU */
|
||||
|
||||
#if defined(VT_EXECWRAP)
|
||||
/* VT_EXECTRACE */
|
||||
vt_def_comment(VT_MASTER_THREAD, VT_UNIFY_STRID_VT_COMMENT" VT_EXECTRACE: %s",
|
||||
vt_env_exectrace() ? "yes" : "no");
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#if defined(VT_IOWRAP)
|
||||
/* VT_IOTRACE */
|
||||
vt_def_comment(VT_MASTER_THREAD, VT_UNIFY_STRID_VT_COMMENT" VT_IOTRACE: %s",
|
||||
@ -737,13 +743,13 @@ static void write_uctl_file(void)
|
||||
2 + /* "*:" */
|
||||
VTThrdn * (8 + 1 + 1) + 1 + /* stream ids[!]:\n */
|
||||
4 * (16 + 1) + 1 + 1; /* ltime0:offset0:ltime1:offset1:\n */
|
||||
#if (defined(VT_LIBCWRAP) && defined(VT_FORK))
|
||||
if (vt_env_libctrace())
|
||||
#if (defined(VT_EXECWRAP) && defined(VT_FORK))
|
||||
if (vt_env_exectrace())
|
||||
{
|
||||
/* additional stream ids of forked processes */
|
||||
uctl_data_size += vt_fork_get_num_childs_tot() * (8 + 1);
|
||||
}
|
||||
#endif /* VT_LIBCWRAP && VT_FORK */
|
||||
#endif /* VT_EXECWRAP && VT_FORK */
|
||||
|
||||
if (vt_my_trace == 0)
|
||||
{
|
||||
@ -796,14 +802,14 @@ static void write_uctl_file(void)
|
||||
VT_PROCESS_ID(vt_my_trace, i), vt_my_trace_is_disabled ? "!" : "");
|
||||
}
|
||||
|
||||
#if (defined(VT_LIBCWRAP) && defined(VT_FORK))
|
||||
#if (defined(VT_EXECWRAP) && defined(VT_FORK))
|
||||
/* add stream ids of forked child processes to uctl data, if necessary */
|
||||
if (vt_env_libctrace())
|
||||
if (vt_env_exectrace())
|
||||
{
|
||||
for (i = 1; i <= (int)vt_fork_get_num_childs_tot(); i++)
|
||||
sprintf(uctl_data + strlen(uctl_data), "%x:", vt_my_trace+1+i);
|
||||
}
|
||||
#endif /* VT_LIBCWRAP && VT_FORK */
|
||||
#endif /* VT_EXECWRAP && VT_FORK */
|
||||
|
||||
strcat(uctl_data, "\n");
|
||||
|
||||
@ -1304,35 +1310,36 @@ void vt_open()
|
||||
vt_misc_cgid = vt_def_counter_group(VT_MASTER_THREAD, "Miscellaneous");
|
||||
|
||||
#if defined(VT_LIBWRAP)
|
||||
|
||||
vt_libwrap_init();
|
||||
|
||||
#endif /* VT_LIBWRAP */
|
||||
|
||||
#if defined(VT_LIBCWRAP)
|
||||
#if defined(VT_EXECWRAP)
|
||||
|
||||
if (vt_env_libctrace())
|
||||
if (vt_env_exectrace())
|
||||
{
|
||||
vt_libcwrap_init();
|
||||
|
||||
vt_execwrap_init();
|
||||
#if defined(VT_FORK)
|
||||
vt_fork_init();
|
||||
#endif /* VT_FORK */
|
||||
|
||||
VT_ENABLE_LIBC_TRACING();
|
||||
}
|
||||
|
||||
#endif /* VT_LIBCWRAP */
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#if defined(VT_IOWRAP)
|
||||
if( vt_env_iotrace() )
|
||||
vt_iowrap_reg();
|
||||
#endif
|
||||
|
||||
#if defined(VT_MEMHOOK)
|
||||
if (vt_env_iotrace())
|
||||
vt_iowrap_reg();
|
||||
|
||||
#endif /* VT_IOWRAP */
|
||||
|
||||
#if defined(VT_MALLOCWRAP)
|
||||
|
||||
if (vt_env_memtrace())
|
||||
vt_memhook_init();
|
||||
vt_mallocwrap_init();
|
||||
|
||||
#endif /* VT_MEMHOOK */
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if defined(VT_GETCPU)
|
||||
|
||||
@ -1475,14 +1482,6 @@ void vt_reset()
|
||||
|
||||
#endif /* VT_PLUGIN_CNTR */
|
||||
|
||||
#if defined(VT_MEMHOOK)
|
||||
|
||||
/* finalize memory hooks if enabled */
|
||||
if (vt_env_memtrace())
|
||||
vt_memhook_finalize();
|
||||
|
||||
#endif /* VT_MEMHOOK */
|
||||
|
||||
#if defined(VT_GETCPU)
|
||||
|
||||
/* finalize cpu id tracing if enabled */
|
||||
@ -1502,21 +1501,26 @@ void vt_reset()
|
||||
|
||||
#endif /* VT_IOWRAP */
|
||||
|
||||
#if defined(VT_LIBCWRAP)
|
||||
#if defined(VT_EXECWRAP)
|
||||
|
||||
/* finalize LIBC wrapper if enabled */
|
||||
if (vt_env_libctrace())
|
||||
/* finalize EXEC wrapper if enabled */
|
||||
if (vt_env_exectrace())
|
||||
{
|
||||
VT_DISABLE_LIBC_TRACING();
|
||||
|
||||
#if defined(VT_FORK)
|
||||
vt_fork_finalize();
|
||||
#endif /* VT_FORK */
|
||||
|
||||
vt_libcwrap_finalize();
|
||||
vt_execwrap_finalize();
|
||||
}
|
||||
|
||||
#endif /* VT_LIBCWRAP */
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
#if defined(VT_MALLOCWRAP)
|
||||
|
||||
/* finalize memory allocation wrapper */
|
||||
if (vt_env_memtrace())
|
||||
vt_mallocwrap_finalize();
|
||||
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if defined(VT_LIBWRAP)
|
||||
|
||||
@ -1604,10 +1608,13 @@ void vt_close()
|
||||
int tnum;
|
||||
int i;
|
||||
|
||||
/* return immediately, if VT isn't initialized */
|
||||
if ( !vt_is_alive ) return;
|
||||
|
||||
/* return immediately, if VT is aborted by a fatal error
|
||||
(i.e. vt_error_msg) */
|
||||
if ( vt_failure ) return;
|
||||
|
||||
|
||||
/* catch vt_close called from child processes through atexit */
|
||||
if ( init_pid != getpid() ) return;
|
||||
|
||||
@ -1653,6 +1660,8 @@ void vt_close()
|
||||
|
||||
#endif /* VT_CUDARTWRAP */
|
||||
|
||||
vt_is_alive = 0;
|
||||
|
||||
tnum = (int)VTThrdn;
|
||||
|
||||
/* write node process group definition */
|
||||
@ -1661,7 +1670,6 @@ void vt_close()
|
||||
char tmp_char[128];
|
||||
|
||||
/* get member array */
|
||||
|
||||
grpv = (uint32_t*)malloc(tnum * sizeof(uint32_t));
|
||||
if ( grpv == NULL )
|
||||
vt_error();
|
||||
@ -1679,20 +1687,10 @@ void vt_close()
|
||||
free(grpv);
|
||||
}
|
||||
|
||||
vt_is_alive = 0;
|
||||
|
||||
#if defined(VT_MEMHOOK)
|
||||
|
||||
/* finalize memory hooks if enabled */
|
||||
if (vt_env_memtrace())
|
||||
vt_memhook_finalize();
|
||||
|
||||
#endif /* VT_MEMHOOK */
|
||||
|
||||
#if defined(VT_GETCPU)
|
||||
|
||||
/* finalize cpu id tracing if enabled */
|
||||
if ( vt_env_cpuidtrace() )
|
||||
if (vt_env_cpuidtrace())
|
||||
vt_getcpu_finalize();
|
||||
|
||||
#endif /* VT_GETCPU */
|
||||
@ -1708,16 +1706,22 @@ void vt_close()
|
||||
|
||||
#endif /* VT_IOWRAP */
|
||||
|
||||
#if defined(VT_LIBCWRAP)
|
||||
#if defined(VT_EXECWRAP)
|
||||
|
||||
/* finalize LIBC wrapper if enabled */
|
||||
if (vt_env_libctrace())
|
||||
{
|
||||
VT_DISABLE_LIBC_TRACING();
|
||||
vt_libcwrap_finalize();
|
||||
}
|
||||
/* finalize EXEC wrapper if enabled */
|
||||
if (vt_env_exectrace())
|
||||
vt_execwrap_finalize();
|
||||
|
||||
#endif /* VT_LIBCWRAP */
|
||||
#endif /* VT_EXECWRAP */
|
||||
|
||||
|
||||
#if defined(VT_MALLOCWRAP)
|
||||
|
||||
/* finalize memory allocation wrapper */
|
||||
if (vt_env_memtrace())
|
||||
vt_mallocwrap_finalize();
|
||||
|
||||
#endif /* VT_MALLOCWRAP */
|
||||
|
||||
#if defined(VT_LIBWRAP)
|
||||
|
||||
@ -1746,20 +1750,20 @@ void vt_close()
|
||||
for (i = 0; i < tnum; i++)
|
||||
VTThrd_close(VTThrdv[i]);
|
||||
|
||||
#if (defined(VT_LIBCWRAP) && defined(VT_FORK))
|
||||
#if (defined(VT_EXECWRAP) && defined(VT_FORK))
|
||||
|
||||
/* wait until all child processes are terminated */
|
||||
if (vt_env_libctrace())
|
||||
if (vt_env_exectrace())
|
||||
vt_fork_waitchilds();
|
||||
|
||||
#endif /* VT_LIBCWRAP && VT_FORK */
|
||||
#endif /* VT_EXECWRAP && VT_FORK */
|
||||
|
||||
/* write unify control file */
|
||||
write_uctl_file();
|
||||
|
||||
#if (defined(VT_LIBCWRAP) && defined(VT_FORK))
|
||||
#if (defined(VT_EXECWRAP) && defined(VT_FORK))
|
||||
|
||||
if (vt_env_libctrace())
|
||||
if (vt_env_exectrace())
|
||||
{
|
||||
/* the master process removes the temp. trace-id file */
|
||||
if (vt_my_trace == 0)
|
||||
@ -1772,7 +1776,7 @@ void vt_close()
|
||||
vt_fork_finalize();
|
||||
}
|
||||
|
||||
#endif /* VT_LIBCWRAP && VT_FORK */
|
||||
#endif /* VT_EXECWRAP && VT_FORK */
|
||||
|
||||
/* free temporary file names */
|
||||
for (i = 0; i < tnum; i++)
|
||||
@ -2385,15 +2389,6 @@ uint32_t vt_def_region(uint32_t tid, const char* rname, uint32_t fid,
|
||||
case VT_INTERNAL:
|
||||
rdesc = "VT_API";
|
||||
break;
|
||||
case VT_LIBC:
|
||||
rdesc = "LIBC";
|
||||
break;
|
||||
case VT_LIBC_IO:
|
||||
rdesc = "LIBC-I/O";
|
||||
break;
|
||||
case VT_MEMORY:
|
||||
rdesc = "MEM";
|
||||
break;
|
||||
case VT_MPI_FUNCTION:
|
||||
case VT_MPI_COLL_ALL2ALL:
|
||||
case VT_MPI_COLL_ALL2ONE:
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "vt_defs.h"
|
||||
#include "vt_fbindings.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
#define VTRACE
|
||||
@ -26,21 +26,19 @@ static int vt_init = 1; /* is initialization needed? */
|
||||
|
||||
#define VT_INIT \
|
||||
if ( vt_init ) { \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
vt_init = 0; \
|
||||
vt_open(); \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
}
|
||||
|
||||
void VT_User_comment_def__(const char* comment)
|
||||
{
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_def_comment(VT_CURRENT_THREAD, comment);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_comment__(const char* comment)
|
||||
@ -49,12 +47,12 @@ void VT_User_comment__(const char* comment)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_comment(VT_CURRENT_THREAD, &time, comment);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "vt_env.h"
|
||||
#include "vt_fbindings.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_trc.h"
|
||||
#if ((defined(VT_MPI) || defined(VT_HYB)) \
|
||||
@ -33,10 +33,8 @@ static int vt_init = 1; /* is initialization needed? */
|
||||
|
||||
#define VT_INIT \
|
||||
if ( vt_init ) { \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
vt_init = 0; \
|
||||
vt_open(); \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
}
|
||||
|
||||
int VT_User_is_trace_on__()
|
||||
@ -45,11 +43,11 @@ int VT_User_is_trace_on__()
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
ret = vt_is_trace_on(VT_CURRENT_THREAD);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -58,33 +56,33 @@ void VT_User_trace_on__()
|
||||
{
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_trace_on(VT_CURRENT_THREAD, 1);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_trace_off__()
|
||||
{
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_trace_off(VT_CURRENT_THREAD, 1, 0);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_buffer_flush__()
|
||||
{
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
vt_buffer_flush(VT_CURRENT_THREAD);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_timesync__()
|
||||
@ -93,12 +91,12 @@ void VT_User_timesync__()
|
||||
&& defined(VT_ETIMESYNC) && TIMER_IS_GLOBAL == 0)
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
if ( vt_num_traces > 1 && vt_env_etimesync() )
|
||||
vt_esync(MPI_COMM_WORLD);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
#endif /* (VT_MPI || VT_HYB) && VT_ETIMESYNC && TIMER_IS_GLOBAL */
|
||||
}
|
||||
|
||||
@ -108,12 +106,12 @@ void VT_User_update_counter__()
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_update_counter(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
|
||||
@ -123,12 +121,12 @@ void VT_User_set_rewind_mark__(void)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_set_rewind_mark(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_rewind__(void)
|
||||
@ -137,12 +135,12 @@ void VT_User_rewind__(void)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_rewind(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "vt_error.h"
|
||||
#include "vt_fbindings.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -31,10 +31,8 @@ static uint32_t def_gid = 0; /* default counter group id */
|
||||
|
||||
#define VT_INIT \
|
||||
if ( vt_init ) { \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
vt_init = 0; \
|
||||
vt_open(); \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
}
|
||||
|
||||
unsigned int VT_User_count_group_def__(const char* gname)
|
||||
@ -43,7 +41,7 @@ unsigned int VT_User_count_group_def__(const char* gname)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
@ -53,7 +51,7 @@ unsigned int VT_User_count_group_def__(const char* gname)
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return gid;
|
||||
}
|
||||
@ -66,7 +64,7 @@ unsigned int VT_User_count_def__(const char* cname, const char* cunit, int ctype
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
if (gid == (uint32_t)VT_COUNT_DEFGROUP)
|
||||
{
|
||||
@ -116,9 +114,9 @@ unsigned int VT_User_count_def__(const char* cname, const char* cunit, int ctype
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return cid;
|
||||
return cid;
|
||||
}
|
||||
|
||||
void VT_User_count_signed_val__(unsigned int cid, long long val)
|
||||
@ -128,13 +126,13 @@ void VT_User_count_signed_val__(unsigned int cid, long long val)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Signed2Counter((int64_t)val);
|
||||
vt_count(VT_CURRENT_THREAD, &time, cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_count_unsigned_val__(unsigned int cid, unsigned long long val)
|
||||
@ -144,13 +142,13 @@ void VT_User_count_unsigned_val__(unsigned int cid, unsigned long long val)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Unsigned2Counter((uint64_t)val);
|
||||
vt_count(VT_CURRENT_THREAD, &time, cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_count_float_val__(unsigned int cid, float val)
|
||||
@ -160,13 +158,13 @@ void VT_User_count_float_val__(unsigned int cid, float val)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Float2Counter(val);
|
||||
vt_count(VT_CURRENT_THREAD, &time, cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_count_double_val__(unsigned int cid, double val)
|
||||
@ -176,13 +174,13 @@ void VT_User_count_double_val__(unsigned int cid, double val)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Double2Counter(val);
|
||||
vt_count(VT_CURRENT_THREAD, &time, cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -238,13 +236,13 @@ VT_DECLDEF(void VT_User_count_integer_val___f(unsigned int* cid, int* val))
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Signed2Counter((int64_t)(*val));
|
||||
vt_count(VT_CURRENT_THREAD, &time, *cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_count_integer_val__,
|
||||
VT_USER_COUNT_INTEGER_VAL__,
|
||||
VT_User_count_integer_val___f,
|
||||
@ -259,13 +257,13 @@ VT_DECLDEF(void VT_User_count_integer8_val___f(unsigned int* cid,
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Signed2Counter((int64_t)(*val));
|
||||
vt_count(VT_CURRENT_THREAD, &time, *cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_count_integer8_val__,
|
||||
VT_USER_COUNT_INTEGER8_VAL__,
|
||||
VT_User_count_integer8_val___f,
|
||||
@ -279,13 +277,13 @@ VT_DECLDEF(void VT_User_count_real_val___f(unsigned int* cid, float* val))
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Float2Counter(*val);
|
||||
vt_count(VT_CURRENT_THREAD, &time, *cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_count_real_val__,
|
||||
VT_USER_COUNT_real_VAL__,
|
||||
VT_User_count_real_val___f,
|
||||
@ -299,13 +297,13 @@ VT_DECLDEF(void VT_User_count_double_val___f(unsigned int* cid, double* val))
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
cval = OTF_Double2Counter(*val);
|
||||
vt_count(VT_CURRENT_THREAD, &time, *cid, cval);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_count_double_val__,
|
||||
VT_USER_COUNT_double_VAL__,
|
||||
VT_User_count_double_val___f,
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "vt_error.h"
|
||||
#include "vt_fbindings.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -28,10 +28,8 @@ static int vt_init = 1; /* is initialization needed? */
|
||||
|
||||
#define VT_INIT \
|
||||
if ( vt_init ) { \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
vt_init = 0; \
|
||||
vt_open(); \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
}
|
||||
|
||||
unsigned int VT_User_marker_def__(const char* mname, int mtype)
|
||||
@ -41,7 +39,7 @@ unsigned int VT_User_marker_def__(const char* mname, int mtype)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
switch(mtype)
|
||||
{
|
||||
@ -75,7 +73,7 @@ unsigned int VT_User_marker_def__(const char* mname, int mtype)
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return mid;
|
||||
}
|
||||
@ -86,12 +84,12 @@ void VT_User_marker__(unsigned int mid, const char* mtext)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
vt_marker(VT_CURRENT_THREAD, &time, mid, mtext);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "vt_fbindings.h"
|
||||
#include "vt_inttypes.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -27,10 +27,8 @@ static uint32_t def_cid = 0; /* default communicator id */
|
||||
|
||||
#define VT_INIT \
|
||||
if ( vt_init ) { \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
vt_init = 0; \
|
||||
vt_open(); \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
}
|
||||
|
||||
unsigned int VT_User_msg_comm_def__(const char* cname)
|
||||
@ -39,7 +37,7 @@ unsigned int VT_User_msg_comm_def__(const char* cname)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
#if (defined(VT_MT) || defined(VT_HYB))
|
||||
VTTHRD_LOCK_IDS();
|
||||
@ -49,7 +47,7 @@ unsigned int VT_User_msg_comm_def__(const char* cname)
|
||||
VTTHRD_UNLOCK_IDS();
|
||||
#endif
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return cid;
|
||||
}
|
||||
@ -61,7 +59,7 @@ void VT_User_msg_send__(unsigned int cid, unsigned int tag,
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
if (cid == (uint32_t)VT_MSG_DEFCOMM)
|
||||
{
|
||||
@ -74,7 +72,7 @@ void VT_User_msg_send__(unsigned int cid, unsigned int tag,
|
||||
time = vt_pform_wtime();
|
||||
vt_user_send(VT_CURRENT_THREAD, &time, cid, tag, sent);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_msg_recv__(unsigned int cid, unsigned int tag,
|
||||
@ -84,7 +82,7 @@ void VT_User_msg_recv__(unsigned int cid, unsigned int tag,
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
if (cid == (uint32_t)VT_MSG_DEFCOMM)
|
||||
{
|
||||
@ -97,7 +95,7 @@ void VT_User_msg_recv__(unsigned int cid, unsigned int tag,
|
||||
time = vt_pform_wtime();
|
||||
vt_user_recv(VT_CURRENT_THREAD, &time, cid, tag, recvd);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "vt_defs.h"
|
||||
#include "vt_error.h"
|
||||
#include "vt_fbindings.h"
|
||||
#include "vt_memhook.h"
|
||||
#include "vt_mallocwrap.h"
|
||||
#include "vt_pform.h"
|
||||
#include "vt_thrd.h"
|
||||
#include "vt_trc.h"
|
||||
@ -32,10 +32,8 @@ static int vt_init = 1; /* is initialization needed? */
|
||||
|
||||
#define VT_INIT \
|
||||
if ( vt_init ) { \
|
||||
VT_MEMHOOKS_OFF(); \
|
||||
vt_init = 0; \
|
||||
vt_open(); \
|
||||
VT_MEMHOOKS_ON(); \
|
||||
}
|
||||
|
||||
#define REGION_HASH_MAX 1024
|
||||
@ -197,7 +195,7 @@ void VT_User_start__(const char* name, const char* file, int lno)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -218,7 +216,7 @@ void VT_User_start__(const char* name, const char* file, int lno)
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_end__(const char* name)
|
||||
@ -227,13 +225,13 @@ void VT_User_end__(const char* name)
|
||||
|
||||
(void)name;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- write exit record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
unsigned int VT_User_def__(const char* name, const char* file, int lno)
|
||||
@ -242,7 +240,7 @@ unsigned int VT_User_def__(const char* name, const char* file, int lno)
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- get region identifier by name, file, and line number -- */
|
||||
if ( (rid = hash_get_region(name, file, lno)) == VT_NO_ID )
|
||||
@ -258,7 +256,7 @@ unsigned int VT_User_def__(const char* name, const char* file, int lno)
|
||||
#endif /* VT_MT || VT_HYB */
|
||||
}
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
return rid;
|
||||
}
|
||||
@ -267,13 +265,13 @@ void VT_User_start_id__(unsigned int rid)
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- write enter record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
void VT_User_end_id__(unsigned int rid)
|
||||
@ -282,13 +280,13 @@ void VT_User_end_id__(unsigned int rid)
|
||||
|
||||
(void)rid;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- write exit record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -308,7 +306,7 @@ VT_DECLDEF(void VT_User_start___f(const char* name, const char* file, int* lno,
|
||||
|
||||
VT_INIT;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
time = vt_pform_wtime();
|
||||
|
||||
@ -337,7 +335,7 @@ VT_DECLDEF(void VT_User_start___f(const char* name, const char* file, int* lno,
|
||||
/* -- write enter record -- */
|
||||
vt_enter(VT_CURRENT_THREAD, &time, rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_start__, VT_USER_START__,
|
||||
VT_User_start___f,
|
||||
(const char* name, const char* file, int* lno,
|
||||
@ -349,13 +347,13 @@ VT_DECLDEF(void VT_User_end___f(const char* name, int nl))
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- write exit record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_end__, VT_USER_END__,
|
||||
VT_User_end___f,
|
||||
(const char *name, int nl),
|
||||
@ -389,13 +387,13 @@ VT_DECLDEF(void VT_User_start_id___f(unsigned int* rid))
|
||||
{
|
||||
uint64_t time;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- write enter record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_enter(VT_CURRENT_THREAD, &time, *rid);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_start_id__, VT_USER_START_ID__,
|
||||
VT_User_start_id___f,
|
||||
(unsigned int* rid),
|
||||
@ -407,13 +405,13 @@ VT_DECLDEF(void VT_User_end_id___f(unsigned int* rid))
|
||||
|
||||
(void)rid;
|
||||
|
||||
VT_MEMHOOKS_OFF();
|
||||
VT_SUSPEND_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
|
||||
/* -- write exit record -- */
|
||||
time = vt_pform_wtime();
|
||||
vt_exit(VT_CURRENT_THREAD, &time);
|
||||
|
||||
VT_MEMHOOKS_ON();
|
||||
VT_RESUME_MALLOC_TRACING(VT_CURRENT_THREAD);
|
||||
} VT_GENERATE_F77_BINDINGS(vt_user_end_id__, VT_USER_END_ID__,
|
||||
VT_User_end_id___f,
|
||||
(unsigned int* rid),
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user