如何将MKL与MPI链接? [英] How to link MKL with MPI?
问题描述
我想用MKL编译此C代码,但是当我使用命令mpicc -mkl mkl_thread.c
运行它时,它给我一个关于无法识别的命令行选项-mkl
的错误.当我以mpicc mkl_thread.c -o mkl_thread
身份运行它时,它给出了另一个错误,说对'MKL_Set_Num_Threads'的未定义引用".我不知道如何使用它或与MKL链接.
I want to compile this C code with MKL, but when I run it using the command mpicc -mkl mkl_thread.c
, it gives me an error about an unrecognized command line option -mkl
. When I run it as mpicc mkl_thread.c -o mkl_thread
, it gives a different error, saying "undefined reference to `MKL_Set_Num_Threads'". I don't know how I can run it with or link with MKL.
我的代码是:
define NUM_PROCS 5
int main (int argc, char ** argv)
{
int threads_per_proc[NUM_PROCS] = { 1,2 ,3, 4,5 };
int rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
// ...
// Signal an error if rank >= 5
// ...
mkl_set_num_threads(threads_per_proc[rank]);
MPI_Finalize();
}
推荐答案
-mkl
是英特尔特定的选项,mpicc
无法识别.
-mkl
is an Intel specific option which can not be recognized by mpicc
.
对于非Intel编译器,您可以显式指定链接选项.
For non-Intel compiler, you could specify the link options explicitly.
$ mpicc mkl_thread.c -o mkl_thread \
-I$(MKLROOT)/include -L$(MKLROOT)/lib/intel64 \
-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core \
-liomp5 -lpthread -lm
有关其他链接选项,请参考英特尔®数学内核库链接行顾问.
Please refer to Intel® Math Kernel Library Link Line Advisor for other link options.
这篇关于如何将MKL与MPI链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!