Re: [f2py] threading with f2py
fred <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
charlie strauss a écrit : > As you may know python threading, unless their is a new module for it, > suffers from the curse of the global lock. > > to remind you, it means that python threading never is able take > advantage of having more than one CPU because every time it goes to > access any variable, it locks all variables, blocking all other threads > for accessing any variable. Thus it can only timeslice a single process > not have concurrent processes. i.e. threads truly stink in python in > terms of processor utilization, but still have their uses for responding > to events. > > Now I had read that the exception to this is that any calls to c-code or > fortran, such as happen during I/O release the global lock and thus are > not blocking while in the binary. > > I must have misunderstood that. Or else I'm doing something wrong. > > what I did was I created some fortran code and wrapped if with f2py. I > then call this code from inside multiple python threads. > > now what I expected to happen was to see my processor utilization jump > up from a mere 100% to 800% since I have 8 cpus and I have 8 threads. May be I misunderstood your problem, but I daily use multi-threading (on linux box which has up to 8 procs) within my python code running my fortran code. I simply use the flag !f2py threadsafe in my fortran code, and that's it. HTH Cheers, -- Fred