Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jmfel1926

macrumors member
Original poster
Jun 22, 2012
74
0
Hello to everyone,

i have a C++ / OpenGL code that has 3 for loops that read in a 3d Image. I want to paralelize these 3 for loops using OpenMP. Although i do not know how to enable OpenMP on Xcode. Some say it is ON by default , some say there is an option in the Build Setting that i should find(but i cannot find).
Currently i do not include the omp.h header file and i add "#pragma omp parallel for " before each loop and the compiler doesn't give any errors and i can run the program and see the result.

Does anyone know if what i am doing now actually works or if have to do something more?

Thanks a lot
 

cbreak

macrumors member
Mar 22, 2008
42
0
OpenMP is not supported (yet) by clang. The old gcc is no longer bundled with Xcode 5. You'll have to use Xcode 4 with the ancient gcc 4.2.1, or compile your own gcc from source (or use some package manager thing that does that for you)

Also, threading with OpenGL is painful, you should really think hard if you want to get into that (you'll have to create separate contexts for each thread, and a bunch of other things, if you want to be anywhere close to portable).
 

jmfel1926

macrumors member
Original poster
Jun 22, 2012
74
0
Thanks a lot for the replies ... This is a lab exercise so in order to pass the labs i have to do it that way. The bad thing is that i have updated both OSX and Xcode ... what can i do now ? are there any simple options for that?
 

cbreak

macrumors member
Mar 22, 2008
42
0
Thanks a lot for the replies ... This is a lab exercise so in order to pass the labs i have to do it that way. The bad thing is that i have updated both OSX and Xcode ... what can i do now ? are there any simple options for that?

OpenMP should degrade to normal code without issue in clang. If you want to actually use it, compile your own gcc or get it via some other way. Maybe this homebrew has something. Or a VM with 10.8 or a Linux.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
OpenMP is not supported (yet) by clang.

OpenMP said:
This implementation supports 3.1 version of OpenMP standard in full; it passes all OpenMP tests we tried with it so far (this includes OpenMP Validation Suite from OpenUH Research Compiler, SPEC OMP2012 and internal Intel test suites). Performance-wise, it demonstrates similar gains and scalability as other compilers with OpenMP support.

http://openmp.org/wp/2013/09/clang/

Thanks a lot for the replies ... This is a lab exercise so in order to pass the labs i have to do it that way. The bad thing is that i have updated both OSX and Xcode ... what can i do now ? are there any simple options for that?

Try a packet manager (Macports, Homebrew, Fink) and install gcc, or get clang-omp.
 

cbreak

macrumors member
Mar 22, 2008
42
0
Yes, as I said above, clang doesn't support OpenMP, you'll have to get something else.

There are plans to implement OpenMP in Clang, but they aren't final yet. There are also plans to integrate Cilk, which are also not final.
 

subsonix

macrumors 68040
Feb 2, 2008
3,551
79
Yes, as I said above, clang doesn't support OpenMP, you'll have to get something else.

There are plans to implement OpenMP in Clang, but they aren't final yet. There are also plans to integrate Cilk, which are also not final.

You can get clang-omp, which I linked to above, it's not merged with the main clang but it is clang.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.