简体   繁体   English

c++ Visual Studio 编译器 OpenMP

[英]c++ visual studio compiler OpenMP

I'm trying to compile a source code on Windows that works great on Linux.我正在尝试在 Linux 上编译 Windows 的源代码。 Now, I'm facing the following issue:现在,我面临以下问题:

The code relies on OpenMP and in there, the scheduling approach should be stored in a string and the chunk size in an integer.该代码依赖于 OpenMP,并且在那里,调度方法应该存储在一个字符串中,并且块大小存储在 integer 中。

The following code does extract the necessary information.以下代码确实提取了必要的信息。

omp_sched_t omp_sched;
int chunkSize;
omp_get_schedule( &omp_sched, &chunkSize );

string jobScheduling;
switch ( omp_sched ) {
    case omp_sched_static:
        jobScheduling = "static";
        break;
    case omp_sched_dynamic:
        jobScheduling = "dynamic";
        break;
    case omp_sched_guided:
        jobScheduling = "guided";
        break;
    case omp_sched_auto:
        jobScheduling = "auto";
        break;
    default:
        jobScheduling = "auto";
        break;
}

On Windows, by using the Microsoft Visual Studio compilers, it does not recognize omp_sched_t , omp_sched_static , omp_sched_dynamic ...在 Windows 上,通过使用 Microsoft Visual Studio 编译器,它无法识别omp_sched_tomp_sched_staticomp_sched_dynamic ...

Is this Linux specific?这是 Linux 特定的吗? If not, how can I fix this (preferably without changing the source code)?如果没有,我该如何解决这个问题(最好不更改源代码)?

You are using features introduced in OpenMP 3.0 but Microsoft VisualC++ only supports OpenMP 2.0.您正在使用 OpenMP 3.0 中引入的功能,但 Microsoft VisualC++ 仅支持 OpenMP 2.0。 And, AFAIK, even that support is deprecated though it's still there.而且,AFAIK,即使这种支持仍然存在,但也已被弃用。

If you want support for modern OpenMP, you simply need a different compiler.如果您想要支持现代 OpenMP,您只需要一个不同的编译器。 Visual Studio comes with optional Clang, which has the required support, but enabling OpenMP via the Project Properties dialog can be a bit tricky. Visual Studio 附带可选的 Clang,它具有所需的支持,但通过“项目属性”对话框启用 OpenMP 可能有点棘手。 Another option is Intel C/C++ Compiler for Windows, which is a commercial piece of software.另一种选择是用于 Windows 的英特尔 C/C++ 编译器,这是一款商业软件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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