Re: Yet another parallel foreach + continue question

2021-07-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/19/21 10:58 PM, H. S. Teoh wrote: I didn't check the implementation to verify this, but I'm pretty sure `break`, `continue`, etc., in the parallel foreach body does not change which iteration gets run or not. `break` should be undefined behavior (it is impossible to know which loops have

Re: Yet another parallel foreach + continue question

2021-07-19 Thread Ali Çehreli via Digitalmars-d-learn
On 7/19/21 5:07 PM, seany wrote: > Consider : > > for (int i = 0; i < max_value_of_i; i++) { > foreach ( j, dummyVar; myTaskPool.parallel(array_to_get_j_from, > my_workunitSize) { > > if ( boolean_function(i,j) ) continue; > double d = expensiveFunction(i,j

Re: Yet another parallel foreach + continue question

2021-07-19 Thread seany via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 02:58:50 UTC, H. S. Teoh wrote: On Tue, Jul 20, 2021 at 02:39:58AM +, seany via Digitalmars-d-learn wrote: > [...] [...] [...] Logically speaking, the size of the work unit should not change the semantics of the loop. That's just an implementation detail tha

Re: Yet another parallel foreach + continue question

2021-07-19 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 20, 2021 at 02:39:58AM +, seany via Digitalmars-d-learn wrote: > On Tuesday, 20 July 2021 at 02:31:14 UTC, H. S. Teoh wrote: > > On Tue, Jul 20, 2021 at 01:07:22AM +, seany via Digitalmars-d-learn > > wrote: > > > On Tuesday, 20 July 2021 at 00:37:56 UTC, H. S. Teoh wrote: > > >

Re: Yet another parallel foreach + continue question

2021-07-19 Thread seany via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 02:31:14 UTC, H. S. Teoh wrote: On Tue, Jul 20, 2021 at 01:07:22AM +, seany via Digitalmars-d-learn wrote: On Tuesday, 20 July 2021 at 00:37:56 UTC, H. S. Teoh wrote: > [...] Ok, therefore it means that, if at `j = 13 `i use a continue, then the thread where I h

Re: Yet another parallel foreach + continue question

2021-07-19 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 20, 2021 at 01:07:22AM +, seany via Digitalmars-d-learn wrote: > On Tuesday, 20 July 2021 at 00:37:56 UTC, H. S. Teoh wrote: > > On Tue, Jul 20, 2021 at 12:07:10AM +, seany via Digitalmars-d-learn > > wrote: > > > [...] > > [...] > > > > I didn't test this, but I'm pretty sure

Re: Yet another parallel foreach + continue question

2021-07-19 Thread seany via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 00:37:56 UTC, H. S. Teoh wrote: On Tue, Jul 20, 2021 at 12:07:10AM +, seany via Digitalmars-d-learn wrote: [...] [...] I didn't test this, but I'm pretty sure `continue` inside a parallel foreach loop simply terminates that iteration early; I don't think it wi

Re: Yet another parallel foreach + continue question

2021-07-19 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Jul 20, 2021 at 12:07:10AM +, seany via Digitalmars-d-learn wrote: > Consider : > > for (int i = 0; i < max_value_of_i; i++) { > foreach ( j, dummyVar; myTaskPool.parallel(array_to_get_j_from, > my_workunitSize) { > > if ( boolean_function(i,j) ) continue; >

Yet another parallel foreach + continue question

2021-07-19 Thread seany via Digitalmars-d-learn
Consider : for (int i = 0; i < max_value_of_i; i++) { foreach ( j, dummyVar; myTaskPool.parallel(array_to_get_j_from, my_workunitSize) { if ( boolean_function(i,j) ) continue; double d = expensiveFunction(i,j); // ... stuff ... } } I