Re: [f2py] threading with f2py
charlie strauss <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
On Jul 15, 2009, at 12:19 AM, fred wrote: > charlie strauss a écrit : >> > 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. could you offer an example. fotran itself is not supposed to be re-entrant. so it's not possible to thread it unless the specific compiler has some tricks to make it re-entrant. obviously the existance of this command belies this. so i'd like to see an example. finally, there are two issues in python threading. One reason to thread is because you want multiple threads for different event loop responses. But another reason, especially for scientific programming, is simply to do multi-processing with shared memory (i.e. rather than forking). python as far as I know cannot do the latter. in python you never utilize more than 1 CPU ever because of the global lock (which if you are a wonderful program supposedly you can turn off, but it's very dangerous) however supposedly the global lock does not apply inside binary code that you call from python. hence you can in theory multi-process if you are spending all your time in the binary and not in the python wrapper. What I'm after is the latter. But so far I have not been able to get the fortran to multi-process (without forking). the threads just block each other and only one thread runs at one time giving you single cpu perfromance. your suggestion is intriguing but I don;t know about this command. > > > HTH > > Cheers, > > > > -- > Fred > > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users Charlie Strauss Bioscience Division [email protected] 505 665 4838 Quidquid latine dictum sit, altum sonatur. _______________________________________________ f2py-users mailing list f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] http://cens.ioc.ee/mailman/listinfo/f2py-users