POV-Ray : Newsgroups : povray.bugreports : POV-ray should use multiple threads : POV-ray should use multiple threads Server Time
15 May 2024 22:19:48 EDT (-0400)
  POV-ray should use multiple threads  
From: Timwi
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

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