473,395 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Python threads and Numeric/SciPy exploit Dual Core ?

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
5 1889
"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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Travis Oliphant | last post by:
Numarray is making great progress and is quite usable for many purposes. An idea that was championed by some is that the Numeric code base would stay static and be replaced entirely by Numarray. ...
1
by: jelle | last post by:
#No rant intended I'm not at all confused wether I should learn an one of the advanced array modules, I'm slightly confused over which I should pick up. I'm impressed with the efforts of SciPy...
2
by: robert | last post by:
There is a strange freeze/crash only on dual core machines: I have a python app (Python 2.3.5 /Pythonwin build 203 / Windows) running with no stability problems on normal machines (Or a crash is...
21
by: S.Mohideen | last post by:
Hi All, I was thinking about the feasbility of adjusting Python as a compiled language. Being said that I feel these are the following advantages of doing so -- 1) Using the powerful easy-to -use...
6
by: nikhilketkar | last post by:
What are the implications of the Global Interpreter Lock in Python ? Does this mean that Python threads cannot exploit a dual core processor and the only advantage of using threads is in that...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.