www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Queue thread

reply bioinfornatics <bioinfornatics fedoraproject.rog> writes:
Dear,
I would like to know if they are a way to run run a queue thread an run
(nb core * 2 + 1) =3D nb thread in same time

something like:
size_t nb_core =3D 9;
Queue q =3D new Queue( 9, process1, process2, process3 );
q.run();

kind regards
Nov 20 2011
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Sunday, November 20, 2011 11:59:14 bioinfornatics wrote:
 Dear,
 I would like to know if they are a way to run run a queue thread an run
 (nb core * 2 + 1) = nb thread in same time
 
 something like:
 size_t nb_core = 9;
 Queue q = new Queue( 9, process1, process2, process3 );
 q.run();
Look at std.parallelism. I don't know if it'll do quite what you want, but it's the closest that you'll find in Phobos. - Jonathan M Davis
Nov 20 2011
parent reply bioinfornatics <bioinfornatics fedoraproject.rog> writes:
Le dimanche 20 novembre 2011 =C3=A0 03:09 -0800, Jonathan M Davis a =C3=A9c=
rit :
 On Sunday, November 20, 2011 11:59:14 bioinfornatics wrote:
 Dear,
 I would like to know if they are a way to run run a queue thread an run
 (nb core * 2 + 1) =3D nb thread in same time
=20
 something like:
 size_t nb_core =3D 9;
 Queue q =3D new Queue( 9, process1, process2, process3 );
 q.run();
=20 Look at std.parallelism. I don't know if it'll do quite what you want, bu=
t=20
 it's the closest that you'll find in Phobos.
=20
 - Jonathan M Davis
i have tred to use TaskPool but i fail Error: /parallelism.d(434): Error: no property 'opCall' for type 'fastcgi.application.Page' the problem raise here: https://github.com/bioinfornatics/DFastCGI/blob/master/src/fastcgi/applicat= ion.d#L74 (i think) Any help are welcome thanks
Nov 20 2011
next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Try
auto t = task(&page.run);

You can't pass a class method as a compile-time argument unless it's a
static method.
Nov 20 2011
parent bioinfornatics <bioinfornatics fedoraproject.rog> writes:
Le lundi 21 novembre 2011 =C3=A0 02:09 +0100, Andrej Mitrovic a =C3=A9crit =
:
 Try
 auto t =3D task(&page.run);
=20
 You can't pass a class method as a compile-time argument unless it's a
 static method.
oh ok thanks :-)
Nov 20 2011
prev sibling parent reply Kai Meyer <kai unixlords.com> writes:
On 11/20/2011 02:36 PM, bioinfornatics wrote:
 Le dimanche 20 novembre 2011 à 03:09 -0800, Jonathan M Davis a écrit :
 On Sunday, November 20, 2011 11:59:14 bioinfornatics wrote:
 Dear,
 I would like to know if they are a way to run run a queue thread an run
 (nb core * 2 + 1) = nb thread in same time

 something like:
 size_t nb_core = 9;
 Queue q = new Queue( 9, process1, process2, process3 );
 q.run();
Look at std.parallelism. I don't know if it'll do quite what you want, but it's the closest that you'll find in Phobos. - Jonathan M Davis
i have tred to use TaskPool but i fail Error: /parallelism.d(434): Error: no property 'opCall' for type 'fastcgi.application.Page' the problem raise here: https://github.com/bioinfornatics/DFastCGI/blob/master/src/fastc i/application.d#L74 (i think) Any help are welcome thanks
I looked at your code, and saw this: https://github.com/bioinfornatics/DFastCGI/blob/master/src/fastcgi/application.d#L18 _taskPool = new TaskPool( totalCPUs * threadsPerCPU + 1); On my machine, that would come out to 1: [kai.meyer kai-rhel6 D]$ cat cpu.d import std.stdio; import std.parallelism : totalCPUs, TaskPool, task; import std.cpuid : threadsPerCPU; void main() { writefln("totalCPUs %s", totalCPUs); writefln("threadsPerCPU %s", threadsPerCPU); writefln("totalCPUs * threadsPerCPU + 1 = %s\n", totalCPUs * threadsPerCPU + 1); } [kai.meyer kai-rhel6 D]$ dmd -run cpu.d totalCPUs 8 threadsPerCPU 0 totalCPUs * threadsPerCPU + 1 = 1 Did you mean this? _taskPool = new TaskPool( totalCPUs * (threadsPerCPU + 1));
Nov 21 2011
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
How come you don't have any threads per CPU? I guess this is a
difference between multi-processor and multi-core machines maybe?
Nov 21 2011
parent Kai Meyer <kai unixlords.com> writes:
On 11/21/2011 11:27 AM, Andrej Mitrovic wrote:
 How come you don't have any threads per CPU? I guess this is a
 difference between multi-processor and multi-core machines maybe?
I don't know, I'm not much of a hardware guy. Here's the 8th CPU's entry from /proc/cpuinfo. This is a Dell Optiplex 980 processor : 7 vendor_id : GenuineIntel cpu family : 6 model : 30 model name : Intel(R) Core(TM) i7 CPU 860 2.80GHz stepping : 5 cpu MHz : 1197.000 cache size : 8192 KB physical id : 0 siblings : 8 core id : 3 cpu cores : 4 apicid : 7 initial apicid : 7 fpu : yes fpu_exception : yes cpuid level : 11 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt lahf_lm ida tpr_shadow vnmi flexpriority ept vpid bogomips : 5585.03 clflush size : 64 cache_alignment : 64 address sizes : 36 bits physical, 48 bits virtual power management:
Nov 22 2011
prev sibling parent Andrea Fontana <advmail katamail.com> writes:
This:
http://www.d-programming-language.org/phobos/std_parallelism.html#TaskPool

?

bioinfornatics wrote:

 Dear,
 I would like to know if they are a way to run run a queue thread an run
 (nb core * 2 + 1) = nb thread in same time

 something like:
 size_t nb_core = 9;
 Queue q = new Queue( 9, process1, process2, process3 );
 q.run();

 kind regards
Nov 20 2011