amrex icon indicating copy to clipboard operation
amrex copied to clipboard

AMREX build errors on Windows Visual Studio 2019 with OpenMP enabled. (-openmp)

Open ramsampath opened this issue 3 years ago • 3 comments

Hello,

Has anyone had success with enabling OpenMP on windows ?

I enabled AMReX_OPENMP to be ON and did a build in visual studio with cmake and got the following errors..along with others.

Severity Code Description Project File Line Suppression State Error C2059 syntax error: '#pragma omp threadprivate' (compiling source file D:\FDYNAMICS\amrex\Src\Base\AMReX.cpp) amrex D:\FDYNAMICS\amrex\Src\Base\AMReX_BLBackTrace.H 32 Error C2143 syntax error: missing ';' before '}' (compiling source file D:\FDYNAMICS\amrex\Src\Base\AMReX.cpp) amrex D:\FDYNAMICS\amrex\Src\Base\AMReX_BLBackTrace.H 34

..it would be great if anyone has experience with this and could point me in the right direction with the correct flags to use to make this work.

Thank you and sorry for the multiple questions and issues.

Ram.

ramsampath avatar Feb 08 '22 20:02 ramsampath

It looks like Visual Studio 2019 C++ compiler doesn't support the following OpenMP directives

#pragma atomic read and #pragma omp threadprivate(xxx)

which is used in AMReX header files.

these occur on lines

82 : AMReX_BoxArray.G

32: AMReX_BLBackTrace.H

and 51-54: AMReX_BaseFab.H

  • Is there any workaround to disable these since Visual Studio 2019 C++ compiler only supports a very outdated version of OpenMP (2.x standard).

Thank you Ram.

ramsampath avatar Feb 09 '22 19:02 ramsampath

In principle, it's possible to reimplement those without using OMP 3. However, you have other choices. You can use Clang, which support OpenMP 3. You can also use flat MPI instead of MPI+OMP.

WeiqunZhang avatar Feb 10 '22 17:02 WeiqunZhang

Thank you Weiqun - i will try these other options. Actually I was able to also build it with the Intel OneAPI C++ compiler with these OMP directives. I will also try the clang/llvm compiler in visual studio 2019.

ramsampath avatar Feb 15 '22 19:02 ramsampath