'omp parallel for' construct

General OpenMP discussion

'omp parallel for' construct

Postby el nino » Fri Jun 27, 2008 5:02 pm

Hi i'm currently developing an graphical application and i have a rendering function that loops through all the objects to be rendered and applies various shaders and lighting effects. I was just wondering if this is possible:

#pragma omp parallel for
for (std::vector<RenderObject*>::iterator it = objects.begin(); it < objects.end(); ++it)
object = *it;
if (object->shader == sceneShader || !object->shader)
shm->render(object, sceneShader);
shm->render(object, object->shader);

i realise that the iterators need to be integers so do i have to attempt to convert the loop variables to use integers or will omp be able to convert the iterators into the required data types(probably not).

If so how would you loop through the various elements of a vector datastructure without using an iterator, and make use of the OMP for construct.

Apologies if this doesn't make sense, i'm a bit of a newb

Thanks in advance


i replaced the for loop with:

for(int i = 0; i < objects.size(); ++i)
object = objects.at(i);


it seems to compile will run it 2mrw.......
el nino

Re: 'omp parallel for' construct

Postby ejd » Fri Jun 27, 2008 7:00 pm

OpenMP V3 allows random access iterators to be parallelized. Unfortunately most vendors are just now implementing this spec. Within the next few months you should start seeing implementations out that support it. Meanwhile you have to do something like what you have in your edit.
Posts: 1025
Joined: Wed Jan 16, 2008 7:21 am

Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 4 guests