diff --git a/gotools-core/include/GoTools/utils/omp.h b/gotools-core/include/GoTools/utils/omp.h new file mode 100644 index 000000000..390a44818 --- /dev/null +++ b/gotools-core/include/GoTools/utils/omp.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT, + * Applied Mathematics, Norway. + * + * Contact information: E-mail: tor.dokken@sintef.no + * SINTEF ICT, Department of Applied Mathematics, + * P.O. Box 124 Blindern, + * 0314 Oslo, Norway. + * + * This file is part of GoTools. + * + * GoTools is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * GoTools is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with GoTools. If not, see + * . + * + * In accordance with Section 7(b) of the GNU Affero General Public + * License, a covered work must retain the producer line in every data + * file that is created or manipulated using GoTools. + * + * Other Usage + * You can be released from the requirements of the license by purchasing + * a commercial license. Buying such a license is mandatory as soon as you + * develop commercial activities involving the GoTools library without + * disclosing the source code of your own applications. + * + * This file may be used in accordance with the terms contained in a + * written agreement between you and SINTEF ICT. + */ + +#pragma once + +#ifdef _OPENMP + +#include + +// Fallback solution for the missing auto scheduler in Visual Studio 2022 (and earlier). The runtime scheduler is the +// closest option. +#ifdef _WIN32 + #define OMP_SCHEDULE_AUTO schedule(runtime) +#else + #define OMP_SCHEDULE_AUTO schedule(auto) +#endif + +#endif diff --git a/gotools-core/src/utils/ClosestPointUtils.C b/gotools-core/src/utils/ClosestPointUtils.C index 5ad14c457..35eaa0e16 100644 --- a/gotools-core/src/utils/ClosestPointUtils.C +++ b/gotools-core/src/utils/ClosestPointUtils.C @@ -51,9 +51,7 @@ #include "GoTools/geometry/Plane.h" #include "GoTools/geometry/ClassType.h" #include "GoTools/utils/ClosestPointUtils.h" -#ifdef _OPENMP -#include -#endif +#include "GoTools/utils/omp.h" using namespace std; using namespace Go; @@ -62,13 +60,6 @@ using namespace Go::boxStructuring; // #define LOG_CLOSEST_POINTS -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - namespace Go { diff --git a/gotools-core/src/utils/RegistrationUtils.C b/gotools-core/src/utils/RegistrationUtils.C index cbf64ffd7..e7e85650b 100644 --- a/gotools-core/src/utils/RegistrationUtils.C +++ b/gotools-core/src/utils/RegistrationUtils.C @@ -43,19 +43,11 @@ #include "GoTools/geometry/ParamSurface.h" #include "GoTools/geometry/SplineSurface.h" #include "GoTools/geometry/BoundedSurface.h" -#ifdef _OPENMP -#include -#endif +#include "GoTools/utils/omp.h" using namespace std; using namespace Go; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif namespace Go { diff --git a/lrsplines2D/src/LRApproxApp.C b/lrsplines2D/src/LRApproxApp.C index 44ee08c06..83cc478b7 100644 --- a/lrsplines2D/src/LRApproxApp.C +++ b/lrsplines2D/src/LRApproxApp.C @@ -48,6 +48,7 @@ #include "GoTools/geometry/PointCloud.h" #include "GoTools/geometry/Utils.h" #include "GoTools/creators/Eval1D3DSurf.h" +#include "GoTools/utils/omp.h" #include #include #include @@ -56,13 +57,6 @@ using namespace Go; using std::vector; using std::string; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - //#define DEBUG diff --git a/lrsplines2D/src/LRSplineMBA.C b/lrsplines2D/src/LRSplineMBA.C index 2ddf03694..ad37ad26c 100644 --- a/lrsplines2D/src/LRSplineMBA.C +++ b/lrsplines2D/src/LRSplineMBA.C @@ -42,12 +42,10 @@ #include "GoTools/lrsplines2D/Element2D.h" #include "GoTools/lrsplines2D/LRSplineUtils.h" #include "GoTools/geometry/Utils.h" +#include "GoTools/utils/omp.h" #include #include -#ifdef _OPENMP -#include -#endif //#define DEBUG @@ -59,13 +57,6 @@ using std::cout; using std::endl; using namespace Go; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - //============================================================================== void LRSplineMBA::MBADistAndUpdate(LRSplineSurface *srf, double significant_factor, diff --git a/lrsplines2D/src/LRSurfApprox.C b/lrsplines2D/src/LRSurfApprox.C index 2ad05f085..475c427bb 100644 --- a/lrsplines2D/src/LRSurfApprox.C +++ b/lrsplines2D/src/LRSurfApprox.C @@ -49,6 +49,7 @@ #include "GoTools/lrsplines2D/LRSplinePlotUtils.h" #include "GoTools/lrsplines2D/LRFeatureUtils.h" #include "GoTools/lrsplines2D/LogLikelyhood.h" +#include "GoTools/utils/omp.h" #include #include #include @@ -56,10 +57,6 @@ #include "stdio.h" #include -#ifdef _OPENMP -#include -#endif - //#define DEBUG //#define DEBUG1 //#define DEBUG2 @@ -75,13 +72,6 @@ using std::pair; using std::make_pair; using namespace Go; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - //============================================================================== LRSurfApprox::LRSurfApprox(vector& points, int dim, double epsge, bool init_mba, diff --git a/lrsplines2D/src/LRSurfSmoothLS.C b/lrsplines2D/src/LRSurfSmoothLS.C index 9d2359883..e5e62bf76 100644 --- a/lrsplines2D/src/LRSurfSmoothLS.C +++ b/lrsplines2D/src/LRSurfSmoothLS.C @@ -40,23 +40,13 @@ #include "GoTools/lrsplines2D/LRSurfSmoothLS.h" #include "GoTools/lrsplines2D/Element2D.h" #include "GoTools/creators/SolveCG.h" - -#ifdef _OPENMP -#include -#endif +#include "GoTools/utils/omp.h" using namespace Go; using std::vector; using std::cout; using std::endl; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - namespace { const int indices[] = {1, 2, 3, 4, 5, 8}; diff --git a/lrsplines3D/src/LRSpline3DMBA.C b/lrsplines3D/src/LRSpline3DMBA.C index 0a763244d..ee7a6f00b 100644 --- a/lrsplines3D/src/LRSpline3DMBA.C +++ b/lrsplines3D/src/LRSpline3DMBA.C @@ -42,12 +42,10 @@ #include "GoTools/lrsplines3D/Element3D.h" #include "GoTools/lrsplines3D/LRSpline3DUtils.h" #include "GoTools/geometry/Utils.h" +#include "GoTools/utils/omp.h" #include #include -#ifdef _OPENMP -#include -#endif //#define DEBUG0 @@ -59,13 +57,6 @@ using std::cout; using std::endl; using namespace Go; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - //============================================================================== void LRSpline3DMBA::MBADistAndUpdate(LRSplineVolume *vol) //============================================================================== diff --git a/lrsplines3D/src/LRVolApprox.C b/lrsplines3D/src/LRVolApprox.C index f4278280d..877647985 100644 --- a/lrsplines3D/src/LRVolApprox.C +++ b/lrsplines3D/src/LRVolApprox.C @@ -48,16 +48,13 @@ #include "GoTools/geometry/PointCloud.h" //#include "GoTools/lrsplines3D/LRSplinePlotUtils.h" #include "GoTools/trivariate/SmoothVolume.h" +#include "GoTools/utils/omp.h" #include #include #include #include #include -#ifdef _OPENMP -#include -#endif - //#define DEBUG //#define DEBUG0 @@ -67,13 +64,6 @@ using std::endl; using std::pair; using namespace Go; -// Visual Studio 2022 (and earlier) does not support the auto schedule. -#ifdef _WIN32 - #define OMP_SCHEDULE_AUTO schedule(runtime) -#else - #define OMP_SCHEDULE_AUTO schedule(auto) -#endif - //============================================================================== LRVolApprox::LRVolApprox(vector& points, int dim, double epsge,