[Cython] 'Referenced before assignment' warning triggered due to OpenMP directives?
Yury V. Zaytsev
yury at shurup.com
Fri Nov 29 14:26:36 CET 2013
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
More information about the cython-devel
mailing list