Xcode 5 and OpenMp

Discussion in 'Mac Programming' started by jmfel1926, Nov 28, 2013.

  1. jmfel1926 macrumors member

    Joined:
    Jun 22, 2012
    #1
    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
     
  2. teagls macrumors regular

    Joined:
    May 16, 2013
    #2
  3. cbreak macrumors member

    cbreak

    Joined:
    Mar 22, 2008
    #3
    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).
     
  4. jmfel1926 thread starter macrumors member

    Joined:
    Jun 22, 2012
    #4
    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?
     
  5. cbreak macrumors member

    cbreak

    Joined:
    Mar 22, 2008
    #5
    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.
     
  6. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #6
    http://openmp.org/wp/2013/09/clang/

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

    cbreak

    Joined:
    Mar 22, 2008
    #7
    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.
     
  8. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #8
    You can get clang-omp, which I linked to above, it's not merged with the main clang but it is clang.
     

Share This Page