Bug 14886 – [REG2.066] std.parallelism.parallel with large static array seems to hang compile

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-08-07T18:49:00Z
Last change time
2017-08-02T08:07:27Z
Keywords
performance, pull
Assigned to
nobody
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2015-08-07T18:49:24Z
example: import std.parallelism; void main() { int x[100_000]; parallel(x); } If you remove one 0 from the number of elements, the compile finishes with an error: /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/parallelism.d-mixin-3780(3878): Error: template std.range.primitives.popFront cannot deduce function from argument types !()(int[10000]), candidates are: /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/range/primitives.d(2032): std.range.primitives.popFront(T)(ref T[] a) if (!isNarrowString!(T[]) && !is(T[] == void[])) /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/range/primitives.d(2055): std.range.primitives.popFront(C)(ref C[] str) if (isNarrowString!(C[])) /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/parallelism.d-mixin-3780(3867): Error: function std.parallelism.ParallelForeach!(int[10000]).ParallelForeach.opApply.doIt.makeTemp no return exp; or assert(0); at end of function /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/parallelism.d-mixin-3792(3890): Error: template std.range.primitives.popFront cannot deduce function from argument types !()(int[10000]), candidates are: /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/range/primitives.d(2032): std.range.primitives.popFront(T)(ref T[] a) if (!isNarrowString!(T[]) && !is(T[] == void[])) /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/range/primitives.d(2055): std.range.primitives.popFront(C)(ref C[] str) if (isNarrowString!(C[])) /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/parallelism.d-mixin-3792(3879): Error: function std.parallelism.ParallelForeach!(int[10000]).ParallelForeach.opApply.doIt.makeTemp no return exp; or assert(0); at end of function /Users/steves/git/dmd2/osx/bin/../../src/phobos/std/parallelism.d(3303): Error: template instance std.parallelism.ParallelForeach!(int[10000]) error instantiating testarray.d(6): instantiated from here: parallel!(int[10000]) I'm unsure if this is a bug in the compiler or a bug in std.parallelism. I don't know how the latter is designed to work, but it does appear that there isn't a valid instantiation for it, so I would suspect a compiler issue. The timing seems to be non-linear based on the number of elements: 10k elements: 1.5 seconds to reach error 20k elements: 5.2 seconds to reach error 30k elements: 12.2 seconds to reach error 40k elements: 20.9 seconds to reach error 50k elements: 32.9 seconds to reach error I stopped after that :)
Comment #1 by schveiguy — 2015-08-07T18:50:05Z
Forgot to link thread that started this bug: http://forum.dlang.org/post/[email protected]
Comment #2 by dlang-bugzilla — 2015-09-01T08:23:01Z
Comment #3 by k.hara.pg — 2015-09-01T10:05:27Z
Reduced test case: @property ref T front(T)(T[] a) { return a[0]; } template ElementType(R) { static if (is(typeof(R.init.front.init) T)) alias ElementType = T; else alias ElementType = void; } void main() { alias R = int[100_000]; alias E = ElementType!R; }
Comment #4 by k.hara.pg — 2015-09-01T10:26:16Z
More: auto front(T)(T[] a) {} void main() { alias R = int[100_000]; alias E = typeof(front(R.init)); }
Comment #5 by k.hara.pg — 2015-09-16T00:16:48Z
*** Issue 15062 has been marked as a duplicate of this issue. ***
Comment #6 by k.hara.pg — 2015-09-17T08:52:18Z
Comment #7 by github-bugzilla — 2015-09-22T04:41:12Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/51ecaf8e47c82f41115cc1d59c6ed384e234eb60 fix Issue 14886 - std.parallelism.parallel with large static array seems to hang compile Add ArrayLiteralExp.basis for repeated array literal elements. https://github.com/D-Programming-Language/dmd/commit/a492f916d022698edb025c4b206ad1af75e0913d Merge pull request #5085 from 9rnsr/fix14886 [REG2.066] Issue 14886 - std.parallelism.parallel with large static array seems to hang compile
Comment #8 by dlang-bugzilla — 2017-07-05T15:18:57Z
*** Issue 10716 has been marked as a duplicate of this issue. ***
Comment #9 by github-bugzilla — 2017-08-02T08:07:27Z
Commit pushed to dmd-cxx at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/53ce42c3256e7a2265613a30399345eac85a7343 Issue 14886 - std.parallelism.parallel with large static array seems to hang compile