Parallel for -Tachyon

Parallel raytracer / renderer that demonstrates the use of parallel_for.
This example includes software developed by John E. Stone. See below for copyright information.
Tachyon Ray Tracing System

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.
The following versions of the example are provided:

serial
Original sequential version.
threads1d
Parallel version that utilizes native threads to parallelize over groups of scan-lines.
By default, this version uses one thread per available processor. To change this default, set the THR_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 THR_GRAINSIZE environment variable to the desired grain size before running. The grain size corresponds to the number of scan-lines in each parallel task.
threads
Parallel version that utilizes native threads to parallelize over rectangular sub-areas.
By default, this version uses one thread per available processor. To change this default, set the THR_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 THR_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.
tbb1d
Parallel version that uses Intel® Threading Building Blocks 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 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 scan-lines in each parallel task.
tbb
Parallel version that uses Intel® Threading Building Blocks 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
video.cpp - Source code for main program and GUI interfaces.
trace.serial.cpp - Source code for original sequential version of example.
trace.threads1d.cpp - Source code for native-threads (scan-line) version of example.
trace.threads.cpp - Source code for native-threads (rectangular sub-area) version of example.
trace.tbb1d.cpp - Source code for Intel® Threading Building Blocks blocked_range (scan-line) version of example.
trace.tbb.cpp - Source code for Intel® Threading Building Blocks blocked_range2d (rectangular sub-area) version of example.

Copyright © 2006 Intel Corporation. All Rights Reserved. Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries. * Other names and brands may be claimed as the property of others.
The original source for this example is
Copyright (c) 1994, 1995, 1996, 1997 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:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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.
All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by John E. Stone
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.


For more complete information about compiler optimizations, see our Optimization Notice.