I'm trying to parallelize a Ray Tracing code that I've found here (in C++): http://www.ffconsultancy.com/languages/ray_tracer/comparison.html.
I'm using Visual Studio 2012 + Intel C++ Composer XE. To run de executable, what I'm doing is to build with VS 2012, and run with cmd like this:
cd "path to the debug folder"
ray.exe 1 > fig.ppm
The number 1 is the level of complexitity of the image, being 1 the lighter to be done, and "> fig.ppm" exports de results to a .ppm image. The program results in a sphere (level 1) or many spheres.
The problem is, when I try to change de code to use Cilk, the results are wrong. Instead of showing the normal result for level 1, the image is completely messed up. I've tried to:
- Change the two firsts "for" in the main to cilk_for (one at the time and both at the same time);
- While doing the #1, tried to add cilk_spawn before function calling;
- While doing #1 and #2, tried to add cilk_sync after the fourth "for".
All these attempts have resulted in wrong outputs.
Can someone help me with this? Where should I add cilk_for, cilk_spawn and/or cilk_sync for this to work?