Hi,

I'm trying to find out whether the number of threads has been actually
set to what I wanted it to be, but the compiler tells me that I'm trying
to reference a variable before assignment. This doesn't happen when I
simply release the GIL, but only within a parallel section.

Is it a problem with Cython or I'm missing something obvious?

Thanks!

$ cat ompt.pyx 
cimport openmp
from cython.parallel import parallel, prange

cdef Py_ssize_t x = 1

with nogil, parallel():
    x = openmp.omp_get_num_threads()

print("Number of OpenMP threads is '{}'!".format(x))

$ cython ompt.pyx 

Error compiling Cython file:
------------------------------------------------------------
...
cdef Py_ssize_t x = 1

with nogil, parallel():
    x = openmp.omp_get_num_threads()

print("Number of OpenMP threads is '{}'!".format(x))
                                                 ^
------------------------------------------------------------

ompt.pyx:9:50: local variable 'x' referenced before assignment


-- 
Sincerely yours,
Yury V. Zaytsev


_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel

Reply via email to