Thread overview
std.parallelism example hangs compiler 2.067.1
Aug 07, 2015
Jay Norwood
Aug 07, 2015
Jay Norwood
August 07, 2015
This appears to hang up dmd compiler 2.067.1. Changing parallel(s) to s works ok. Is this a known problem?

import std.stdio;
import std.string;
import std.format;
import std.range;
import std.parallelism;

int main(string[] argv)
{

	string s[100000];
	foreach (i, ref si ; parallel(s)){
		si = format("hi:%d",i);
	}

	foreach (ref rm; s[99000..99010]){
		writeln(rm);
	}
    return 0;
}

August 07, 2015
On 8/7/15 2:19 PM, Jay Norwood wrote:
> This appears to hang up dmd compiler 2.067.1. Changing parallel(s) to s
> works ok. Is this a known problem?
>
> import std.stdio;
> import std.string;
> import std.format;
> import std.range;
> import std.parallelism;
>
> int main(string[] argv)
> {
>
>      string s[100000];
>      foreach (i, ref si ; parallel(s)){
>          si = format("hi:%d",i);
>      }
>
>      foreach (ref rm; s[99000..99010]){
>          writeln(rm);
>      }
>      return 0;
> }
>

When you said "hang up", I didn't understand what you meant.

Now I see, it actually hangs dmd (actually, it's not hung, it is still running as far as I can tell).

If I reduce to 10000, it completes the compile with an error.

I think it has to do with parallel(s).

In fact, this code also hangs:

int main(string[] argv)
{
   string s[100000];
   parallel(s);
}

In order to get what you really do want (no hangs, no errors), use this:

parallel(s[])

I'll file a bug on this.

-Steve
August 07, 2015
On 8/7/15 2:37 PM, Steven Schveighoffer wrote:

> I'll file a bug on this.

https://issues.dlang.org/show_bug.cgi?id=14886

-Steve

August 07, 2015
On Friday, 7 August 2015 at 18:51:45 UTC, Steven Schveighoffer wrote:
> On 8/7/15 2:37 PM, Steven Schveighoffer wrote:
>
>> I'll file a bug on this.
>
> https://issues.dlang.org/show_bug.cgi?id=14886
>
> -Steve

Thanks.  The workaround works ok.