开发者

openmp sections running sequentially

I have the following code:

#pragma omp parallel sections private(x,y,cpsrcptr) fi开发者_如何转开发rstprivate(srcptr) lastprivate(srcptr)
{
    #pragma omp section
    {
       //stuff
    }
    #pragma omp section
    {
       //stuff
    }
}

According to the Zoom profiler, two threads are created, one thread executes both the sections, and the other thread simply blocks!

Has anyone encountered anything like this before? (And yes, I do have a dual core machine).


I guess I don't know too much about profilers yet, but one problem I've run into is forgetting to use the OpenMP flag and enable support.

Alternatively, what if you just created a simple application to try to verify the threads?

#pragma omp parallel num_threads(2)
{
#pragma omp critical
    std::cout << "hello from thread: " << omp_get_thread_num() << "\n" << std::endl;
}

Maybe see if that works?


No, I can't say that I have encountered anything quite like this before. I have encountered a variety of problems with OpenMP codes though.

I can't see anything immediately wrong with your code snippet. When you use the Zoom profiler it affects the execution of the program. Have you checked that, outside the profiler, the program runs the sections on different threads ? If you have more sections do they all run on the same thread or do they run on different threads ? If you only have two sections, add some dummy ones while you test this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜