-
Notifications
You must be signed in to change notification settings - Fork 0
How to run Valgrind on the C libraries
The utilities for running Valgrind are provided in devtools/valgrind
directory. The following commands are specific to Minion2.
module load gcc/7.2.0
module load intel/mkl/64/2018/1.163
module load valgrind/3.13.0
The packages liblapack-dev
, liblapacke-dev
and libblas-dev
were also installed using apt
.
Let us first check if Valgrind works on this computer, and things are set up properly. A trial file addition.c
has been written for this purpose. It uses the cblas_dasum
function, which return the sum of the absolute values of the input vector array elements. See the reference in MKL and Netlib.
- Compile using BLAS
gcc addition.c -lm -lblas -o addition
valgrind --tool=memcheck --leak-check=full ./addition
- Compile using MKL
gcc -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -std=c99 -DMKL_ILP64 -m64 -I${MKLROOT}/include addition.c -o addition
valgrind --tool=memcheck --leak-check=full ./addition
Once everything is set up, running Valgrind on the libraries are very easy.
- The file
cjpa.c
uses the librarylinear_regression.h
. Copy it from../../lib
directory and compile.
cp ../../lib/linear_regression.c linear_regression.h
gcc cjpa.c -lm -g -o cjpa
For quick run, use
./valgrind_cjpa
- The file
crevreg.c
uses the librariessvd.h
,utils.h
andreverse_regression.h
. For quick run, use:
./valgrind_crevreg {option} ## option can be MKL or BLAS
The above script copies the prerequisites in the present directory:
cp ../../lib/reverse_regression.c reverse_regression.h
cp ../../lib/svd.h svd.h
cp ../../lib/utils.h utils.h
cp -r ../../lib/dcdflib ./
The file can be compiled either using MKL:
gcc -L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl -std=c99 -DMKL_ILP64 -m64 -I${MKLROOT}/include crevreg.c -o crevreg
or LAPACKE:
gcc crevreg.c -lm -lblas -llapacke -o crevreg
Finally run valgrind:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ./crevreg
and deletes the header files
rm -rf reverse_regression.h svd.h utils.h dcdflib crevreg