Skip to content

Commit

Permalink
Merge pull request SINTEF-Geometry#365 from sbriseid/omp_config_file
Browse files Browse the repository at this point in the history
Moved omp macro (for handling missing windows auto schedule) to omp c…
  • Loading branch information
sbriseid authored Sep 24, 2024
2 parents 0a3b251 + 422caeb commit 5345dd5
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 79 deletions.
54 changes: 54 additions & 0 deletions gotools-core/include/GoTools/utils/omp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF ICT,
* Applied Mathematics, Norway.
*
* Contact information: E-mail: [email protected]
* 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
* <http://www.gnu.org/licenses/>.
*
* 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 <omp.h>

// 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
11 changes: 1 addition & 10 deletions gotools-core/src/utils/ClosestPointUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
#include "GoTools/geometry/Plane.h"
#include "GoTools/geometry/ClassType.h"
#include "GoTools/utils/ClosestPointUtils.h"
#ifdef _OPENMP
#include <omp.h>
#endif
#include "GoTools/utils/omp.h"

using namespace std;
using namespace Go;
Expand All @@ -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
{
Expand Down
10 changes: 1 addition & 9 deletions gotools-core/src/utils/RegistrationUtils.C
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,11 @@
#include "GoTools/geometry/ParamSurface.h"
#include "GoTools/geometry/SplineSurface.h"
#include "GoTools/geometry/BoundedSurface.h"
#ifdef _OPENMP
#include <omp.h>
#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
{
Expand Down
8 changes: 1 addition & 7 deletions lrsplines2D/src/LRApproxApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <fstream>
#include <string.h>
Expand All @@ -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


Expand Down
11 changes: 1 addition & 10 deletions lrsplines2D/src/LRSplineMBA.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <fstream>
#ifdef _OPENMP
#include <omp.h>
#endif

//#define DEBUG

Expand All @@ -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,
Expand Down
12 changes: 1 addition & 11 deletions lrsplines2D/src/LRSurfApprox.C
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,14 @@
#include "GoTools/lrsplines2D/LRSplinePlotUtils.h"
#include "GoTools/lrsplines2D/LRFeatureUtils.h"
#include "GoTools/lrsplines2D/LogLikelyhood.h"
#include "GoTools/utils/omp.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include "stdio.h"
#include <cstring>

#ifdef _OPENMP
#include <omp.h>
#endif

//#define DEBUG
//#define DEBUG1
//#define DEBUG2
Expand All @@ -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<double>& points,
int dim, double epsge, bool init_mba,
Expand Down
12 changes: 1 addition & 11 deletions lrsplines2D/src/LRSurfSmoothLS.C
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,13 @@
#include "GoTools/lrsplines2D/LRSurfSmoothLS.h"
#include "GoTools/lrsplines2D/Element2D.h"
#include "GoTools/creators/SolveCG.h"

#ifdef _OPENMP
#include <omp.h>
#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};
Expand Down
11 changes: 1 addition & 10 deletions lrsplines3D/src/LRSpline3DMBA.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <fstream>
#ifdef _OPENMP
#include <omp.h>
#endif

//#define DEBUG0

Expand All @@ -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)
//==============================================================================
Expand Down
12 changes: 1 addition & 11 deletions lrsplines3D/src/LRVolApprox.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstring>

#ifdef _OPENMP
#include <omp.h>
#endif

//#define DEBUG
//#define DEBUG0

Expand All @@ -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<double>& points,
int dim, double epsge,
Expand Down

0 comments on commit 5345dd5

Please sign in to comment.