简体   繁体   中英

/MP doesn't enable OpenMP support in VS2012

I have this code in visual c++ 2012:

void Run()
{
    #pragma omp parallel for
    for(int imageNo=0;imageNo<4;imageNo++)
    {
        RunForOneImage(imageNo, Data[imageNo],
                       width, height,
                       OutputWidth, OutputHeight);  
    }
}

All variables in RunForOneImage are local variables and it doesn't use any global or class member variables.

When run it, I can see that only one core became busy and other core are idle.

Why this is not running in parallel?

I selected multi processor option in visual studio (/MP). Is there any other option that I should select?

The /MP option means that the compilation will run on multiple processors, it's purpose is to "reduce the total time to compile the source files" .

It has nothing to do with OpenMP API . To enable OpenMP support, there's an /openmp option (in the documentation you'll also find an example and the description of how to enable OpenMP support).

只需转到“项目属性”->“ C / C ++”->“语言”->“打开MP支持”,然后将其切换为“是”即可。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM