[racket] values primitive blocks future execution
On Thu, Feb 21, 2013 at 4:47 PM, James Swaine <
james.swaine at eecs.northwestern.edu> wrote:
> 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.
>
This seems suspicious to me. Probably if that is really the case, we should
fix it.
Robby
> These were expanding to define-values, which seemed to be the source of
> the `values' barricading. If you rewrite `render-scene-dummy' like so:
>
> (define (render-scene-dummy object-list)
> (let* ([f (future
> (lambda ()
> (define x (/ screen-width 2))
> (define y screen-height)
> (define ray-res (ray-cast x y sph-vec))
> (define pix-col (point-col (int-res-p ray-res)))
> #t))])
> (for* ([x (in-range (/ screen-width 2) screen-width)]
> [y screen-height])
> (let* ([ray-res (ray-cast x y sph-vec)]
> [pix-col (point-col (int-res-p ray-res))])
> #t))
> (touch f))
> )
>
> 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.
>
> 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.
>
>
> Date: Fri, 22 Feb 2013 00:03:28 +0300
>> From: Dmitry Cherkassov <dcherkassov at gmail.com>
>> To: users at racket-lang.org
>> Subject: [racket] values primitive blocks future execution
>> Message-ID:
>> <CAN0j1dRCGY7A2WxXBYXP=
>> JbLntw_-L3O7eoYJvD1VTAb+qDLYQ at mail.gmail.com>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi list.
>> I've been doing a simple ray tracer[1] and decided to parallelize it using
>> futures.
>>
>> I've tried to use flonums everywhere and added (in-range) to loops [3]
>> (over x and y coordinates).
>>
>> The problem is that execution of future is blocked seriously.
>> (apparently by the value primitive) [2]
>>
>> Are there any ideas why it doesn't work?
>>
>> I use racket v5.3.3.
>>
>> [1] Complete source code: http://pastebin.com/EGSzR1Tv
>>
>> [2] Future visualizer screenshot: http://ompldr.org/vaGpiaQ
>> Invoked via
>> (require future-visualizer)
>> (visualize-futures (run-no-render))
>>
>> [3] Source code for main loop:
>> (define (render-scene-dummy object-list)
>> (let* ([f (future
>> (lambda ()
>> (for* ([x (in-range (/ screen-width 2))]
>> [y (in-range screen-height)])
>> (let* ([ray-res (ray-cast x y object-list)]
>> [pix-col (point-col (int-res-p ray-res))])
>> #t))
>> ))])
>>
>> (for* ([x (in-range (/ screen-width 2) screen-width)]
>> [y (in-range screen-height)])
>> (let* ([ray-res (ray-cast x y object-list)]
>> [pix-col (point-col (int-res-p ray-res))])
>> #t))
>> (touch f)))
>>
>>
>>
>> --
>> With best regards,
>> Dmitry
>> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <
>> http://lists.racket-lang.org/users/archive/attachments/20130222/6e2262a8/attachment-0001.html
>> >
>>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130221/67d92666/attachment.html>