Feb 18, 2010

A way to build gcc

The following method comes from the Linux system administrator of our department. The credit should go to him.

It took me a while to get this figured out. Things have changed a good bit since I've last
compiled gcc. I got this to work on a CentOS x86_64 system:

# set this to your desired prefix
PREFIX=/local/duckwos/foobar

# extract sources
tar jxf gmp-4.3.1.tar.bz2
tar jxf mpfr-2.4.1.tar.bz2
tar jxf gcc-4.4.2.tar.bz2

# build 32-bit gmp
cd gmp-4.3.1
./configure --prefix=$PREFIX --enable-cxx ABI=32
make -j2
make -j2 check
make install
make distclean

# build 32-bit mpfr
cd ../mpfr-2.4.1
./configure --prefix=$PREFIX --with-gmp=$PREFIX
make -j2
make -j2 check
make install
make distclean

# build 64-bit gmp
cd ../gmp-4.3.1
mv $PREFIX/include/gmp.h $PREFIX/include/gmp-i386.h
./configure --prefix=$PREFIX --libdir=$PREFIX/lib64 --enable-cxx ABI=64
make -j2
make -j2 check
make install

# build 64-bit mpfr
cd ../mpfr-2.4.1
./configure --prefix=$PREFIX --libdir=$PREFIX/lib64 --with-gmp-include=$PREFIX/include --with-gmp-lib=$PREFIX/lib64
make -j2
make -j2 check
make install

# fix up gmp header files
mv $PREFIX/include/gmp.h $PREFIX/include/gmp-x86_64.h
cp /usr/include/gmp.h $PREFIX/include/gmp.h

# build gcc
cd ../gcc-4.4.2
mkdir build
cd build
export LDFLAGS="-L$PREFIX/lib64 -Xlinker -R$PREFIX/lib64"
export LD_OPTIONS="$LDFLAGS"
export LD_RUN_PATH=$PREFIX/lib64
../configure --prefix=$PREFIX --with-gmp-include=$PREFIX/include --with-gmp-lib=$PREFIX/lib64 --with-mpfr-include=$PREFIX/include --with-mpfr-lib=$PREFIX/lib64 --enable-shared --enable-threads=posix --enable-languages=c,c++
make -j2
make install

# tell linker to specify rpath
$PREFIX/bin/gcc -dumpspecs > $PREFIX/lib/gcc/x86_64-unknown-linux-gnu/4.4.2/specs
vi $PREFIX/lib/gcc/x86_64-unknown-linux-gnu/4.4.2/specs

Find the line that contains only "*link:".
On the next line, append the text:
%{!m32:-L/local/duckwos/foobar/lib64 -R/local/duckwos/foobar/lib64} %{m32:-L/local/duckwos/foobar/lib -R/local/duckwos/foobar/lib}
Save the file.

Then you should have a working compiler.

Feb 17, 2010

Sample Images


Scene 1 Render Time 13,358,183 ms


Scene 2 Render time 129,024,982 ms


Scene 3 Render time 131,736,748 ms


Scene 4 Render time 106,477,129 ms


Scene 5 Render time 53,098,855 ms


Scene 7 Render time 22,924,387 ms
Texture map size 4096 * 2048
Bump map size 1024 * 1024


Scene 6 Render time counter overflows and offers negative values


Another Scene 6 with different object attributes.


Scene 6 with nice looking soft shadow

You can find the program tarball here.

Program Features

(0) Basic ray tracing, ambient, diffuse, specular, shadow, transparency.
(1) Reflection
(2) Refraction. My program is able to do refraction for continuous changing media without air/vacuum interfering in between. For example, a big ball contains a small ball and both of them are translucent and of different index of refraction.
(3) Geometry includes sphere, general shaped polygon (even including concave polygon) and plane.
(4) Objects include fully opaque, translucent, fully translucent, fully reflective and partially reflective.
(5) Super sampling, soft shadow.
(6) Recursive ray trace controlled by arbitrary user-defined level threshold and ray-traveled distance threshold.
(7) Texture map and bump map on sphere object, checkerboard pattern on infinite plane.
(8) Program runs faster than POV-Ray for the test scenes.
(9) Program is able to output both PPM P6 raw format and 24-bit BMP format.
(10) Use yacc/lex parser to parse POV configuration file.
(11) I wrote my own numerical library for vector and matrix computation, employing template meta-programming and expression template techniques as well as latest features from the incoming new C++ standard.

Assignment Description

Copied from Dr. Duchowski's webpage
Write a program to implement a ray tracer:
* Use either an interactive method of setting up the scene or create a simple scene "manually".
* Objects in the scene should include both spheres (and/or other quadrics), and polygonal objects (e.g., planes, cubes, the teapot).
* Images should include:
o fully opaque objects
o transluscent objects
o fully transparent objects (e.g., panes of glass)
o fully reflective objects (e.g., mirrors)
o partially reflective objects
* Shadow/Reflection/Transmission: demonstrate reflection, refraction, and shadows.
* Sampling: minimally, sample the scene at screen resolution, or optionally implement supersampling, adaptive supersampling, or distributed (stochastic) supersampling, and/or progressive sampling.
* Recursion: terminate recursion at an arbitrary (e.g., user-defined) level, or adaptively based on diminishing intensity contribution.
* Texture/bump maps: texture/bump maps should be demonstrated on planar surfaces (e.g., "walls" in the image) and spheres.