473,747 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1912
"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*****@python ware.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
1414
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. However, Numeric is currently used in a large installed base. In particular SciPy uses Numeric as its core array. While no doubt numarray arrays will be supported in the future, the speed of the less bulky Numeric arrays and the typical case...
1
1573
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 and Scientific, but since I'm fairly new to programming & OO, choosing Numarray over Numeric hasnt been that satisfactory at all, which is not a problem of the quality of Numarray, but the fact that a lot of modules still heavily realy on Numeric....
2
2326
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 so rare, that absolutely nobody obverses it, though the overall majority of users uses single core machines). Threads, network & pythonwin/win32ui all in use. Yet, from 3 users, _all_ using a Dual Processor System (XEON, amd x2 3800+)...
21
1258
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 feature of Python programming language constructs. 2) Making the program to run at par with the compiled version of C/C++ program- this is the main benefit which can be derived out of this. 3) Highly re-use existing Python code for High...
6
2940
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 computation and IO-bound operations can continue in parallel ? Thanks, Nikhil
0
8818
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9522
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9353
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9222
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8231
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6790
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6067
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4860
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2771
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.