- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I use openmp commands such as:
in my main project they work properly (I have 4 cores, and four threads are shown).
BUT if create a static library and THE SAME commands are used in some function of from this static library program shows only 1 thread available.
Why is that ?
int nthreads, tid;
#pragma omp parallel private(tid)
{
/* Obtain and print thread id */
tid = omp_get_thread_num();
printf("Hello World from thread = %d\\n", tid);
/* Only master thread does this */
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("Number of threads = %d\\n", nthreads);
}
} /* All threads join master thread and terminate */
in my main project they work properly (I have 4 cores, and four threads are shown).
BUT if create a static library and THE SAME commands are used in some function of from this static library program shows only 1 thread available.
Why is that ?
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Make sure that you use the proper compiler option to compile your code with OpenMP pragmas: "-openmp" on Linux and "/Qopenmp" on Windows.
You might not notice any problems while compiling your code because the compiler just emits the warning about unrecognized pragma but not the error.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page