File: taucc

package info (click to toggle)
tau 2.17.3.1.dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 20,488 kB
  • ctags: 27,426
  • sloc: java: 94,358; cpp: 51,160; ansic: 48,343; tcl: 15,473; sh: 10,475; fortran: 8,357; python: 5,643; makefile: 3,665; f90: 632; sql: 454; perl: 260; xml: 231; yacc: 117; php: 93; csh: 82; sed: 59; modula3: 29; awk: 19
file content (228 lines) | stat: -rwxr-xr-x 6,300 bytes parent folder | download | duplicates (2)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/sh

# Get configuration
PATH=$PATH:`dirname $0`
eval `tau-config`

# Define variables 
makefile_specified=no
options_specified=no

# depending on the options, we might invoke the regular compiler, TAU_COMPILER, or both
invoke_without_tau=no
invoke_with_tau=yes


usage()
{
    cmd=`basename $0`
    echo ""
    echo " $cmd - C compiler wrapper for TAU"
    echo ""
    echo " Usage: $cmd [-tau:help] [-tau:<options>] [-tau:makefile <tau_stub_makefile>] "
    echo "             [-tau:verbose] [-tau:keepfiles] [-tau:show] ..."
    echo ""
    echo " Options:"
    echo "   -tau:help            Show this help message"
    echo "   -tau:verbose         Enable verbose mode"
    echo "   -tau:keepfiles       Keep intermediate files"
    echo "   -tau:show            Do not invoke, just show what would be done"
    echo "   -tau:<options>       Specify comma separated list of TAU options"
    echo "                        <MPI,PTHREAD,OPENMP,PROFILE,"
    echo "                         CALLPATH,TRACE,VAMPIRTRACE,EPILOG>"
    echo " "
    echo " Notes:"
    echo "   If the -tau:makefile option is not used, the TAU_MAKEFILE"
    echo "   environment variable will be checked, if it is not specified,"
    echo "   then the -tau:<options> will be checked against available"
    echo "   bindings."
    echo ""
    echo " Example usage:"
    echo ""
    echo "   $cmd foo.c -o foo"
    echo "   $cmd -tau:MPI,OPENMP,TRACE foo.c -o foo"
    echo "   $cmd -tau:verbose -tau:PTHREAD foo.c -o foo"
    echo ""
    exit 1
}

TAUARGS=
NON_TAUARGS=
EATNEXT=false
next_arg_makefile=false
next_arg_options=false
verbose=false
binding_options=
opt_keepfiles=false

for arg in "$@" ; do
  # Thanks to Bernd Mohr for the following that handles quotes and spaces (see configure for explanation)
  modarg=`echo "x$arg" | sed -e 's/^x//' -e 's/"/\\\"/g' -e s,\',%@%\',g -e 's/%@%/\\\/g' -e 's/ /\\\ /g' -e 's#(#\\\(#g' -e 's#)#\\\)#g'`
  if [ $EATNEXT = true ] ; then
      # these arguments should only go to the non-tau invocation
      NON_TAUARGS="$NON_TAUARGS $modarg"
      EATNEXT=false
  elif [ $next_arg_makefile = true ] ; then
      MAKEFILE=$arg
      next_arg_makefile=false
  elif [ $next_arg_options = true ] ; then
      TAUCOMPILER_OPTIONS="$TAUCOMPILER_OPTIONS $arg"
      next_arg_options=false
  else
      case $arg in 
	  -tau:makefile)
	      makefile_specified=yes
	      next_arg_makefile=true
	      ;;
	  -tau:options)
	      options_specified=yes
	      next_arg_options=true
	      ;;
	  -tau:verbose)
	      verbose=true
	      ;;
	  -tau:keepfiles)
	      opt_keepfiles=true
	      ;;
	  -tau:show)
	      invoke_without_tau=yes
	      invoke_with_tau=no
	      NON_TAUARGS="$NON_TAUARGS $modarg"
              SHOW=show
	      ;;
	  -tau:help)
	      usage
	      ;;
	  -tau:*)
	      binding_options="$binding_options `echo $arg | sed -e 's/-tau://' -e 's/,/ /g'`"
	      ;;
	  -E)
	      invoke_without_tau=yes
	      invoke_with_tau=no
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  -MD | -MMD)
              # if either of these are specified, we invoke the regular compiler
              # and TAU_COMPILER, unless -E or another disabling option is specified
	      invoke_without_tau=yes
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  -MF | -MT | -MQ)
              # these arguments should only go to the non-tau invocation
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      # we must eat the next argument as well and use it for the non-tau invocation only
	      EATNEXT=true
	      ;;
	  -MF* | -MT* | -MQ* | -MP | -MG)
              # these arguments should only go to the non-tau invocation
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  -M | -MM | -V | -v | --version | -print-prog-name=ld | -print-search-dirs | -dumpversion)
              # if any of these are specified, we invoke the regular compiler only
	      invoke_without_tau=yes
	      invoke_with_tau=no
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
	  *)
	      TAUARGS="$TAUARGS $modarg"
	      NON_TAUARGS="$NON_TAUARGS $modarg"
	      ;;
      esac
  fi
done


if [ "x$NON_TAUARGS" = x ] ; then
    invoke_without_tau=yes
    invoke_with_tau=no
fi

# Find the makefile to use
if [ $makefile_specified = no ] ; then
    if [ "x$binding_options" != "x" ] ; then
	MAKEFILE=`tau-config --makefile $binding_options`
	if [ $verbose = true ] ; then 
	    echo "Matching bindings:"
	    tau-config --makefile --list-matching $binding_options
	    echo ""
	fi
	
    elif [ "x$TAU_MAKEFILE" != "x" ] ; then
	if [ ! -r $MAKEFILE ] ; then
	    echo "ERROR: environment variable TAU_MAKEFILE is set but the file is not readable"
	    exit 1
        fi
	MAKEFILE=$TAU_MAKEFILE
    elif [ "x$DEFAULT_MAKEFILE" != "x" ] ; then
	MAKEFILE=$DEFAULT_MAKEFILE
    else
	MAKEFILE=`tau-config --makefile`
    fi
fi

if [ "x$MAKEFILE" = "x" ] ; then
    echo "ERROR: unable to locate stub makefile" >&2
    exit 1
fi

if [ ! -r $MAKEFILE ] ; then
    echo "ERROR: unable to read stub makefile '$MAKEFILE'" >&2
    exit 1
fi

if [ $verbose = true ] ; then 
    echo "Using: $MAKEFILE"
fi


# if no tau_compiler options were set, use $TAU_OPTIONS
if [ $options_specified = no ] ; then
    TAUCOMPILER_OPTIONS=$TAU_OPTIONS
fi

# unless verbose is specified, use -optQuiet
if [ $verbose = true ] ; then
    TAUCOMPILER_OPTIONS="$TAUCOMPILER_OPTIONS -optVerbose"
else
    TAUCOMPILER_OPTIONS="$TAUCOMPILER_OPTIONS -optQuiet"
fi

TAUCOMPILER_OPTIONS="$TAUCOMPILER_OPTIONS -optCompInst"

# Pathscale/Opari workaround
if [ "$SICORTEX" = "yes" ] ; then
    TAUCOMPILER_OPTIONS="$TAUCOMPILER_OPTIONS -optOpariOpts=-nodecl"
fi

if [ $opt_keepfiles = true ] ; then
    TAUCOMPILER_OPTIONS="$TAUCOMPILER_OPTIONS -optKeepFiles"
fi

tmpmakefile=$( mktemp --tmpdir makefile.tau.$USER.$$-XXXXXX )

if [ $invoke_without_tau = yes ] ; then
cat <<EOF > $tmpmakefile
include $MAKEFILE
all:
	@\$(TAU_RUN_CC) \$(TAU_MPI_INCLUDE) $NON_TAUARGS || exit 0
show:
	@echo \$(TAU_RUN_CC) \$(TAU_MPI_FLIBS) \$(TAU_LIBS) \$(TAU_LDFLAGS) \$(TAU_CXXLIBS)
EOF
make -s -f $tmpmakefile $SHOW
fi


if [ $invoke_with_tau = yes ] ; then
cat <<EOF > $tmpmakefile
include $MAKEFILE
all:
	@\$(TAU_COMPILER) $TAUCOMPILER_OPTIONS \$(TAU_RUN_CC) $TAUARGS || exit 0

EOF
make -s -f $tmpmakefile 
x=$?
fi 

/bin/rm -f $tmpmakefile
exit $x