Run the application
and collect samples in an experiment: The name of the experiment is printed in
the console when the application starts, say /tmp/test.0.er. Running collect by
itself would show the range of values for some of its parameters on the given
machine.
For a
serial application:
collect -p 1 -d
/tmp
For
profiling only the master of a MPI job, run it like this:
mpirun -f ./hosts -perhost 1
-np 4 ./prof.sh
where prof.sh is a script with
content:
#! /bin/csh
if ($PMI_RANK == 0) then
collect -p 1 -d /tmp $*
else
$*
endif
Analyze the
experiment:
analyzer
(In the GUI, load the experiment by browsing to it)
--------------------------------------------------------------------------------- To dump binary data from application, and then see it --------------------------------------------------------------------------------- void dump_data (float *a, size_t bytes, char *root, int count, int rank) { char filename[256]; sprintf (filename, "%s_%d_%d", root, rank, count); int fd = open (filename, O_RDWR|O_CREAT|O_TRUNC, 00644); if (fd == -1) { printf ("Could not open file %s for writing\n", filename); return; } ucsl_printf ("Dumping data into %s\n", filename); fflush (_UCSL_LOG); write (fd, a, bytes); close (fd); }
Call like this: --------------- int iter=0; func() { ... dump_data ((float *)array, n*sizeof(float), "/tmp/a", iter++); }
To visualize: --------------- Say a and b are the two dumps where n1=2001, then run the script: ./xdiff a b 2001 Content of xdiff is as follows: ------------------------------- $ cat xdiff #! /bin/csh -Xf
if ($#argv != 3) then echo "Usage: $0 file1 file2 n1" exit 0 endif diff $1 $2 cp -f $1 aaaaaa cat $2 >> aaaaaa cat diff.bin >> aaaaaa ximage perc=90 n1=$3 < aaaaaa exit 0 --------------------------------------------------------------------------------- diff is an executable produced from the following C code: #include #include #include #include #include #include #include #include Using python to do the same: --------------------------------------------------------------------------------- Using python: python2.7.9 is a script that loads python/2.7.9 and PrgEnv-gnu --------------------------------------------------------------------------------- % source python2.7.9 This modulefile provides python (2.7.9)
More information about python can be found at: http://docs.python.org/2/
% which ipython % ipython --pylab Python 2.7.9 (default, Jan 7 2016, 09:44:23) Type "copyright", "credits" or "license" for more information.
IPython 4.0.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. Using matplotlib backend: TkAgg
In [1]: run ./compute.py
In [2]: dd = data1-data2
In [4]: dd.min() Out[4]: -12.869473
--------------------------------------------------------------------------------- To check diff between two binary files --------------------------------------------------------------------------------- $ python --version Python 2.6.6 $ python Python 2.6.6 (r266:84292, Dec 7 2011, 20:48:22) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np >>> np.fromfile('/tmp/a',dtype=np.float32) array([ 1536.7668457 , 1534.49963379, 1528.29431152, ..., 3819.53222656, 3827.30517578, 3833.81079102], dtype=float32) >>> aa = np.fromfile('/tmp/a',dtype=np.float32) >>> aa.shape (40330178,) >>> bb = np.fromfile('/tmp/a',dtype=np.float32) >>> cc = aa - bb >>> cc.sum >>> cc.sum() 0.0 >>>
compute.py looks like this: ---------------------------------------------- import matplotlib.pylab as plt import numpy as np import time
fname1 = '/tmp/a' fname2 = '/tmp/b'
nt = 2001 # number of time pts nc = 190 # receiver samples (number of channel)
To disable automatic comment insertion in blank lines ------------------------------------------------------- :set formatoptions-=r formatoptions-=c formatoptions-=o or insert this in .vimrc ------------------------ au FileType * setlocal fo-=c fo-=r fo-=o
For 4 spaces instead of tab in vi, add this to ~.vimrc: ------------------------------------------------------- set expandtab set tabstop=4 set shiftwidth=4 au FileType * setlocal fo-=c fo-=r fo-=o " To read fortran code -------------------------------------------------------- let fortran_free_source=1 let fortran_do_enddo=1 "filetype plugin indent on syntax on
highlight! link DiffText Todo
To create a zero 11G file: -------------------------- dd if=/dev/zero of=/tmp/dummy_gina count=10 bs=1G --------------------------------------------------------------------------------- To avoid typing password for ssh login to a mach: --------------------------------------------------------------------------------- vi ~/.ssh/id_rsa.pub (copy the line here) ssh vi ~/.ssh/authorized_keys, add the public key from the machine you are logging in from. Make sure permissions on this file is 600 --------------------------------------------------------------------------------- Bash scripts --------------------------------------------------------------------------------- while true do echo "Hi" sleep 1 done (or) while sleep 30; do pmap -x ; done
for host in `cat ~/jlt`; do echo $host; done for i in `cat /tmp/nodes`; do ssh $i dmesg|grep OOM; done for i in `cat /tmp/nodes`; do ssh $i dmesg|grep segfaul; donefor i in `cat /tmp/nodes`; do ssh $i dmesg|grep segfaul; done
Script to run a list of commands in a file called "cmdlist":
#!/bin/bash
#------------------------------------------------------------------------ # Set the field separator to a newline IFS=" "
if [ "$#" -ne 1 ]; then echo "Usage: $0 " exit fi
# Loop through the file for line in `cat "$1"`; do a=(eval "$line" ">& /dev/null") "${a[@]}" let status=$? if [ $status != 0 ]; then echo "${a[1]} ================> FAILED" fi done