1

Where can I find a pseudocode to parallelize a path tracer using multiple cpu threads? How should I change the normal path tracer to be capable of parallelization?

bitWise
  • 213
  • 1
  • 8
  • 1
    `#pragma omp parallel for`, you'll have to provide separate prngs. You can refer to my modification of inoneweekend: https://github.com/vchizhov/InOneWeekend-1/blob/master/src/main.cc – lightxbulb Nov 08 '19 at 21:03

1 Answers1

5

An easy way to parallelize a path tracer is to have different threads (or machines!) work on different parts of the image.

For instance, you could break the image into a 20x20 grid and have each thread grab a tile, render it, and try to grab another tile.

A way I like to divy out this work is to use an atomic integer. Each thread atomically increments the integer and uses the value as an index into the work to do. They repeat this process until the atomic integer goes out of bounds.

Alan Wolfe
  • 7,711
  • 3
  • 29
  • 72