|
Automatic Tuning and Troubleshooting System User's GuideTable of Contents
1 IntroductionThe Automatic Tuning and Troubleshooting System (ATS) is a binary reoptimization and recompilation tool that can be used for tuning and troubleshooting applications. By default, ATS works by rebuilding a Portable Executable Code (PEC) binary, which means that the original source code is not required when tuning or troubleshooting the application.ATS contains many easy-to-use scripts to perform simple and complex tasks. For example, ATS can:
1.1 Tuning Your ApplicationYou can use ATS scripts like autotuning and combo to tune your applications.The ATS script autotuning will recompile and run your application with different sets of compiler flags. Flags that improve performance are accumulated and used in the next compilation. Flags that do not improve performance are set aside to be used later in new combinations if time permits. For example, to create a PEC binary (from C source code) and run the autotuning script, all you need to do is: % cc -xO3 -Wd,-pec *.c % ats -i 'script:autotuning' a.outThe autotuning script is the default action, so the above ATS command can be rewritten simply as: % ats a.outThe ATS script combo will generate all combinations of a set of given options. This may be useful if you know a few compiler options that improve the performance of your application and you would like to find out which combination of options is the best. For example, the following ats command: % ats -i 'script:combo 3 -f1 "-f2a -f2b" -f3 -f4' a.outwould recompile and run a.out with the following sets of flags:
-f1 -f2a -f2b -f3
-f1 -f2a -f2b -f4
-f1 -f3 -f4
-f2a -f2b -f3 -f4
1.2 Troubleshooting Your ApplicationYou can use ATS scripts like modulesearch and sweep to troubleshoot your application.The ATS script sweep will help you identify which option is causing a failure. If your application fails when compiled with a long set of options, then sweep will first compile with all the options, and then repeatably remove one option and recompile the application. For example, the following ats command: % ats -i 'script:sweep 3 -f1 "-f2a -f2b" -f3 -f4' a.outwould recompile and run a.out with the following sets of flags: -f1 -f2a -f2b -f3 -f4 -f1 -f2a -f2b -f3 -f1 -f2a -f2b -f1The ATS script modulesearch will help you find which module (source code file) is causing a failure. If your application generates different results when compiled with two different sets of options, then modulesearch will search for the single module (or set of modules) that generates the different results. For example, if you had an application that produced different results when compiled with the -xO3 and -fast options, then you could create the PEC binary and run the modulesearch script like this: % cc -xO3 -Wd,-pec *.c % ats -i 'script:modulesearch -xO3 -fast' a.out 2 Using ATSTo use ATS you need to: There are some situations where the following alternatives may be useful:2.1 Creating a PEC BinaryPortable Executable Code (PEC) binary files are executables or shared objects that contain extra information that enable the PEC files to be recompiled with new compiler options without requiring the source code or original build infrastructure (for example, make files or build scripts).PEC binary files can be created using the Sun Studio 11 compilers for C, C++, and FORTRAN, as well as the GCC for SPARC Systems, hereafter referred to as "gcc". The PEC option is specified slightly differently for different compilers:
Note: All FORTRAN compilers require "f90" in the Option string. Note: Compiling with the PEC option requires an optimization level of 3 or higher. The following examples show how to specify the PEC option for each compiler: % cc -xO3 -Wd,-pec *.c % CC -xO3 -Qoption CC -pec *.C *.cc % f77 -xO3 -Qoption f90 -pec *.f *.F % f90 -xO3 -Qoption f90 -pec *.90 *.ftn % f95 -xO3 -Qoption f90 -pec *.95 % gcc -O3 -xpec *.c % g++ -O3 -xpec *.C *.cc 2.2 Running ATSTo use ATS you must specify information about the application and what actions you would like ATS to execute.2.2.1 Specifying the Application InformationTo use ATS you need to give ATS information about the application like:
% ats a.outThis command above tells ATS to:
% ats -r "a.out < input.txt > output.txt" \
-c "head output.txt | diff - output.gold" \
-metric "grep TOTAL output.txt" \
a.out
This command above tells ATS to:
% cat run.csh
a.out < input.txt > output.txt
% cat check.csh
head output.txt | diff - output.gold
% cat metric.csh
grep TOTAL output.txt
% ats -r run.csh \
-c check.csh \
-metric metric.csh \
a.out
2.2.2 Specifying the Experiment ActionsHere are some examples of different experiment actions:% ats a.out % ats -i 'script:autotuning' a.out % ats -i 'script:combo 3 -f1 "-f2a -f2b" -f3 -f4' a.out % ats -i 'script:sweep 3 -f1 "-f2a -f2b" -f3 -f4' a.out % ats -i 'script:modulesearch -xO3 -fast' a.out % ats -i '-xO4' a.outThe first two commands above are equivalent because autotuning is the default ATS experiment action. The final example above will compile the PEC file a.out with the '-xO4' compiler option and then run the new executable file. You can find more detail on specifying scripts and other experiment actions in the ATS Scripts and ATS Experiment Actions sections below. 2.3 Running ATS without Compiling a PEC FileThere are some situations where there may be advantages to running ATS without building a PEC binary. For these situations, you can provide the ATS software with a build command instead of a PEC binary file. ATS will set environment variables like CC, GCC, F90C, CFLAGS, CCFLAGS, and GCFLAGS that the build command can use. Therefore, ATS can select the flags used to recompile the application.Here are a few examples of using the ats command with the -build option:
% ats -build '$CC $CFLAGS hello.c' \
-r 'a.out' -i '-xO4'
% ats -build '$GCC $GCFLAGS hello.c' \
-r 'a.out' -i '-O4'
% ats -build 'make CC=$CC CFLAGS="$CFLAGS" clean a.out' \
-r 'a.out' -i '-xO4'
% ats -build 'gmake CC=$GCC CFLAGS="$GCFLAGS" clean a.out' \
-r 'a.out' -i '-O4'
% ats -build 'build_it' \
-r 'a.out' -i '-xO4'
Note: The -build option requires that a -r option (the run command option) is also specified.
2.4 Running ATS in a BrowserYou can access all ATS features from both the command-line interface and the browser interface.The ATS command-line interface is very useful for batch or automated jobs (such as running ATS as part of a test suite). The browser interface provides a simple form that may be helpful for learning the ATS software, and it may help with the initial setup of a new ATS job. You can use the browser interface's dryrun checkbox to generate an equivalent ats tool command. To use the ATS software in a browser, first start the ATS server on the machine where you want to recompile and execute your binary file, and then you control and observe the ATS server by way of the ATS software's web interface HTML page. For example, you can start an ATS server like this: % rlogin some_machine % ats -server Go to file:///some_very_long_path/ats.html in a browser Use the following when prompted in browser User Name: harry Password : 371425Then you enter the specified URL in a browser, fill out the ATS form, and click on the "Run Experiment" button. At that time ATS will ask you for a "User Name & Password" and you enter the information printed when you started the server. The ats.html page has helpful links to an ats_info.html page which contains instructions on how to fill in the ATS form. 3 ATS ScriptsThe ATS software has many easy-to-use scripts that you can use to perform a variety of simple and complex tasks. The ATS scripts include:3.1 autotuningautotuning will recompile and run your application with different sets of compiler flags. Flags that improve performance are accumulated and used in the next compilation. Flags that do not improve performance are set aside and used later in new combinations if time permits.% ats -i "script:autotuning --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:autotuning --h # Usage: autotuning [--h|--i|--p|--s] [flags...] # # Default => automatic tuning using first class flags # --h => print this help message # --i => internal flags are also tried # internal flags may not be supported # --p => existing profile is used (no profile is collected) # --s => only specified flags are tried. No predefined flags # are tried (--i and --p are also ignored) # # Example 1: Default automatic tuning # % cc -xO3 -Wd,-pec *.c # % ats a.out # # Example 2: Use existing profile # % ats -i '-xO3 -xprofile=collect ;; do_train_run' \ # -i 'script:autotuning --p' \ # -r 'do_run' a.out # # Example 3: Use all available preloaded options # % ats -i 'script:autotuning --i' a.out # 3.2 binarysearch% ats -i "script:binarysearch --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:binarysearch --h # Usage: binarysearch [--h] <opts with %d> pass_no fail_no # where: # <opts with %d> is a set of options like "-foo=%d" # pass_no when %d is replaced by this number the test passes # fail_no when %d is replaced by this number the test fails # # Example 1: Search the option -foo=%d between values 0 and 175 # # If -foo=0 passes and -foo=175 fails and you want to find # a number (n) such that -foo=(n) passes and -foo=(n+1) fails, # then you can use this command: # # % ats -i 'script:binarysearch "-foo=%d" 0 175' a.out # 3.3 combocombo takes a set of compiler options and recompiles them using different combinations of the same options. If your application runs faster or slower when you add a long string of options, then combo will let you know how each flag (or sets of flags) affects performance.% ats -i "script:combo --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:combo --h # Usage: combo [--h] <how-many-at-a-time> [options...] # # Example 1: Four flags combined three-at-a-time # # % ats -i 'script:combo 3 -a -b -c -d' a.out # # The above command will try these options: # # -a -b -c # -a -b -d # -a -c -d # -b -c -d # 3.4 deepsweep% ats -i "script:deepsweep --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:deepsweep --h # Usage: deepsweep [--h] options.... # # Example 1: Sweep through some options # # % ats -i 'script:deepsweep -a -fast -c -d' a.out # # The above command will try these options: # # -a -fast -c -d # -a -fast -c # -a -fast # -a -xO5 -fns -fsimple=2 -xmemalign=8s -xtarget=native -xlibmil -xlibmopt # -a -xO5 -fns -fsimple=2 -xmemalign=8s -xtarget=native -xlibmil # -a -xO5 -fns -fsimple=2 -xmemalign=8s -xtarget=native # -a -xO5 -fns -fsimple=2 -xmemalign=8s # -a -xO5 -fns -fsimple=2 # -a -xO5 -fns -fsimple=1 # -a -xO5 -fns # -a -xO5 # -a -xO4 # -a -xO3 # -xO3 # 3.5 findbug% ats -i "script:findbug --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:findbug --h # Usage: findbug [--h] options.... # # IMPORTANT NOTE: uses modulesearch (requires PEC; no -build) # # Example 1: Find options and module that causes failure # # % ats -i 'script:findbug -a -b -c' a.out # # The above command starts by issuing these options: # # DEEPSWEEP_STOP_ON_PASS=1 # script:deepsweep '-a' '-b' '-c' # script:modulesearch "" "" # # You can see by the lines above that findbug first # does a deepsweep and then a modulesearch. # 3.6 fixbug% ats -i "script:fixbug --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:fixbug --h # Usage: fixbug [--h] options.... # # Example 1: Do a findbug and then create executable without bug # # % ats -i 'script:fixbug -a -b -c' a.out # 3.7 modulesearchmodulesearch will help you find which module (source code file) is causing a failure. If your application generates different results when compiled with two different sets of options, then the modulesearch script will search for the single module (or set of modules) that generates the different results.% ats -i "script:modulesearch --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:modulesearch --h # Usage: modulesearch [--h] "working options" "faulty options" # internal usage: modulesearch [--h] "working options" "faulty options" # output.html start end mid failing_mid known_bad ... # # IMPORTANT NOTE: requires PEC and is not compatible with the ats -build option # # Example 1: Find module that passes with -xO4 but fails with -fast # # % ats -i 'script:modulesearch "-xO4" "-fast"' a.out # 3.8 sweep% ats -i "script:sweep --h" -build foo -r bar === Starting Automatic Tuning System === Will try the following set of options: script:sweep --h # Usage: sweep [--h] options.... # # Example 1: Sweep through some options # # % ats -i 'script:sweep -a -fast -c -d' a.out # # The above command will try these options: # # -a -fast -c -d # -a -fast -c # -a -fast # -xO3 -a # -xO3 #
-xO4 -xipo cc[-xdepend -xalias_level=strong] f90[-xia]
-fast CC[-xlinkopt]
Advanced users can do more.
Each line above can be of one of following forms:
1. Recompilation options, run command, and verify command
set_of_options [;; overriding_run_command [;; overriding_verify_cmd]]
-xO3 -xO5
-xO3 -xO5 ;; collect pec.out
-xO3 -xO5 ;; truss pec.out ;; check_for_errors
2. Script invocation
The script can print on stdout the sets of options that ATS should try. Lines printed by scripts can be of any of the general forms.
script:progname [args ...]
script:testpl
script:binarysearch 1 100
Scripts are also passed ATS environment variables corresponding to the preceding run
ATS_LAST_STATUS - empty if there was no previous run
ATS_LAST_METRIC - empty if there was no previous run
3. Environment Variable Setting (scripts can use them)
VAR=value
LOW=0
HIGH=100
5 Command-Line Option DescriptionsThe ats command accepts the following options.5.1 -build <command> OptionThe -build option can pass a command to the ats tool when it builds non-PEC binaries. (This option can be specified more than once).The ATS software will set the following environmental variables: CC, CCC, FC, F90C, F95C, GCC, GXX, CFLAGS, CCFLAGS, FFLAGS, F90FLAGS, F95FLAGS, GCFLAGS, and GXFLAGS. 5.2 -c <command> OptionUse the -c command option to verify that the execution of the run command either was completed successfully or failed. The status of the command is used for verification (a 0 status means the command ran successfully, and any other status means there was a failure). Examples of using the -c option:
% ats -r "a.out < input.txt > output.txt" \
-c "cmp output.txt gold.txt" \
a.out
% ats -r "run.sh" -c "verify.sh" a.out
5.3 -cc <dir> OptionUse the -cc option to specify the compiler directory. The compiler directory field (dir) can contain either a single directory or a file that contains a list of directories where the compiler drivers can be found.The PEC binary file is examined to determine the name of the driver (cc, CC, f90, gcc, or g++) that was used to compile the modules of the binary file. The compiler directory and the driver name are then combined to create the driver used by the ATS software. Examples of a single directory:
/compilers/current/binExamples of a file that contains a list of directories: /home/ron/ats/compiler.listWhere: % more /home/ron/ats/compiler.listThe default compiler directory is the directory where the ats script is located. 5.4 -d OptionThe debug option is used to enable ATS debugging messages.Note: This option is used primarily for debugging the ATS software itself, and it may not be helpful for debugging your application. % ats -d a.out 5.5 -distribute OptionRun each try associated with the -i <opt> distributedly. This flag requires the -tarfile <file> option. Each recompilation is done in a different sub directory under the default output directory, and all are done in parallel.Examples of using the -dstribute option: % ats -distribute -tarfile test.tar -i -O3 -i fast -i '-O3 -xipo=2' pec.out % ats -distribute -distr_cmd /opt/SUNWscs/bin/scsx -tarfile test.tar -i '-O4' -i '-fast' pec.outNote: When using the -i <opt> option with the -distribute option, <opt> cannot be a file. 5.6 -distr_cmd <command> OptionUse <command> to accomplish the parallelism. The default is to use the 'dmake' tool.When 'dmake' is used, ATS will generate a Makefile containing separate ATS commands for each option specified. Then ATS will issue a dmake command. When the dmake command is complete, ATS will collect the results ("reuse") and present the results in a results file. Read the documentation on 'dmake' or refer to the man pages of 'dmake' to learn how to use it. The only other command accepted is 'scsx' (Sun Compiler Server). Please refer to 'scsx' documentaion on how to use it. Note: For now, all distribute commands other than 'dmake' or 'scsx' will be ignored. 5.7 -h OptionThis option prints the following ats command usage message:
% ats -h
Usage: ats [options] {<app>|<app-list>} ...
where options include:
-build <command> command to build non-PEC binaries (can be specified more than once)
ats sets CC CCC FC F90C F95C GCC GXX CFLAGS CCFLAGS FFLAGS F90FLAGS F95FLAGS GCFLAGS & GXFLAGS
-c[heck] <command> verify command to be called after each run
-cc <dir> compiler driver directory or compiler list file; default = where ats is
-d print debug info
-distr[ibute] distribute and run each -i <opt> experiment
-distr_cmd <command> specify the command used to distribute experiments
-h output this help message
-i <options> options or a file with list of options (can be specified more than once); default = script:autotuning
-ias ignore application status; default = false
-keepbin do not delete rebuilt binaries; default = false
-metric <command> command that prints a numerical metric
-metric_higher_is_better use if a higher value of metric is preferred; default = lower is better
-no_auto_detect[={libs|xarch}] do not try to automatically link in shared libraries and/or detect -xarch
-o <dir> results directory; default = location of the first binary
-ob <build_flags> options added to all builds
-p <port> port to be used for communication with browser (valid with -server); default = 21000
-r[un] <command> run command
-rebuild_from_source rebuilds the PEC binaries using their source files
-reuse <dir> reuse the results from a previous run (can be specified more than once)
-s silent mode (no screen output)
-server start the ats server (accepts requests from a browser)
-stopon <state> stop on first [fail|pass|change|completion|runs <num>]
-tarfile <file> get source files from a tarfile
-timeout <seconds> {exit0|exit1|pass|fail} application killed after timeout and specified exit status assumed
-V display current version of ats
-w <dir> working directory
<app> PEC binary with options specific to it (e.g. a.out 'libx.so -G')
<app-list> a text file listing one PEC (with its specific options) per line
5.8 -i <options> OptionThe -i option is used to specify a set of compiler options, a script, or a file that contains sets of options to be used by the ats command.Examples of using the -i option:
% ats -i "-xO4" \
-i "-xO5" \
-i "-fast" \
a.out
% ats -i "-xO4 -xprofile=collect" \
-i "-script:autotuning" \
a.out
% ats -i "my_opts.txt" a.out
Compiler options that should be applied only to a certain driver
(cc, CC, f90, gcc, or g++)
can be given
in square brackets and prefixed with the driver name. Notating compiler options this way can
be useful for applications and binaries that use more than one language, for example:
% ats -i "-xO4 -xipo cc[-xdepend -xalias_level=strong] f90[-xia]" a.out % ats -i "-fast CC[-xlinkopt]" a.outUsing advanced options, you can do more. For example, each set of the above options can be used in one of following formats:
5.9 -ias OptionThe -ias option informs the ATS software to ignore the status returned by the application. Use this option when the application does not follow the standard UNIX(R) convention of returning a zero for success.The -ias option is commonly used with the -c verification option. For example: % ats -ias -c "verify_status.sh" a.out 5.10 -keepbin OptionBy default, the ATS software deletes the intermediate binaries it creates. Use the -keepbin option to request to keep the generated binary files.5.11 -metric <command> OptionThe -metric option specifies a command that prints out a performance metric number. The default sorting of the resulting metrics is done from lower values to higher values. (The default performance metric is the total run time.)Examples of using the -metric option: % ats -metric "cat timetaken" a.out % ats -metric "extract_benchmark_time" a.out 5.12 -metric_higher_is_better OptionUse this option if a higher value of metric is preferred (which is opposite of the default).5.13 -no_auto_detect[={libs|xarch}] OptionWhen specified, the system attempts to link shared objects that the binaries depend on automatically, so that the shared objects do not need to be specified manually. For example, a -lm option used to link the math library is automatically done, so there is no need to use the -ob (extra build) option.5.14 -o <dir> OptionUse the -o option to specify the results directory. Relative directory names are relative to the location of the first binary. The default value is "ATS", which is the "ATS" directory located in the same directory as the first binary.
5.15 -ob <build_flags> OptionUse the -ob extra build option to specify options that will always be used when recompiling the binary file. These specified options will be added after of all other options.5.16 -p <port> OptionUse the -p option to specify the port to be used for communication with an ATS server (valid with the -server option). The default network port is 21000.% ats -server -p 22345 Go to file:///opt/installed/compiler/html/ats.html in a browser Use the following when prompted in browser User Name: harry Password : 943314Then you would enter the indicated URL in a browser to use the ATS browser interface to specify your ATS command. 5.17 -r <command> OptionUse the -r run command option to specify a binary file, a binary file name with additional arguments, or a script that uses the binary.The default run command is just the binary file name, so, for example, the following two commands are the same: % ats a.out % ats -r a.out a.outHere is an example that has input and output files: % ats -r "a.out < input.txt > output.txt" a.outAnd here is an example that uses a run script: % ats -r "run.sh" a.out 5.18 -rebuild_from_source OptionUse the -rebuild_from_source option to rebuild the PEC binaries using their source files.5.19 -reuse <res_dir> OptionReuse the results from a previous run (can be specified more than once). For example:% ats -reuse ATS/run1 -reuse ATS/run4 a.out 5.20 -s OptionUse the -s option to stop the ATS software from printing any screen output ("silent mode").5.21 -server OptionThe -server option starts an ATS server which then waits for requests from the ATS browser interface.% ats -server Go to file:///usr/installed/compilers/ats.html in a browser Use the following when prompted in browser User Name: harry Password : 943314Then you would enter the indicated URL in a browser and start using the ATS browser interface. 5.22 -stopon <state> Option
Use the -stopon option to specify one of the following states:
5.23 -tarfile <file> OptionThe -tarfile option specifies a tarfile that contains all the user files required for an ATS run, i.e., the PEC files, run scripts, input files, verify scripts, etc...When the -tarfile is used with the -distribute option, separate copies of the contents of the tarfile will be created and used by ATS in parallel to save time. With the specified tarfile, ATS will create a directory (the "tardir"), expand ("untar") the tarfile into the tardir, and then set the working directory to the tardir. The default tardir is ./ATS/run/untar. 5.24 -timeout <seconds> {exit0|exit1|pass|fail} OptionThe -timeout option permits you to specify a time (in seconds) when to terminate an application. For example:% ats -timeout 30 a.outIf you have an application that does not terminate, or runs for too long as a result of an error, use the exit1 or fail option. The ATS software will terminate the application after the timeout has expired and consider it a failed run. % ats -timeout 30 exit1 a.out ...or... % ats -timeout 30 fail a.outIf you have an application that fails quickly, but continues to run longer in case of a successful run, use the exit0 or pass option. The ATS software will terminate the application after the timeout expires and consider it a successful run. The ATS software will then execute the verification command if you specified one. For example: % ats -timeout 30 exit0 a.out ...or... % ats -timeout 30 pass a.out 5.25 -V OptionThis option will display the current version of ats command:% ats -V a.out ats: Sun Automatic Tuning and Troubleshooting System 1.2 2007/01/09 5.26 -w <dir> OptionThe -w option specifies the working directory from which the build, run, and verification commands will be executed.5.27 {<app>|<app-list>}... OptionThis option can be either a list of PEC binary files with options specific to the files (for example, a.out 'libx.so -G'), or a text file listing one PEC file (with its specific options) per line.6 Examples6.1 Example: recompile with PECThis example first creates the PEC executable a.out. The example then recompiles the a.out PEC executable with the -xO4 option, and then it executes it:% cc -xO3 -Wd,-pec *.c % ats -i -xO4 a.outThe optimization level 3 or higher is required when creating a PEC executable. Note: When using gcc, use the -On and -xpec options. 6.2 Example: -build (without PEC) with makeThis example does not use PEC binary, but it uses the -build option to tell the ats command how to build the a.out file using a make command:% ats -i -xO4 -build 'make CFLAGS=$CFLAGS' -r a.out 6.3 Example: -build (without PEC) with gccThis example does not use PEC binary, but it uses the -build option to tell the ats command how to build the a.out file with a gmake command using the gcc compiler:% ats -i -O3 -build 'gmake CC=$GCC CFLAGS=$GCFLAGS' -r a.out 6.4 Example: -build (without PEC) with a scriptThis example does not use a PEC binary, but it uses the -build option to tell the ats command how to build the a.out file with a build script ("doit") using the FORTRAN 90 compiler:% more doit #!/bin/bash $F90C $F90FLAGS *.f % ats -i -xO4 -build doit -r a.out 6.5 Example: -build (without PEC) with a gcc scriptThis example does not use a PEC binary, but it uses the -build option to tell the ats command how to build the a.out file with a build script (build_app) using gcc compiler:% more build_app #!/bin/bash $GCC $GCFLAGS *.c % ats -i -O4 -build build_app -r a.out (last updated 03/20/2007) |
|
![]() |
By any use of this Website, you agree to be bound by these Policies and Terms of Use. |