Combining Cython with MKL

2019-05-30 03:54发布

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?

标签: python c cython
0条回答
登录 后发表回答