I have a heavy-duty algorithm in C# that takes two large Bitmaps of about 10000×5000 and performs photo and ray collision operations on a 3D model to map photos on the 3D model.
I would like to know if it is possible to convert such an algorithm to OpenCL to optimize parallel operations during the algorithm. But before asking you to go into the details of the algorithm, I would like to know how I can investigate if my algorithm is convertible to OpenCL.
I am not experienced in OpenCL and I would like to know if it is worth it to get into it and learn how it works. Are there things I have to look for that will definitely not work on the graphics card? (for-loops, recursion)
Update:
My algorithm goes something like:
foreach photo
split the photo in 64x64 blocks
foreach block
cast a ray from the camera to the 3D model
foreach triangle in 3D model
perform raycheck
Yes, opencl is very possible for this type of work. ray casting is a place where gpu hardware can shine.
One way to divide this up:
There are some other things to consider when you implement this algorithm.
1) are there always 64^2 rays to be cast per block?
2) what ratio of rays will ‘hit’ the image and/or the geometry? conditional branches will hurt performance on gpu hardware.
3) have you considered casting from the geometry perspective, rather than the image? ie foreach triangle, foreach vertex, cast ray from camera and detect position on screen. you might be able to interpolate the remaining points on the triangle as well as z-buffer the results to prevent redrawing of the pixels.
4) if you are only crunching graphics, does opengl/directx have what you need already?