Tuesday 19 July 2011

Multi-threading

This was probably the most frustrating objective to complete... and I'm not all that sure it's complete. The program now allows the user to chose 1, 2, 4 or 8 threads to render the image. This speeds up the rendering time dramatically, but only if your computer has at least a number of cores matching the number of threads selected.
Below is a graph showing the time it takes to render a simple 256x256 image with 5x5 grid sampling:



This was tested on a 4-core machine, so there are no results for 8 threads. It's pretty obvious that more threads is awesome.
A fun byproduct of mutli-threading is that you can see different sections of the image partly drawn when you cancel a render. Here's an example of an image partially drawn with 4 threads:



A not-so-fun byproduct of multi-threading the unreliability. It's difficult to make a thread-safe program. My ray tracer has some undiscovered threading issues, so it will occasionally seg-fault. Ah well. I did my best.

No comments:

Post a Comment