OpenMP
Productivity, generality and OpenMP
Posted July 13th, 2008 by DavideFlash news.. I'm very busy at work 8)
I could work less, but I want to produce something good. I like the idea to take a more general approach to problems and make something bigger out of it.
One of my current goals is to develop in a scalable manner. In order to do that, things need to be rethought in a more generic form.
For example one can have a triangular mesh, or could develop a system to do a remeshing to turn the original geometry into a semi-regular data structure that can easily be compressed and streamed progressively.
I think that scalability is really a key to the much needed productivity improvement in game development.
At work we talk every day about how to go about some solution, and there the key question is always: "can we use a scalable and generic solution ?".
This is usually about development pipeline.. not about actual code. The idea of code reusability is less straightforward. I actually aim more at providing simple implementations, to modularize code so that it can easily be grabbed without too many dependencies.. rather than trying to fit all in a supposed grand scheme of hierarchy of objects and whatnot.
In the end the harder problems are really those about how to organize data and how to transform those data across the development pipeline.
On the side, I also used OpenMP for the first time. After a few odd results, I managed to parallelize a loop that uncompresses images in that progressive-JPEG-like format that I've been working on.
Like for JPEG, the image is processed by 8x8 sub-blocks. Using OpenMP pragmas I set the parallel section to happen on rows of blocks.
Parallelizing every row of blocks makes sense, but I could probably try to do multiple rows at once to see if I can reduce overhead of context switching and potential cache trashing. Parellelizing every block instead turned out to be overkill.
As a rule of thumb, if I think that I could wrap some code into a function with practically no overhead, then perhaps I can make parallel section out of it. In fact, I think that OpenMP eventually grabs that section and makes a function out of it anyway...
Aside from some early decoding artifacts due to my inability to share some variables from outside the "parallel for" (see the example at the bottom here), using OpenMP was really easy. Definitely much simpler than manually creating and reusing threads, also less involved than using Threading Building Blocks because one doesn't need to create functor objects and also because OpenMP is readily available with modern compilers with minimal effort.
cool
zzzzzzzzzz


Recent comments
1 week 6 hours ago
4 weeks 5 days ago
6 weeks 1 day ago
7 weeks 4 days ago
9 weeks 12 hours ago
10 weeks 18 hours ago
10 weeks 23 hours ago
10 weeks 2 days ago
10 weeks 3 days ago
10 weeks 3 days ago