Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 1 April 2023 at 22:48:46 UTC, Ali Çehreli wrote: On 4/1/23 15:30, Paul wrote: > Is there a way to verify that it split up the work in to tasks/threads > ...? It is hard to see the difference unless there is actual work in the loop that takes time. I always use the Rowland

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Ali Çehreli via Digitalmars-d-learn
On 4/1/23 15:30, Paul wrote: > Is there a way to verify that it split up the work in to tasks/threads > ...? It is hard to see the difference unless there is actual work in the loop that takes time. You can add a Thread.sleep call. (Commented-out in the following program.) Another option is

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Paul via Digitalmars-d-learn
On Saturday, 1 April 2023 at 18:30:32 UTC, Steven Schveighoffer wrote: On 4/1/23 2:25 PM, Paul wrote: ```d import std.range; foreach(; iota(0, 2_000_000).parallel) ``` -Steve Is there a way to tell if the parallelism actually divided up the work? Both versions of my program run in the

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Paul via Digitalmars-d-learn
```d import std.range; foreach(; iota(0, 2_000_000).parallel) ``` -Steve Is there a way to verify that it split up the work in to tasks/threads ...? The example you gave me works...compiles w/o errors but the execution time is the same as the non-parallel version. They both take about 6

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread IGotD- via Digitalmars-d-learn
On Saturday, 1 April 2023 at 15:02:12 UTC, Ali Çehreli wrote: Does anyone have documentation on why Rust and Zip does not do thread local by default? I wonder what experience it was based on. I think that would hard to get documentation on the rationale for that decision. Maybe you can

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Paul via Digitalmars-d-learn
Thanks Steve.

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/1/23 2:25 PM, Paul wrote: Thanks in advance for any assistance. As the subject line suggests can I do something like? : ```d foreach (i; taskPool.parallel(0..2_000_000)) ``` Obviously this exact syntax doesn't work but I think it expresses the gist of my challenge. ```d import

foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Paul via Digitalmars-d-learn
Thanks in advance for any assistance. As the subject line suggests can I do something like? : ```d foreach (i; taskPool.parallel(0..2_000_000)) ``` Obviously this exact syntax doesn't work but I think it expresses the gist of my challenge.

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread Timon Gehr via Digitalmars-d-learn
On 4/1/23 17:02, Ali Çehreli wrote: Does anyone have documentation on why Rust and Zip does not do thread local by default? Rust just does not do mutable globals except in unsafe code.

Re: Is this code correct?

2023-04-01 Thread Dennis via Digitalmars-d-learn
On Friday, 31 March 2023 at 13:11:58 UTC, z wrote: I've tried to search before but was only able to find articles for 3D triangles, and documentation for OpenGL, which i don't use. The first function you posted takes a 3D triangle as input, so I assumed you're working in 3D. What are you

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread Ali Çehreli via Digitalmars-d-learn
On 3/26/23 13:41, ryuukk_ wrote: > C, C++, Rust, Zig, Go doesn't do TLS by default for example C doesn't do because there was no such concept when it was conceived. C++ doesn't do because they built on top of C. (D does because it has always been innovative.) Go doesn't do because it had no

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 1 April 2023 at 13:11:46 UTC, Guillaume Piolat wrote: TLS could be explicit and we wouldn't need a -vtls flag. Yeah, I think what we should do is make each thing be explicitly marked. When I want tls, I tend to comment that it was intentional anyway to make it clear I didn't

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread Guillaume Piolat via Digitalmars-d-learn
On Saturday, 1 April 2023 at 08:47:54 UTC, IGotD- wrote: TLS by default is mistake in my opinion and it doesn't really help. TLS should be discouraged as much as possible as it is complicated and slows down thread creation. It looks like a mistake if we consider none of the D-inspired

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread Guillaume Piolat via Digitalmars-d-learn
On Friday, 31 March 2023 at 19:43:42 UTC, bachmeier wrote: Those of us that have been scarred by reading FORTRAN 77 code would disagree. I use global mutables myself (and even the occasional goto), but if anything, it should be `__GLOBAL_MUTABLE_VARIABLE` to increase the pain of using them.

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread IGotD- via Digitalmars-d-learn
On Sunday, 26 March 2023 at 18:25:54 UTC, Richard (Rikki) Andrew Cattermole wrote: Having TLS by default is actually quite desirable if you like your code to be safe without having to do anything extra. As soon as you go into global to the process memory, you are responsible for

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread IGotD- via Digitalmars-d-learn
On Sunday, 26 March 2023 at 18:25:54 UTC, Richard (Rikki) Andrew Cattermole wrote: Having TLS by default is actually quite desirable if you like your code to be safe without having to do anything extra. As soon as you go into global to the process memory, you are responsible for