0
votes

I would like to implement mkl_lapack's tridiagonal eigenvalue algorithm dstevr in one of my header files

#include "mkl.h"

void trideigs(int N, int LDZ, double *Z, double *W, double *D, double *E){

double VL=0.0, VU=1.0, ABSTOL=0.0;
int IL=1, IU=N, M=N, LWORK=20*N, LIWORK=10*N, INFO;

int *ISUPPZ=(int*)malloc(2*M*sizeof(int));
int *IWORK=(int*)malloc(LIWORK*sizeof(int));
W=(double*)malloc(N*sizeof(double));
Z=(double*)malloc(LDZ*M*sizeof(double));
double *WORK=(double*)malloc(LWORK*sizeof(double));

dstevr("V","A",&N,D,E,&VL,&VU,&IL,&IU,&ABSTOL,&M,W,Z,&LDZ,ISUPPZ,WORK,&LWORK,IWORK,&LIWORK,&INFO);
}

I managed to change Nsight's default compiler to icc and set the -mkl option directly with -Xcompiler.

At compile time NVCC Compiler runs successfully, but NVCC Linker fails with the following error message:

Building target: cuMatlab Invoking: NVCC Linker /usr/local/cuda-8.0/bin/nvcc --cudart static -L/usr/local/cuda/lib64 -ccbin /opt/intel/bin/icpc --relocatable-device-code=false -gencode arch=compute_52,code=compute_52 -gencode arch=compute_52,code=sm_52 -link -o "cuMatlab" ./src/cuMatlab.o -lcublas -lcusolver -lcufft -lgomp ./src/cuMatlab.o: In function trideigs(int, int, double*, double*, double*, double*)': /tmp/tmpxft_000045f8_00000000-13_cuMatlab.ii:85694: undefined reference todstevr' makefile:59: recipe for target 'cuMatlab' failed make: *** [cuMatlab] Error 1

Do I need to add a library path? Any ideas?

1

1 Answers

1
votes

You can mix nvcc, icpc and MKL together, but at least you have to link MKL explicitly with the options both recognized by icpc and nvcc, such as -L and -l. '-mkl' is a short-cut for those options only recognized by icpc. You could refer to Intel® Math Kernel Library Link Line Advisor for the option details.

If you want more specific answers, you could create an example to demo how you plan to compile and link your code.

Update

According to your update, you have found the place of -Xcopmiler for NVCC Compiler. But for NVCC Linker, you only specified -ccbin but not -Xlinker. You will be able to find -Xlinker at a similar place in NVCC Linker page. It is the place you should put -mkl to. It will pass suitable options to the linker icpc.