Chris Colbert wrote:
> alright i made the change and here is the code:
> 
> cdef double count(int n) nogil:
>     cdef int i, j, k
>     cdef double out
>     for i from 0 <= i < n:
>         for j from 0 <= j < n:
>             out = 0
>             for k from 0 <= k < n:
>                 out += k
>    
>     return out
>                
> 
> def myinterface():
>     cdef int n = 10000000
>     cdef double out
>     out = count(n)
>     return out
<SNIP>
> i presume this is because myinterface() doesn't release the gil, and 
> thus waits for count() to return.
> 
> How do I work this so that I can run a c-function outside the gil and 
> thus make use of the multi-cores on my machine?

When you do

cdef double count(int n) nogil

it merely declared that the function /can/ be run without the GIL, but 
it doesn't explicitly release it. Do this:

def myinterface():
     ...
     with nogil:
         out = count(n)
     return out

--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to