-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtau_gen_wrapper
More file actions
executable file
·158 lines (146 loc) · 4.72 KB
/
tau_gen_wrapper
File metadata and controls
executable file
·158 lines (146 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh
usage()
{
cmd=`basename $0`
echo ""
echo " $cmd - Generates a wrapper library that can intercept "
echo " at link time or at runtime routines specified in a header file"
echo " Usage: $cmd <headerfile> <library> [-w (default) | -d | -r] [-upc={berkeley,gnu,cray}]"
echo " -w (default): generates wrappers for re-linking the application"
echo " -d : generates wrappers by redefining routines during compilation in header files"
echo " -r : generates wrappers that may be pre-loaded using tau_exec at runtime"
echo " -upc: generates UPC runtime wrapper for use with -optTrackUPCR"
echo "NOTE: $cmd reads the TAU_MAKEFILE environment variable to get PDT settings"
echo " Example: "
echo " % $cmd hdf5.h /usr/lib/libhdf5.a "
echo " generates a wrapper library that may be linked in using TAU_OPTIONS -optTauWrapFile=<wrapperdir>/link_options.tau"
echo ""
exit 1
}
runtime_specified=0;
header_redirection_specified=0;
headerfile=""
library=""
modarg=""
upc=""
if [ $# = 0 ] ; then
usage
fi
if [ $# -gt 1 ]; then
headerfile=$1
library=$2
shift;
shift;
fi
for arg in "$@"; do
case $arg in
-r)
runtime_specified=1
shift
;;
-d)
header_redirection_specified=1
shift
;;
-upc=*)
upc="`echo $1 | sed 's/-upc=//'`"
shift
;;
-h|-help|--help)
usage
;;
esac
done
if [ "x$TAU_MAKEFILE" = "x" ] ;then
echo "ERROR: Please set the TAU_MAKEFILE environment variable."
exit 1
fi
if [ ! -r $TAU_MAKEFILE ] ;then
echo "ERROR: environment variable TAU_MAKEFILE is set but the file is not readable"
exit 1
fi
if ! which tau-config > /dev/null 2>&1 ; then
echo "ERROR: tau-config is not in your path."
exit 1
fi
pdtdir="`grep PDTDIR= $TAU_MAKEFILE | sed -e 's/PDTDIR=//g' `"
tauarch="`tau-config | grep TAUARCH | sed -e 's@TAUARCH=@@g' `"
tauroot="`tau-config | grep TAUROOT | sed -e 's@TAUROOT=@@g' `"
basedir="`tau-config | grep BASEDIR | sed -e 's@BASEDIR=@@g' `"
if [ "x$upc" != "x" ] ; then
gasnetdir="`grep TAU_GASNET_DIR= $TAU_MAKEFILE | sed -e 's/TAU_GASNET_DIR=//g' `"
upcnetwork="`grep UPCNETWORK= $TAU_MAKEFILE | sed -e 's/UPCNETWORK=//g' `"
case $upc in
berkeley)
if ! which upcc > /dev/null 2>&1 ; then
echo "ERROR: upcc is not in your path."
exit 1
fi
upcdir="`which upcc | sed -e 's@bin/upcc@@g'`"
if [ -d $upcdir/opt_inst ] ; then
upcdir="$upcdir/opt_inst"
elif [ -d "$upcdir/inst/opt" ] ; then
upcdir="$upcdir/inst/opt"
else
echo "ERROR: Cannot locate instrumented Berkeley configuration at $upcdir"
exit 1
fi
echo PATH="$basedir/bin:$PATH" $tauroot/src/wrappers/upc/bupc/upcr/tau_upc_runtime_wrapper "$headerfile" -lm -gasnet="$gasnetdir" -gasnetconduit=$upcnetwork -upc="$upcdir"
PATH="$basedir/bin:$PATH" $tauroot/src/wrappers/upc/bupc/upcr/tau_upc_runtime_wrapper "$headerfile" "$library" -gasnet="$gasnetdir" -gasnetconduit=$upcnetwork -upc="$upcdir"
retval=$?
mv select.tau `basename "$headerfile" .h`_wrapper
exit $retval
;;
gnu)
if ! which upc > /dev/null 2>&1 ; then
echo "ERROR: upc is not in your path."
exit 1
else
upcdir="`which upc | sed -e 's@bin/upc@@g'`"
fi
echo PATH="$basedir/bin:$PATH" $tauroot/src/wrappers/upc/gupc/tau_upc_wrapper "$headerfile" "$library" -gasnet="$gasnetdir" -gasnetconduit=$upcnetwork -upc="$upcdir"
PATH="$basedir/bin:$PATH" $tauroot/src/wrappers/upc/gupc/tau_upc_wrapper "$headerfile" "$library" -gasnet="$gasnetdir" -gasnetconduit=$upcnetwork -upc="$upcdir"
retval=$?
mv select.tau `basename "$headerfile" .h`_wrapper
exit $retval
;;
cray)
if ! which cc > /dev/null 2>&1 ; then
echo "ERROR: cc is not in your path."
exit 1
fi
PATH="$basedir/bin:$PATH" $tauroot/src/wrappers/upc/crayupc/tau_upc_wrapper "$headerfile" "$library"
retval=$?
mv select.tau `basename "$headerfile" .h`_wrapper
exit $retval
;;
*)
echo "ERROR: Unknown UPC family: $upc"
exit 1
exit $?
;;
esac
fi
parser=$pdtdir/$tauarch/bin/cxxparse
if [ ! -x $parser ]; then
echo "ERROR: Can't execute $parser: Using PDT = $pdtdir, ARCH = $tauarch"
exit 1
fi
$parser $headerfile `tau_cc.sh -tau:showincludes`
if [ $runtime_specified = 1 ] ; then
runtimeopt='-r'
else
if [ $header_redirection_specified = 1 ]; then
runtimeopt=''
else
runtimeopt='-w'
fi
fi
#echo "tau_wrap $headerfile.pdb $headerfile -o wr.c $runtimeopt $library $*"
tau_wrap $headerfile.pdb $headerfile -o wr.c $runtimeopt $library $*
dirname=`basename ${headerfile} .h`_wrapper
mkdir -p ${dirname}
cd ${dirname}
make
cd ..
rm -f ${headerfile}.pdb