Thread: openMP - intervals assigned to threads

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    110

    openMP - intervals assigned to threads

    Is there a way of knowing which indices a thread is assigned in a parallel openMP scope?

  2. #2
    Registered User
    Join Date
    Mar 2012
    Posts
    110
    I found this:omp_get_num_threads() - should do the trick!

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    omp_get_thread_num() tells you the id of the current running thread. Use it to index inside arrays in parallel scopes.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Mar 2012
    Posts
    110
    Elysia - That's exactly what I planed to do. There is no 'automatic' way of knowing the intervals assigned in a parallel for loop in openmp, right?

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Not to my knowledge. But it's also an abstraction factor as the iterations assigned to a thread can change depending on the schedule used.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Mar 2012
    Posts
    110
    OK! I'll wont look into it further, based on the assumption that you know what you're talking about. :-)

    THANKS!

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, I'm no expert, so feel free to look around. I have experimented with it a little, though.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 22
    Last Post: 12-14-2012, 11:00 AM
  2. Replies: 4
    Last Post: 08-08-2012, 01:05 PM
  3. Replies: 77
    Last Post: 10-15-2011, 04:45 PM
  4. Connecting intervals together
    By kaspari22 in forum C++ Programming
    Replies: 5
    Last Post: 06-24-2011, 11:32 AM
  5. OpenMP parallel threads for matrix multiplier
    By collymitch in forum C Programming
    Replies: 0
    Last Post: 04-07-2005, 04:38 PM