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

Openmp loop variable compiled into unsigned int instead of int #2810

Open
NicolasHug opened this Issue Jan 22, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@NicolasHug
Copy link

NicolasHug commented Jan 22, 2019

Cython version 0.29.2

Here is a minimal reproducing example:

# cython: profile=True
# cython: cdivision=True
# cython: boundscheck=False
# cython: wraparound=False
# cython: language_level=3
from cython.parallel import prange


cdef float sum(float [:] a):
    cdef:
        int i
        unsigned int n_samples  # Changing this to int will make 'i' an int as expected
        float out = 0.

    with nogil:
        n_samples = a.shape[0]

        for i in prange(n_samples, schedule='static'):
            out += a[i]

    return out

Despite i being declared as int, it will be compiled as unsigned int because of n_samples. This causes an error in earlier versions of openmp for which the prange loop variable must be int.

@NicolasHug NicolasHug changed the title Opennp loop variable compiled into unsigned int instead of int Openmp loop variable compiled into unsigned int instead of int Jan 22, 2019

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