OpenMP, automatic threading

Tired of creating threes and writing code to manage deadlocks and work queues? Search is cpu intensive, and we uses a lot of threads. For example indexes are sorted in parallel, and the pages that go on the result page is fetched from the disk and processed in parallel. We started out creating threads manually, but that i slow going in C.  We have now almost entirely changed to OpenMP, and haven’t looked back since.

Initializing a large array in parallel is as easy as this.

int main(int argc, char *argv[]) {
        const int N = 100000;
          int i, a[N];
 
          #pragma omp parallel for
          for (i = 0; i < N; i++)
                  a[i] = 2 * i;
 
          return 0;
}
Example from Wikipedia.

OpenMP will decide how many threads to use.

 

Comments

Leave a Comment

Name *: (required)

Email : (not required) (will not be published)

URL: (not required)

Remember my personal information
Notify me of follow-up comments?

 
   
  Categories
  Uncategorized
  Feeds
  Rss
 
 
   
  Copyright © Searchdaimon AS. All Rights Reserved. You find it easy!