POV-Ray : Newsgroups : povray.bugreports : POV-ray should use multiple threads Server Time
29 Apr 2024 02:02:24 EDT (-0400)
  POV-ray should use multiple threads (Message 1 to 5 of 5)  
From: Timwi
Subject: POV-ray should use multiple threads
Date: 12 Aug 2009 15:25:27
Message: <4a831727@news.povray.org>
Ray-tracing is trivially parallelisable. Keeping to a single thread even 
on multiple-CPU machines is kind of weird.

POV-ray should try to detect the number of CPUs, or if it can't, let the 
user enter the number of threads POV-ray should spawn.

POV-ray should then split the workload of rendering the image into that 
number of threads.



Suggested algorithm (pseudo-code):

Let n = number of CPUs (or configured number of threads).
Let h = height of the output bitmap.
Let lines = list of integers initialised to [0, 1, 2, ..., h-1].

Spawn n threads, where each thread does the following:
   Obtain a mutex on 'lines'.
   If 'lines' is empty, release the mutex and return.
   Remove an integer y from 'lines'.
   Release the mutex on 'lines'.
   Render the row of pixels at y co-ordinate 'y'.
   Go back to start.

Wait for all n threads to complete.
Done.



Timwi


Post a reply to this message

From: Warp
Subject: Re: POV-ray should use multiple threads
Date: 12 Aug 2009 17:07:34
Message: <4a832f16@news.povray.org>
Timwi <tim### [at] gmxnet> wrote:
> Suggested algorithm (pseudo-code):

  A much easier algorithm: Write the following in the address bar of your
web browser: http://povray.org/beta/

-- 
                                                          - Warp


Post a reply to this message

From: clipka
Subject: Re: POV-ray should use multiple threads
Date: 12 Aug 2009 19:15:10
Message: <4a834cfe$1@news.povray.org>
Timwi schrieb:
> Suggested algorithm (pseudo-code):
> 
> Let n = number of CPUs (or configured number of threads).
> Let h = height of the output bitmap.
> Let lines = list of integers initialised to [0, 1, 2, ..., h-1].
> 
> Spawn n threads, where each thread does the following:
>   Obtain a mutex on 'lines'.
>   If 'lines' is empty, release the mutex and return.
>   Remove an integer y from 'lines'.
>   Release the mutex on 'lines'.
>   Render the row of pixels at y co-ordinate 'y'.
>   Go back to start.
> 
> Wait for all n threads to complete.
> Done.

Congratulations - you just re-invented POV-Ray 3.7 (which is currently 
in public beta phase) :P.

Except that 3.7 schedules square blocks instead of lines (to allow for 
better efficiency of some caching mechanisms). And that things start 
getting more complicated than you expect when it comes to some more 
sophisticated features (like radiosity for instance).


Post a reply to this message

From: SharkD
Subject: Re: POV-ray should use multiple threads
Date: 6 Nov 2009 17:31:27
Message: <4af4a3bf@news.povray.org>
On 8/12/2009 7:14 PM, clipka wrote:
> Congratulations - you just re-invented POV-Ray 3.7 (which is currently
> in public beta phase) :P.
>
> Except that 3.7 schedules square blocks instead of lines (to allow for
> better efficiency of some caching mechanisms). And that things start
> getting more complicated than you expect when it comes to some more
> sophisticated features (like radiosity for instance).

Also, if you don't want to install the beta, simply render half the 
image (or animation) in one instance of POV-Ray; then open another 
instance and execute the other half. (Assuming you have two cores.)

Mike


Post a reply to this message

From: Warp
Subject: Re: POV-ray should use multiple threads
Date: 6 Nov 2009 19:01:19
Message: <4af4b8ce@news.povray.org>
SharkD <mik### [at] gmailcom> wrote:
> Also, if you don't want to install the beta, simply render half the 
> image (or animation) in one instance of POV-Ray; then open another 
> instance and execute the other half. (Assuming you have two cores.)

  And assuming that the single instance is taking less than half of your
RAM...

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.