I have been reading many of the posting on the GIL and impact on
threading etc.
I have found is confusing and would welcome some clarity on this.
I understand that embedding the interpreter in a C/C++ application
limits it to one CPU.
If the application is multi-threaded (system threads) in will not use
additional CPUs as the interpreter is tied to one CPU courtesy of the
GIL.
True or False?
I understand that forking or running multiple process instances of the
above application would make use of multiple CPUs. This is because each
process would have its own interpreter and GIL that is independent of
any other process.
True or False?
Can anyone clarify the above?
Thanks
A 3 1457 ad*******@eirco m.net wrote: I have been reading many of the posting on the GIL and impact on threading etc. I have found is confusing and would welcome some clarity on this.
I understand that embedding the interpreter in a C/C++ application limits it to one CPU. If the application is multi-threaded (system threads) in will not use additional CPUs as the interpreter is tied to one CPU courtesy of the GIL. True or False?
True. More than one CPU can be used if the GIL is released during calls
to external libraries, though. Well-written C extension modules and the
Python standard library do this where appropriate. Still only one thread
can execute pure Python code at a time.
I understand that forking or running multiple process instances of the above application would make use of multiple CPUs. This is because each process would have its own interpreter and GIL that is independent of any other process. True or False? [...]
True.
HTH,
-- Gerhard ad*******@eirco m.net wrote: I have been reading many of the posting on the GIL and impact on threading etc. I have found is confusing and would welcome some clarity on this.
I understand that embedding the interpreter in a C/C++ application limits it to one CPU. If the application is multi-threaded (system threads) in will not use additional CPUs as the interpreter is tied to one CPU courtesy of the GIL. True or False?
As I understand it, the interpreter needs the GIL held in order to run.
That means that you can only run Python code on one CPU at once, but
plain C/C++ code can be multithreaded.
I understand that forking or running multiple process instances of the above application would make use of multiple CPUs. This is because each process would have its own interpreter and GIL that is independent of any other process. True or False?
I suppose it would, yes. But this is just like running multiple copies
of Python, in that you won't be able to use PyObject *s from one
instance in another directly, so the multiple processes would have to
communicate by sockets or IPC or some other way.
[ad*******@eirco m.net] I understand that embedding the interpreter in a C/C++ application limits it to one CPU. If the application is multi-threaded (system threads) in will not use additional CPUs as the interpreter is tied to one CPU courtesy of the GIL. True or False?
True, only when a thread is inside pure python code. C-level extensions
and library modules, e.g. I/O modules, release the GIL, thus permitting
other threads in the same process to run simultaneously. But only one
thread can be running *inside the python interpreter* at a time.
I understand that forking or running multiple process instances of the above application would make use of multiple CPUs. This is because each process would have its own interpreter and GIL that is independent of any other process. True or False?
True. Every separate process will have its own python interpreter,
meaning it has its own GIL. Python code running in multiple processes
can execute truly simultaneously.
So you can run pure python code simultaneously on multiple cpus on a
multi-cpu box by using multiple independent processes. But if your
processes need to communicate, then you need to de/serialise
objects/parameters for transmission between those processes.
--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Canneloni |
last post by:
Xeon hyperthreaded CPUs show up as two CPUs in the cpuinfo file.
So a dual Xeon machine appears as a quad processor.
In Windows, it's the same thing.
A dual Xeon will have 4 CPU charts showing in the Task Manager cpu chart.
Ok, then question.
|
by: Viviana Vc |
last post by:
Hi all,
I have a computer with 2 CPUs where I have to build a big project. I am
using WinXP and MS Visual Stuio .NET (VC++ 7.1).
When I'm building the project one of the CPU is completely taken, and
the other one is idleing.
Is there any way to force the compilation of the project on both of the
CPUs?
|
by: AWHK |
last post by:
I got 4 virtual CPUs on my computer (xeon processor) and I got this .NET
application that runs a lengthy processor intensive task.
I have noticed when I start two instances of the application (each one
running its lengthy processor intensive task) they use one virtual CPU each.
How can I implement this functionallity within one application ie. running
two lengthy tasks within one application using two CPUs. Do I use
appdomains,...
|
by: Abhishek Srivastava |
last post by:
Hello All,
In IIS 6.0 We have a concept of worker processes and application pools.
As I understand it, we can have multiple worker process per appliction
pool. Each worker process is dedicated to a pool. If I assign only one
application to a applicaton pool and have multiple worker processes
assigned to that pool. Will my application be processed by many worker
processes?
|
by: RP |
last post by:
Hi all, where can I find some docs on tuning asp.net 1.1 for HT CPUs? We
just upgraded our server to a single HT CPU and it appears that the OS still
reports 2 CPUs?
TIA!
| |
by: Klaas Vantournhout |
last post by:
Hi,
I am currently using OpenMP (gcc 4.2.0) to do parallel computing on a
computer with a certain amount of cpu's.
I need the total number of cpu's as a variable in my code. So I was
wondering how I could do this. Does there exists a system call for that
or something or is the best way just to take this out of /proc/cpuinfo?
I also would like to use some preprocessor code in it to cancel out the
|
by: Carl J. Van Arsdall |
last post by:
Alright, based a on discussion on this mailing list, I've started to
wonder, why use threads vs processes. So, If I have a system that has a
large area of shared memory, which would be better? I've been leaning
towards threads, I'm going to say why.
Processes seem fairly expensive from my research so far. Each fork
copies the entire contents of memory into the new process. There's also
a more expensive context switch between...
|
by: rcamarda |
last post by:
I have been unsuccessful locating information about the maximum number
of CPU's SQL Server 2005 Enterprise supports.
However I did find info in a document about configuring a fail over
cluster solution. It said 4 CPUs, but it is unclear how that works out
with multi core processors.
Is it 4 sockets? So with a quad core quad socket we could go have a 16
core system?
BTW the chart shows the CPU count jumping to 64 CPU's under Server
2003...
|
by: jazon |
last post by:
Let me start by saying this for an Operating Systems class. No, I don't expect the work to be done for me.
The assignment is as follows:
To be honest, I feel like a fish out of water, like many of the others in the class. We haven't been exposed to any Unix and the professor hasn't, yet, said much more than the book, which is no help at this point.
From what I've figured out and what I've blindly seen on the net and hoped would...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |