openMP

you can configure openCV for openMP. i think there’s a switch for ./configure.

the only problem with openMP is that i was not able to use it with pthreads.

best
joerg
[/code]

sounds great, will check it out thanks…

Hi,

I am also really interested to get my for loops parrallelized. I did what you said but when I change the GCC version to 4.2 it throws some errors:

8 of these: /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory

if I only toggle use openMP and stick to GCC version 4.0 I don’t get the errors but the speed neither seems to improve.-

Any ideas?

Thanks!

EDIT:

Okay, I read a little bit about all that stuff. As far as I can tell you need GCC 4.2 to make use of OpenMP.

GCC 4.2 only works with the Base SDK for Mac OSX 10.5. If I select that with my OF project it throws a whole bunch of errors since OF does not really like that SDK as far as I can tell.

If I make an emtpy cocoa project everything works fine.

So how did you manage to do that? If it is too difficult would you mind uploading an empty xcode project using of and openMP?

Thank you!

in fact it’s really easy as i mentioned in a different thread:
http://forum.openframeworks.cc/t/compilation-errors-with-gcc-4.2/1387/0

but i am using the 00573-xcode-fat-ycam-day3 version of OF.

i hope that helps

best
joerg

thanks, I will try that. Is your of Version allready using poco? I am using this one:
http://www.openframeworks.cc/files/0057-…-ithGui.zip

So the changes should be similar right?

So you are not compiling for mac osx 10.5?

yes it’s with poco (which is causing most of the trouble). and i also use the 10.5 sdk.

best
joerg

Wow thank you, I got it to work!

What an incredible change in Performance. Even though I am on a first generation MBP (I think they have 2 cores, not sure though) I get almost big speed improvement for this simple loop:

  
  
//#pragma omp parallel for  
for(int i=0; i<1000000; i++){  
}  
  

approx. 410 fps with using openMP
and 270 without it.

I am seriously impressed with this :slight_smile:

Wow. That’s super impressive. So, excuse my naivety on these matters, but OpenMP is just being used to parallelize for loops that are doing the image processing for 3 simultaneous camera feeds and there’s no shared memory problems with that? Did you have to do anything special to get the camera data into a parallelizable state that’s markedly different than what you would do for a multithreaded app?

the fun thing is: i don’t need to rewrite the program much other than adding the pragmas and take care so that the for loops don’t have data dependencies in themselves. all the rest is sequential. so the program processes the data of the three cameras after each other. only the processing loops are parallel.

best
joerg

I just applied some of it to some unoptimized 3D metaballs code and then the speed improvement is only something from 5-15%.

I think thats only due to ma old hardware though. I think on a Mac Pro things would become reaaally fast.

i think it really depends on what kind of loops you parallelize. i guess image processing works well because most of it is just all the same for each pixel.
however openMP creates only one worker thread for each core, so if you only have one or two cores the improvement might be much less than with the mighty 8-core mac pro.

best
joerg

This is interesting. Does anyone have an example on how to turn on openMP support for opencv? Does it require editing anything or it’s already written into openCv?

maybe you have to recompile openCV. there’s a switch for ./configure:
–enable-openmp

best
joerg

Hi

I am also trying to use OpenMP for parallelizing my huge “image processing” loops. I’m on Windows and using CB with Mingw 4.7.1, since those have the additional libraries needed to run oF. But it doesn’t have OpenMP support (no lib files).

If I upgrade to Mingw 4.8.1, I can run OpenMP’s sample program nicely, but the oF lib addons that came for Mingw 4.7.1 fail to run because of version mismatch.

Any help is appreciated.

P.S: I tried looking at Intel TBB, but it is too confusing to use.

@divyanshu_grover, I know it’s not a solution, but I recommend you to use Visual Studio 2015 (I guess it’s free) and oF0.9.0 rc. I have used Visual Studio with OpenMP and works well. You just need to add /openmp flag, include omp.h and add pragmas:
https://msdn.microsoft.com/en-us/library/fw509c3b.aspx

FYI: OpenCV itself has a CUDA support but I never tried it (nor with oF).

2 Likes

@micuat Thanks for the reply. I checked out the oF 0.9.0 rc thread. It does seem that using that would it with VS 2015 would remove the OpenMP support problem. I just hope I don’t have to make too many changes in the code. Fingers crossed

Would report back soon.

I think you can also use it in Visual Studio 2012 too with the 0.8.4 release.

@chuckleplant Oh that’d be much easier. Thanks! Already have both of these. Would try that first. VS2015 is already taking a lot to time to download and install.

see here for enabling openMP in VS2012 + header/lib downloads:

1 Like

I actually had VS2013 installed. I downloaded oF 0.8.4 source for VS 2013 from the link here. The following the instruction here, I was able to run OpenMP finally!
Thanks everyone.