I am trying to parallelize a for loop in cython using prange. My setup file is pretty basic:
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize('my_cython_code.pyx'))
So I am using -fopenmp as a cython compiler flag, which I accomplish by having the first two lines of the my_cython_code module be:
# distutils: extra_compile_args = -fopenmp
# distutils: extra_link_args = -fopenmp
However, my machine runs on OSX, and the mac gcc compiler is essentially Clang, which does not support OpenMP. This means that when I try to build my parallelized cython extension module, I get a fatal compiler error:
ld: library not found for -lgomp
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
Is there a way around this problem? How can I use a different compiler that will accept OpenMP when building my extension? Are there other approaches that will let me parallelize cython for loops with standard mac architecture?