user1154648
user1154648

Reputation: 21

Using Cython with intel compilers and OpenMP

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.

Upvotes: 2

Views: 1594

Answers (1)

Fred Foo
Fred Foo

Reputation: 363517

The Intel C command line option to compile with OpenMP support is -openmp.

Upvotes: 2

Related Questions