Development Logs

Community Bonding Period

  • During the community bonding period, I read the code and asked some questions about the ANSI C boolean evaluation algorithm to better understand some concepts and to plan the necessary things to port to OpenCL.
  • I started to write some code in order to get an advance on my project. This consisted in creating the kernels in OpenCl to weave the segments and to evaluate the partitions, and setting the arguments for those kernels. Ended with an initial version of the "weave_segs" kernel.

May 30, 2017

  • Coding Period officially begins!!
  • Because I misunderstood an important concept about the weave of segments, the resulting number of partitions with the initial version of the 'weave_segs' kernel was incorrect. Started to implement a new version of the code

Week 1: 30 May - 2 June

  • Finalized the "weave_segs" kernel and the the solution seems ok. When testing the code with a simple CSG scene (two spheres intersecting), the number of partitions and the number of segments in each partition is correct. 1, 2 or 3 partitions per ray at most, and the rays with 3 partitions have only 2 segments in the second partition, which is supposed according to the testing example.
  • After evaluating the partitions, the results also seemed correct. Every partition evaluated with "TRUE" value is from a ray with 3 partitions, and only

the middle partition of the ray has the "TRUE" value.

  • Planning to shade the segments from the evaluated partitions next week.
Testing scene with two spheres intersecting

Week 2:

5 June

  • Worked on an initial solution to shade the segments resulting from boolean evaluation. The resulting image differs from the expected result, so i will have to get back to this and figure out what is missing

6 June

  • After suggestion from my mentor, implemented a white/black shading of the resulting partitions. From the resulting image, I could figure out that a large number of partitions that should be evaluated with 'true' were missing

7-8 June

  • After debugging the 'weave_segs' and the code to evaluate partitions, found some issues on the 'weave_segs' kernel that caused the missing resulting partitions. After fixing the bugs on the code, the total number of partitions evaluated with true by the OCL code matched with the total number of partitions evaluated by the Ansi C code and the resulting white/black image was correct!

9 June

  • Adaptaded the code of the 'shade_segs' kernel to shade the segments of the resulting partitions. There are still some problems in the resulting image.
  • The next figure contains images with the results of the OCL code and a comparison with the Ansi C code.
Ocl results.png
  • Planning to refractor the 'weave_segs' kernel next week to a solution that does not use a bounded array for the segments in each partition and to clean up the code in order to submit an initial patch.

Week 3

12-14 June

  • Implemented the 'weave_segs' kernel without using a bounded array to store the segments in each partition. The number of evaluated partitions matches the number of evaluated partitions in the ansi c code and the resulting image is correct.
  • Tomorrow I will create some more CSG scenes and will test the code with those new scenes to make sure everything is okay before submitting the patch to weave segments into partitions.

15 June

  • Reviewed the code with my mentor and will make some improvements based on the received feedback

16-17 June

  • Fixed an issue on the code that would occur when inserting new partitions on the partitions list
  • Implemented a bitvector to represent the segments in each partition

Week 4

19 June

  • Fixed a bug on the code that would cause some missing partitions when running the OCL code in the GPU

21 June

  • Added a lightmodel to the ansi code to perform white shading, in order to have a more exact comparision between the Ansi C and the OpenCL code
White shading results.png
Ansi C OCL - Intel i5 4690k OCL - Nvidia GTX 970
Union 0,314 sec 0,098 sec 0,173 sec
Difference 0,318 sec 0,098 sec 0,175 sec
Intersection 0,301 sec 0,097 sec 0,164 sec

22 June

23 June

  • shade_segs kernel shading only segments from evaluated partitions
  • optimized struct cl_partition to store indexes to segments instead of cl_segs, making it more memory efficient

24 - 26 June

  • working on a list structure to store the partitions instead of an array of partitions and implementing a dynamic bit vector to represent the segments in each partition. Still some issues to fix