diff --git a/MathLib/LinAlg/Solvers/CGParallel.cpp b/MathLib/LinAlg/Solvers/CGParallel.cpp index dc689053b2d30ea328f741e8545c981d839ef12e..e5fc627ec8395a7b862666f38d447da506fa01d1 100644 --- a/MathLib/LinAlg/Solvers/CGParallel.cpp +++ b/MathLib/LinAlg/Solvers/CGParallel.cpp @@ -66,7 +66,7 @@ unsigned CGParallel(CRSMatrix<double,unsigned> const * mat, double const * const return 0; } - unsigned k; + OPENMP_LOOP_TYPE k; for (unsigned l = 1; l <= nsteps; ++l) { #ifndef NDEBUG std::cout << "Step " << l << ", resid=" << resid / nrmb << std::endl; diff --git a/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h b/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h index cce05d48ad6da4df17c730bcc5fc388472f5b4cc..7fa2cf0ec399e71fde91f204068c74861a8f91a8 100644 --- a/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h +++ b/MathLib/LinAlg/Sparse/CRSMatrixDiagPrecond.h @@ -72,7 +72,7 @@ public: void precondApply(double* x) const { { - unsigned k; + OPENMP_LOOP_TYPE k; // #pragma omp parallel for for (k=0; k<_n_rows; ++k) { x[k] = _inv_diag[k]*x[k]; diff --git a/MathLib/LinAlg/Sparse/amuxCRS.h b/MathLib/LinAlg/Sparse/amuxCRS.h index 584ef3190a92d9299b07355e55fdd9f18951bf0d..bcc354f4541603017088c0ea2c57446d40c9e23d 100644 --- a/MathLib/LinAlg/Sparse/amuxCRS.h +++ b/MathLib/LinAlg/Sparse/amuxCRS.h @@ -28,7 +28,7 @@ void amuxCRSParallelOpenMP (FP_TYPE a, unsigned n, IDX_TYPE const * const __restrict__ iA, IDX_TYPE const * const __restrict__ jA, FP_TYPE const * const A, FP_TYPE const * const __restrict__ x, FP_TYPE* __restrict__ y) { - unsigned i; + OPENMP_LOOP_TYPE i; { #pragma omp parallel for for (i = 0; i < n; i++) { diff --git a/MathLib/MathTools.cpp b/MathLib/MathTools.cpp index 8058f11cc6421fc39a7be220fbd56c6382592103..de68f0338d476b7dabfde5e795d9ffaade5a3336 100644 --- a/MathLib/MathTools.cpp +++ b/MathLib/MathTools.cpp @@ -13,7 +13,7 @@ namespace MathLib { double scpr(double const * const v, double const * const w, unsigned n) { long double res (v[0]*w[0]); - unsigned k; + OPENMP_LOOP_TYPE k; #pragma omp parallel for reduction (+:res) for (k = 1; k<n; k++) { diff --git a/scripts/cmake/CompilerSetup.cmake b/scripts/cmake/CompilerSetup.cmake index a8beb71af657177de51e4cdfe038e6c6f0cda4e7..8421b1eefc3973c37e5b760df34cbec945861324 100644 --- a/scripts/cmake/CompilerSetup.cmake +++ b/scripts/cmake/CompilerSetup.cmake @@ -49,8 +49,12 @@ ENDIF (OGS_PROFILE) IF (WIN32) ## For Visual Studio compiler IF (MSVC) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS - -D_CRT_XNONSTDC_NO_WARNINGS) + ADD_DEFINITIONS( + -D_CRT_SECURE_NO_WARNINGS + -D_CRT_NONSTDC_NO_WARNINGS + -D_CRT_XNONSTDC_NO_WARNINGS + -D__restrict__=__restrict # this fixes #5 + ) # Sets warning level 3 and ignores some warnings SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4290 /wd4267") # cygwin @@ -59,3 +63,10 @@ IF (WIN32) ADD_DEFINITIONS( -DGCC ) ENDIF (MSVC) ENDIF (WIN32) + +# Missing OpenMP 3.0 implementation fix for Windows, this fixes #6 +IF(MSVC) + ADD_DEFINITIONS(-DOPENMP_LOOP_TYPE=int) +ELSE() + ADD_DEFINITIONS(-DOPENMP_LOOP_TYPE=unsigned) +ENDIF()