<div dir="ltr"><div style>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. 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 style><br></div><div style><div>(define (render-scene-dummy object-list)</div><div> (let* ([f (future </div><div> (lambda () </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> (for* ([x (in-range (/ screen-width 2) screen-width)]</div>
<div><span class="" style="white-space:pre">        </span> [y screen-height])</div><div> (let* ([ray-res (ray-cast x y sph-vec)]</div><div><span class="" style="white-space:pre">        </span> [pix-col (point-col (int-res-p ray-res))])</div>
<div><span class="" style="white-space:pre">        </span>#t))</div><div> (touch f))</div><div>) </div><div><br></div><div style>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 style><br></div><div style>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">
Date: Fri, 22 Feb 2013 00:03:28 +0300<br>
From: Dmitry Cherkassov <<a href="mailto:dcherkassov@gmail.com">dcherkassov@gmail.com</a>><br>
To: <a href="mailto:users@racket-lang.org">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">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>
--<br>
With best regards,<br>
Dmitry<br>
-------------- 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>
</blockquote></div></div></div>