Combining Cython with MKL

微笑、不失礼 提交于 2020-01-23 18:13:06

问题


I want to use some functions of the MKL-library in my cython-code. Thus I wrote the function

#include <stdlib.h>
#include <complex.h>
#include <stdbool.h>
#define MKL__Complex16 double _Complex
#include <mkl.h>
#include <mkl_cblas.h>
#include <mkl_blas.h>
#include <mkl_lapack.h>
#include <mkl_lapacke.h>
inline void scalarMult(const double _Complex *a, const int a_len, double _Complex *b, const int b_len, const double z)
{
    if(a_len != b_len)
        return;
    if(z == 1)
        memcpy(b, a, a_len);
    else
        cblas_daxpy(a_len, (z-1), (double*)a, 1, (double*)b, 1);
} 

(and yes, I am loosing precision, but that is not the point).
Now I looked the necessary commands up here, and added them to the setup.py-file in the extra-compile-args-part in the configuration.

 -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_sequential.a -Wl,--end-group -lpthread -lm

Now the compiler (gcc) first complains about the unknown commands --start-group and --end-group, and afterwards I get the error during execution:

./cython_wrapper.so: undefined symbol: cblas_daxpy

How can I fix that problem?

来源:https://stackoverflow.com/questions/33596817/combining-cython-with-mkl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!