Nogil with jitclass?

Dear all,
I am trying to use joblib parallel (with threading backend) to parallelize a set of calls to a jitclass. That doesn’t seem to work, probably because jitclass doesn’t release the GIL. Is there a way to pass something like nogil=True to jitclass, or is that generally not supported?

Thanks!

Hi @wielandbrendel,

From memory, @njit flags in general cannot be passed to jitclass, construction is “automatic” and uses njit directly.


Hope that answers your question?

Thanks so much! So the short answer is: it is currently not possible to use jitclass without GIL, right?

Yes, this is the case.

I’m sure I’m misunderstanding, but I had thought that a nogil njit function calling another not-declared-nogil njit function would not reacquire the gil- is that correct? Sample pseudocode:

@njit(nogil=False)
def has_gil():
    # is gil owned here?
    pass

@njit(nogil=True)
def no_gil():
    has_gil()

no_gil()