Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

example of dcgmrhs

alvesker86
Beginner
388 Views
Can anyone provide a simple example to solve the symmetric positive-definite system with multiple right hand side with dsgmrhs (Fortran 90)?

I tried to follow the instruction of link advisor. Below are the libraries that were linked.

libmkl_gf.a, libmkl_intel_thread.a, libmkl_core.a, libmkl_lapack.a, libmkl_solver.a, liomp5, lpthread



But when I try to compile my code I got the following:

/usr/local/intel/mkl/10.1.0.015/lib/32/libmkl_solver.a(dcgmrhs.o): In function `dcgmrhs_':
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xa3): undefined reference to `dcopy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xcc): undefined reference to `dscal_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x112): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x18b): undefined reference to `dnrm2_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x4b4): undefined reference to `dcopy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x5e3): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x624): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x6a2): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x6ea): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x748): undefined reference to `dnrm2_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x827): undefined reference to `dcopy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x8fb): undefined reference to `dscal_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0x923): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xa09): undefined reference to `dcopy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xa7c): undefined reference to `dcopy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xaa5): undefined reference to `dscal_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xaeb): undefined reference to `daxpy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xb0d): undefined reference to `dnrm2_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xbf3): undefined reference to `dcopy_'
../../../../solvers_is/kernel/default/dcgmrhs.f:(.text+0xcc7): undefined reference to `dcopy_'
0 Kudos
4 Replies
mecej4
Honored Contributor III
388 Views
An example would not be of much help (although you could try cg_mrhs.f in the .../mkl/examples/solverf/source directory --this is in the MKL version distributed with the 12.1 Fortran compiler), since your problem is with linking. Libraries are searched in the order listed, and your list of libraries shows libmkl_solver.a appearing after libmkl_core.a. This would cause the BLAS routines needed by the solver routines to go unresolved.

The Link Line Advisor gave me this:

$(MKLROOT)/lib/32/libmkl_solver.a -Wl,--start-group $(MKLROOT)/lib/32/libmkl_intel.a $(MKLROOT)/lib/32/libmkl_intel_thread.a $(MKLROOT)/lib/32/libmkl_core.a -Wl,--end-group -openmp -lpthread

However, the much simpler command

$ ifort -mkl cg_mrhs.f

may suffice, depending on the compiler version that you use.

0 Kudos
alvesker86
Beginner
388 Views
Thanks for the quick respond mecej4!

The problem was really in the order of libraries to link

0 Kudos
alvesker86
Beginner
388 Views
The other question is that according to the MKL userguide if ipar(10)=1 the routine dcgmrhs should perform user defined stopped test by settinh RCI_request=2

call dcgmrhs_init(N, xi1, 3, xi, 1, RCI_request, ipar, dpar, tmp)
xi1 = 0._DP
call dcgmrhs_check(N, xi1, 3, xi, RCI_request, ipar, dpar, tmp)
1 print*,ipar(10)
call dcgmrhs(N, xi1, 3, xi, RCI_request, ipar, dpar, tmp)
print*,ipar(10)
print*,RCI_request

when I run this it prints RCI_request=1 first (after that as written in userguide I multiply a matrix by tmp(:,1) and copy to tmp(:,2)), the RCI_request=0 instead of 2. But how it is possible as ipar(10)=1?

I haven't this problem when use dcg, it sets RCI_request=3 normally
0 Kudos
alvesker86
Beginner
388 Views
problem solved after initialization of ipar and dpar arrays
0 Kudos
Reply