简体   繁体   中英

c++ visual studio compiler OpenMP

I'm trying to compile a source code on Windows that works great on Linux. 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.

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 ...

Is this Linux specific? 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. And, AFAIK, even that support is deprecated though it's still there.

If you want support for modern OpenMP, you simply need a different compiler. Visual Studio comes with optional Clang, which has the required support, but enabling OpenMP via the Project Properties dialog can be a bit tricky. Another option is Intel C/C++ Compiler for Windows, which is a commercial piece of software.

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