Skip to content

sblinnikov/matrices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This directory has a few examples demonstrating the work with matrices.

MKL

Define directory where mkl libraries are installed, e.g.
I have MKL in HOMEMKL=/opt/intel/mkl2020
and then
 source $HOMEMKL/bin/compilervars.csh intel64 -platform linux

If you have full intel parallel studio, this step is not needed after

source /opt/intel/bin/compilervars.csh intel64

check:

 echo ${MKLROOT}

cd src:

dgemm_example.f  has a commented example to
compute real matrix C=alpha*A*B+beta*C using Intel® MKL function dgemm

define F95ROOT as MKLROOT, e.g.
 export F95ROOT=$MKLROOT
or
 setenv F95ROOT $MKLROOT

gfortran -fdefault-integer-8 -I${F95ROOT}/include/intel64/ilp64 -m64 -I${MKLROOT}/include dgemm_example.f -o tdgemm.exe ${F95ROOT}/lib/intel64/libmkl_lapack95_ilp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_gf_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl

run:

./tdgemm.exe


To find code examples that use Intel® MKL PARDISO routines to solve systems of linear equations,
unzip the archive file in the examples folder of the Intel® MKL installation directory.
Code examples will be in the examples/solverc/source folder.

E.g. I have MKL in HOMEMKL=/opt/intel/mkl2020

ls $HOMEMKL/compilers_and_libraries_2020.0.166/linux/mkl/examples

gives

 examples_cluster_c.tgz  examples_core_c.tgz  examples_f95.tgz
 examples_cluster_f.tgz  examples_core_f.tgz

core_f.txt  has the list of codes from examples_core_f.tgz
f95.txt has the list of codes from examples_f95.tgz


pardiso_unsym_f.f is an example program to show the use of the "PARDISO" routine
for nonsymmetric linear systems, define F95ROOT as described above

cd src:

   gfortran -fdefault-integer-8 -I${F95ROOT}/include/intel64/ilp64 -m64 -I${MKLROOT}/include pardiso_unsym_f.f -o tpardiso.exe ${F95ROOT}/lib/intel64/libmkl_lapack95_ilp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_gf_ilp64.a ${MKLROOT}/lib/intel64/libmkl_sequential.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -lpthread -lm -ldl

or try this:

   gfortran -m64  -w -fno-second-underscore -fcray-pointer -x f77-cpp-input -I${MKLROOT}/include \
   ./pardiso_unsym_f.f -x none -Wl,--start-group  "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" \
   "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" \
   -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardiso.exe


run
   ./tpardiso.exe


Another example for 3-diagonal N=10 matrix:

gfortran -m64 -w -fno-second-underscore -fcray-pointer -x f77-cpp-input -I${MKLROOT}/include ./pardisoTridiag1.f -x none -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTridiag1.exe
or
ifort -I${MKLROOT}/include ./pardisoTridiag1.f -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTridiag1.exe

For arbitrary N
reading form files like SBlcsrTridiag{N}.dat, rename it to SBlcsrTridiagN.dat

gfortran -m64 -w -fno-second-underscore -fcray-pointer -x f77-cpp-input -I${MKLROOT}/include ./pardisoTridiagN.f -x none -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTridiagN.exe
or
ifort -I${MKLROOT}/include ./pardisoTridiagN.f -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTridiagN.exe

The code
 pardisoTridiagN.f
fails with segmentation fault due to allocation statements

pardisoTridiag3.f with fixed array dimensions for N=1000 works, but produces bad results like MUMPS and our m28y12.f:

gfortran -m64 -w -fno-second-underscore -fcray-pointer -x f77-cpp-input -I${MKLROOT}/include ./pardisoTridiag3.f -x none -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTridiag3.exe
or
ifort -I${MKLROOT}/include ./pardisoTridiag3.f -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTridiag3.exe

much better for diagonal-dominated case:

gfortran -m64 -w -fno-second-underscore -fcray-pointer -x f77-cpp-input -I${MKLROOT}/include ./pardisoTridiag3C1000.f -x none -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTrid3C1000.exe
or
ifort -I${MKLROOT}/include ./pardisoTridiag3C1000.f -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o tpardisoTrid3C1000.exe


Next is only in mkl2020 (mkl for 2013 does not work):

mkl2020 # aliased to e.g.
source /opt/intel/mkl2020/compilers_and_libraries_2020.3.279/linux/mkl/bin/mklvars.csh intel64

ifort -I${MKLROOT}/include mkl_spblas.f90 fgmres_no_precon_f.f90 -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o gmres_no_precon_f.exe

ifort -I${MKLROOT}/include mkl_spblas.f90 fgmresTridiag1.f90 -Wl,--start-group "${MKLROOT}/lib/intel64/libmkl_gf_lp64.a" "${MKLROOT}/lib/intel64/libmkl_gnu_thread.a" "${MKLROOT}/lib/intel64/libmkl_core.a" -Wl,--end-group -L"${MKLROOT}/../compiler/lib/intel64" -liomp5 -lpthread -lm -ldl -o fgmresTridiag1.exe

-- the same for Tridiag3, but nor convergence with slight perturbations of expected solution

About

tests for various matrix solvers and linear algebra

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published