Logo Cineca Logo SCAI

You are here

BLAS exercise

Write a program that uses BLAS routines; at least one routine for each BLAS level. For example:
Level 1: DCOPY, DSCAL, DNRM2, DDOT
Level 2: DGEMV, DGER
Level 3: DGEMM
Print all matrices and vectors generated.


To compile (on Galileo):

#GNU Compilers:
module load gnu/4.9.2              
module load blas/3.5.0--gnu--4.9.2

#FORTRAN:   
LALIB="-L${LAPACK_LIB} -llapack -L${BLAS_LIB} -lblas"
gfortran -o program.x program.f90 ${LALIB}

#C: remember to include the header files "cblas.h" and/or “lapacke.h”
LALIB="-I${BLAS_INC} -I${LAPACK_INC} \
       -L${LAPACK_LIB} -llapacke -llapack \
       -L${BLAS_LIB} -lcblas -lblas -lgfortran -lm"
gcc -o program.x program.f90 ${LALIB}

 

#Intel Compilers:
module load intel/pe-xe-2016--binary module load mkl/11.3.0--binary LALIB="-I${MKL_INC} -L${MKL_LIB} -lmkl_intel_lp64 \ -lmkl_sequential -lmkl_core -lpthread -lm -ldl" #C: remember to include the header file "mkl.h" icc -o program.x program.c ${LALIB} icc -mkl -o program.x program.c -lpthread -lm -ldl #FORTRAN: ifort -o program.x program.f90 ${LALIB} ifort -mkl -o program.x program.f90 -lpthread -lm -ldl

http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor