Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parallel.parallel(num_threads=None) leads to a generated code which cannot be compiled #1957

realead opened this issue Oct 28, 2017 · 1 comment


Copy link

realead commented Oct 28, 2017

In the online documentation the signature is given as cython.parallel.parallel(num_threads=None)

Please consider the following example (python3.6.2, cython 0.27.1, gcc 5.4):

from cython import parallel
def do_without_gil():
      unsigned int thread_id
      int i
    with nogil, parallel.parallel(num_threads=None): #that seems to be the problem
        for i in parallel.prange(300, schedule="static", chunksize=10):
            thread_id = parallel.threadid()
            with gil:
                print i,": ",thread_id
from distutils.core import setup
from Cython.Build import cythonize
from distutils.extension import Extension

      ext_modules=cythonize(Extension('parallel_error', ['parallel_error.pyx'], extra_compile_args=['-fopenmp'], extra_link_args=['-fopenmp'])))

and now:

python build_ext --inplace
Compiling parallel_error.pyx because it changed.
[1/1] Cythonizing parallel_error.pyx
running build_ext
building 'parallel_error' extension
gcc -pthread -B /home/XXX/compiler_compat -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/XXX/include/python3.6m -c parallel_error.c -o build/temp.linux-x86_64-3.6/parallel_error.o -fopenmp
parallel_error.c: In function ‘__pyx_pf_14parallel_error_do_without_gil’:
parallel_error.c:1025:307: error: expected integer expression before end of line
error: command 'gcc' failed with exit status 1

The problem seems to be the resulting #pragma:

#pragma omp parallel private(__pyx_t_1, __pyx_t_2, __pyx_t_3, __pyx_t_4) firstprivate(__pyx_t_5, __pyx_t_6, __pyx_t_7) private(__pyx_filename, __pyx_lineno, __pyx_clineno) shared(__pyx_parallel_why, __pyx_parallel_exc_type, __pyx_parallel_exc_value, __pyx_parallel_exc_tb) num_threads(Py_None)

num_threads(Py_None) seems to be the problem here.

That is probably not a big deal, as I don't have to use None as parameter and can just use parallel.parallel().

@scoder scoder closed this as completed in 47f8466 Nov 28, 2017
@scoder scoder added the defect label Nov 28, 2017
@scoder scoder added this to the 0.28 milestone Nov 28, 2017
Copy link

scoder commented Nov 28, 2017

Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants