www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - CPU cores & threads & fibers

reply =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
Hi, just to x-check if I have the correct understanding:

fibers 	= look parallel, are sequential 	=> use 1 CPU core
threads 	= look parallel, are parallel 	=> use several CPU cores

Is that right?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
Jun 14 2015
next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Sunday, 14 June 2015 at 12:35:44 UTC, Robert M. Münch wrote:
 Hi, just to x-check if I have the correct understanding:

 fibers 	= look parallel, are sequential 	=> use 1 CPU core
 threads 	= look parallel, are parallel 	=> use several CPU cores

 Is that right?
Pretty much.
Jun 14 2015
prev sibling next sibling parent reply Etienne Cimon <etcimon gmail.com> writes:
On 2015-06-14 08:35, Robert M. Münch wrote:
 Hi, just to x-check if I have the correct understanding:

 fibers     = look parallel, are sequential     => use 1 CPU core
 threads     = look parallel, are parallel     => use several CPU cores

 Is that right?
Yes, however nothing really guarantees multi-threading = multi-core. The kernel reserves the right and will most likely do everything possible to keep your process core-local to use caching efficiently. There's a few ways around that though https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247%28v=vs.85%29.aspx http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html
Jun 14 2015
next sibling parent =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
On 2015-06-14 15:54:30 +0000, Etienne Cimon said:

 Yes, however nothing really guarantees multi-threading = multi-core. 
 The kernel reserves the right and will most likely do everything 
 possible to keep your process core-local to use caching efficiently.
Hi, sure. It's more about raising the chance to use the cores ;-) -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Jun 15 2015
prev sibling parent reply "Rob T" <alanb ucora.com> writes:
On Sunday, 14 June 2015 at 15:54:30 UTC, Etienne Cimon wrote:
 On 2015-06-14 08:35, Robert M. Münch wrote:
 Hi, just to x-check if I have the correct understanding:

 fibers     = look parallel, are sequential     => use 1 CPU 
 core
 threads     = look parallel, are parallel     => use several 
 CPU cores

 Is that right?
Yes, however nothing really guarantees multi-threading = multi-core. The kernel reserves the right and will most likely do everything possible to keep your process core-local to use caching efficiently. There's a few ways around that though https://msdn.microsoft.com/en-us/library/windows/desktop/ms686247%28v=vs.85%29.aspx http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html
FYI: https://issues.dlang.org/show_bug.cgi?id=11686 https://issues.dlang.org/show_bug.cgi?id=11687
Jun 16 2015
parent =?iso-8859-1?Q?Robert_M._M=FCnch?= <robert.muench saphirion.com> writes:
On 2015-06-16 18:36:09 +0000, Rob T said:

 FYI:
 
 https://issues.dlang.org/show_bug.cgi?id=11686
 https://issues.dlang.org/show_bug.cgi?id=11687
Thanks. We are currently experimenting to see how want to use the threads and what code to refactor. If we are going to bite the bullet I keep this in mind, maybe we can contribute something along. -- Robert M. Münch http://www.saphirion.com smarter | better | faster
Jun 18 2015
prev sibling parent "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Sunday, 14 June 2015 at 12:35:44 UTC, Robert M. Münch wrote:
 Hi, just to x-check if I have the correct understanding:

 fibers 	= look parallel, are sequential 	=> use 1 CPU core
 threads 	= look parallel, are parallel 	=> use several CPU cores

 Is that right?
Fibers/co-routines run on a thread and is conceptually the same as a functor/object-with-method that can suspend itself and hold onto the state until it is restarted. Like yield in Python generators. Fibers have their own stack, but that is an implementation detail. It is possible to do the same thing with object-method-calls if you have stackless code-generation (D does not support stackless runtimes, but you'll find this in other languages).
Jun 14 2015