A small program that compiles and executed fine with DMD 2.065 and LDC master (794d5d, DMD v2.063.2 and LLVM 3.4), gives the following error using GDC 4.8.1 /usr/include/d/4.8/std/parallelism.d: In member function 'reduce': /usr/include/d/4.8/std/parallelism.d:2630: error: cannot access frame of function 'main' from 'reduce'
Sorry for the delayed response. Would you have this 'small program' available as a test case?
It is the variant of my π by Quadrature example that David Simcha and I came up with whilst he was writing parallelism.d: /* * A D program to calculate π using quadrature as a parallel reduce of individual expression evaluations * with no manual batching. * * Copyright © 2011–2013 Russel Winder */ // This version originally due to David Simcha, stemming from various emails on the various D email lists // and reified in the documentation for std.parallelism: http://dlang.org/phobos/std_parallelism.html, // http://cis.jhu.edu/~dsimcha/d/phobos/std_parallelism.html import std.algorithm; import std.datetime; import std.parallelism; import std.range; import outputFunctions; int main(immutable string[] args) { immutable n = 1000000000; immutable delta = 1.0 / n; StopWatch stopWatch; stopWatch.start(); // There is a problem using a lambda function here. David Simcha reports it is a consequence of issue // 5710 http://d.puremagic.com/issues/show_bug.cgi?id=5710. Live with this and use the string syntax // for specifying a lambda function. //immutable pi = 4.0 * delta * taskPool.reduce !((a, b) { return a + b; }) ( //immutable pi = 4.0 * delta * taskPool.reduce !((a, b) => a + b) ( immutable pi = 4.0 * delta * taskPool.reduce!"a + b"( map!((int i) { immutable x = (i - 0.5) * delta; return 1.0 / (1.0 + x * x); })(iota(n))); stopWatch.stop(); immutable elapseTime = stopWatch.peek().hnsecs * 100e-9; output(__FILE__, pi, n, elapseTime); return 0; }
Problem still happens with gdc 4.9 :-( gdc -I. -O3 -c -o pi_parallelReduce.o pi_parallelReduce.d /usr/include/d/4.9/std/parallelism.d: In member function 'reduce': /usr/include/d/4.9/std/parallelism.d:2630: error: cannot access frame of function 'main' from 'reduce' scons: *** [pi_parallelReduce.o] Error 1
Two things have happened that have opened this up for fixing: https://github.com/D-Programming-GDC/GDC/commit/eb915d6dd4b2bcd96463a5c73f74774ae5941404 https://github.com/D-Programming-GDC/GDC/commit/8b77c001db6cc78fd4b4c33ba7963aad4f62ed6f This error being in the glue is now only historical for preventing an ICE in the backend that should no longer occur. However as all things historical, it's rather deep rooted.
Oops, that first link should have been: https://github.com/D-Programming-GDC/GDC/commit/16be749d160c19bd2cc2fbc70853a7409b3b96da
Technical notes (so I don't forget when I look at this): AssignExp::toElem - e1->op == TOKslice - this->ismemset == true There is no shortcut for calling BUILT_IN_MEMSET here, so the initialisation is handed down to IRState::doArraySet, which needlessly attempts to generate each individual initialiser.
https://github.com/D-Programming-GDC/GDC/commit/a3c0cb128a4b3b8d13c266b0101f4e7bd22455e5