Re: parallelism with delegate

2023-09-22 Thread Imperatorn via Digitalmars-d-learn
On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev wrote: able ? how to use correctly? ```d import std.parallelism; auto async_task = task!fn( args ); // error // Error: no property `opCall` for type `app.A`, did you mean `new A`?

Re: parallelism with delegate

2023-09-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 21, 2023 10:33:44 PM MDT Vitaliy Fadeev via Digitalmars-d-learn wrote: > On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev > > wrote: > > ... > > Skip this thread. I see solution. > > How to delete missed posts on this forum ? This forum is esentially just a web

Re: parallelism with delegate

2023-09-21 Thread user1234 via Digitalmars-d-learn
On Friday, 22 September 2023 at 04:33:44 UTC, Vitaliy Fadeev wrote: On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev wrote: ... Skip this thread. I see solution. How to delete missed posts on this forum ? It's there forever, you have to live with that error ;) See

Re: parallelism with delegate

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
On Friday, 22 September 2023 at 04:24:19 UTC, Vitaliy Fadeev wrote: ... Skip this thread. I see solution. How to delete missed posts on this forum ?

parallelism with delegate

2023-09-21 Thread Vitaliy Fadeev via Digitalmars-d-learn
able ? how to use correctly? ```d import std.parallelism; auto async_task = task!fn( args ); // error // Error: no property `opCall` for type `app.A`, did you mean `new A`? async_task.executeInNewThread(); ``` where ```d auto a = new A(); auto

Re: Recommendation for parallelism with nested for loops?

2022-08-20 Thread Christian Köstlin via Digitalmars-d-learn
, [https://forum.dlang.org/post/xysyidbkjdinclmrx...@forum.dlang.org](this forum post) says that only one loop can be parallelized. Will it be an error or inefficient or useless if I try to do both? Also, what is the best way to do parallelism in such a situation? You could also do a custom range

Re: Recommendation for parallelism with nested for loops?

2022-08-20 Thread Christian Köstlin via Digitalmars-d-learn
/xysyidbkjdinclmrx...@forum.dlang.org](this forum post) says that only one loop can be parallelized. Will it be an error or inefficient or useless if I try to do both? Also, what is the best way to do parallelism in such a situation? You could also do a custom range that makes a one-dimensional range (aka

Re: Recommendation for parallelism with nested for loops?

2022-08-19 Thread bachmeier via Digitalmars-d-learn
On Friday, 19 August 2022 at 02:02:57 UTC, Adam D Ruppe wrote: Even if they aren't equal, you'll get decent benefit from parallel on the outer one alone, but not as good since the work won't be balanced. Unless there's some kind of blocking going on in D's implementation, if the number of

Re: Recommendation for parallelism with nested for loops?

2022-08-18 Thread Ali Çehreli via Digitalmars-d-learn
On 8/18/22 18:49, Shriramana Sharma wrote: > Hello. I want to parallelize a computation which has two for loops An option is to add tasks individually but I am not sure how wise doing this and I don't know how to determine whether all tasks are completed. In any case, Roy Margalit's DConf

Re: Recommendation for parallelism with nested for loops?

2022-08-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 19 August 2022 at 01:49:43 UTC, Shriramana Sharma wrote: Also, what is the best way to do parallelism in such a situation? If the inner loops are about the same size for each pass of the outer loop, you can just simply parallel on the outer loop and get the same benefit. Even

Recommendation for parallelism with nested for loops?

2022-08-18 Thread Shriramana Sharma via Digitalmars-d-learn
) says that only one loop can be parallelized. Will it be an error or inefficient or useless if I try to do both? Also, what is the best way to do parallelism in such a situation?

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 14 November 2021 at 16:55:24 UTC, Alexey wrote: Remove "!"

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Alexey via Digitalmars-d-learn
On Sunday, 14 November 2021 at 17:42:18 UTC, Imperatorn wrote: Try task() instead of task!() worked! huge thanks!

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 14 November 2021 at 16:55:24 UTC, Alexey wrote: On Sunday, 14 November 2021 at 16:40:58 UTC, Andrey Zherikov wrote: Just do `auto t1 = task()` in `threadCreator` then. Error: value of `this` is not known at compile time ```D import std.stdio; import std.parallelism; class TC {

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Alexey via Digitalmars-d-learn
On Sunday, 14 November 2021 at 16:40:58 UTC, Andrey Zherikov wrote: Just do `auto t1 = task()` in `threadCreator` then. Error: value of `this` is not known at compile time ```D import std.stdio; import std.parallelism; class TC { void threadFunc() { import core.thread;

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 14 November 2021 at 14:41:21 UTC, Alexey wrote: On Sunday, 14 November 2021 at 14:24:00 UTC, Andrey Zherikov wrote: On Sunday, 14 November 2021 at 12:01:36 UTC, Alexey wrote: You just need two changes: - make `threadFunc` function static: `static void threadFunc()` - use `task`

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Alexey via Digitalmars-d-learn
On Sunday, 14 November 2021 at 14:24:00 UTC, Andrey Zherikov wrote: On Sunday, 14 November 2021 at 12:01:36 UTC, Alexey wrote: You just need two changes: - make `threadFunc` function static: `static void threadFunc()` - use `task` instead of `Task`: `auto t1 = task!threadFunc;` I need

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Andrey Zherikov via Digitalmars-d-learn
On Sunday, 14 November 2021 at 12:01:36 UTC, Alexey wrote: You just need two changes: - make `threadFunc` function static: `static void threadFunc()` - use `task` instead of `Task`: `auto t1 = task!threadFunc;`

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Alexey via Digitalmars-d-learn
On Sunday, 14 November 2021 at 12:01:36 UTC, Alexey wrote: /home/animuspexus/dlang/d_v2.098.0/dmd/generated/linux/release/64/../../../../../phobos/std/parallelism.d(436): Error: need `this` for `threadFunc` of type `void()` Go example for contrast. Ideally, I'd like something similar; ```Go

Re: need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Alexey via Digitalmars-d-learn
On Sunday, 14 November 2021 at 12:01:36 UTC, Alexey wrote: auto t1 = Task!threadFunc; if this line rewritten as `auto t1 = Task!(TC.threadFunc, this);` ```text /home/animuspexus/dlang/d_v2.098.0/dmd/generated/linux/release/64/../../../../../phobos/std/parallelism.d(451):

need `this` on trying to use class method with parallelism Task! or task!

2021-11-14 Thread Alexey via Digitalmars-d-learn
/home/animuspexus/dlang/d_v2.098.0/dmd/generated/linux/release/64/../../../../../phobos/std/parallelism.d(436): Error: need `this` for `threadFunc` of type `void()` ./t.d(22): Error: template instance `std.parallelism.Task!(threadFunc)` error instantiating thou documentation says `a function

Re: parallelism

2018-01-28 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Sunday, 28 January 2018 at 04:44:23 UTC, thedeemon wrote: On Saturday, 27 January 2018 at 20:49:43 UTC, Arun Chandrasekaran wrote: But really I'm not sure why you want static foreach here I was just trying to see if static foreach can be used here, but well, you showed that it's not

Re: parallelism

2018-01-27 Thread thedeemon via Digitalmars-d-learn
On Saturday, 27 January 2018 at 20:49:43 UTC, Arun Chandrasekaran wrote: Error: must use labeled break within static foreach Just follow the compiler suggestion: void main(string[] args) { auto op = Operation.a; foreach (_; 0 .. args.length) { ops: final switch (op) {

Re: parallelism

2018-01-27 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 27 January 2018 at 17:54:53 UTC, thedeemon wrote: On Saturday, 27 January 2018 at 11:19:37 UTC, Arun Chandrasekaran wrote: Simplified test case that still errors: You got really close here. Here's a working version: enum Operation { a, b } import std.traits, std.conv,

Re: parallelism

2018-01-27 Thread thedeemon via Digitalmars-d-learn
On Saturday, 27 January 2018 at 11:19:37 UTC, Arun Chandrasekaran wrote: Simplified test case that still errors: You got really close here. Here's a working version: enum Operation { a, b } import std.traits, std.conv, std.stdio; void main(string[] args) { auto op = Operation.a;

Re: parallelism

2018-01-27 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 27 January 2018 at 10:49:45 UTC, Arun Chandrasekaran wrote: On Saturday, 27 January 2018 at 10:38:25 UTC, Nicholas Wilson wrote: ... [snip] Simplified test case that still errors: ``` enum Operation { a, b } import std.traits; import std.conv; void main(string[] args)

Re: parallelism

2018-01-27 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 27 January 2018 at 10:38:25 UTC, Nicholas Wilson wrote: On Saturday, 27 January 2018 at 10:28:10 UTC, Arun Chandrasekaran wrote: ``` import std.parallelism; auto pool = new TaskPool(options.threadCount); foreach (_; 0 .. options.iterationCount) { switch

Re: parallelism

2018-01-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 27 January 2018 at 10:28:10 UTC, Arun Chandrasekaran wrote: ``` import std.parallelism; auto pool = new TaskPool(options.threadCount); foreach (_; 0 .. options.iterationCount) { switch (options.operation) { static foreach(e; EnumMembers!Operation) {

Re: parallelism

2018-01-27 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Saturday, 27 January 2018 at 10:28:10 UTC, Arun Chandrasekaran wrote: Hi All, Is there a way to rewrite this [...] Damn! The subject should've been something else.. naming is surely hard..

parallelism

2018-01-27 Thread Arun Chandrasekaran via Digitalmars-d-learn
Hi All, Is there a way to rewrite this ``` import std.parallelism; auto pool = new TaskPool(options.threadCount); foreach (_; 0 .. options.iterationCount) { switch (options.operation) { case Operation.a: pool.put(task!a(options)); break;

Re: Fold in Parallelism

2017-12-21 Thread Vino via Digitalmars-d-learn
On Friday, 22 December 2017 at 00:18:40 UTC, Seb wrote: On Friday, 22 December 2017 at 00:12:45 UTC, Vino wrote: On Thursday, 21 December 2017 at 06:31:52 UTC, Ali Çehreli wrote: [...] Hi Ali, Thank you very much, the pull request is in open state, so can you please let me know when can we

Re: Fold in Parallelism

2017-12-21 Thread Seb via Digitalmars-d-learn
On Friday, 22 December 2017 at 00:12:45 UTC, Vino wrote: On Thursday, 21 December 2017 at 06:31:52 UTC, Ali Çehreli wrote: On 12/19/2017 02:32 AM, Vino wrote: > even though it is a simple code copy+paste The change was a little more complicated than my naive adaptation from

Re: Fold in Parallelism

2017-12-21 Thread Vino via Digitalmars-d-learn
On Thursday, 21 December 2017 at 06:31:52 UTC, Ali Çehreli wrote: On 12/19/2017 02:32 AM, Vino wrote: > even though it is a simple code copy+paste The change was a little more complicated than my naive adaptation from std.algorithm.fold. Here is the pull request:

Re: Fold in Parallelism

2017-12-21 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2017-12-20 at 22:31 -0800, Ali Çehreli via Digitalmars-d-learn wrote: > On 12/19/2017 02:32 AM, Vino wrote: > > > even though it is a simple code copy+paste > > The change was a little more complicated than my naive adaptation > from > std.algorithm.fold. Here is the pull request: > >

Re: Fold in Parallelism

2017-12-20 Thread Ali Çehreli via Digitalmars-d-learn
On 12/19/2017 02:32 AM, Vino wrote: > even though it is a simple code copy+paste The change was a little more complicated than my naive adaptation from std.algorithm.fold. Here is the pull request: https://github.com/dlang/phobos/pull/5951 Ali

Re: Fold in Parallelism

2017-12-19 Thread Vino via Digitalmars-d-learn
On Monday, 18 December 2017 at 20:53:28 UTC, Russel Winder wrote: Ali, Shouldn't this be a pull request for std.parallelism to be extended? If the function is in std.algorithm, then people should not have to write it for themselves in std.parallelism. On Mon, 2017-12-18 at 11:01 -0800,

Re: Fold in Parallelism

2017-12-18 Thread Russel Winder via Digitalmars-d-learn
Ali, Shouldn't this be a pull request for std.parallelism to be extended? If the function is in std.algorithm, then people should not have to write it for themselves in std.parallelism. On Mon, 2017-12-18 at 11:01 -0800, Ali Çehreli via Digitalmars-d-learn wrote: > […] > > Hi Ali, > > > >

Re: Fold in Parallelism

2017-12-18 Thread Ali Çehreli via Digitalmars-d-learn
On 12/18/2017 02:18 AM, Vino wrote: On Sunday, 17 December 2017 at 20:00:53 UTC, Ali Çehreli wrote: On 12/17/2017 08:11 AM, Vino wrote: >   As per the document form std.parallelism it states that we can use > taskPool.reduce so can we use the same for fold (taskPool.fold) as > basically both

Re: Fold in Parallelism

2017-12-18 Thread Vino via Digitalmars-d-learn
On Sunday, 17 December 2017 at 20:00:53 UTC, Ali Çehreli wrote: On 12/17/2017 08:11 AM, Vino wrote: > As per the document form std.parallelism it states that we can use > taskPool.reduce so can we use the same for fold (taskPool.fold) as > basically both are same with slight variation on seed

Re: Fold in Parallelism

2017-12-17 Thread Ali Çehreli via Digitalmars-d-learn
On 12/17/2017 08:11 AM, Vino wrote: > As per the document form std.parallelism it states that we can use > taskPool.reduce so can we use the same for fold (taskPool.fold) as > basically both are same with slight variation on seed values, if > possible can can we define the same in the below

Fold in Parallelism

2017-12-17 Thread Vino via Digitalmars-d-learn
HI All, As per the document form std.parallelism it states that we can use taskPool.reduce so can we use the same for fold (taskPool.fold) as basically both are same with slight variation on seed values, if possible can can we define the same in the below lines Tried the below but getting

Re: What's the "right" way to do openmp-style parallelism?

2015-09-09 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-09-08 at 07:33 +, Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: > On Tuesday, 8 September 2015 at 05:50:30 UTC, Russel Winder wrote: > > void main() { > > immutable imax = 10; > > immutable jmax = 10; > > float[imax][jmax] x; > > foreach(int

Re: What's the "right" way to do openmp-style parallelism?

2015-09-08 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 05:50:30 UTC, Russel Winder wrote: void main() { immutable imax = 10; immutable jmax = 10; float[imax][jmax] x; foreach(int j; 1..jmax){ foreach(int i, ref item; parallel(x[j-1])){ x[j][i] = complicatedFunction(i,

Re: What's the "right" way to do openmp-style parallelism?

2015-09-07 Thread Russel Winder via Digitalmars-d-learn
} } } (though sadly, this doesn't compile for a reason I can't fathom instantly) this brings into stark relieve the fact that there is a potential coupling between x[j-1][m] and x[j-1][n] which means enforcing parallelism here will almost certainly result in the wrong value

Re: What's the "right" way to do openmp-style parallelism?

2015-09-06 Thread Meta via Digitalmars-d-learn
On Monday, 7 September 2015 at 02:56:04 UTC, Charles wrote: Friends, I have a program that would be pretty easy to parallelize with an openmp pragra in C. I'd like to avoid the performance cost of using message passing, and the shared qualifier seems like it's enforcing guarantees I don't

What's the "right" way to do openmp-style parallelism?

2015-09-06 Thread Charles via Digitalmars-d-learn
Friends, I have a program that would be pretty easy to parallelize with an openmp pragra in C. I'd like to avoid the performance cost of using message passing, and the shared qualifier seems like it's enforcing guarantees I don't need. Essentially, I have x = float[imax][jmax]; //x is about

2D array parallelism

2014-01-26 Thread Andrew Klaassen
I've got some code which sets values in a 2D array. Each value is independent, so I'm using std.parallelism to set the values a row at a time. When my variables are class variables it seems to work (though it's hard to tell, given that the effect is intermittent), but when I use module-level

Re: 2D array parallelism

2014-01-26 Thread bearophile
Andrew Klaassen: This happens with dmd, ldc2 and gdc, so I assume it's something I'm doing wrong rather than a bug. What's the explanation? What am I doing wrong? Do you know that module level variables in D are thread-local? If you don't what that, you have to use __gshared. Bye,

Multiple while-loops parallelism

2014-01-17 Thread Mineko
Today I'm asking a more theoretical question, since I can't quite grasp this one too well. Let's say I want 3 while-loops running in parallel, without getting in the way of each other, how would I do that? With std.parallel of course, but that's where I get confused, perhaps someone could

Re: Multiple while-loops parallelism

2014-01-17 Thread Stanislav Blinov
On Friday, 17 January 2014 at 21:07:46 UTC, Mineko wrote: Let's say I want 3 while-loops running in parallel, without getting in the way of each other, how would I do that? On the same set of data? That's optimistic if one of the loops writes :) Otherwise, you could just create three tasks,

Re: Multiple while-loops parallelism

2014-01-17 Thread Kelet
On Friday, 17 January 2014 at 21:07:46 UTC, Mineko wrote: Today I'm asking a more theoretical question, since I can't quite grasp this one too well. Let's say I want 3 while-loops running in parallel, without getting in the way of each other, how would I do that? With std.parallel of

Re: Parallelism Map and Reduce

2012-12-12 Thread Zardoz
On Tuesday, 11 December 2012 at 17:50:31 UTC, Ali Çehreli wrote: On 12/11/2012 08:12 AM, Zardoz wrote: Could you please move MapIntegrator() to module-level. Then it should work. Ali I try it and now even with normal Map function give me errors with dmd ! public Entity MapIntegrator (

Re: Parallelism Map and Reduce

2012-12-12 Thread Ali Çehreli
On 12/12/2012 05:47 AM, Zardoz wrote: On Tuesday, 11 December 2012 at 17:50:31 UTC, Ali Çehreli wrote: On 12/11/2012 08:12 AM, Zardoz wrote: Could you please move MapIntegrator() to module-level. Then it should work. Ali I try it and now even with normal Map function give me errors with

Re: Parallelism Map and Reduce

2012-12-11 Thread Ali Çehreli
On 12/11/2012 02:53 AM, Zardoz wrote: auto acelByObjs = map!( (Entity o) { Vector3 r = o.pos[0] - pos[0]; return r * (o.mass / pow((r.sq_length + epsilon2), 1.5)); } )(objects); newAcel = reduce!(a + b)(acelByObjs); It works very well with the std.algorithm Map and Reduce but when I try

Re: Parallelism Map and Reduce

2012-12-11 Thread bearophile
Ali Çehreli: The single pointer of the lambda is not sufficient to store both without big changes in the compiler. I think adding a heavier 3-word delegate is not too much hard to do. But it makes the language more complex, so so far Walter is not willing to introduce them. But in the end

Re: Parallelism Map and Reduce

2012-12-11 Thread Zardoz
On Tuesday, 11 December 2012 at 15:22:49 UTC, Ali Çehreli wrote: That used to work a couple of dmd versions ago. I think it was a bug that it worked, so it stopped working after bug fixes. If I'm not mistaken this is actually related to a compiler implementation issue: Lambda's have a single