<div dir="ltr">No, I made a mistake there -- I removed a for by accident, when the real problem was that the original for loop wasn't using 'in-range'. But Dmitry figured that out with the latest version of his code.<br>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 21, 2013 at 7:02 PM, Robby Findler <span dir="ltr"><<a href="mailto:robby@eecs.northwestern.edu" target="_blank">robby@eecs.northwestern.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div class="im">On Thu, Feb 21, 2013 at 4:47 PM, James Swaine <span dir="ltr"><<a href="mailto:james.swaine@eecs.northwestern.edu" target="_blank">james.swaine@eecs.northwestern.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I think the problem (in addition to the ones I mentioned in my previous message) is the use of let*, etc. inside your future thunk. </div>
</div></blockquote><div><br></div><div><br></div></div><div>This seems suspicious to me. Probably if that is really the case, we should fix it.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Robby</div>
<div> </div></font></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div dir="ltr"><div> These were expanding to define-values, which seemed to be the source of the `values' barricading. If you rewrite `render-scene-dummy' like so:</div>
<div><br></div><div><div><div>(define (render-scene-dummy object-list)</div><div> (let* ([f (future </div><div> (lambda () </div></div><div> (define x (/ screen-width 2))</div><div>
(define y screen-height)</div>
<div> (define ray-res (ray-cast x y sph-vec))</div><div> (define pix-col (point-col (int-res-p ray-res)))</div><div> #t))])</div><div><div> (for* ([x (in-range (/ screen-width 2) screen-width)]</div>
</div><div><span style="white-space:pre-wrap">        </span> [y screen-height])</div><div> (let* ([ray-res (ray-cast x y sph-vec)]</div><div><div><span style="white-space:pre-wrap">        </span> [pix-col (point-col (int-res-p ray-res))])</div>
<div><span style="white-space:pre-wrap">        </span>#t))</div><div> (touch f))</div><div>) </div><div><br></div></div><div>I don't see any blocks on my machine. Are you still in experimentation mode with futures? It seems there won't be much parallelism in this program because you are only creating the one future. </div>
<div><br></div><div>In general, it's better to restrict the use of futures to the hottest parts of your program; variables that will be uniform across all parallel tasks should be defined outside the thunk.</div>
</div><div><br></div><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div><div>
Date: Fri, 22 Feb 2013 00:03:28 +0300<br>
From: Dmitry Cherkassov <<a href="mailto:dcherkassov@gmail.com" target="_blank">dcherkassov@gmail.com</a>><br>
To: <a href="mailto:users@racket-lang.org" target="_blank">users@racket-lang.org</a><br>
Subject: [racket] values primitive blocks future execution<br>
Message-ID:<br>
<CAN0j1dRCGY7A2WxXBYXP=<a href="mailto:JbLntw_-L3O7eoYJvD1VTAb%2BqDLYQ@mail.gmail.com" target="_blank">JbLntw_-L3O7eoYJvD1VTAb+qDLYQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi list.<br>
I've been doing a simple ray tracer[1] and decided to parallelize it using<br>
futures.<br>
<br>
I've tried to use flonums everywhere and added (in-range) to loops [3]<br>
(over x and y coordinates).<br>
<br>
The problem is that execution of future is blocked seriously.<br>
(apparently by the value primitive) [2]<br>
<br>
Are there any ideas why it doesn't work?<br>
<br>
I use racket v5.3.3.<br>
<br>
[1] Complete source code: <a href="http://pastebin.com/EGSzR1Tv" target="_blank">http://pastebin.com/EGSzR1Tv</a><br>
<br>
[2] Future visualizer screenshot: <a href="http://ompldr.org/vaGpiaQ" target="_blank">http://ompldr.org/vaGpiaQ</a><br>
Invoked via<br>
(require future-visualizer)<br>
(visualize-futures (run-no-render))<br>
<br>
[3] Source code for main loop:<br>
(define (render-scene-dummy object-list)<br>
(let* ([f (future<br>
(lambda ()<br>
(for* ([x (in-range (/ screen-width 2))]<br>
[y (in-range screen-height)])<br>
(let* ([ray-res (ray-cast x y object-list)]<br>
[pix-col (point-col (int-res-p ray-res))])<br>
#t))<br>
))])<br>
<br>
(for* ([x (in-range (/ screen-width 2) screen-width)]<br>
[y (in-range screen-height)])<br>
(let* ([ray-res (ray-cast x y object-list)]<br>
[pix-col (point-col (int-res-p ray-res))])<br>
#t))<br>
(touch f)))<br>
<br>
<br>
<br></div></div><div>
--<br>
With best regards,<br>
Dmitry<br></div><div>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.racket-lang.org/users/archive/attachments/20130222/6e2262a8/attachment-0001.html" target="_blank">http://lists.racket-lang.org/users/archive/attachments/20130222/6e2262a8/attachment-0001.html</a>><br>
</div></blockquote></div></div></div>
<br></div></div><div class="im">____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
<br></div></blockquote></div><br></div></div>
</blockquote></div><br></div></div>