By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,907 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,907 IT Pros & Developers. It's quick & easy.

Python threads and Numeric/SciPy exploit Dual Core ?

P: n/a
Simple Python code obviously cannot use the dual core by Python threads.
Yet, a program drawing CPU mainly for matrix computations - preferably
with Numeric/SciPy - will this profit from a dual core when using 2 (or
more) Python threads?

robert
Oct 2 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"robert" wrote:
Simple Python code obviously cannot use the dual core by Python threads.
Yet, a program drawing CPU mainly for matrix computations - preferably
with Numeric/SciPy - will this profit from a dual core when using 2 (or
more) Python threads?
as long as the binding releases the GIL, sure.

</F>

Oct 2 '06 #2

P: n/a
I've been trying to make my music app use dual core,
and would very much like some more detailed information on this.

Excuse my lack of knowledge,
but how do I explicitly release the GIL ?

I haven't learned this, but have found through experimentation that I
can release a thread by using time.sleep(0) inside a thread's "run
while true" loop. This seems to create an interrupt, and give other
threads a chance to do their thing.
If this is terribly wrong (it works, but I dont' know how stable it
is), please do point me in the direction of a proper way to implement
it.
As stated in an earlier post, my threads do not work on shared data,
so I have not implemented any sort of lock or mutex.

best
Oeyvind

On 10/2/06, Fredrik Lundh <fr*****@pythonware.comwrote:
"robert" wrote:
Simple Python code obviously cannot use the dual core by Python threads.
Yet, a program drawing CPU mainly for matrix computations - preferably
with Numeric/SciPy - will this profit from a dual core when using 2 (or
more) Python threads?

as long as the binding releases the GIL, sure.

</F>

--
http://mail.python.org/mailman/listinfo/python-list
Oct 2 '06 #3

P: n/a
Oeyvind Brandtsegg wrote:
I've been trying to make my music app use dual core,
and would very much like some more detailed information on this.

Excuse my lack of knowledge,
but how do I explicitly release the GIL ?
http://docs.python.org/api/threads.html
I haven't learned this, but have found through experimentation that I
can release a thread by using time.sleep(0) inside a thread's "run
while true" loop. This seems to create an interrupt, and give other
threads a chance to do their thing.
that (momentarily) blocks the current thread, and forces a rescheduling.

</F>

Oct 2 '06 #4

P: n/a
Fredrik Lundh wrote:
"robert" wrote:

>>Simple Python code obviously cannot use the dual core by Python threads.
Yet, a program drawing CPU mainly for matrix computations - preferably
with Numeric/SciPy - will this profit from a dual core when using 2 (or
more) Python threads?


as long as the binding releases the GIL, sure.
Thus - does Numeric/SciPy release it?
The same q about the orange (data mining) lib.

Robert
Oct 2 '06 #5

P: n/a
robert wrote:
Fredrik Lundh wrote:
>"robert" wrote:
>>Simple Python code obviously cannot use the dual core by Python threads.
Yet, a program drawing CPU mainly for matrix computations - preferably
with Numeric/SciPy - will this profit from a dual core when using 2 (or
more) Python threads?

as long as the binding releases the GIL, sure.

Thus - does Numeric/SciPy release it?
Depends. Some of the linear algebra functions in scipy do. Most operations do
not. People are looking at adding more.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Oct 2 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.