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

Want to link MKL to existing code

Saumik_D_
Beginner
473 Views

Hi, 

I am replacing certain operations specifically vector dot product,matrix vector multiplication and solve AX=b in existing code by calls to lapack subroutines. Do I need to link the MKL in the makefile explicitly? 

The following is content of my makefile

!-----------------------------------------------------------

.SUFFIXES: .o .f90
.f90.o:
    $(F90) -c $(F90FLAGS) $<
F90 = ifort -warn -WB -C
LD  = $(F90)
LIBS = -ldl
PROFILE = -fast
OPTFLAGS = -g
CFLAGS = $(OPTFLAGS) $(PROFILE)
F90FLAGS = $(CFLAGS)
LDFLAGS =  

PROGRAM = fadd2d
F90SRCS = global.f90 main.f90 nrtype.f90 nrutil.f90 remesh_module.f90 \
          prep.f90 elem_charles.f90 \
          assemb_charles.f90 formakf_charles.f90 gauss.f90 shape.f90 solver.f90 \
          post_remesh.f90 proc.f90 volume_solver.f90 pressure_solver.f90 \
          rearge.f90 sif.f90 sifaniso.f90 root.f90 kernel1_c.f90 kernel2.f90 \
          tstress.f90 tstress1.f90 tstress2.f90 tstress2a.f90 tstress3.f90 \
          assemb_tstress.f90 rigidinner4.f90

SRCS = $(F90SRCS) 

OBJS = $(F90SRCS:.f90=.o)

all: $(PROGRAM)

$(PROGRAM): $(OBJS)
    $(LD) -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

elem_charles.o: elem_charles.f90 ekc_8.f90 ekd_8_temp.f90 ek_b2.f90 ek_at2.f90 \
        eatts2.f90 eattip.f90 eat3.f90 ebts2.f90 ebtip.f90 eb3.f90 \
        eat_rigid.f90 eb_rigid.f90
    $(F90) -c $(F90FLAGS) elem_charles.f90

#Dec10_09: add prep.f90 to following line to recompile prep.f90
prep.o: prep.f90 setint.f90
    $(F90) -c $(F90FLAGS) prep.f90
clean:
    rm -f $(OBJS) $(PROGRAM)
    rm *.mod
tidy:
    rm -f *.BAK *.bak *.CKP *~

undepend:
    rm -f $(OBJS:%.o=.%.d) 

spotless: tidy clean undepend

!-----------------------------------------------------------

Thanks

Saumik Dana.

0 Kudos
1 Reply
Zhang_Z_Intel
Employee
473 Views

Yes. You do need to link MKL explicitly in your makefile. There is an online tool to help you figure out how to do it:

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

The tool generates a link line that is appropriate for your situation, based on the input you give it. You then copy/paste the link line into your makefile.

 

 

0 Kudos
Reply