Parallel raytracer / renderer that demonstrates the use of parallel_for.

This example includes software developed by John E. Stone. See here for copyright information.

This example is a 2-D raytracer/renderer that visually shows different parallel scheduling methods and their resulting speedup. The code was parallelized by speculating that each pixel could be rendered in parallel. The resulting parallel code was then checked for correctness by using Intel® Thread Checker, which pointed out where synchronization was needed. Minimal synchronization was then inserted into the parallel code. The resulting parallel code exhibits good speedup.

System Requirements

For the most up to date system requirements, see the release notes.

Versions
serial
Original sequential version.
tbb1d
Parallel version that uses Intel® Threading Building Blocks (Intel® TBB) and blocked_range to parallelize over tasks that are groups of scan-lines.
  • By default, this version uses one thread per available processor. To change this default, set the TBB_NUM_THREADS environment variable to the desired number of threads before running.
  • This version uses the preview feature: auto_range_partitioner. No grain size is provided to blocked_range. The blocked_range class uses a default grain size of 1 when none is provided. However, the auto_range_partitioner controls the amount of range splitting dynamically at runtime, resulting in sub-ranges of varying sizes.
tbb
Parallel version that uses Intel TBB and blocked_range2d to parallelize over tasks that are rectangular sub-areas.
  • By default, this version uses one thread per available processor. To change this default, set the TBB_NUM_THREADS environment variable to the desired number of threads before running.
  • This version uses a reasonable task grain size by default. To change this default, set the TBB_GRAINSIZE environment variable to the desired grain size before running. The grain size corresponds to the number of pixels (in the X or Y direction, for a rectangular sub-area) in each parallel task.
Files
src/main.cpp
Main program which parses command line options and runs the raytracer.
src/tachyon_video.cpp
Source code for GUI interfaces.
src/trace.serial.cpp
Source code for original sequential version of example.
src/trace.tbb1d.cpp
Source code for Intel TBB blocked_range (scan-line) version of example.
src/trace.tbb.cpp
Source code for Intel TBB blocked_range2d (rectangular sub-area) version of example.
(src/*.cpp)
Remainder of source code for example.
(src/*.h)
Remainder of include files for example.
Makefile
Makefile for building the example.
Directories
src
Contains source code and include files for the example.
dat
Contains data sets for running the example.
msvs
Contains Microsoft* Visual Studio* workspace for building and running the example (Windows* systems only).
xcode
Contains Xcode* IDE workspace for building and running the example (macOS* systems only).

For information about the minimum supported version of IDE, see release notes.

Build instructions

General build directions can be found here.

For Windows* systems Microsoft* Visual Studio* projects are provided for each of the above example versions.

The Makefile supports the following build targets (in addition to the general ones). Here, <version> is one of the above versions of the example, i.e., {serial, tbb1d, tbb}.

make <version>[_debug]
Build and run a single version (release or debug). Equivalent to 'make build_<version>[_debug] run_<version>'.
make build_<version>[_debug]
Compile and link a single version (release or debug). The resulting executable is left in the directory for the example.
make run_<version>
Run a single version previously produced by one of the above commands.
make [(above options or targets)] DATASET={820spheres, balls, balls3, lattice, model2, teapot, trypsin4pti}
Build and run as above, but run with the specified data set.
make [(above options or targets)] ARGS=-D
Build and run as above, but run with disabled run-time display updating for use in making performance measurements (strongly recommended when measuring performance or scalability; see note below).
make [(above options or targets)] UI={con, gdi, d2d, x, mac}
Build and run as usual, but build with the specified GUI driver: console, GDI+*, Direct2D*, X11, or OpenGL* (see the description of the common GUI code for more information on available graphics support). For Linux* and macOS* systems, the best available driver is detected automatically by the Makefile. For Windows* systems, UI=gdi is the default GUI driver; compiling with UI=d2d may offer superior performance, but can only be used if the Microsoft* DirectX* SDK is installed on your system. Use UI=con to build without the GUI for use in making performance measurements (strongly recommended when measuring performance or scalability; see note below).
make [(above options or targets)] XARCH=x64
Build and run as above, but also specify XARCH=x64 (or XARCH=AMD64 for older compilers) when building the example on Windows* as a 64-bit binary.
make [(above options or targets)] DDLIB_DIR=<specify path to Direct Draw* SDK here>
If you experience ddraw.lib linking problems, specify the correct library directory via this option.
Usage

Building via the above make commands, or via Visual Studio projects on Windows* systems, produces executable files named tachyon.<version>.exe. To run these executables directly, use one or more of the following commands.

tachyon.<version> -h
Prints the help for command line options
tachyon.<version> [dataset=value] [boundthresh=value] [no-display-updating] [nobounding] [silent]
tachyon.<version> [dataset [boundthresh]] [no-display-updating] [nobounding] [silent]
dataset is the path/name of one of the *.dat files in the dat directory for the example.
boundthresh is a bounding threshold value.
no-display-updating - disable run-time display updating.
no-bounding - disable bounding technique.
silent - no output except elapsed time.
tachyon.<version> [dataset] [no-display-updating]
Run this version (release or debug), but run with disabled run-time display updating for use in making performance measurements (strongly recommended when measuring performance or scalability; see note below).
To run a short version of this example, e.g., for use with Intel® Parallel Inspector:
Build a debug version of the tbb example with the GUI turned off (e.g., make UI=con tbb_debug; see also the build directions above).
Run it with a small dataset, e.g., tachyon.tbb.exe dat/820spheres.dat no-display-updating.
Keys

While running with the GUI display turned on the following keyboard keys can be used:

ESC
Interrupt the rendering and exit
Any key
Enable repetition of rendering after the pause. Press ESC to stop the application.
Space
Toggle run-time display updating mode while rendering (see no-display-updating above).
p
Holds the picture after rendering completion. Press 'p' again to continue.
Notes

Up to parent directory
Legal Information

Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
© 2019, Intel Corporation

The original source for this example is Copyright (c) 1994-2008 John E. Stone All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.