Re: Parallelization of a large array

2015-03-11 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2015-03-11 at 07:10 -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 03/11/2015 01:07 AM, Russel Winder via Digitalmars-d-learn wrote: > > On Tue, 2015-03-10 at 15:34 -0700, Ali Çehreli via Digitalmars-d-learn > > wrote: > > […] > >> We can hope to make it simpler by taking advantage

Re: Parallelization of a large array

2015-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 03/11/2015 01:07 AM, Russel Winder via Digitalmars-d-learn wrote: On Tue, 2015-03-10 at 15:34 -0700, Ali Çehreli via Digitalmars-d-learn wrote: […] We can hope to make it simpler by taking advantage of parallel map but it requires a static local function or a global function (a lambda cannot

Re: Parallelization of a large array

2015-03-11 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-03-10 at 15:34 -0700, Ali Çehreli via Digitalmars-d-learn wrote: […] > We can hope to make it simpler by taking advantage of parallel map but > it requires a static local function or a global function (a lambda > cannot be used): […] Is there a reason for excluding lambdas, it a pri

Re: Parallelization of a large array

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:37:29 UTC, Ali Çehreli wrote: On 03/10/2015 03:16 PM, Meta wrote: > Just add a condition variable. > > import std.stdio; > import std.algorithm; > import std.parallelism; > > void main() { > > int b = 2; > > auto a = [1, 2, 2, 3]; > > if (find(a, b)

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:43:08 UTC, Ali Çehreli wrote: The following is the program that does NOT use taskPool.map. I am also changing the name of a variable because the local 'chunks' looked like std.range.chunks. import std.stdio; import std.algorithm; import std.parallelism; import s

Re: Parallelization of a large array

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 03:34 PM, Ali Çehreli wrote: > It is possible by accessing the actual range by chunks: Sorry, I posted a jumbled program that does not compile. The following is the program that does NOT use taskPool.map. I am also changing the name of a variable because the local 'chunks' looked

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:34:34 UTC, Ali Çehreli wrote: It is possible by accessing the actual range by chunks: import std.stdio; import std.algorithm; import std.parallelism; import std.range; import std.conv; void main() { const size_t elementCount = 895640; int[] a = iota(elem

Re: Parallelization of a large array

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 03:16 PM, Meta wrote: > Just add a condition variable. > > import std.stdio; > import std.algorithm; > import std.parallelism; > > void main() { > > int b = 2; > > auto a = [1, 2, 2, 3]; > > if (find(a, b).length != 0) > writeln("Yes_"); > > auto found =

Re: Parallelization of a large array

2015-03-10 Thread Ali Çehreli via Digitalmars-d-learn
On 03/10/2015 01:41 PM, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? std.stdio; std.algorithm; std.parallelism; void main() { int[] a = new int[100]; foreach (i, ref elem; a) elem =

Re: Parallelization of a large array

2015-03-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:11:57 UTC, Dennis Ritchie wrote: On Tuesday, 10 March 2015 at 21:27:42 UTC, Dennis Ritchie wrote: Thanks. No, it does not suit me, because of the parallel array in a foreach loop there is no break. import std.stdio; import std.algorithm; import std.parallelis

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 22:11:57 UTC, Dennis Ritchie wrote: No, it does not suit me, because of the parallel array in a foreach loop there is no break. I already understood everything: found = true;

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 21:27:42 UTC, Dennis Ritchie wrote: Thanks. No, it does not suit me, because of the parallel array in a foreach loop there is no break. import std.stdio; import std.algorithm; import std.parallelism; void main() { int b = 2; auto a = [1, 2, 2,

Re: Parallelization of a large array

2015-03-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 21:15:17 UTC, safety0ff wrote: On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? Here's a simple method (warning: has pitfalls): import s

Re: Parallelization of a large array

2015-03-10 Thread safety0ff via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? Here's a simple method (warning: has pitfalls): import std.stdio; import std.parallelism; void main() { int[] a

Re: Parallelization of a large array

2015-03-10 Thread anonymous via Digitalmars-d-learn
On Tuesday, 10 March 2015 at 20:41:14 UTC, Dennis Ritchie wrote: Hi. How to parallelize a large array to check for the presence of an element matching the value with the data? std.stdio; std.algorithm; std.parallelism; You forgot a couple "import"s here. void main() { int[] a = n