Home:ALL Converter>Using Cython with intel compilers and OpenMP

Using Cython with intel compilers and OpenMP

Ask Time:2012-05-25T06:33:44         Author:user1154648

Json Formatter

I am now using Cython compiler to wrap a C-language program which needs OpenMP with setup.py script as follows (the Cython script "test.pyx" imports "test.h" module).

from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

ext_modules = [
    Extension("wrap_test",
          ["test.pyx"],
          libraries=["gomp"],
          extra_compile_args=["-fopenmp"])]

setup(
    name="wrap_test",
    cmdclass={"build_ext": build_ext},
    ext_modules=ext_modules)

This is for gcc. Then, what is the Intel compiler (icc) counterpart? Does anyone know the answer?


If I just set the environmental variable CC to icc and type "python setup.py build_ext --inplace", then several error messages appear and gcc is automatically invoked in stead of icc (to link object files). This results in a shared object "wrap_test.so", which cannot be imported to other Python scripts due to some mistakes. So I guess I have to tell Cython a proper set of a compiler, libraries and compile options to use in the setup.py script.

Author:user1154648,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/10746228/using-cython-with-intel-compilers-and-openmp
yy